Gutenberg - Version 11.4.0

Version Description

Download this release

Release Info

Developer gutenbergplugin
Plugin Icon 128x128 Gutenberg
Version 11.4.0
Comparing to
See all releases

Code changes from version 11.3.0 to 11.4.0

build/block-directory/index.js CHANGED
@@ -566,7 +566,7 @@ function* installBlockType(block) {
566
  }
567
  });
568
  yield loadAssets(assets);
569
- const registeredBlocks = yield external_wp_data_namespaceObject.controls.select(external_wp_blocks_namespaceObject.store.name, 'getBlockTypes');
570
 
571
  if (!registeredBlocks.some(i => i.name === block.name)) {
572
  throw new Error((0,external_wp_i18n_namespaceObject.__)('Error registering block. Try reloading the page.'));
566
  }
567
  });
568
  yield loadAssets(assets);
569
+ const registeredBlocks = yield external_wp_data_namespaceObject.controls.select(external_wp_blocks_namespaceObject.store, 'getBlockTypes');
570
 
571
  if (!registeredBlocks.some(i => i.name === block.name)) {
572
  throw new Error((0,external_wp_i18n_namespaceObject.__)('Error registering block. Try reloading the page.'));
build/block-directory/index.min.asset.php CHANGED
@@ -1 +1 @@
1
- <?php return array('dependencies' => array('lodash', 'wp-a11y', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-data-controls', 'wp-edit-post', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-html-entities', 'wp-i18n', 'wp-notices', 'wp-plugins', 'wp-polyfill', 'wp-primitives'), 'version' => 'b3109a2dd6422202672ef1cdd5631f05');
1
+ <?php return array('dependencies' => array('lodash', 'wp-a11y', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-data-controls', 'wp-edit-post', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-html-entities', 'wp-i18n', 'wp-notices', 'wp-plugins', 'wp-polyfill', 'wp-primitives'), 'version' => '8d08e92fb0e9378b598429cbc8a31f64');
build/block-directory/index.min.js CHANGED
@@ -1,4 +1,4 @@
1
- !function(){"use strict";var e={n:function(t){var l=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(l,{a:l}),l},d:function(t,l){for(var n in l)e.o(l,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:l[n]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r:function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{store:function(){return $}});var l={};e.r(l),e.d(l,{getDownloadableBlocks:function(){return _},getErrorNoticeForBlock:function(){return h},getErrorNotices:function(){return f},getInstalledBlockTypes:function(){return w},getNewBlockTypes:function(){return E},getUnusedBlockTypes:function(){return y},isInstalling:function(){return g},isRequestingDownloadableBlocks:function(){return b}});var n={};e.r(n),e.d(n,{addInstalledBlockType:function(){return R},clearErrorNotice:function(){return V},fetchDownloadableBlocks:function(){return C},installBlockType:function(){return D},receiveDownloadableBlocks:function(){return O},removeInstalledBlockType:function(){return A},setErrorNotice:function(){return F},setIsInstalling:function(){return M},uninstallBlockType:function(){return P}});var o=window.wp.element,r=window.wp.plugins,a=window.wp.hooks,i=window.wp.blocks,s=window.wp.data,c=window.wp.editor,d=window.wp.dataControls,u=window.lodash,m=(0,s.combineReducers)({downloadableBlocks:(e={},t)=>{switch(t.type){case"FETCH_DOWNLOADABLE_BLOCKS":return{...e,[t.filterValue]:{isRequesting:!0}};case"RECEIVE_DOWNLOADABLE_BLOCKS":return{...e,[t.filterValue]:{results:t.downloadableBlocks,isRequesting:!1}}}return e},blockManagement:(e={installedBlockTypes:[],isInstalling:{}},t)=>{switch(t.type){case"ADD_INSTALLED_BLOCK_TYPE":return{...e,installedBlockTypes:[...e.installedBlockTypes,t.item]};case"REMOVE_INSTALLED_BLOCK_TYPE":return{...e,installedBlockTypes:e.installedBlockTypes.filter((e=>e.name!==t.item.name))};case"SET_INSTALLING_BLOCK":return{...e,isInstalling:{...e.isInstalling,[t.blockId]:t.isInstalling}}}return e},errorNotices:(e={},t)=>{switch(t.type){case"SET_ERROR_NOTICE":return{...e,[t.blockId]:{message:t.message,isFatal:t.isFatal}};case"CLEAR_ERROR_NOTICE":return(0,u.omit)(e,t.blockId)}return e}}),p=window.wp.blockEditor;function k(e,t=[]){if(!t.length)return!1;if(t.some((({name:t})=>t===e.name)))return!0;for(let l=0;l<t.length;l++)if(k(e,t[l].innerBlocks))return!0;return!1}function b(e,t){return!(!e.downloadableBlocks[t]||!e.downloadableBlocks[t].isRequesting)&&e.downloadableBlocks[t].isRequesting}function _(e,t){return e.downloadableBlocks[t]&&e.downloadableBlocks[t].results?e.downloadableBlocks[t].results:[]}function w(e){return e.blockManagement.installedBlockTypes}const E=(0,s.createRegistrySelector)((e=>t=>{const l=e(p.store).getBlocks();return w(t).filter((e=>k(e,l)))})),y=(0,s.createRegistrySelector)((e=>t=>{const l=e(p.store).getBlocks();return w(t).filter((e=>!k(e,l)))}));function g(e,t){return e.blockManagement.isInstalling[t]||!1}function f(e){return e.errorNotices}function h(e,t){return e.errorNotices[t]}var B=window.wp.i18n,v=window.wp.notices,N=window.wp.apiFetch,I=e.n(N);const T=e=>new Promise(((t,l)=>{const n=document.createElement(e.nodeName);["id","rel","src","href","type"].forEach((t=>{e[t]&&(n[t]=e[t])})),e.innerHTML&&n.appendChild(document.createTextNode(e.innerHTML)),n.onload=()=>t(!0),n.onerror=()=>l(new Error("Error loading asset.")),document.body.appendChild(n),("link"===n.nodeName.toLowerCase()||"script"===n.nodeName.toLowerCase()&&!n.src)&&t()}));var S={async LOAD_ASSETS(){const e=await I()({url:document.location.href,parse:!1}),t=await e.text(),l=(new window.DOMParser).parseFromString(t,"text/html"),n=Array.from(l.querySelectorAll('link[rel="stylesheet"],script')).filter((e=>e.id&&!document.getElementById(e.id)));for(const e of n)await T(e)}};function L(e){if(!e)return!1;const t=e.links["wp:plugin"]||e.links.self;return!(!t||!t.length)&&t[0].href}function C(e){return{type:"FETCH_DOWNLOADABLE_BLOCKS",filterValue:e}}function O(e,t){return{type:"RECEIVE_DOWNLOADABLE_BLOCKS",downloadableBlocks:e,filterValue:t}}function*D(e){const{id:t,assets:l}=e;let n=!1;yield V(t);try{yield M(e.id,!0);const t=L(e);let o={};if(t?yield(0,d.apiFetch)({url:t,data:{status:"active"},method:"PUT"}):o=(yield(0,d.apiFetch)({path:"wp/v2/plugins",data:{slug:e.id,status:"active"},method:"POST"}))._links,yield R({...e,links:{...e.links,...o}}),yield function(e){return{type:"LOAD_ASSETS",assets:e}}(l),!(yield s.controls.select(i.store.name,"getBlockTypes")).some((t=>t.name===e.name)))throw new Error((0,B.__)("Error registering block. Try reloading the page."));yield s.controls.dispatch(v.store,"createInfoNotice",(0,B.sprintf)(// translators: %s is the block title.
2
  (0,B.__)("Block %s installed and added."),e.title),{speak:!0,type:"snackbar"}),n=!0}catch(e){let l=e.message||(0,B.__)("An error occurred."),n=e instanceof Error;const o={folder_exists:(0,B.__)("This block is already installed. Try reloading the page."),unable_to_connect_to_filesystem:(0,B.__)("Error installing block. You can reload the page and try again.")};o[e.code]&&(n=!0,l=o[e.code]),yield F(t,l,n),yield s.controls.dispatch(v.store,"createErrorNotice",l,{speak:!0,isDismissible:!0})}return yield M(e.id,!1),n}function*P(e){try{yield(0,d.apiFetch)({url:L(e),data:{status:"inactive"},method:"PUT"}),yield(0,d.apiFetch)({url:L(e),method:"DELETE"}),yield A(e)}catch(e){yield s.controls.dispatch(v.store,"createErrorNotice",e.message||(0,B.__)("An error occurred."))}}function R(e){return{type:"ADD_INSTALLED_BLOCK_TYPE",item:e}}function A(e){return{type:"REMOVE_INSTALLED_BLOCK_TYPE",item:e}}function M(e,t){return{type:"SET_INSTALLING_BLOCK",blockId:e,isInstalling:t}}function F(e,t,l=!1){return{type:"SET_ERROR_NOTICE",blockId:e,message:t,isFatal:l}}function V(e){return{type:"CLEAR_ERROR_NOTICE",blockId:e}}var H={*getDownloadableBlocks(e){if(e)try{yield C(e);const t=(yield(0,d.apiFetch)({path:`wp/v2/block-directory/search?term=${e}`})).map((e=>(0,u.mapKeys)(e,((e,t)=>(0,u.camelCase)(t)))));yield O(t,e)}catch(e){}}};const x={reducer:m,selectors:l,actions:n,controls:{...d.controls,...S},resolvers:H},$=(0,s.createReduxStore)("core/block-directory",x);function K(){const{uninstallBlockType:e}=(0,s.useDispatch)($),t=(0,s.useSelect)((e=>{const{isAutosavingPost:t,isSavingPost:l}=e(c.store);return l()&&!t()}),[]),l=(0,s.useSelect)((e=>e($).getUnusedBlockTypes()),[]);return(0,o.useEffect)((()=>{t&&l.length&&l.forEach((t=>{e(t),(0,i.unregisterBlockType)(t.name)}))}),[t]),null}(0,s.register)($);var z=window.wp.components,q=window.wp.compose,Y=window.wp.coreData;function j(){return(j=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var l=arguments[t];for(var n in l)Object.prototype.hasOwnProperty.call(l,n)&&(e[n]=l[n])}return e}).apply(this,arguments)}var U=window.wp.htmlEntities,G=function({icon:e,size:t=24,...l}){return(0,o.cloneElement)(e,{width:t,height:t,...l})},W=window.wp.primitives,J=(0,o.createElement)(W.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,o.createElement)(W.Path,{d:"M11.776 4.454a.25.25 0 01.448 0l2.069 4.192a.25.25 0 00.188.137l4.626.672a.25.25 0 01.139.426l-3.348 3.263a.25.25 0 00-.072.222l.79 4.607a.25.25 0 01-.362.263l-4.138-2.175a.25.25 0 00-.232 0l-4.138 2.175a.25.25 0 01-.363-.263l.79-4.607a.25.25 0 00-.071-.222L4.754 9.881a.25.25 0 01.139-.426l4.626-.672a.25.25 0 00.188-.137l2.069-4.192z"})),Q=(0,o.createElement)(W.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,o.createElement)(W.Path,{d:"M9.518 8.783a.25.25 0 00.188-.137l2.069-4.192a.25.25 0 01.448 0l2.07 4.192a.25.25 0 00.187.137l4.626.672a.25.25 0 01.139.427l-3.347 3.262a.25.25 0 00-.072.222l.79 4.607a.25.25 0 01-.363.264l-4.137-2.176a.25.25 0 00-.233 0l-4.138 2.175a.25.25 0 01-.362-.263l.79-4.607a.25.25 0 00-.072-.222L4.753 9.882a.25.25 0 01.14-.427l4.625-.672zM12 14.533c.28 0 .559.067.814.2l1.895.997-.362-2.11a1.75 1.75 0 01.504-1.55l1.533-1.495-2.12-.308a1.75 1.75 0 01-1.317-.957L12 7.39v7.143z"})),X=(0,o.createElement)(W.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,o.createElement)(W.Path,{fillRule:"evenodd",d:"M9.706 8.646a.25.25 0 01-.188.137l-4.626.672a.25.25 0 00-.139.427l3.348 3.262a.25.25 0 01.072.222l-.79 4.607a.25.25 0 00.362.264l4.138-2.176a.25.25 0 01.233 0l4.137 2.175a.25.25 0 00.363-.263l-.79-4.607a.25.25 0 01.072-.222l3.347-3.262a.25.25 0 00-.139-.427l-4.626-.672a.25.25 0 01-.188-.137l-2.069-4.192a.25.25 0 00-.448 0L9.706 8.646zM12 7.39l-.948 1.921a1.75 1.75 0 01-1.317.957l-2.12.308 1.534 1.495c.412.402.6.982.503 1.55l-.362 2.11 1.896-.997a1.75 1.75 0 011.629 0l1.895.997-.362-2.11a1.75 1.75 0 01.504-1.55l1.533-1.495-2.12-.308a1.75 1.75 0 01-1.317-.957L12 7.39z",clipRule:"evenodd"})),Z=function({rating:e}){const t=.5*Math.round(e/.5),l=Math.floor(e),n=Math.ceil(e-l),r=5-(l+n);return(0,o.createElement)("span",{"aria-label":(0,B.sprintf)(
3
  /* translators: %s: number of stars. */
4
  (0,B.__)("%s out of 5 stars"),t)},(0,u.times)(l,(e=>(0,o.createElement)(G,{key:`full_stars_${e}`,className:"block-directory-block-ratings__star-full",icon:J,size:16}))),(0,u.times)(n,(e=>(0,o.createElement)(G,{key:`half_stars_${e}`,className:"block-directory-block-ratings__star-half-full",icon:Q,size:16}))),(0,u.times)(r,(e=>(0,o.createElement)(G,{key:`empty_stars_${e}`,className:"block-directory-block-ratings__star-empty",icon:X,size:16}))))},ee=({rating:e})=>(0,o.createElement)("span",{className:"block-directory-block-ratings"},(0,o.createElement)(Z,{rating:e})),te=function({icon:e}){const t="block-directory-downloadable-block-icon";return null!==e.match(/\.(jpeg|jpg|gif|png|svg)(?:\?.*)?$/)?(0,o.createElement)("img",{className:t,src:e,alt:""}):(0,o.createElement)(p.BlockIcon,{className:t,icon:e,showColors:!0})},le=({block:e})=>{const t=(0,s.useSelect)((t=>t($).getErrorNoticeForBlock(e.id)),[e]);return t?(0,o.createElement)("div",{className:"block-directory-downloadable-block-notice"},(0,o.createElement)("div",{className:"block-directory-downloadable-block-notice__content"},t.message,t.isFatal?" "+(0,B.__)("Try reloading the page."):null)):null};function ne({title:e,rating:t,ratingCount:l},{hasNotice:n,isInstalled:o,isInstalling:r}){const a=.5*Math.round(t/.5);return!o&&n?(0,B.sprintf)("Retry installing %s.",(0,U.decodeEntities)(e)):o?(0,B.sprintf)("Add %s.",(0,U.decodeEntities)(e)):r?(0,B.sprintf)("Installing %s.",(0,U.decodeEntities)(e)):l<1?(0,B.sprintf)("Install %s.",(0,U.decodeEntities)(e)):(0,B.sprintf)(
1
+ !function(){"use strict";var e={n:function(t){var l=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(l,{a:l}),l},d:function(t,l){for(var n in l)e.o(l,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:l[n]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r:function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{store:function(){return $}});var l={};e.r(l),e.d(l,{getDownloadableBlocks:function(){return _},getErrorNoticeForBlock:function(){return h},getErrorNotices:function(){return f},getInstalledBlockTypes:function(){return w},getNewBlockTypes:function(){return E},getUnusedBlockTypes:function(){return y},isInstalling:function(){return g},isRequestingDownloadableBlocks:function(){return b}});var n={};e.r(n),e.d(n,{addInstalledBlockType:function(){return R},clearErrorNotice:function(){return V},fetchDownloadableBlocks:function(){return C},installBlockType:function(){return D},receiveDownloadableBlocks:function(){return O},removeInstalledBlockType:function(){return A},setErrorNotice:function(){return F},setIsInstalling:function(){return M},uninstallBlockType:function(){return P}});var o=window.wp.element,r=window.wp.plugins,a=window.wp.hooks,i=window.wp.blocks,s=window.wp.data,c=window.wp.editor,d=window.wp.dataControls,u=window.lodash,m=(0,s.combineReducers)({downloadableBlocks:(e={},t)=>{switch(t.type){case"FETCH_DOWNLOADABLE_BLOCKS":return{...e,[t.filterValue]:{isRequesting:!0}};case"RECEIVE_DOWNLOADABLE_BLOCKS":return{...e,[t.filterValue]:{results:t.downloadableBlocks,isRequesting:!1}}}return e},blockManagement:(e={installedBlockTypes:[],isInstalling:{}},t)=>{switch(t.type){case"ADD_INSTALLED_BLOCK_TYPE":return{...e,installedBlockTypes:[...e.installedBlockTypes,t.item]};case"REMOVE_INSTALLED_BLOCK_TYPE":return{...e,installedBlockTypes:e.installedBlockTypes.filter((e=>e.name!==t.item.name))};case"SET_INSTALLING_BLOCK":return{...e,isInstalling:{...e.isInstalling,[t.blockId]:t.isInstalling}}}return e},errorNotices:(e={},t)=>{switch(t.type){case"SET_ERROR_NOTICE":return{...e,[t.blockId]:{message:t.message,isFatal:t.isFatal}};case"CLEAR_ERROR_NOTICE":return(0,u.omit)(e,t.blockId)}return e}}),p=window.wp.blockEditor;function k(e,t=[]){if(!t.length)return!1;if(t.some((({name:t})=>t===e.name)))return!0;for(let l=0;l<t.length;l++)if(k(e,t[l].innerBlocks))return!0;return!1}function b(e,t){return!(!e.downloadableBlocks[t]||!e.downloadableBlocks[t].isRequesting)&&e.downloadableBlocks[t].isRequesting}function _(e,t){return e.downloadableBlocks[t]&&e.downloadableBlocks[t].results?e.downloadableBlocks[t].results:[]}function w(e){return e.blockManagement.installedBlockTypes}const E=(0,s.createRegistrySelector)((e=>t=>{const l=e(p.store).getBlocks();return w(t).filter((e=>k(e,l)))})),y=(0,s.createRegistrySelector)((e=>t=>{const l=e(p.store).getBlocks();return w(t).filter((e=>!k(e,l)))}));function g(e,t){return e.blockManagement.isInstalling[t]||!1}function f(e){return e.errorNotices}function h(e,t){return e.errorNotices[t]}var B=window.wp.i18n,v=window.wp.notices,N=window.wp.apiFetch,I=e.n(N);const T=e=>new Promise(((t,l)=>{const n=document.createElement(e.nodeName);["id","rel","src","href","type"].forEach((t=>{e[t]&&(n[t]=e[t])})),e.innerHTML&&n.appendChild(document.createTextNode(e.innerHTML)),n.onload=()=>t(!0),n.onerror=()=>l(new Error("Error loading asset.")),document.body.appendChild(n),("link"===n.nodeName.toLowerCase()||"script"===n.nodeName.toLowerCase()&&!n.src)&&t()}));var S={async LOAD_ASSETS(){const e=await I()({url:document.location.href,parse:!1}),t=await e.text(),l=(new window.DOMParser).parseFromString(t,"text/html"),n=Array.from(l.querySelectorAll('link[rel="stylesheet"],script')).filter((e=>e.id&&!document.getElementById(e.id)));for(const e of n)await T(e)}};function L(e){if(!e)return!1;const t=e.links["wp:plugin"]||e.links.self;return!(!t||!t.length)&&t[0].href}function C(e){return{type:"FETCH_DOWNLOADABLE_BLOCKS",filterValue:e}}function O(e,t){return{type:"RECEIVE_DOWNLOADABLE_BLOCKS",downloadableBlocks:e,filterValue:t}}function*D(e){const{id:t,assets:l}=e;let n=!1;yield V(t);try{yield M(e.id,!0);const t=L(e);let o={};if(t?yield(0,d.apiFetch)({url:t,data:{status:"active"},method:"PUT"}):o=(yield(0,d.apiFetch)({path:"wp/v2/plugins",data:{slug:e.id,status:"active"},method:"POST"}))._links,yield R({...e,links:{...e.links,...o}}),yield function(e){return{type:"LOAD_ASSETS",assets:e}}(l),!(yield s.controls.select(i.store,"getBlockTypes")).some((t=>t.name===e.name)))throw new Error((0,B.__)("Error registering block. Try reloading the page."));yield s.controls.dispatch(v.store,"createInfoNotice",(0,B.sprintf)(// translators: %s is the block title.
2
  (0,B.__)("Block %s installed and added."),e.title),{speak:!0,type:"snackbar"}),n=!0}catch(e){let l=e.message||(0,B.__)("An error occurred."),n=e instanceof Error;const o={folder_exists:(0,B.__)("This block is already installed. Try reloading the page."),unable_to_connect_to_filesystem:(0,B.__)("Error installing block. You can reload the page and try again.")};o[e.code]&&(n=!0,l=o[e.code]),yield F(t,l,n),yield s.controls.dispatch(v.store,"createErrorNotice",l,{speak:!0,isDismissible:!0})}return yield M(e.id,!1),n}function*P(e){try{yield(0,d.apiFetch)({url:L(e),data:{status:"inactive"},method:"PUT"}),yield(0,d.apiFetch)({url:L(e),method:"DELETE"}),yield A(e)}catch(e){yield s.controls.dispatch(v.store,"createErrorNotice",e.message||(0,B.__)("An error occurred."))}}function R(e){return{type:"ADD_INSTALLED_BLOCK_TYPE",item:e}}function A(e){return{type:"REMOVE_INSTALLED_BLOCK_TYPE",item:e}}function M(e,t){return{type:"SET_INSTALLING_BLOCK",blockId:e,isInstalling:t}}function F(e,t,l=!1){return{type:"SET_ERROR_NOTICE",blockId:e,message:t,isFatal:l}}function V(e){return{type:"CLEAR_ERROR_NOTICE",blockId:e}}var H={*getDownloadableBlocks(e){if(e)try{yield C(e);const t=(yield(0,d.apiFetch)({path:`wp/v2/block-directory/search?term=${e}`})).map((e=>(0,u.mapKeys)(e,((e,t)=>(0,u.camelCase)(t)))));yield O(t,e)}catch(e){}}};const x={reducer:m,selectors:l,actions:n,controls:{...d.controls,...S},resolvers:H},$=(0,s.createReduxStore)("core/block-directory",x);function K(){const{uninstallBlockType:e}=(0,s.useDispatch)($),t=(0,s.useSelect)((e=>{const{isAutosavingPost:t,isSavingPost:l}=e(c.store);return l()&&!t()}),[]),l=(0,s.useSelect)((e=>e($).getUnusedBlockTypes()),[]);return(0,o.useEffect)((()=>{t&&l.length&&l.forEach((t=>{e(t),(0,i.unregisterBlockType)(t.name)}))}),[t]),null}(0,s.register)($);var z=window.wp.components,q=window.wp.compose,Y=window.wp.coreData;function j(){return(j=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var l=arguments[t];for(var n in l)Object.prototype.hasOwnProperty.call(l,n)&&(e[n]=l[n])}return e}).apply(this,arguments)}var U=window.wp.htmlEntities,G=function({icon:e,size:t=24,...l}){return(0,o.cloneElement)(e,{width:t,height:t,...l})},W=window.wp.primitives,J=(0,o.createElement)(W.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,o.createElement)(W.Path,{d:"M11.776 4.454a.25.25 0 01.448 0l2.069 4.192a.25.25 0 00.188.137l4.626.672a.25.25 0 01.139.426l-3.348 3.263a.25.25 0 00-.072.222l.79 4.607a.25.25 0 01-.362.263l-4.138-2.175a.25.25 0 00-.232 0l-4.138 2.175a.25.25 0 01-.363-.263l.79-4.607a.25.25 0 00-.071-.222L4.754 9.881a.25.25 0 01.139-.426l4.626-.672a.25.25 0 00.188-.137l2.069-4.192z"})),Q=(0,o.createElement)(W.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,o.createElement)(W.Path,{d:"M9.518 8.783a.25.25 0 00.188-.137l2.069-4.192a.25.25 0 01.448 0l2.07 4.192a.25.25 0 00.187.137l4.626.672a.25.25 0 01.139.427l-3.347 3.262a.25.25 0 00-.072.222l.79 4.607a.25.25 0 01-.363.264l-4.137-2.176a.25.25 0 00-.233 0l-4.138 2.175a.25.25 0 01-.362-.263l.79-4.607a.25.25 0 00-.072-.222L4.753 9.882a.25.25 0 01.14-.427l4.625-.672zM12 14.533c.28 0 .559.067.814.2l1.895.997-.362-2.11a1.75 1.75 0 01.504-1.55l1.533-1.495-2.12-.308a1.75 1.75 0 01-1.317-.957L12 7.39v7.143z"})),X=(0,o.createElement)(W.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,o.createElement)(W.Path,{fillRule:"evenodd",d:"M9.706 8.646a.25.25 0 01-.188.137l-4.626.672a.25.25 0 00-.139.427l3.348 3.262a.25.25 0 01.072.222l-.79 4.607a.25.25 0 00.362.264l4.138-2.176a.25.25 0 01.233 0l4.137 2.175a.25.25 0 00.363-.263l-.79-4.607a.25.25 0 01.072-.222l3.347-3.262a.25.25 0 00-.139-.427l-4.626-.672a.25.25 0 01-.188-.137l-2.069-4.192a.25.25 0 00-.448 0L9.706 8.646zM12 7.39l-.948 1.921a1.75 1.75 0 01-1.317.957l-2.12.308 1.534 1.495c.412.402.6.982.503 1.55l-.362 2.11 1.896-.997a1.75 1.75 0 011.629 0l1.895.997-.362-2.11a1.75 1.75 0 01.504-1.55l1.533-1.495-2.12-.308a1.75 1.75 0 01-1.317-.957L12 7.39z",clipRule:"evenodd"})),Z=function({rating:e}){const t=.5*Math.round(e/.5),l=Math.floor(e),n=Math.ceil(e-l),r=5-(l+n);return(0,o.createElement)("span",{"aria-label":(0,B.sprintf)(
3
  /* translators: %s: number of stars. */
4
  (0,B.__)("%s out of 5 stars"),t)},(0,u.times)(l,(e=>(0,o.createElement)(G,{key:`full_stars_${e}`,className:"block-directory-block-ratings__star-full",icon:J,size:16}))),(0,u.times)(n,(e=>(0,o.createElement)(G,{key:`half_stars_${e}`,className:"block-directory-block-ratings__star-half-full",icon:Q,size:16}))),(0,u.times)(r,(e=>(0,o.createElement)(G,{key:`empty_stars_${e}`,className:"block-directory-block-ratings__star-empty",icon:X,size:16}))))},ee=({rating:e})=>(0,o.createElement)("span",{className:"block-directory-block-ratings"},(0,o.createElement)(Z,{rating:e})),te=function({icon:e}){const t="block-directory-downloadable-block-icon";return null!==e.match(/\.(jpeg|jpg|gif|png|svg)(?:\?.*)?$/)?(0,o.createElement)("img",{className:t,src:e,alt:""}):(0,o.createElement)(p.BlockIcon,{className:t,icon:e,showColors:!0})},le=({block:e})=>{const t=(0,s.useSelect)((t=>t($).getErrorNoticeForBlock(e.id)),[e]);return t?(0,o.createElement)("div",{className:"block-directory-downloadable-block-notice"},(0,o.createElement)("div",{className:"block-directory-downloadable-block-notice__content"},t.message,t.isFatal?" "+(0,B.__)("Try reloading the page."):null)):null};function ne({title:e,rating:t,ratingCount:l},{hasNotice:n,isInstalled:o,isInstalling:r}){const a=.5*Math.round(t/.5);return!o&&n?(0,B.sprintf)("Retry installing %s.",(0,U.decodeEntities)(e)):o?(0,B.sprintf)("Add %s.",(0,U.decodeEntities)(e)):r?(0,B.sprintf)("Installing %s.",(0,U.decodeEntities)(e)):l<1?(0,B.sprintf)("Install %s.",(0,U.decodeEntities)(e)):(0,B.sprintf)(
build/block-editor/index.js CHANGED
@@ -486,172 +486,6 @@ var computedStyle = function (el, prop, getComputedStyle) {
486
  module.exports = computedStyle;
487
 
488
 
489
- /***/ }),
490
-
491
- /***/ 8988:
492
- /***/ (function(__unused_webpack_module, exports) {
493
-
494
- "use strict";
495
- var __webpack_unused_export__;
496
- /*
497
- Copyright (c) 2014, Yahoo! Inc. All rights reserved.
498
- Copyrights licensed under the New BSD License.
499
- See the accompanying LICENSE file for terms.
500
- */
501
-
502
-
503
-
504
- exports.E = matchQuery;
505
- __webpack_unused_export__ = parseQuery;
506
-
507
- // -----------------------------------------------------------------------------
508
-
509
- var RE_MEDIA_QUERY = /(?:(only|not)?\s*([^\s\(\)]+)(?:\s*and)?\s*)?(.+)?/i,
510
- RE_MQ_EXPRESSION = /\(\s*([^\s\:\)]+)\s*(?:\:\s*([^\s\)]+))?\s*\)/,
511
- RE_MQ_FEATURE = /^(?:(min|max)-)?(.+)/,
512
- RE_LENGTH_UNIT = /(em|rem|px|cm|mm|in|pt|pc)?$/,
513
- RE_RESOLUTION_UNIT = /(dpi|dpcm|dppx)?$/;
514
-
515
- function matchQuery(mediaQuery, values) {
516
- return parseQuery(mediaQuery).some(function (query) {
517
- var inverse = query.inverse;
518
-
519
- // Either the parsed or specified `type` is "all", or the types must be
520
- // equal for a match.
521
- var typeMatch = query.type === 'all' || values.type === query.type;
522
-
523
- // Quit early when `type` doesn't match, but take "not" into account.
524
- if ((typeMatch && inverse) || !(typeMatch || inverse)) {
525
- return false;
526
- }
527
-
528
- var expressionsMatch = query.expressions.every(function (expression) {
529
- var feature = expression.feature,
530
- modifier = expression.modifier,
531
- expValue = expression.value,
532
- value = values[feature];
533
-
534
- // Missing or falsy values don't match.
535
- if (!value) { return false; }
536
-
537
- switch (feature) {
538
- case 'orientation':
539
- case 'scan':
540
- return value.toLowerCase() === expValue.toLowerCase();
541
-
542
- case 'width':
543
- case 'height':
544
- case 'device-width':
545
- case 'device-height':
546
- expValue = toPx(expValue);
547
- value = toPx(value);
548
- break;
549
-
550
- case 'resolution':
551
- expValue = toDpi(expValue);
552
- value = toDpi(value);
553
- break;
554
-
555
- case 'aspect-ratio':
556
- case 'device-aspect-ratio':
557
- case /* Deprecated */ 'device-pixel-ratio':
558
- expValue = toDecimal(expValue);
559
- value = toDecimal(value);
560
- break;
561
-
562
- case 'grid':
563
- case 'color':
564
- case 'color-index':
565
- case 'monochrome':
566
- expValue = parseInt(expValue, 10) || 1;
567
- value = parseInt(value, 10) || 0;
568
- break;
569
- }
570
-
571
- switch (modifier) {
572
- case 'min': return value >= expValue;
573
- case 'max': return value <= expValue;
574
- default : return value === expValue;
575
- }
576
- });
577
-
578
- return (expressionsMatch && !inverse) || (!expressionsMatch && inverse);
579
- });
580
- }
581
-
582
- function parseQuery(mediaQuery) {
583
- return mediaQuery.split(',').map(function (query) {
584
- query = query.trim();
585
-
586
- var captures = query.match(RE_MEDIA_QUERY),
587
- modifier = captures[1],
588
- type = captures[2],
589
- expressions = captures[3] || '',
590
- parsed = {};
591
-
592
- parsed.inverse = !!modifier && modifier.toLowerCase() === 'not';
593
- parsed.type = type ? type.toLowerCase() : 'all';
594
-
595
- // Split expressions into a list.
596
- expressions = expressions.match(/\([^\)]+\)/g) || [];
597
-
598
- parsed.expressions = expressions.map(function (expression) {
599
- var captures = expression.match(RE_MQ_EXPRESSION),
600
- feature = captures[1].toLowerCase().match(RE_MQ_FEATURE);
601
-
602
- return {
603
- modifier: feature[1],
604
- feature : feature[2],
605
- value : captures[2]
606
- };
607
- });
608
-
609
- return parsed;
610
- });
611
- }
612
-
613
- // -- Utilities ----------------------------------------------------------------
614
-
615
- function toDecimal(ratio) {
616
- var decimal = Number(ratio),
617
- numbers;
618
-
619
- if (!decimal) {
620
- numbers = ratio.match(/^(\d+)\s*\/\s*(\d+)$/);
621
- decimal = numbers[1] / numbers[2];
622
- }
623
-
624
- return decimal;
625
- }
626
-
627
- function toDpi(resolution) {
628
- var value = parseFloat(resolution),
629
- units = String(resolution).match(RE_RESOLUTION_UNIT)[1];
630
-
631
- switch (units) {
632
- case 'dpcm': return value / 2.54;
633
- case 'dppx': return value * 96;
634
- default : return value;
635
- }
636
- }
637
-
638
- function toPx(length) {
639
- var value = parseFloat(length),
640
- units = String(length).match(RE_LENGTH_UNIT)[1];
641
-
642
- switch (units) {
643
- case 'em' : return value * 16;
644
- case 'rem': return value * 16;
645
- case 'cm' : return value * 96 / 2.54;
646
- case 'mm' : return value * 96 / 2.54 / 10;
647
- case 'in' : return value * 96;
648
- case 'pt' : return value * 72;
649
- case 'pc' : return value * 72 / 12;
650
- default : return value;
651
- }
652
- }
653
-
654
-
655
  /***/ }),
656
 
657
  /***/ 5913:
@@ -5963,7 +5797,7 @@ __webpack_require__.d(__webpack_exports__, {
5963
  "FontSizePicker": function() { return /* reexport */ font_size_picker; },
5964
  "InnerBlocks": function() { return /* reexport */ inner_blocks; },
5965
  "Inserter": function() { return /* reexport */ inserter; },
5966
- "InspectorAdvancedControls": function() { return /* reexport */ inspector_advanced_controls; },
5967
  "InspectorControls": function() { return /* reexport */ inspector_controls; },
5968
  "JustifyContentControl": function() { return /* reexport */ JustifyContentControl; },
5969
  "JustifyToolbar": function() { return /* reexport */ JustifyToolbar; },
@@ -6031,7 +5865,6 @@ __webpack_require__.d(__webpack_exports__, {
6031
  "__experimentalUseInnerBlocksProps": function() { return /* reexport */ useInnerBlocksProps; },
6032
  "__experimentalUseNoRecursiveRenders": function() { return /* reexport */ useNoRecursiveRenders; },
6033
  "__experimentalUseResizeCanvas": function() { return /* reexport */ useResizeCanvas; },
6034
- "__experimentalUseSimulatedMediaQuery": function() { return /* reexport */ useSimulatedMediaQuery; },
6035
  "__unstableBlockSettingsMenuFirstItem": function() { return /* reexport */ block_settings_menu_first_item; },
6036
  "__unstableEditorStyles": function() { return /* reexport */ EditorStyles; },
6037
  "__unstableIframe": function() { return /* reexport */ iframe; },
@@ -6254,30 +6087,25 @@ var external_wp_blocks_namespaceObject = window["wp"]["blocks"];
6254
  var external_wp_components_namespaceObject = window["wp"]["components"];
6255
  ;// CONCATENATED MODULE: external ["wp","data"]
6256
  var external_wp_data_namespaceObject = window["wp"]["data"];
6257
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-edit/context.js
6258
  /**
6259
  * WordPress dependencies
6260
  */
6261
 
6262
- const Context = (0,external_wp_element_namespaceObject.createContext)({
6263
- name: '',
6264
- isSelected: false,
6265
- clientId: null
6266
- });
6267
- const {
6268
- Provider
6269
- } = Context;
6270
-
6271
- /**
6272
- * A hook that returns the block edit context.
6273
- *
6274
- * @return {Object} Block edit context
6275
- */
6276
-
6277
- function useBlockEditContext() {
6278
- return (0,external_wp_element_namespaceObject.useContext)(Context);
6279
- }
6280
- //# sourceMappingURL=context.js.map
6281
  ;// CONCATENATED MODULE: external ["wp","i18n"]
6282
  var external_wp_i18n_namespaceObject = window["wp"]["i18n"];
6283
  ;// CONCATENATED MODULE: ./packages/block-editor/build-module/store/defaults.js
@@ -6309,6 +6137,7 @@ const PREFERENCES_DEFAULTS = {
6309
  * @property {boolean} __experimentalBlockDirectory Whether the user has enabled the Block Directory
6310
  * @property {Array} __experimentalBlockPatterns Array of objects representing the block patterns
6311
  * @property {Array} __experimentalBlockPatternCategories Array of objects representing the block pattern categories
 
6312
  */
6313
 
6314
  const SETTINGS_DEFAULTS = {
@@ -6420,6 +6249,7 @@ const SETTINGS_DEFAULTS = {
6420
  __experimentalBlockPatterns: [],
6421
  __experimentalBlockPatternCategories: [],
6422
  __experimentalSpotlightEntityBlocks: [],
 
6423
  // gradients setting is not used anymore now defaults are passed from theme.json on the server and core has its own defaults.
6424
  // The setting is only kept for backward compatibility purposes.
6425
  gradients: [{
@@ -9910,27 +9740,32 @@ const getInserterItems = rememo((state, rootClientId = null) => {
9910
  const variationMapper = getItemFromVariation(state, item);
9911
  blockVariations.push(...variations.map(variationMapper));
9912
  }
9913
- } // Prioritize core blocks's display in inserter.
9914
-
9915
-
9916
- const prioritizeCoreBlocks = (a, b) => {
9917
- const coreBlockNamePrefix = 'core/';
9918
- const firstIsCoreBlock = a.name.startsWith(coreBlockNamePrefix);
9919
- const secondIsCoreBlock = b.name.startsWith(coreBlockNamePrefix);
9920
-
9921
- if (firstIsCoreBlock && secondIsCoreBlock) {
9922
- return 0;
9923
- }
9924
-
9925
- return firstIsCoreBlock && !secondIsCoreBlock ? -1 : 1;
9926
- }; // Ensure core blocks are prioritized in the returned results,
9927
  // because third party blocks can be registered earlier than
9928
  // the core blocks (usually by using the `init` action),
9929
  // thus affecting the display order.
9930
  // We don't sort reusable blocks as they are handled differently.
9931
 
9932
 
9933
- const sortedBlockTypes = [...visibleBlockTypeInserterItems, ...blockVariations].sort(prioritizeCoreBlocks);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9934
  return [...sortedBlockTypes, ...reusableBlockInserterItems];
9935
  }, (state, rootClientId) => [state.blockListSettings[rootClientId], state.blocks.byClientId, state.blocks.order, state.preferences.insertUsage, state.settings.allowedBlockTypes, state.settings.templateLock, getReusableBlocks(state), (0,external_wp_blocks_namespaceObject.getBlockTypes)()]);
9936
  /**
@@ -11641,6 +11476,30 @@ const store = (0,external_wp_data_namespaceObject.createReduxStore)(STORE_NAME,
11641
  persist: ['preferences']
11642
  });
11643
  //# sourceMappingURL=index.js.map
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11644
  ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/use-display-block-controls/index.js
11645
  /**
11646
  * WordPress dependencies
@@ -11658,10 +11517,9 @@ function useDisplayBlockControls() {
11658
  clientId,
11659
  name
11660
  } = useBlockEditContext();
11661
- const isFirstAndSameTypeMultiSelected = (0,external_wp_data_namespaceObject.useSelect)(select => {
11662
- // Don't bother checking, see OR statement below.
11663
  if (isSelected) {
11664
- return;
11665
  }
11666
 
11667
  const {
@@ -11670,32 +11528,57 @@ function useDisplayBlockControls() {
11670
  getMultiSelectedBlockClientIds
11671
  } = select(store);
11672
 
11673
- if (!isFirstMultiSelectedBlock(clientId)) {
11674
- return false;
11675
  }
11676
 
11677
- return getMultiSelectedBlockClientIds().every(id => getBlockName(id) === name);
11678
  }, [clientId, isSelected, name]);
11679
- return isSelected || isFirstAndSameTypeMultiSelected;
11680
  }
11681
  //# sourceMappingURL=index.js.map
11682
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-controls/groups.js
11683
  /**
11684
  * WordPress dependencies
11685
  */
11686
 
11687
- const BlockControlsDefault = (0,external_wp_components_namespaceObject.createSlotFill)('BlockControls');
11688
- const BlockControlsBlock = (0,external_wp_components_namespaceObject.createSlotFill)('BlockControlsBlock');
11689
- const BlockControlsInline = (0,external_wp_components_namespaceObject.createSlotFill)('BlockFormatControls');
11690
- const BlockControlsOther = (0,external_wp_components_namespaceObject.createSlotFill)('BlockControlsOther');
11691
- const groups = {
11692
- default: BlockControlsDefault,
11693
- block: BlockControlsBlock,
11694
- inline: BlockControlsInline,
11695
- other: BlockControlsOther
11696
- };
11697
- /* harmony default export */ var block_controls_groups = (groups);
11698
- //# sourceMappingURL=groups.js.map
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11699
  ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-controls/fill.js
11700
 
11701
 
@@ -11713,17 +11596,18 @@ const groups = {
11713
  */
11714
 
11715
 
11716
-
11717
  function BlockControlsFill({
11718
  group = 'default',
11719
  controls,
11720
- children
 
11721
  }) {
11722
- if (!useDisplayBlockControls()) {
 
 
11723
  return null;
11724
  }
11725
 
11726
- const Fill = block_controls_groups[group].Fill;
11727
  return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalStyleProvider, {
11728
  document: document
11729
  }, (0,external_wp_element_namespaceObject.createElement)(Fill, null, fillProps => {
@@ -11921,11 +11805,18 @@ function appendSelectors(selectors, append = '') {
11921
  save: function FlexLayoutStyle({
11922
  selector
11923
  }) {
11924
- return (0,external_wp_element_namespaceObject.createElement)("style", null, `${appendSelectors(selector)} {
11925
- display: flex;
11926
- column-gap: 0.5em;
11927
- align-items: center;
11928
- }`);
 
 
 
 
 
 
 
11929
  },
11930
 
11931
  getOrientation() {
@@ -12177,6 +12068,11 @@ function useSetting(path) {
12177
  float: right;
12178
  margin-left: 2em;
12179
  }
 
 
 
 
 
12180
  `;
12181
  return (0,external_wp_element_namespaceObject.createElement)("style", null, style);
12182
  },
@@ -12554,16 +12450,14 @@ const withToolbarControls = (0,external_wp_compose_namespaceObject.createHigherO
12554
  });
12555
  };
12556
 
12557
- return [validAlignments.length > 0 && props.isSelected && (0,external_wp_element_namespaceObject.createElement)(block_controls, {
12558
- key: "align-controls",
12559
- group: "block"
12560
  }, (0,external_wp_element_namespaceObject.createElement)(BlockAlignmentControl, {
12561
  value: props.attributes.align,
12562
  onChange: updateAlignment,
12563
  controls: validAlignments
12564
- })), (0,external_wp_element_namespaceObject.createElement)(BlockEdit, _extends({
12565
- key: "edit"
12566
- }, props))];
12567
  }, 'withToolbarControls');
12568
  /**
12569
  * Override the default block element to add alignment wrapper props.
@@ -12634,69 +12528,124 @@ function addAssignedAlign(props, blockType, attributes) {
12634
  (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockEdit', 'core/editor/align/with-toolbar-controls', withToolbarControls);
12635
  (0,external_wp_hooks_namespaceObject.addFilter)('blocks.getSaveContent.extraProps', 'core/align/addAssignedAlign', addAssignedAlign);
12636
  //# sourceMappingURL=align.js.map
12637
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/inspector-advanced-controls/index.js
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12638
 
12639
 
12640
  /**
12641
  * WordPress dependencies
12642
  */
12643
 
 
12644
  /**
12645
  * Internal dependencies
12646
  */
12647
 
12648
 
12649
- const inspector_advanced_controls_name = 'InspectorAdvancedControls';
12650
- const {
12651
- Fill,
12652
- Slot
12653
- } = (0,external_wp_components_namespaceObject.createSlotFill)(inspector_advanced_controls_name);
12654
 
12655
- function InspectorAdvancedControls({
 
12656
  children
12657
  }) {
12658
- const {
12659
- isSelected
12660
- } = useBlockEditContext();
12661
- return isSelected ? (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalStyleProvider, {
 
 
 
 
 
 
 
 
 
 
 
12662
  document: document
12663
- }, (0,external_wp_element_namespaceObject.createElement)(Fill, null, children)) : null;
12664
  }
 
 
12665
 
12666
- InspectorAdvancedControls.slotName = inspector_advanced_controls_name;
12667
- InspectorAdvancedControls.Slot = Slot;
12668
- /**
12669
- * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/inspector-advanced-controls/README.md
12670
- */
12671
-
12672
- /* harmony default export */ var inspector_advanced_controls = (InspectorAdvancedControls);
12673
- //# sourceMappingURL=index.js.map
12674
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/inspector-controls/index.js
12675
 
12676
 
12677
  /**
12678
  * WordPress dependencies
12679
  */
12680
 
 
12681
  /**
12682
  * Internal dependencies
12683
  */
12684
 
12685
 
12686
- const {
12687
- Fill: inspector_controls_Fill,
12688
- Slot: inspector_controls_Slot
12689
- } = (0,external_wp_components_namespaceObject.createSlotFill)('InspectorControls');
12690
-
12691
- function InspectorControls({
12692
- children
12693
  }) {
12694
- return useDisplayBlockControls() ? (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalStyleProvider, {
12695
- document: document
12696
- }, (0,external_wp_element_namespaceObject.createElement)(inspector_controls_Fill, null, children)) : null;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12697
  }
 
 
 
12698
 
12699
- InspectorControls.Slot = inspector_controls_Slot;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12700
  /**
12701
  * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/inspector-controls/README.md
12702
  */
@@ -12793,7 +12742,9 @@ const withInspectorControl = (0,external_wp_compose_namespaceObject.createHigher
12793
  autoCapitalize: "none",
12794
  autoComplete: "off"
12795
  });
12796
- return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(BlockEdit, props), isWeb && (0,external_wp_element_namespaceObject.createElement)(inspector_advanced_controls, null, textControl), !isWeb && props.name === 'core/heading' && (0,external_wp_element_namespaceObject.createElement)(inspector_controls, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelBody, {
 
 
12797
  title: (0,external_wp_i18n_namespaceObject.__)('Heading settings')
12798
  }, textControl)));
12799
  }
@@ -12880,7 +12831,9 @@ const custom_class_name_withInspectorControl = (0,external_wp_compose_namespaceO
12880
  const hasCustomClassName = (0,external_wp_blocks_namespaceObject.hasBlockSupport)(props.name, 'customClassName', true);
12881
 
12882
  if (hasCustomClassName && props.isSelected) {
12883
- return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(BlockEdit, props), (0,external_wp_element_namespaceObject.createElement)(inspector_advanced_controls, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextControl, {
 
 
12884
  autoComplete: "off",
12885
  label: (0,external_wp_i18n_namespaceObject.__)('Additional CSS class(es)'),
12886
  value: props.attributes.className || '',
@@ -16421,7 +16374,6 @@ function useIsLetterSpacingDisabled({
16421
 
16422
 
16423
 
16424
-
16425
  /**
16426
  * Internal dependencies
16427
  */
@@ -16447,7 +16399,7 @@ function TypographyPanel(props) {
16447
  }
16448
 
16449
  const hasTypographySupport = blockName => {
16450
- return external_wp_element_namespaceObject.Platform.OS === 'web' && TYPOGRAPHY_SUPPORT_KEYS.some(key => (0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockName, key));
16451
  };
16452
 
16453
  function useIsTypographyDisabled(props = {}) {
@@ -16532,7 +16484,8 @@ function useIsMarginDisabled({
16532
  name: blockName
16533
  } = {}) {
16534
  const isDisabled = !useSetting('spacing.customMargin');
16535
- return !hasMarginSupport(blockName) || isDisabled;
 
16536
  }
16537
  /**
16538
  * Inspector control panel containing the margin related configuration
@@ -16556,6 +16509,7 @@ function MarginEdit(props) {
16556
  availableUnits: useSetting('spacing.units') || ['%', 'px', 'em', 'rem', 'vw']
16557
  });
16558
  const sides = useCustomSides(blockName, 'margin');
 
16559
 
16560
  if (useIsMarginDisabled(props)) {
16561
  return null;
@@ -16591,7 +16545,8 @@ function MarginEdit(props) {
16591
  label: (0,external_wp_i18n_namespaceObject.__)('Margin'),
16592
  sides: sides,
16593
  units: units,
16594
- allowReset: false
 
16595
  })),
16596
  native: null
16597
  });
@@ -16674,7 +16629,8 @@ function useIsPaddingDisabled({
16674
  name: blockName
16675
  } = {}) {
16676
  const isDisabled = !useSetting('spacing.customPadding');
16677
- return !hasPaddingSupport(blockName) || isDisabled;
 
16678
  }
16679
  /**
16680
  * Inspector control panel containing the padding related configuration
@@ -16698,6 +16654,7 @@ function PaddingEdit(props) {
16698
  availableUnits: useSetting('spacing.units') || ['%', 'px', 'em', 'rem', 'vw']
16699
  });
16700
  const sides = useCustomSides(blockName, 'padding');
 
16701
 
16702
  if (useIsPaddingDisabled(props)) {
16703
  return null;
@@ -16733,7 +16690,8 @@ function PaddingEdit(props) {
16733
  label: (0,external_wp_i18n_namespaceObject.__)('Padding'),
16734
  sides: sides,
16735
  units: units,
16736
- allowReset: false
 
16737
  })),
16738
  native: null
16739
  });
@@ -16758,6 +16716,8 @@ function PaddingEdit(props) {
16758
 
16759
 
16760
  const SPACING_SUPPORT_KEY = 'spacing';
 
 
16761
  /**
16762
  * Inspector controls for dimensions support.
16763
  *
@@ -16855,12 +16815,34 @@ const useIsDimensionsDisabled = (props = {}) => {
16855
  function useCustomSides(blockName, feature) {
16856
  const support = (0,external_wp_blocks_namespaceObject.getBlockSupport)(blockName, SPACING_SUPPORT_KEY); // Skip when setting is boolean as theme isn't setting arbitrary sides.
16857
 
16858
- if (typeof support[feature] === 'boolean') {
16859
  return;
16860
  }
16861
 
16862
  return support[feature];
16863
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16864
  //# sourceMappingURL=dimensions.js.map
16865
  ;// CONCATENATED MODULE: ./packages/block-editor/build-module/hooks/style.js
16866
 
@@ -17175,27 +17157,52 @@ function DuotoneControl({
17175
 
17176
  /* harmony default export */ var duotone_control = (DuotoneControl);
17177
  //# sourceMappingURL=index.js.map
17178
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-list/head.js
 
 
17179
 
17180
 
17181
  /**
17182
  * WordPress dependencies
17183
  */
17184
 
17185
- const context = (0,external_wp_element_namespaceObject.createContext)();
17186
- function Head({
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17187
  children
17188
  }) {
17189
- const [element, setElement] = (0,external_wp_element_namespaceObject.useState)();
17190
- return (0,external_wp_element_namespaceObject.createElement)(context.Provider, {
17191
- value: element
17192
- }, (0,external_wp_element_namespaceObject.createElement)("div", {
17193
- ref: setElement
17194
- }), children);
 
 
17195
  }
17196
- Head.context = context;
17197
- //# sourceMappingURL=head.js.map
17198
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/hooks/duotone.js
17199
 
17200
 
17201
 
@@ -17211,230 +17218,113 @@ Head.context = context;
17211
 
17212
 
17213
 
17214
-
17215
-
17216
  /**
17217
  * Internal dependencies
17218
  */
17219
 
17220
 
17221
-
17222
- const duotone_EMPTY_ARRAY = [];
17223
- /**
17224
- * Convert a list of colors to an object of R, G, and B values.
17225
- *
17226
- * @param {string[]} colors Array of RBG color strings.
17227
- *
17228
- * @return {Object} R, G, and B values.
17229
- */
17230
-
17231
- function getValuesFromColors(colors = []) {
17232
- const values = {
17233
- r: [],
17234
- g: [],
17235
- b: []
17236
- };
17237
- colors.forEach(color => {
17238
- // Access values directly to skip extra rounding that tinycolor.toRgb() does.
17239
- const tcolor = tinycolor_default()(color);
17240
- values.r.push(tcolor._r / 255);
17241
- values.g.push(tcolor._g / 255);
17242
- values.b.push(tcolor._b / 255);
17243
- });
17244
- return values;
17245
- }
17246
- /**
17247
- * Values for the SVG `feComponentTransfer`.
17248
- *
17249
- * @typedef Values {Object}
17250
- * @property {number[]} r Red values.
17251
- * @property {number[]} g Green values.
17252
- * @property {number[]} b Blue values.
17253
- */
17254
-
17255
  /**
17256
- * SVG and stylesheet needed for rendering the duotone filter.
17257
- *
17258
- * @param {Object} props Duotone props.
17259
- * @param {string} props.selector Selector to apply the filter to.
17260
- * @param {string} props.id Unique id for this duotone filter.
17261
- * @param {Values} props.values R, G, and B values to filter with.
17262
  *
17263
- * @return {WPElement} Duotone element.
17264
  */
17265
 
17266
- function DuotoneFilter({
17267
- selector,
17268
- id,
17269
- values
17270
- }) {
17271
- const stylesheet = `
17272
- ${selector} {
17273
- filter: url( #${id} );
17274
- }
17275
- `;
17276
- return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SVG, {
17277
- xmlnsXlink: "http://www.w3.org/1999/xlink",
17278
- viewBox: "0 0 0 0",
17279
- width: "0",
17280
- height: "0",
17281
- focusable: "false",
17282
- role: "none",
17283
- style: {
17284
- visibility: 'hidden',
17285
- position: 'absolute',
17286
- left: '-9999px',
17287
- overflow: 'hidden'
17288
- }
17289
- }, (0,external_wp_element_namespaceObject.createElement)("defs", null, (0,external_wp_element_namespaceObject.createElement)("filter", {
17290
- id: id
17291
- }, (0,external_wp_element_namespaceObject.createElement)("feColorMatrix", {
17292
- type: "matrix" // Use perceptual brightness to convert to grayscale.
17293
- // prettier-ignore
17294
- ,
17295
- values: ".299 .587 .114 0 0 .299 .587 .114 0 0 .299 .587 .114 0 0 0 0 0 1 0"
17296
- }), (0,external_wp_element_namespaceObject.createElement)("feComponentTransfer", {
17297
- // Use sRGB instead of linearRGB to be consistent with how CSS gradients work.
17298
- colorInterpolationFilters: "sRGB"
17299
- }, (0,external_wp_element_namespaceObject.createElement)("feFuncR", {
17300
- type: "table",
17301
- tableValues: values.r.join(' ')
17302
- }), (0,external_wp_element_namespaceObject.createElement)("feFuncG", {
17303
- type: "table",
17304
- tableValues: values.g.join(' ')
17305
- }), (0,external_wp_element_namespaceObject.createElement)("feFuncB", {
17306
- type: "table",
17307
- tableValues: values.b.join(' ')
17308
- }))))), (0,external_wp_element_namespaceObject.createElement)("style", {
17309
- dangerouslySetInnerHTML: {
17310
- __html: stylesheet
17311
- }
17312
- }));
17313
- }
17314
-
17315
- function DuotonePanel({
17316
- attributes,
17317
- setAttributes
17318
- }) {
17319
- var _style$color;
17320
 
17321
- const style = attributes === null || attributes === void 0 ? void 0 : attributes.style;
17322
- const duotone = style === null || style === void 0 ? void 0 : (_style$color = style.color) === null || _style$color === void 0 ? void 0 : _style$color.duotone;
17323
- const duotonePalette = useSetting('color.duotone') || duotone_EMPTY_ARRAY;
17324
- const colorPalette = useSetting('color.palette') || duotone_EMPTY_ARRAY;
17325
- const disableCustomColors = !useSetting('color.custom');
17326
- const disableCustomDuotone = !useSetting('color.customDuotone') || (colorPalette === null || colorPalette === void 0 ? void 0 : colorPalette.length) === 0 && disableCustomColors;
17327
 
17328
- if ((duotonePalette === null || duotonePalette === void 0 ? void 0 : duotonePalette.length) === 0 && disableCustomDuotone) {
17329
  return null;
17330
- }
 
 
17331
 
17332
- return (0,external_wp_element_namespaceObject.createElement)(block_controls, {
17333
- group: "block"
17334
- }, (0,external_wp_element_namespaceObject.createElement)(duotone_control, {
17335
- duotonePalette: duotonePalette,
17336
- colorPalette: colorPalette,
17337
- disableCustomDuotone: disableCustomDuotone,
17338
- disableCustomColors: disableCustomColors,
17339
- value: duotone,
17340
- onChange: newDuotone => {
17341
- const newStyle = { ...style,
17342
- color: { ...(style === null || style === void 0 ? void 0 : style.color),
17343
- duotone: newDuotone
17344
- }
17345
- };
17346
- setAttributes({
17347
- style: newStyle
17348
- });
17349
- }
17350
- }));
17351
- }
17352
- /**
17353
- * Filters registered block settings, extending attributes to include
17354
- * the `duotone` attribute.
17355
- *
17356
- * @param {Object} settings Original block settings.
17357
- *
17358
- * @return {Object} Filtered block settings.
17359
- */
17360
 
 
 
 
 
 
 
 
17361
 
17362
- function addDuotoneAttributes(settings) {
17363
- if (!(0,external_wp_blocks_namespaceObject.hasBlockSupport)(settings, 'color.__experimentalDuotone')) {
17364
- return settings;
17365
- } // Allow blocks to specify their own attribute definition with default
17366
- // values if needed.
17367
 
 
 
 
 
 
 
 
 
 
 
17368
 
17369
- if (!settings.attributes.style) {
17370
- Object.assign(settings.attributes, {
17371
- style: {
17372
- type: 'object'
17373
- }
17374
- });
17375
- }
17376
 
17377
- return settings;
17378
- }
17379
  /**
17380
- * Override the default edit UI to include toolbar controls for duotone if the
17381
- * block supports duotone.
17382
- *
17383
- * @param {Function} BlockEdit Original component.
17384
- *
17385
- * @return {Function} Wrapped component.
17386
  */
17387
 
17388
-
17389
- const withDuotoneControls = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockEdit => props => {
17390
- const hasDuotoneSupport = (0,external_wp_blocks_namespaceObject.hasBlockSupport)(props.name, 'color.__experimentalDuotone');
17391
- return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(BlockEdit, props), hasDuotoneSupport && (0,external_wp_element_namespaceObject.createElement)(DuotonePanel, props));
17392
- }, 'withDuotoneControls');
17393
  /**
17394
- * Override the default block element to include duotone styles.
17395
- *
17396
- * @param {Function} BlockListBlock Original component.
17397
- *
17398
- * @return {Function} Wrapped component.
17399
  */
17400
 
17401
- const withDuotoneStyles = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockListBlock => props => {
17402
- var _props$attributes, _props$attributes$sty, _props$attributes$sty2;
17403
 
17404
- const duotoneSupport = (0,external_wp_blocks_namespaceObject.getBlockSupport)(props.name, 'color.__experimentalDuotone');
17405
- const values = props === null || props === void 0 ? void 0 : (_props$attributes = props.attributes) === null || _props$attributes === void 0 ? void 0 : (_props$attributes$sty = _props$attributes.style) === null || _props$attributes$sty === void 0 ? void 0 : (_props$attributes$sty2 = _props$attributes$sty.color) === null || _props$attributes$sty2 === void 0 ? void 0 : _props$attributes$sty2.duotone;
17406
 
17407
- if (!duotoneSupport || !values) {
17408
- return (0,external_wp_element_namespaceObject.createElement)(BlockListBlock, props);
17409
- }
17410
 
17411
- const id = `wp-duotone-filter-${(0,external_wp_compose_namespaceObject.useInstanceId)(BlockListBlock)}`;
17412
- const selectors = duotoneSupport.split(',');
17413
- const selectorsScoped = selectors.map(selector => `.${id} ${selector.trim()}`);
17414
- const selectorsGroup = selectorsScoped.join(', ');
17415
- const className = classnames_default()(props === null || props === void 0 ? void 0 : props.className, id);
17416
- const element = (0,external_wp_element_namespaceObject.useContext)(Head.context);
17417
- return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, element && (0,external_wp_element_namespaceObject.createPortal)((0,external_wp_element_namespaceObject.createElement)(DuotoneFilter, {
17418
- selector: selectorsGroup,
17419
- id: id,
17420
- values: getValuesFromColors(values)
17421
- }), element), (0,external_wp_element_namespaceObject.createElement)(BlockListBlock, _extends({}, props, {
17422
- className: className
17423
- })));
17424
- }, 'withDuotoneStyles');
17425
- (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'core/editor/duotone/add-attributes', addDuotoneAttributes);
17426
- (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockEdit', 'core/editor/duotone/with-editor-controls', withDuotoneControls);
17427
- (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockListBlock', 'core/editor/duotone/with-styles', withDuotoneStyles);
17428
- //# sourceMappingURL=duotone.js.map
17429
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/hooks/layout.js
 
 
 
 
 
 
17430
 
 
 
 
 
 
 
 
 
 
17431
 
17432
 
17433
  /**
17434
  * External dependencies
17435
  */
17436
 
17437
-
17438
  /**
17439
  * WordPress dependencies
17440
  */
@@ -17444,180 +17334,273 @@ const withDuotoneStyles = (0,external_wp_compose_namespaceObject.createHigherOrd
17444
 
17445
 
17446
 
17447
-
17448
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17449
  /**
17450
- * Internal dependencies
17451
  */
17452
 
17453
 
 
 
 
 
 
17454
 
17455
 
 
 
 
17456
 
17457
 
17458
 
17459
- const layoutBlockSupportKey = '__experimentalLayout';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17460
 
17461
- const canBlockSwitchLayout = blockTypeOrName => {
17462
- const layoutBlockSupportConfig = (0,external_wp_blocks_namespaceObject.getBlockSupport)(blockTypeOrName, layoutBlockSupportKey);
17463
- return layoutBlockSupportConfig === null || layoutBlockSupportConfig === void 0 ? void 0 : layoutBlockSupportConfig.allowSwitching;
17464
- };
17465
 
17466
- function LayoutPanel({
17467
- setAttributes,
17468
- attributes,
17469
- name: blockName
17470
- }) {
17471
- const {
17472
- layout = {}
17473
- } = attributes;
17474
- const defaultLayout = useSetting('layout');
17475
- const themeSupportsLayout = (0,external_wp_data_namespaceObject.useSelect)(select => {
17476
- const {
17477
- getSettings
17478
- } = select(store);
17479
- return getSettings().supportsLayout;
17480
- }, []);
17481
 
17482
- if (!themeSupportsLayout) {
17483
- return null;
17484
- }
17485
 
17486
- const allowLayoutSwitching = canBlockSwitchLayout(blockName);
17487
- const {
17488
- inherit = false,
17489
- type = 'default'
17490
- } = layout;
17491
- const layoutType = getLayoutType(type);
17492
 
17493
- const onChangeType = newType => setAttributes({
17494
- layout: {
17495
- type: newType
17496
- }
17497
- });
17498
 
17499
- const onChangeLayout = newLayout => setAttributes({
17500
- layout: newLayout
17501
- });
17502
 
17503
- return (0,external_wp_element_namespaceObject.createElement)(inspector_controls, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelBody, {
17504
- title: (0,external_wp_i18n_namespaceObject.__)('Layout')
17505
- }, !!defaultLayout && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToggleControl, {
17506
- label: (0,external_wp_i18n_namespaceObject.__)('Inherit default layout'),
17507
- checked: !!inherit,
17508
- onChange: () => setAttributes({
17509
- layout: {
17510
- inherit: !inherit
17511
- }
17512
- })
17513
- }), !inherit && allowLayoutSwitching && (0,external_wp_element_namespaceObject.createElement)(LayoutTypeSwitcher, {
17514
- type: type,
17515
- onChange: onChangeType
17516
- }), !inherit && layoutType && (0,external_wp_element_namespaceObject.createElement)(layoutType.edit, {
17517
- layout: layout,
17518
- onChange: onChangeLayout
17519
- })));
17520
- }
17521
 
17522
- function LayoutTypeSwitcher({
17523
- type,
17524
- onChange
17525
- }) {
17526
- return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ButtonGroup, null, getLayoutTypes().map(({
17527
- name,
17528
- label
17529
- }) => {
17530
- return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
17531
- key: name,
17532
- isPressed: type === name,
17533
- onClick: () => onChange(name)
17534
- }, label);
17535
- }));
17536
- }
17537
  /**
17538
- * Filters registered block settings, extending attributes to include `layout`.
17539
- *
17540
- * @param {Object} settings Original block settings.
17541
- *
17542
- * @return {Object} Filtered block settings.
17543
  */
17544
 
17545
 
17546
- function layout_addAttribute(settings) {
17547
- if ((0,external_lodash_namespaceObject.has)(settings.attributes, ['layout', 'type'])) {
17548
- return settings;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17549
  }
17550
 
17551
- if ((0,external_wp_blocks_namespaceObject.hasBlockSupport)(settings, layoutBlockSupportKey)) {
17552
- settings.attributes = { ...settings.attributes,
17553
- layout: {
17554
- type: 'object'
17555
- }
17556
- };
17557
  }
17558
 
17559
- return settings;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17560
  }
 
 
 
 
 
 
17561
  /**
17562
- * Override the default edit UI to include layout controls
17563
- *
17564
- * @param {Function} BlockEdit Original component.
17565
- *
17566
- * @return {Function} Wrapped component.
17567
  */
17568
 
17569
- const withInspectorControls = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockEdit => props => {
17570
- const {
17571
- name: blockName
17572
- } = props;
17573
- const supportLayout = (0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockName, layoutBlockSupportKey);
17574
- return [supportLayout && (0,external_wp_element_namespaceObject.createElement)(LayoutPanel, _extends({
17575
- key: "layout"
17576
- }, props)), (0,external_wp_element_namespaceObject.createElement)(BlockEdit, _extends({
17577
- key: "edit"
17578
- }, props))];
17579
- }, 'withInspectorControls');
17580
  /**
17581
- * Override the default block element to add the layout styles.
17582
- *
17583
- * @param {Function} BlockListBlock Original component.
17584
- *
17585
- * @return {Function} Wrapped component.
17586
  */
17587
 
17588
- const withLayoutStyles = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockListBlock => props => {
17589
- const {
17590
- name,
17591
- attributes
17592
- } = props;
17593
- const supportLayout = (0,external_wp_blocks_namespaceObject.hasBlockSupport)(name, layoutBlockSupportKey);
17594
- const id = (0,external_wp_compose_namespaceObject.useInstanceId)(BlockListBlock);
17595
- const defaultLayout = useSetting('layout') || {};
17596
 
17597
- if (!supportLayout) {
17598
- return (0,external_wp_element_namespaceObject.createElement)(BlockListBlock, props);
17599
- }
17600
 
17601
- const {
17602
- layout = {}
17603
- } = attributes;
17604
- const usedLayout = !!layout && layout.inherit ? defaultLayout : layout;
17605
- const className = classnames_default()(props === null || props === void 0 ? void 0 : props.className, `wp-container-${id}`);
17606
- const element = (0,external_wp_element_namespaceObject.useContext)(Head.context);
17607
- return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, element && (0,external_wp_element_namespaceObject.createPortal)((0,external_wp_element_namespaceObject.createElement)(LayoutStyle, {
17608
- selector: `.wp-container-${id}`,
17609
- layout: usedLayout
17610
- }), element), (0,external_wp_element_namespaceObject.createElement)(BlockListBlock, _extends({}, props, {
17611
- className: className
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17612
  })));
 
 
 
 
17613
  });
17614
- (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'core/layout/addAttribute', layout_addAttribute);
17615
- (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockListBlock', 'core/editor/layout/with-layout-styles', withLayoutStyles);
17616
- (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockEdit', 'core/editor/layout/with-inspector-controls', withInspectorControls);
17617
- //# sourceMappingURL=layout.js.map
17618
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/hooks/use-border-props.js
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17619
  /**
17620
- * External dependencies
17621
  */
17622
 
17623
  /**
@@ -17625,224 +17608,337 @@ const withLayoutStyles = (0,external_wp_compose_namespaceObject.createHigherOrde
17625
  */
17626
 
17627
 
17628
-
17629
- // This utility is intended to assist where the serialization of the border
17630
- // block support is being skipped for a block but the border related CSS classes
17631
- // & styles still need to be generated so they can be applied to inner elements.
17632
-
17633
- const use_border_props_EMPTY_ARRAY = [];
17634
  /**
17635
- * Provides the CSS class names and inline styles for a block's border support
17636
- * attributes.
17637
- *
17638
- * @param {Object} attributes Block attributes.
17639
- * @param {string} attributes.borderColor Selected named border color.
17640
- * @param {Object} attributes.style Block's styles attribute.
17641
- *
17642
- * @return {Object} Border block support derived CSS classes & styles.
17643
  */
17644
 
17645
- function getBorderClassesAndStyles({
17646
- borderColor,
17647
- style
17648
- }) {
17649
- var _style$border;
17650
 
17651
- const borderStyles = (style === null || style === void 0 ? void 0 : style.border) || {};
17652
- const borderClass = getColorClassName('border-color', borderColor);
17653
- const className = classnames_default()({
17654
- [borderClass]: !!borderClass,
17655
- 'has-border-color': borderColor || (style === null || style === void 0 ? void 0 : (_style$border = style.border) === null || _style$border === void 0 ? void 0 : _style$border.color)
17656
- });
17657
- return {
17658
- className: className || undefined,
17659
- style: getInlineStyles({
17660
- border: borderStyles
17661
- })
17662
- };
17663
- }
17664
- /**
17665
- * Derives the border related props for a block from its border block support
17666
- * attributes.
17667
- *
17668
- * Inline styles are forced for named colors to ensure these selections are
17669
- * reflected when themes do not load their color stylesheets in the editor.
17670
- *
17671
- * @param {Object} attributes Block attributes.
17672
- *
17673
- * @return {Object} ClassName & style props from border block support.
17674
- */
17675
 
17676
- function useBorderProps(attributes) {
17677
- const colors = useSetting('color.palette') || use_border_props_EMPTY_ARRAY;
17678
- const borderProps = getBorderClassesAndStyles(attributes); // Force inline style to apply border color when themes do not load their
17679
- // color stylesheets in the editor.
 
17680
 
17681
- if (attributes.borderColor) {
17682
- const borderColorObject = getColorObjectByAttributeValues(colors, attributes.borderColor);
17683
- borderProps.style.borderColor = borderColorObject.color;
 
 
 
17684
  }
17685
 
17686
- return borderProps;
17687
  }
17688
- //# sourceMappingURL=use-border-props.js.map
17689
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/hooks/use-color-props.js
 
 
 
 
 
 
17690
  /**
17691
  * External dependencies
17692
  */
17693
 
17694
  /**
17695
- * Internal dependencies
17696
  */
17697
 
17698
 
17699
 
17700
 
17701
- // The code in this file has largely been lifted from the color block support
17702
- // hook.
17703
- //
17704
- // This utility is intended to assist where the serialization of the colors
17705
- // block support is being skipped for a block but the color related CSS classes
17706
- // & styles still need to be generated so they can be applied to inner elements.
17707
-
17708
- const use_color_props_EMPTY_ARRAY = [];
17709
  /**
17710
- * Provides the CSS class names and inline styles for a block's color support
17711
- * attributes.
17712
- *
17713
- * @param {Object} attributes Block attributes.
17714
- *
17715
- * @return {Object} Color block support derived CSS classes & styles.
17716
  */
17717
 
17718
- function getColorClassesAndStyles(attributes) {
17719
- var _style$color, _style$color2, _style$color3, _style$color4, _style$elements, _style$elements$link;
17720
-
17721
- const {
17722
- backgroundColor,
17723
- textColor,
17724
- gradient,
17725
- style
17726
- } = attributes; // Collect color CSS classes.
17727
-
17728
- const backgroundClass = getColorClassName('background-color', backgroundColor);
17729
- const textClass = getColorClassName('color', textColor);
17730
 
17731
- const gradientClass = __experimentalGetGradientClass(gradient);
17732
 
17733
- const hasGradient = gradientClass || (style === null || style === void 0 ? void 0 : (_style$color = style.color) === null || _style$color === void 0 ? void 0 : _style$color.gradient); // Determine color CSS class name list.
 
 
 
 
 
 
 
17734
 
17735
- const className = classnames_default()(textClass, gradientClass, {
17736
- // Don't apply the background class if there's a gradient.
17737
- [backgroundClass]: !hasGradient && !!backgroundClass,
17738
- 'has-text-color': textColor || (style === null || style === void 0 ? void 0 : (_style$color2 = style.color) === null || _style$color2 === void 0 ? void 0 : _style$color2.text),
17739
- 'has-background': backgroundColor || (style === null || style === void 0 ? void 0 : (_style$color3 = style.color) === null || _style$color3 === void 0 ? void 0 : _style$color3.background) || gradient || (style === null || style === void 0 ? void 0 : (_style$color4 = style.color) === null || _style$color4 === void 0 ? void 0 : _style$color4.gradient),
17740
- 'has-link-color': style === null || style === void 0 ? void 0 : (_style$elements = style.elements) === null || _style$elements === void 0 ? void 0 : (_style$elements$link = _style$elements.link) === null || _style$elements$link === void 0 ? void 0 : _style$elements$link.color
17741
- }); // Collect inline styles for colors.
17742
 
17743
- const colorStyles = (style === null || style === void 0 ? void 0 : style.color) || {};
17744
- const styleProp = getInlineStyles({
17745
- color: colorStyles
17746
- });
17747
- return {
17748
- className: className || undefined,
17749
- style: styleProp
 
 
 
 
 
 
17750
  };
 
 
 
 
 
 
 
 
 
 
17751
  }
 
 
 
 
 
 
17752
  /**
17753
- * Determines the color related props for a block derived from its color block
17754
- * support attributes.
17755
- *
17756
- * Inline styles are forced for named colors to ensure these selections are
17757
- * reflected when themes do not load their color stylesheets in the editor.
17758
- *
17759
- * @param {Object} attributes Block attributes.
17760
- *
17761
- * @return {Object} ClassName & style props from colors block support.
17762
  */
17763
 
17764
- function useColorProps(attributes) {
17765
- const {
17766
- backgroundColor,
17767
- textColor,
17768
- gradient
17769
- } = attributes;
17770
- const colors = useSetting('color.palette') || use_color_props_EMPTY_ARRAY;
17771
- const gradients = useSetting('color.gradients') || use_color_props_EMPTY_ARRAY;
17772
- const colorProps = getColorClassesAndStyles(attributes); // Force inline styles to apply colors when themes do not load their color
17773
- // stylesheets in the editor.
17774
 
17775
- if (backgroundColor) {
17776
- const backgroundColorObject = getColorObjectByAttributeValues(colors, backgroundColor);
17777
- colorProps.style.backgroundColor = backgroundColorObject.color;
17778
- }
17779
 
17780
- if (gradient) {
17781
- colorProps.style.background = getGradientValueBySlug(gradients, gradient);
17782
- }
17783
 
17784
- if (textColor) {
17785
- const textColorObject = getColorObjectByAttributeValues(colors, textColor);
17786
- colorProps.style.color = textColorObject.color;
17787
- }
17788
 
17789
- return colorProps;
17790
- }
17791
- //# sourceMappingURL=use-color-props.js.map
17792
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/hooks/use-spacing-props.js
17793
  /**
17794
- * Internal dependencies
 
 
 
17795
  */
17796
- // This utility is intended to assist where the serialization of the spacing
17797
- // block support is being skipped for a block but the spacing related CSS
17798
- // styles still need to be generated so they can be applied to inner elements.
17799
 
 
 
 
 
 
 
 
 
17800
  /**
17801
- * Provides the CSS class names and inline styles for a block's spacing support
17802
- * attributes.
17803
  *
17804
- * @param {Object} attributes Block attributes.
 
 
 
 
 
 
17805
  *
17806
- * @return {Object} Spacing block support derived CSS classes & styles.
 
 
 
 
17807
  */
17808
 
17809
- function getSpacingClassesAndStyles(attributes) {
17810
- const {
17811
- style
17812
- } = attributes; // Collect inline styles for spacing.
17813
 
17814
- const spacingStyles = (style === null || style === void 0 ? void 0 : style.spacing) || {};
17815
- const styleProp = getInlineStyles({
17816
- spacing: spacingStyles
 
 
 
 
 
 
 
 
 
 
17817
  });
17818
- return {
17819
- style: styleProp
17820
- };
17821
- }
17822
- //# sourceMappingURL=use-spacing-props.js.map
17823
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/hooks/index.js
17824
- /**
17825
- * Internal dependencies
17826
- */
17827
 
 
 
 
 
17828
 
 
17829
 
 
 
 
17830
 
 
 
 
 
17831
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17832
 
 
 
 
 
 
 
17833
 
 
 
 
 
 
 
 
 
17834
 
 
 
 
 
 
 
 
17835
 
 
 
 
 
 
 
17836
 
17837
 
 
 
 
 
 
 
17838
 
 
 
 
 
 
 
 
 
 
17839
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17840
 
 
17841
  //# sourceMappingURL=index.js.map
17842
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/colors/with-colors.js
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17843
 
 
 
 
 
17844
 
 
 
 
17845
 
 
 
 
 
17846
  /**
17847
  * External dependencies
17848
  */
@@ -17853,203 +17949,142 @@ function getSpacingClassesAndStyles(attributes) {
17853
 
17854
 
17855
 
 
17856
  /**
17857
  * Internal dependencies
17858
  */
17859
 
17860
 
17861
 
17862
- const DEFAULT_COLORS = [];
 
17863
  /**
17864
- * Higher order component factory for injecting the `colorsArray` argument as
17865
- * the colors prop in the `withCustomColors` HOC.
17866
  *
17867
- * @param {Array} colorsArray An array of color objects.
17868
  *
17869
- * @return {Function} The higher order component.
17870
  */
17871
 
17872
- const withCustomColorPalette = colorsArray => (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(WrappedComponent => props => (0,external_wp_element_namespaceObject.createElement)(WrappedComponent, _extends({}, props, {
17873
- colors: colorsArray
17874
- })), 'withCustomColorPalette');
17875
- /**
17876
- * Higher order component factory for injecting the editor colors as the
17877
- * `colors` prop in the `withColors` HOC.
17878
- *
17879
- * @return {Function} The higher order component.
17880
- */
17881
 
 
 
 
17882
 
17883
- const withEditorColorPalette = () => (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(WrappedComponent => props => {
17884
- const colors = useSetting('color.palette') || DEFAULT_COLORS;
17885
- return (0,external_wp_element_namespaceObject.createElement)(WrappedComponent, _extends({}, props, {
17886
- colors: colors
17887
- }));
17888
- }, 'withEditorColorPalette');
 
 
17889
  /**
17890
- * Helper function used with `createHigherOrderComponent` to create
17891
- * higher order components for managing color logic.
17892
  *
17893
- * @param {Array} colorTypes An array of color types (e.g. 'backgroundColor, borderColor).
17894
- * @param {Function} withColorPalette A HOC for injecting the 'colors' prop into the WrappedComponent.
17895
  *
17896
- * @return {WPComponent} The component that can be used as a HOC.
17897
  */
17898
 
17899
 
17900
- function createColorHOC(colorTypes, withColorPalette) {
17901
- const colorMap = (0,external_lodash_namespaceObject.reduce)(colorTypes, (colorObject, colorType) => {
17902
- return { ...colorObject,
17903
- ...((0,external_lodash_namespaceObject.isString)(colorType) ? {
17904
- [colorType]: (0,external_lodash_namespaceObject.kebabCase)(colorType)
17905
- } : colorType)
17906
- };
17907
- }, {});
17908
- return (0,external_wp_compose_namespaceObject.compose)([withColorPalette, WrappedComponent => {
17909
- return class extends external_wp_element_namespaceObject.Component {
17910
- constructor(props) {
17911
- super(props);
17912
- this.setters = this.createSetters();
17913
- this.colorUtils = {
17914
- getMostReadableColor: this.getMostReadableColor.bind(this)
17915
- };
17916
- this.state = {};
17917
- }
17918
 
17919
- getMostReadableColor(colorValue) {
17920
- const {
17921
- colors
17922
- } = this.props;
17923
- return getMostReadableColor(colors, colorValue);
17924
- }
17925
 
17926
- createSetters() {
17927
- return (0,external_lodash_namespaceObject.reduce)(colorMap, (settersAccumulator, colorContext, colorAttributeName) => {
17928
- const upperFirstColorAttributeName = (0,external_lodash_namespaceObject.upperFirst)(colorAttributeName);
17929
- const customColorAttributeName = `custom${upperFirstColorAttributeName}`;
17930
- settersAccumulator[`set${upperFirstColorAttributeName}`] = this.createSetColor(colorAttributeName, customColorAttributeName);
17931
- return settersAccumulator;
17932
- }, {});
17933
- }
17934
 
17935
- createSetColor(colorAttributeName, customColorAttributeName) {
17936
- return colorValue => {
17937
- const colorObject = getColorObjectByColorValue(this.props.colors, colorValue);
17938
- this.props.setAttributes({
17939
- [colorAttributeName]: colorObject && colorObject.slug ? colorObject.slug : undefined,
17940
- [customColorAttributeName]: colorObject && colorObject.slug ? undefined : colorValue
17941
- });
17942
- };
17943
- }
17944
 
17945
- static getDerivedStateFromProps({
17946
- attributes,
17947
- colors
17948
- }, previousState) {
17949
- return (0,external_lodash_namespaceObject.reduce)(colorMap, (newState, colorContext, colorAttributeName) => {
17950
- const colorObject = getColorObjectByAttributeValues(colors, attributes[colorAttributeName], attributes[`custom${(0,external_lodash_namespaceObject.upperFirst)(colorAttributeName)}`]);
17951
- const previousColorObject = previousState[colorAttributeName];
17952
- const previousColor = previousColorObject === null || previousColorObject === void 0 ? void 0 : previousColorObject.color;
17953
- /**
17954
- * The "and previousColorObject" condition checks that a previous color object was already computed.
17955
- * At the start previousColorObject and colorValue are both equal to undefined
17956
- * bus as previousColorObject does not exist we should compute the object.
17957
- */
17958
 
17959
- if (previousColor === colorObject.color && previousColorObject) {
17960
- newState[colorAttributeName] = previousColorObject;
17961
- } else {
17962
- newState[colorAttributeName] = { ...colorObject,
17963
- class: getColorClassName(colorContext, colorObject.slug)
17964
- };
17965
- }
17966
 
17967
- return newState;
17968
- }, {});
17969
- }
17970
 
17971
- render() {
17972
- return (0,external_wp_element_namespaceObject.createElement)(WrappedComponent, _extends({}, this.props, {
17973
- colors: undefined
17974
- }, this.state, this.setters, {
17975
- colorUtils: this.colorUtils
17976
- }));
17977
- }
17978
 
17979
- };
17980
- }]);
 
17981
  }
 
 
17982
  /**
17983
- * A higher-order component factory for creating a 'withCustomColors' HOC, which handles color logic
17984
- * for class generation color value, retrieval and color attribute setting.
17985
- *
17986
- * Use this higher-order component to work with a custom set of colors.
17987
- *
17988
- * @example
17989
- *
17990
- * ```jsx
17991
- * const CUSTOM_COLORS = [ { name: 'Red', slug: 'red', color: '#ff0000' }, { name: 'Blue', slug: 'blue', color: '#0000ff' } ];
17992
- * const withCustomColors = createCustomColorsHOC( CUSTOM_COLORS );
17993
- * // ...
17994
- * export default compose(
17995
- * withCustomColors( 'backgroundColor', 'borderColor' ),
17996
- * MyColorfulComponent,
17997
- * );
17998
- * ```
17999
- *
18000
- * @param {Array} colorsArray The array of color objects (name, slug, color, etc... ).
18001
- *
18002
- * @return {Function} Higher-order component.
18003
  */
18004
 
18005
 
18006
- function createCustomColorsHOC(colorsArray) {
18007
- return (...colorTypes) => {
18008
- const withColorPalette = withCustomColorPalette(colorsArray);
18009
- return (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(createColorHOC(colorTypes, withColorPalette), 'withCustomColors');
18010
- };
 
 
 
 
 
 
 
 
 
18011
  }
18012
  /**
18013
- * A higher-order component, which handles color logic for class generation color value, retrieval and color attribute setting.
18014
- *
18015
- * For use with the default editor/theme color palette.
18016
- *
18017
- * @example
18018
- *
18019
- * ```jsx
18020
- * export default compose(
18021
- * withColors( 'backgroundColor', { textColor: 'color' } ),
18022
- * MyColorfulComponent,
18023
- * );
18024
- * ```
18025
- *
18026
- * @param {...(Object|string)} colorTypes The arguments can be strings or objects. If the argument is an object,
18027
- * it should contain the color attribute name as key and the color context as value.
18028
- * If the argument is a string the value should be the color attribute name,
18029
- * the color context is computed by applying a kebab case transform to the value.
18030
- * Color context represents the context/place where the color is going to be used.
18031
- * The class name of the color is generated using 'has' followed by the color name
18032
- * and ending with the color context all in kebab case e.g: has-green-background-color.
18033
- *
18034
- * @return {Function} Higher-order component.
18035
  */
18036
 
18037
- function withColors(...colorTypes) {
18038
- const withColorPalette = withEditorColorPalette();
18039
- return (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(createColorHOC(colorTypes, withColorPalette), 'withColors');
18040
- }
18041
- //# sourceMappingURL=with-colors.js.map
18042
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/colors/index.js
18043
-
18044
-
18045
- //# sourceMappingURL=index.js.map
18046
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/gradients/index.js
18047
-
18048
- //# sourceMappingURL=index.js.map
18049
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/font-sizes/with-font-sizes.js
18050
-
18051
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18052
 
 
 
 
 
 
 
 
18053
  /**
18054
  * External dependencies
18055
  */
@@ -18065,162 +18100,133 @@ function withColors(...colorTypes) {
18065
  */
18066
 
18067
 
18068
-
18069
- const DEFAULT_FONT_SIZES = [];
18070
  /**
18071
- * Higher-order component, which handles font size logic for class generation,
18072
- * font size value retrieval, and font size change handling.
18073
  *
18074
- * @param {...(Object|string)} fontSizeNames The arguments should all be strings.
18075
- * Each string contains the font size
18076
- * attribute name e.g: 'fontSize'.
18077
  *
18078
- * @return {Function} Higher-order component.
18079
  */
18080
 
18081
- /* harmony default export */ var with_font_sizes = ((...fontSizeNames) => {
18082
- /*
18083
- * Computes an object whose key is the font size attribute name as passed in the array,
18084
- * and the value is the custom font size attribute name.
18085
- * Custom font size is automatically compted by appending custom followed by the font size attribute name in with the first letter capitalized.
18086
- */
18087
- const fontSizeAttributeNames = (0,external_lodash_namespaceObject.reduce)(fontSizeNames, (fontSizeAttributeNamesAccumulator, fontSizeAttributeName) => {
18088
- fontSizeAttributeNamesAccumulator[fontSizeAttributeName] = `custom${(0,external_lodash_namespaceObject.upperFirst)(fontSizeAttributeName)}`;
18089
- return fontSizeAttributeNamesAccumulator;
18090
- }, {});
18091
- return (0,external_wp_compose_namespaceObject.createHigherOrderComponent)((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_compose_namespaceObject.createHigherOrderComponent)(WrappedComponent => props => {
18092
- const fontSizes = useSetting('typography.fontSizes') || DEFAULT_FONT_SIZES;
18093
- return (0,external_wp_element_namespaceObject.createElement)(WrappedComponent, _extends({}, props, {
18094
- fontSizes: fontSizes
18095
- }));
18096
- }, 'withFontSizes'), WrappedComponent => {
18097
- return class extends external_wp_element_namespaceObject.Component {
18098
- constructor(props) {
18099
- super(props);
18100
- this.setters = this.createSetters();
18101
- this.state = {};
18102
- }
18103
-
18104
- createSetters() {
18105
- return (0,external_lodash_namespaceObject.reduce)(fontSizeAttributeNames, (settersAccumulator, customFontSizeAttributeName, fontSizeAttributeName) => {
18106
- const upperFirstFontSizeAttributeName = (0,external_lodash_namespaceObject.upperFirst)(fontSizeAttributeName);
18107
- settersAccumulator[`set${upperFirstFontSizeAttributeName}`] = this.createSetFontSize(fontSizeAttributeName, customFontSizeAttributeName);
18108
- return settersAccumulator;
18109
- }, {});
18110
- }
18111
-
18112
- createSetFontSize(fontSizeAttributeName, customFontSizeAttributeName) {
18113
- return fontSizeValue => {
18114
- const fontSizeObject = (0,external_lodash_namespaceObject.find)(this.props.fontSizes, {
18115
- size: Number(fontSizeValue)
18116
- });
18117
- this.props.setAttributes({
18118
- [fontSizeAttributeName]: fontSizeObject && fontSizeObject.slug ? fontSizeObject.slug : undefined,
18119
- [customFontSizeAttributeName]: fontSizeObject && fontSizeObject.slug ? undefined : fontSizeValue
18120
- });
18121
- };
18122
- }
18123
-
18124
- static getDerivedStateFromProps({
18125
- attributes,
18126
- fontSizes
18127
- }, previousState) {
18128
- const didAttributesChange = (customFontSizeAttributeName, fontSizeAttributeName) => {
18129
- if (previousState[fontSizeAttributeName]) {
18130
- // if new font size is name compare with the previous slug
18131
- if (attributes[fontSizeAttributeName]) {
18132
- return attributes[fontSizeAttributeName] !== previousState[fontSizeAttributeName].slug;
18133
- } // if font size is not named, update when the font size value changes.
18134
-
18135
-
18136
- return previousState[fontSizeAttributeName].size !== attributes[customFontSizeAttributeName];
18137
- } // in this case we need to build the font size object
18138
-
18139
-
18140
- return true;
18141
- };
18142
-
18143
- if (!(0,external_lodash_namespaceObject.some)(fontSizeAttributeNames, didAttributesChange)) {
18144
- return null;
18145
- }
18146
 
18147
- const newState = (0,external_lodash_namespaceObject.reduce)((0,external_lodash_namespaceObject.pickBy)(fontSizeAttributeNames, didAttributesChange), (newStateAccumulator, customFontSizeAttributeName, fontSizeAttributeName) => {
18148
- const fontSizeAttributeValue = attributes[fontSizeAttributeName];
18149
- const fontSizeObject = getFontSize(fontSizes, fontSizeAttributeValue, attributes[customFontSizeAttributeName]);
18150
- newStateAccumulator[fontSizeAttributeName] = { ...fontSizeObject,
18151
- class: getFontSizeClass(fontSizeAttributeValue)
18152
- };
18153
- return newStateAccumulator;
18154
- }, {});
18155
- return { ...previousState,
18156
- ...newState
18157
- };
18158
- }
 
 
 
 
 
 
 
 
 
18159
 
18160
- render() {
18161
- return (0,external_wp_element_namespaceObject.createElement)(WrappedComponent, _extends({}, this.props, {
18162
- fontSizes: undefined
18163
- }, this.state, this.setters));
18164
- }
18165
 
18166
- };
18167
- }]), 'withFontSizes');
18168
- });
18169
- //# sourceMappingURL=with-font-sizes.js.map
18170
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/font-sizes/index.js
18171
 
18172
 
 
 
 
 
 
 
 
 
18173
 
18174
- //# sourceMappingURL=index.js.map
18175
- ;// CONCATENATED MODULE: ./packages/icons/build-module/library/align-left.js
 
 
 
18176
 
 
 
 
18177
 
 
 
 
 
 
18178
  /**
18179
  * WordPress dependencies
18180
  */
18181
 
18182
- const alignLeft = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
18183
- xmlns: "http://www.w3.org/2000/svg",
18184
- viewBox: "0 0 24 24"
18185
- }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
18186
- d: "M4 19.8h8.9v-1.5H4v1.5zm8.9-15.6H4v1.5h8.9V4.2zm-8.9 7v1.5h16v-1.5H4z"
18187
- }));
18188
- /* harmony default export */ var align_left = (alignLeft);
18189
- //# sourceMappingURL=align-left.js.map
18190
- ;// CONCATENATED MODULE: ./packages/icons/build-module/library/align-center.js
18191
-
18192
 
18193
  /**
18194
- * WordPress dependencies
18195
  */
18196
 
18197
- const alignCenter = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
18198
- xmlns: "http://www.w3.org/2000/svg",
18199
- viewBox: "0 0 24 24"
18200
- }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
18201
- d: "M16.4 4.2H7.6v1.5h8.9V4.2zM4 11.2v1.5h16v-1.5H4zm3.6 8.6h8.9v-1.5H7.6v1.5z"
18202
- }));
18203
- /* harmony default export */ var align_center = (alignCenter);
18204
- //# sourceMappingURL=align-center.js.map
18205
- ;// CONCATENATED MODULE: ./packages/icons/build-module/library/align-right.js
18206
-
18207
 
18208
  /**
18209
- * WordPress dependencies
 
 
 
 
18210
  */
18211
 
18212
- const alignRight = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
18213
- xmlns: "http://www.w3.org/2000/svg",
18214
- viewBox: "0 0 24 24"
18215
- }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
18216
- d: "M11.1 19.8H20v-1.5h-8.9v1.5zm0-15.6v1.5H20V4.2h-8.9zM4 12.8h16v-1.5H4v1.5z"
18217
- }));
18218
- /* harmony default export */ var align_right = (alignRight);
18219
- //# sourceMappingURL=align-right.js.map
18220
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/alignment-control/ui.js
 
18221
 
 
 
 
 
 
 
18222
 
 
 
 
18223
 
 
 
 
 
 
18224
  /**
18225
  * External dependencies
18226
  */
@@ -18230,319 +18236,252 @@ const alignRight = (0,external_wp_element_namespaceObject.createElement)(externa
18230
  */
18231
 
18232
 
 
 
 
18233
 
18234
 
18235
- const DEFAULT_ALIGNMENT_CONTROLS = [{
18236
- icon: align_left,
18237
- title: (0,external_wp_i18n_namespaceObject.__)('Align text left'),
18238
- align: 'left'
18239
- }, {
18240
- icon: align_center,
18241
- title: (0,external_wp_i18n_namespaceObject.__)('Align text center'),
18242
- align: 'center'
18243
- }, {
18244
- icon: align_right,
18245
- title: (0,external_wp_i18n_namespaceObject.__)('Align text right'),
18246
- align: 'right'
18247
- }];
18248
- const ui_POPOVER_PROPS = {
18249
- position: 'bottom right',
18250
- isAlternate: true
18251
- };
18252
-
18253
- function AlignmentUI({
18254
- value,
18255
- onChange,
18256
- alignmentControls = DEFAULT_ALIGNMENT_CONTROLS,
18257
- label = (0,external_wp_i18n_namespaceObject.__)('Align'),
18258
- describedBy = (0,external_wp_i18n_namespaceObject.__)('Change text alignment'),
18259
- isCollapsed = true,
18260
- isToolbar
18261
- }) {
18262
- function applyOrUnset(align) {
18263
- return () => onChange(value === align ? undefined : align);
18264
- }
18265
-
18266
- const activeAlignment = (0,external_lodash_namespaceObject.find)(alignmentControls, control => control.align === value);
18267
-
18268
- function setIcon() {
18269
- if (activeAlignment) return activeAlignment.icon;
18270
- return (0,external_wp_i18n_namespaceObject.isRTL)() ? align_right : align_left;
18271
- }
18272
-
18273
- const UIComponent = isToolbar ? external_wp_components_namespaceObject.ToolbarGroup : external_wp_components_namespaceObject.ToolbarDropdownMenu;
18274
- const extraProps = isToolbar ? {
18275
- isCollapsed
18276
- } : {};
18277
- return (0,external_wp_element_namespaceObject.createElement)(UIComponent, _extends({
18278
- icon: setIcon(),
18279
- label: label,
18280
- toggleProps: {
18281
- describedBy
18282
- },
18283
- popoverProps: ui_POPOVER_PROPS,
18284
- controls: alignmentControls.map(control => {
18285
- const {
18286
- align
18287
- } = control;
18288
- const isActive = value === align;
18289
- return { ...control,
18290
- isActive,
18291
- role: isCollapsed ? 'menuitemradio' : undefined,
18292
- onClick: applyOrUnset(align)
18293
- };
18294
- })
18295
- }, extraProps));
18296
- }
18297
 
18298
- /* harmony default export */ var alignment_control_ui = (AlignmentUI);
18299
- //# sourceMappingURL=ui.js.map
18300
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/alignment-control/index.js
 
 
 
 
 
 
 
18301
 
 
 
 
18302
 
 
18303
 
18304
- /**
18305
- * Internal dependencies
18306
- */
18307
 
18308
- function AlignmentControl(props) {
18309
- return (0,external_wp_element_namespaceObject.createElement)(alignment_control_ui, _extends({}, props, {
18310
- isToolbar: false
18311
- }));
18312
- }
18313
- function AlignmentToolbar(props) {
18314
- return (0,external_wp_element_namespaceObject.createElement)(alignment_control_ui, _extends({}, props, {
18315
- isToolbar: true
18316
- }));
18317
  }
18318
- //# sourceMappingURL=index.js.map
18319
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/inserter/search-items.js
18320
  /**
18321
- * External dependencies
18322
  */
18323
- // Default search helpers
18324
-
18325
- const defaultGetName = item => item.name || '';
18326
 
18327
- const defaultGetTitle = item => item.title;
18328
 
18329
- const defaultGetDescription = item => item.description || '';
 
 
18330
 
18331
- const defaultGetKeywords = item => item.keywords || [];
18332
 
18333
- const defaultGetCategory = item => item.category;
18334
 
18335
- const defaultGetCollection = () => null;
18336
  /**
18337
- * Sanitizes the search input string.
18338
- *
18339
- * @param {string} input The search input to normalize.
18340
  *
18341
- * @return {string} The normalized search input.
18342
  */
18343
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18344
 
18345
- function normalizeSearchInput(input = '') {
18346
- // Disregard diacritics.
18347
- // Input: "média"
18348
- input = (0,external_lodash_namespaceObject.deburr)(input); // Accommodate leading slash, matching autocomplete expectations.
18349
- // Input: "/media"
18350
 
18351
- input = input.replace(/^\//, ''); // Lowercase.
18352
- // Input: "MEDIA"
 
18353
 
18354
- input = input.toLowerCase();
18355
- return input;
 
 
 
 
 
 
18356
  }
 
 
18357
  /**
18358
- * Converts the search term into a list of normalized terms.
18359
- *
18360
- * @param {string} input The search term to normalize.
18361
- *
18362
- * @return {string[]} The normalized list of search terms.
18363
  */
18364
 
18365
 
18366
- const getNormalizedSearchTerms = (input = '') => {
18367
- // Extract words.
18368
- return (0,external_lodash_namespaceObject.words)(normalizeSearchInput(input));
18369
- };
18370
-
18371
- const removeMatchingTerms = (unmatchedTerms, unprocessedTerms) => {
18372
- return (0,external_lodash_namespaceObject.differenceWith)(unmatchedTerms, getNormalizedSearchTerms(unprocessedTerms), (unmatchedTerm, unprocessedTerm) => unprocessedTerm.includes(unmatchedTerm));
18373
- };
18374
 
18375
- const searchBlockItems = (items, categories, collections, searchInput) => {
18376
- const normalizedSearchTerms = getNormalizedSearchTerms(searchInput);
18377
-
18378
- if (normalizedSearchTerms.length === 0) {
18379
- return items;
18380
- }
18381
 
18382
- const config = {
18383
- getCategory: item => {
18384
- var _find;
18385
 
18386
- return (_find = (0,external_lodash_namespaceObject.find)(categories, {
18387
- slug: item.category
18388
- })) === null || _find === void 0 ? void 0 : _find.title;
18389
- },
18390
- getCollection: item => {
18391
- var _collections$item$nam;
18392
 
18393
- return (_collections$item$nam = collections[item.name.split('/')[0]]) === null || _collections$item$nam === void 0 ? void 0 : _collections$item$nam.title;
18394
- }
18395
- };
18396
- return searchItems(items, searchInput, config);
18397
- };
18398
  /**
18399
- * Filters an item list given a search term.
18400
- *
18401
- * @param {Array} items Item list
18402
- * @param {string} searchInput Search input.
18403
- * @param {Object} config Search Config.
18404
  *
18405
- * @return {Array} Filtered item list.
18406
  */
18407
 
18408
- const searchItems = (items = [], searchInput = '', config = {}) => {
18409
- const normalizedSearchTerms = getNormalizedSearchTerms(searchInput);
18410
-
18411
- if (normalizedSearchTerms.length === 0) {
18412
- return items;
18413
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18414
 
18415
- const rankedItems = items.map(item => {
18416
- return [item, getItemSearchRank(item, searchInput, config)];
18417
- }).filter(([, rank]) => rank > 0);
18418
- rankedItems.sort(([, rank1], [, rank2]) => rank2 - rank1);
18419
- return rankedItems.map(([item]) => item);
18420
- };
18421
- /**
18422
- * Get the search rank for a given item and a specific search term.
18423
- * The better the match, the higher the rank.
18424
- * If the rank equals 0, it should be excluded from the results.
18425
- *
18426
- * @param {Object} item Item to filter.
18427
- * @param {string} searchTerm Search term.
18428
- * @param {Object} config Search Config.
18429
- *
18430
- * @return {number} Search Rank.
18431
- */
18432
 
18433
- function getItemSearchRank(item, searchTerm, config = {}) {
18434
- const {
18435
- getName = defaultGetName,
18436
- getTitle = defaultGetTitle,
18437
- getDescription = defaultGetDescription,
18438
- getKeywords = defaultGetKeywords,
18439
- getCategory = defaultGetCategory,
18440
- getCollection = defaultGetCollection
18441
- } = config;
18442
- const name = getName(item);
18443
- const title = getTitle(item);
18444
- const description = getDescription(item);
18445
- const keywords = getKeywords(item);
18446
- const category = getCategory(item);
18447
- const collection = getCollection(item);
18448
- const normalizedSearchInput = normalizeSearchInput(searchTerm);
18449
- const normalizedTitle = normalizeSearchInput(title);
18450
- let rank = 0; // Prefers exact matches
18451
- // Then prefers if the beginning of the title matches the search term
18452
- // name, keywords, categories, collection, variations match come later.
18453
 
18454
- if (normalizedSearchInput === normalizedTitle) {
18455
- rank += 30;
18456
- } else if (normalizedTitle.startsWith(normalizedSearchInput)) {
18457
- rank += 20;
18458
- } else {
18459
- const terms = [name, title, description, ...keywords, category, collection].join(' ');
18460
- const normalizedSearchTerms = (0,external_lodash_namespaceObject.words)(normalizedSearchInput);
18461
- const unmatchedTerms = removeMatchingTerms(normalizedSearchTerms, terms);
18462
 
18463
- if (unmatchedTerms.length === 0) {
18464
- rank += 10;
 
 
 
 
 
 
 
 
 
18465
  }
18466
- } // Give a better rank to "core" namespaced items.
 
 
 
 
 
18467
 
18468
 
18469
- if (rank !== 0 && name.startsWith('core/')) {
18470
- rank++;
18471
- }
18472
 
18473
- return rank;
 
 
 
 
 
 
18474
  }
18475
- //# sourceMappingURL=search-items.js.map
18476
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/inserter/hooks/use-block-types-state.js
18477
  /**
18478
  * WordPress dependencies
18479
  */
18480
 
18481
 
18482
-
18483
  /**
18484
  * Internal dependencies
18485
  */
18486
 
18487
 
18488
  /**
18489
- * Retrieves the block types inserter state.
18490
  *
18491
- * @param {string=} rootClientId Insertion's root client ID.
18492
- * @param {Function} onInsert function called when inserter a list of blocks.
18493
- * @return {Array} Returns the block types state. (block types, categories, collections, onSelect handler)
18494
  */
18495
 
18496
- const useBlockTypesState = (rootClientId, onInsert) => {
18497
  const {
18498
- categories,
18499
- collections,
18500
- items
18501
- } = (0,external_wp_data_namespaceObject.useSelect)(select => {
18502
- const {
18503
- getInserterItems
18504
- } = select(store);
18505
- const {
18506
- getCategories,
18507
- getCollections
18508
- } = select(external_wp_blocks_namespaceObject.store);
18509
- return {
18510
- categories: getCategories(),
18511
- collections: getCollections(),
18512
- items: getInserterItems(rootClientId)
18513
- };
18514
- }, [rootClientId]);
18515
- const onSelectItem = (0,external_wp_element_namespaceObject.useCallback)(({
18516
- name,
18517
- initialAttributes,
18518
- innerBlocks
18519
- }, shouldFocusBlock) => {
18520
- const insertedBlock = (0,external_wp_blocks_namespaceObject.createBlock)(name, initialAttributes, (0,external_wp_blocks_namespaceObject.createBlocksFromInnerBlocksTemplate)(innerBlocks));
18521
- onInsert(insertedBlock, undefined, shouldFocusBlock);
18522
- }, [onInsert]);
18523
- return [items, categories, collections, onSelectItem];
18524
- };
18525
-
18526
- /* harmony default export */ var use_block_types_state = (useBlockTypesState);
18527
- //# sourceMappingURL=use-block-types-state.js.map
18528
- ;// CONCATENATED MODULE: ./packages/icons/build-module/library/block-default.js
18529
-
18530
-
18531
- /**
18532
- * WordPress dependencies
18533
- */
18534
-
18535
- const blockDefault = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
18536
- xmlns: "http://www.w3.org/2000/svg",
18537
- viewBox: "0 0 24 24"
18538
- }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
18539
- d: "M19 8h-1V6h-5v2h-2V6H6v2H5c-1.1 0-2 .9-2 2v8c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2v-8c0-1.1-.9-2-2-2zm.5 10c0 .3-.2.5-.5.5H5c-.3 0-.5-.2-.5-.5v-8c0-.3.2-.5.5-.5h14c.3 0 .5.2.5.5v8z"
18540
- }));
18541
- /* harmony default export */ var block_default = (blockDefault);
18542
- //# sourceMappingURL=block-default.js.map
18543
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-icon/index.js
18544
 
 
 
 
 
 
 
 
18545
 
 
 
 
 
 
 
 
 
 
 
 
18546
  /**
18547
  * External dependencies
18548
  */
@@ -18551,43 +18490,6 @@ const blockDefault = (0,external_wp_element_namespaceObject.createElement)(exter
18551
  * WordPress dependencies
18552
  */
18553
 
18554
-
18555
-
18556
- function BlockIcon({
18557
- icon,
18558
- showColors = false,
18559
- className
18560
- }) {
18561
- var _icon;
18562
-
18563
- if (((_icon = icon) === null || _icon === void 0 ? void 0 : _icon.src) === 'block-default') {
18564
- icon = {
18565
- src: block_default
18566
- };
18567
- }
18568
-
18569
- const renderedIcon = (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Icon, {
18570
- icon: icon && icon.src ? icon.src : icon
18571
- });
18572
- const style = showColors ? {
18573
- backgroundColor: icon && icon.background,
18574
- color: icon && icon.foreground
18575
- } : {};
18576
- return (0,external_wp_element_namespaceObject.createElement)("span", {
18577
- style: style,
18578
- className: classnames_default()('block-editor-block-icon', className, {
18579
- 'has-colors': showColors
18580
- })
18581
- }, renderedIcon);
18582
- }
18583
- //# sourceMappingURL=index.js.map
18584
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/autocompleters/block.js
18585
-
18586
-
18587
- /**
18588
- * External dependencies
18589
- */
18590
-
18591
  /**
18592
  * WordPress dependencies
18593
  */
@@ -18600,298 +18502,232 @@ function BlockIcon({
18600
  */
18601
 
18602
 
 
 
 
 
 
 
 
 
 
 
 
18603
 
 
 
 
 
18604
 
 
18605
 
18606
- const SHOWN_BLOCK_TYPES = 9;
18607
- /** @typedef {import('@wordpress/components').WPCompleter} WPCompleter */
18608
-
18609
- /**
18610
- * Creates a blocks repeater for replacing the current block with a selected block type.
18611
- *
18612
- * @return {WPCompleter} A blocks completer.
18613
- */
18614
 
18615
- function createBlockCompleter() {
18616
- return {
18617
- name: 'blocks',
18618
- className: 'block-editor-autocompleters__block',
18619
- triggerPrefix: '/',
18620
 
18621
- useItems(filterValue) {
18622
- const {
18623
- rootClientId,
18624
- selectedBlockName
18625
- } = (0,external_wp_data_namespaceObject.useSelect)(select => {
18626
- const {
18627
- getSelectedBlockClientId,
18628
- getBlockName,
18629
- getBlockInsertionPoint
18630
- } = select(store);
18631
- const selectedBlockClientId = getSelectedBlockClientId();
18632
- return {
18633
- selectedBlockName: selectedBlockClientId ? getBlockName(selectedBlockClientId) : null,
18634
- rootClientId: getBlockInsertionPoint().rootClientId
18635
- };
18636
- }, []);
18637
- const [items, categories, collections] = use_block_types_state(rootClientId, external_lodash_namespaceObject.noop);
18638
- const filteredItems = (0,external_wp_element_namespaceObject.useMemo)(() => {
18639
- const initialFilteredItems = !!filterValue.trim() ? searchBlockItems(items, categories, collections, filterValue) : (0,external_lodash_namespaceObject.orderBy)(items, ['frecency'], ['desc']);
18640
- return initialFilteredItems.filter(item => item.name !== selectedBlockName).slice(0, SHOWN_BLOCK_TYPES);
18641
- }, [filterValue, selectedBlockName, items, categories, collections]);
18642
- const options = (0,external_wp_element_namespaceObject.useMemo)(() => filteredItems.map(blockItem => {
18643
- const {
18644
- title,
18645
- icon,
18646
- isDisabled
18647
- } = blockItem;
18648
- return {
18649
- key: `block-${blockItem.id}`,
18650
- value: blockItem,
18651
- label: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(BlockIcon, {
18652
- key: "icon",
18653
- icon: icon,
18654
- showColors: true
18655
- }), title),
18656
- isDisabled
18657
- };
18658
- }), [filteredItems]);
18659
- return [options];
18660
- },
18661
 
18662
- allowContext(before, after) {
18663
- return !(/\S/.test(before) || /\S/.test(after));
18664
- },
18665
 
18666
- getOptionCompletion(inserterItem) {
18667
- const {
18668
- name,
18669
- initialAttributes,
18670
- innerBlocks
18671
- } = inserterItem;
18672
- return {
18673
- action: 'replace',
18674
- value: (0,external_wp_blocks_namespaceObject.createBlock)(name, initialAttributes, (0,external_wp_blocks_namespaceObject.createBlocksFromInnerBlocksTemplate)(innerBlocks))
18675
- };
18676
  }
18677
 
18678
- };
 
 
 
 
18679
  }
18680
- /**
18681
- * Creates a blocks repeater for replacing the current block with a selected block type.
18682
- *
18683
- * @return {WPCompleter} A blocks completer.
18684
- */
18685
-
18686
-
18687
- /* harmony default export */ var block = (createBlockCompleter());
18688
- //# sourceMappingURL=block.js.map
18689
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/autocomplete/index.js
18690
-
18691
-
18692
-
18693
- /**
18694
- * External dependencies
18695
- */
18696
-
18697
  /**
18698
  * WordPress dependencies
18699
  */
18700
 
18701
 
18702
-
18703
-
18704
-
18705
  /**
18706
  * Internal dependencies
18707
  */
18708
 
18709
 
18710
 
 
 
 
 
 
 
 
 
 
 
18711
  /**
18712
- * Shared reference to an empty array for cases where it is important to avoid
18713
- * returning a new array reference on every invocation.
18714
  *
18715
- * @type {Array}
18716
  */
18717
 
18718
- const autocomplete_EMPTY_ARRAY = [];
18719
 
18720
- function useCompleters({
18721
- completers = autocomplete_EMPTY_ARRAY
18722
- }) {
18723
  const {
18724
- name
18725
- } = useBlockEditContext();
18726
- return (0,external_wp_element_namespaceObject.useMemo)(() => {
18727
- let filteredCompleters = completers;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18728
 
18729
- if (name === (0,external_wp_blocks_namespaceObject.getDefaultBlockName)()) {
18730
- filteredCompleters = filteredCompleters.concat([block]);
18731
- }
 
 
18732
 
18733
- if ((0,external_wp_hooks_namespaceObject.hasFilter)('editor.Autocomplete.completers')) {
18734
- // Provide copies so filters may directly modify them.
18735
- if (filteredCompleters === completers) {
18736
- filteredCompleters = filteredCompleters.map(external_lodash_namespaceObject.clone);
18737
  }
18738
 
18739
- filteredCompleters = (0,external_wp_hooks_namespaceObject.applyFilters)('editor.Autocomplete.completers', filteredCompleters, name);
18740
- }
18741
-
18742
- return filteredCompleters;
18743
- }, [completers, name]);
18744
- }
18745
-
18746
- function useBlockEditorAutocompleteProps(props) {
18747
- return (0,external_wp_components_namespaceObject.__unstableUseAutocompleteProps)({ ...props,
18748
- completers: useCompleters(props)
18749
- });
18750
- }
18751
- /**
18752
- * Wrap the default Autocomplete component with one that supports a filter hook
18753
- * for customizing its list of autocompleters.
18754
- *
18755
- * @type {import('react').FC}
18756
- */
18757
 
18758
- function BlockEditorAutocomplete(props) {
18759
- return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Autocomplete, _extends({}, props, {
18760
- completers: useCompleters(props)
18761
- }));
18762
- }
18763
- /**
18764
- * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/autocomplete/README.md
18765
- */
18766
 
 
 
18767
 
18768
- /* harmony default export */ var autocomplete = (BlockEditorAutocomplete);
18769
- //# sourceMappingURL=index.js.map
18770
- ;// CONCATENATED MODULE: ./packages/icons/build-module/library/fullscreen.js
 
18771
 
 
 
 
 
 
 
 
 
 
 
 
 
18772
 
18773
- /**
18774
- * WordPress dependencies
18775
- */
18776
 
18777
- const fullscreen = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
18778
- xmlns: "http://www.w3.org/2000/svg",
18779
- viewBox: "0 0 24 24"
18780
- }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
18781
- d: "M4.2 9h1.5V5.8H9V4.2H4.2V9zm14 9.2H15v1.5h4.8V15h-1.5v3.2zM15 4.2v1.5h3.2V9h1.5V4.2H15zM5.8 15H4.2v4.8H9v-1.5H5.8V15z"
18782
- }));
18783
- /* harmony default export */ var library_fullscreen = (fullscreen);
18784
- //# sourceMappingURL=fullscreen.js.map
18785
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-full-height-alignment-control/index.js
18786
 
 
 
 
 
 
 
 
18787
 
18788
- /**
18789
- * WordPress dependencies
18790
- */
 
 
 
 
 
18791
 
 
 
 
18792
 
 
 
 
 
18793
 
 
 
 
 
 
 
 
 
 
 
18794
 
18795
- function BlockFullHeightAlignmentControl({
18796
- isActive,
18797
- label = (0,external_wp_i18n_namespaceObject.__)('Toggle full height'),
18798
- onToggle,
18799
- isDisabled
18800
- }) {
18801
- return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, {
18802
- isActive: isActive,
18803
- icon: library_fullscreen,
18804
- label: label,
18805
- onClick: () => onToggle(!isActive),
18806
- disabled: isDisabled
18807
- });
18808
- }
18809
-
18810
- /* harmony default export */ var block_full_height_alignment_control = (BlockFullHeightAlignmentControl);
18811
- //# sourceMappingURL=index.js.map
18812
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-alignment-matrix-control/index.js
18813
-
18814
-
18815
- /**
18816
- * External dependencies
18817
- */
18818
-
18819
- /**
18820
- * WordPress dependencies
18821
- */
18822
-
18823
-
18824
 
 
 
 
 
 
 
18825
 
 
 
 
 
18826
 
18827
- function BlockAlignmentMatrixControl(props) {
18828
- const {
18829
- label = (0,external_wp_i18n_namespaceObject.__)('Change matrix alignment'),
18830
- onChange = external_lodash_namespaceObject.noop,
18831
- value = 'center',
18832
- isDisabled
18833
- } = props;
18834
- const icon = (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalAlignmentMatrixControl.Icon, {
18835
- value: value
18836
- });
18837
- const className = 'block-editor-block-alignment-matrix-control';
18838
- const popoverClassName = `${className}__popover`;
18839
- const isAlternate = true;
18840
- return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Dropdown, {
18841
- position: "bottom right",
18842
- className: className,
18843
- popoverProps: {
18844
- className: popoverClassName,
18845
- isAlternate
18846
- },
18847
- renderToggle: ({
18848
- onToggle,
18849
- isOpen
18850
- }) => {
18851
- const openOnArrowDown = event => {
18852
- if (!isOpen && event.keyCode === external_wp_keycodes_namespaceObject.DOWN) {
18853
  event.preventDefault();
18854
- onToggle();
18855
  }
18856
- };
 
 
 
 
 
 
 
 
 
18857
 
18858
- return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, {
18859
- onClick: onToggle,
18860
- "aria-haspopup": "true",
18861
- "aria-expanded": isOpen,
18862
- onKeyDown: openOnArrowDown,
18863
- label: label,
18864
- icon: icon,
18865
- showTooltip: true,
18866
- disabled: isDisabled
18867
- });
18868
- },
18869
- renderContent: () => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalAlignmentMatrixControl, {
18870
- hasFocusBorder: false,
18871
- onChange: onChange,
18872
- value: value
18873
- })
18874
- });
18875
  }
18876
-
18877
- /* harmony default export */ var block_alignment_matrix_control = (BlockAlignmentMatrixControl);
18878
- //# sourceMappingURL=index.js.map
18879
- ;// CONCATENATED MODULE: ./packages/icons/build-module/library/chevron-right-small.js
18880
-
18881
-
18882
- /**
18883
- * WordPress dependencies
18884
- */
18885
-
18886
- const chevronRightSmall = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
18887
- xmlns: "http://www.w3.org/2000/svg",
18888
- viewBox: "0 0 24 24"
18889
- }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
18890
- d: "M10.8622 8.04053L14.2805 12.0286L10.8622 16.0167L9.72327 15.0405L12.3049 12.0286L9.72327 9.01672L10.8622 8.04053Z"
18891
- }));
18892
- /* harmony default export */ var chevron_right_small = (chevronRightSmall);
18893
- //# sourceMappingURL=chevron-right-small.js.map
18894
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/use-block-display-information/index.js
18895
  /**
18896
  * WordPress dependencies
18897
  */
@@ -18902,65 +18738,19 @@ const chevronRightSmall = (0,external_wp_element_namespaceObject.createElement)(
18902
  */
18903
 
18904
 
18905
- /** @typedef {import('@wordpress/blocks').WPIcon} WPIcon */
18906
-
18907
- /**
18908
- * Contains basic block's information for display reasons.
18909
- *
18910
- * @typedef {Object} WPBlockDisplayInformation
18911
- *
18912
- * @property {string} title Human-readable block type label.
18913
- * @property {WPIcon} icon Block type icon.
18914
- * @property {string} description A detailed block type description.
18915
- */
18916
-
18917
- /**
18918
- * Hook used to try to find a matching block variation and return
18919
- * the appropriate information for display reasons. In order to
18920
- * to try to find a match we need to things:
18921
- * 1. Block's client id to extract it's current attributes.
18922
- * 2. A block variation should have set `isActive` prop to a proper function.
18923
- *
18924
- * If for any reason a block variaton match cannot be found,
18925
- * the returned information come from the Block Type.
18926
- * If no blockType is found with the provided clientId, returns null.
18927
- *
18928
- * @param {string} clientId Block's client id.
18929
- * @return {?WPBlockDisplayInformation} Block's display information, or `null` when the block or its type not found.
18930
- */
18931
-
18932
- function useBlockDisplayInformation(clientId) {
18933
- return (0,external_wp_data_namespaceObject.useSelect)(select => {
18934
- if (!clientId) return null;
18935
- const {
18936
- getBlockName,
18937
- getBlockAttributes
18938
- } = select(store);
18939
- const {
18940
- getBlockType,
18941
- getActiveBlockVariation
18942
- } = select(external_wp_blocks_namespaceObject.store);
18943
- const blockName = getBlockName(clientId);
18944
- const blockType = getBlockType(blockName);
18945
- if (!blockType) return null;
18946
- const attributes = getBlockAttributes(clientId);
18947
- const match = getActiveBlockVariation(blockName, attributes);
18948
- const blockTypeInfo = {
18949
- title: blockType.title,
18950
- icon: blockType.icon,
18951
- description: blockType.description,
18952
- anchor: attributes === null || attributes === void 0 ? void 0 : attributes.anchor
18953
- };
18954
- if (!match) return blockTypeInfo;
18955
- return {
18956
- title: match.title || blockType.title,
18957
- icon: match.icon || blockType.icon,
18958
- description: match.description || blockType.description
18959
- };
18960
- }, [clientId]);
18961
  }
18962
- //# sourceMappingURL=index.js.map
18963
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-title/index.js
18964
  /**
18965
  * External dependencies
18966
  */
@@ -18971,521 +18761,502 @@ function useBlockDisplayInformation(clientId) {
18971
 
18972
 
18973
 
 
 
 
 
18974
  /**
18975
  * Internal dependencies
18976
  */
18977
 
18978
 
18979
 
18980
- /**
18981
- * Renders the block's configured title as a string, or empty if the title
18982
- * cannot be determined.
18983
- *
18984
- * @example
18985
- *
18986
- * ```jsx
18987
- * <BlockTitle clientId="afd1cb17-2c08-4e7a-91be-007ba7ddc3a1" />
18988
- * ```
18989
- *
18990
- * @param {Object} props
18991
- * @param {string} props.clientId Client ID of block.
18992
- *
18993
- * @return {?string} Block title.
18994
- */
18995
 
18996
- function BlockTitle({
18997
- clientId
18998
- }) {
18999
- const {
19000
- attributes,
19001
- name,
19002
- reusableBlockTitle
19003
- } = (0,external_wp_data_namespaceObject.useSelect)(select => {
19004
- if (!clientId) {
19005
- return {};
19006
- }
19007
 
19008
- const {
19009
- getBlockName,
19010
- getBlockAttributes,
19011
- __experimentalGetReusableBlockTitle
19012
- } = select(store);
19013
- const blockName = getBlockName(clientId);
19014
 
19015
- if (!blockName) {
19016
- return {};
19017
- }
19018
 
19019
- const isReusable = (0,external_wp_blocks_namespaceObject.isReusableBlock)((0,external_wp_blocks_namespaceObject.getBlockType)(blockName));
19020
- return {
19021
- attributes: getBlockAttributes(clientId),
19022
- name: blockName,
19023
- reusableBlockTitle: isReusable && __experimentalGetReusableBlockTitle(getBlockAttributes(clientId).ref)
19024
- };
19025
- }, [clientId]);
19026
- const blockInformation = useBlockDisplayInformation(clientId);
19027
- if (!name || !blockInformation) return null;
19028
- const blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(name);
19029
- const label = reusableBlockTitle || (0,external_wp_blocks_namespaceObject.__experimentalGetBlockLabel)(blockType, attributes); // Label will fallback to the title if no label is defined for the current
19030
- // label context. If the label is defined we prioritize it over possible
19031
- // possible block variation title match.
19032
 
19033
- if (label !== blockType.title) {
19034
- return (0,external_lodash_namespaceObject.truncate)(label, {
19035
- length: 35
19036
- });
19037
- }
19038
 
19039
- return blockInformation.title;
19040
- }
19041
- //# sourceMappingURL=index.js.map
19042
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-breadcrumb/index.js
19043
 
19044
 
19045
- /**
19046
- * WordPress dependencies
19047
- */
19048
 
19049
 
19050
 
19051
 
19052
- /**
19053
- * Internal dependencies
19054
- */
19055
 
19056
 
19057
 
19058
  /**
19059
- * Block breadcrumb component, displaying the hierarchy of the current block selection as a breadcrumb.
 
 
 
 
 
 
 
 
 
 
 
 
19060
  *
19061
- * @param {Object} props Component props.
19062
- * @param {string} props.rootLabelText Translated label for the root element of the breadcrumb trail.
19063
- * @return {WPElement} Block Breadcrumb.
 
 
 
19064
  */
19065
 
19066
- function BlockBreadcrumb({
19067
- rootLabelText
19068
- }) {
19069
- const {
19070
- selectBlock,
19071
- clearSelectedBlock
19072
- } = (0,external_wp_data_namespaceObject.useDispatch)(store);
19073
  const {
19074
  clientId,
19075
- parents,
19076
- hasSelection
 
 
 
 
 
 
 
 
 
 
 
19077
  } = (0,external_wp_data_namespaceObject.useSelect)(select => {
19078
  const {
19079
- getSelectionStart,
19080
- getSelectedBlockClientId,
19081
- getBlockParents
 
 
 
 
 
 
 
19082
  } = select(store);
19083
- const selectedBlockClientId = getSelectedBlockClientId();
 
 
 
 
19084
  return {
19085
- parents: getBlockParents(selectedBlockClientId),
19086
- clientId: selectedBlockClientId,
19087
- hasSelection: !!getSelectionStart().clientId
 
 
 
 
 
19088
  };
19089
- }, []);
19090
-
19091
- const rootLabel = rootLabelText || (0,external_wp_i18n_namespaceObject.__)('Document');
19092
- /*
19093
- * Disable reason: The `list` ARIA role is redundant but
19094
- * Safari+VoiceOver won't announce the list otherwise.
19095
- */
19096
 
19097
- /* eslint-disable jsx-a11y/no-redundant-roles */
 
 
 
 
 
 
 
 
 
19098
 
 
 
 
19099
 
19100
- return (0,external_wp_element_namespaceObject.createElement)("ul", {
19101
- className: "block-editor-block-breadcrumb",
19102
- role: "list",
19103
- "aria-label": (0,external_wp_i18n_namespaceObject.__)('Block breadcrumb')
19104
- }, (0,external_wp_element_namespaceObject.createElement)("li", {
19105
- className: !hasSelection ? 'block-editor-block-breadcrumb__current' : undefined,
19106
- "aria-current": !hasSelection ? 'true' : undefined
19107
- }, hasSelection && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
19108
- className: "block-editor-block-breadcrumb__button",
19109
- variant: "tertiary",
19110
- onClick: clearSelectedBlock
19111
- }, rootLabel), !hasSelection && rootLabel, !!clientId && (0,external_wp_element_namespaceObject.createElement)(icon, {
19112
- icon: chevron_right_small,
19113
- className: "block-editor-block-breadcrumb__separator"
19114
- })), parents.map(parentClientId => (0,external_wp_element_namespaceObject.createElement)("li", {
19115
- key: parentClientId
19116
- }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
19117
- className: "block-editor-block-breadcrumb__button",
19118
- variant: "tertiary",
19119
- onClick: () => selectBlock(parentClientId)
19120
- }, (0,external_wp_element_namespaceObject.createElement)(BlockTitle, {
19121
- clientId: parentClientId
19122
- })), (0,external_wp_element_namespaceObject.createElement)(icon, {
19123
- icon: chevron_right_small,
19124
- className: "block-editor-block-breadcrumb__separator"
19125
- }))), !!clientId && (0,external_wp_element_namespaceObject.createElement)("li", {
19126
- className: "block-editor-block-breadcrumb__current",
19127
- "aria-current": "true"
19128
- }, (0,external_wp_element_namespaceObject.createElement)(BlockTitle, {
19129
- clientId: clientId
19130
- })))
19131
- /* eslint-enable jsx-a11y/no-redundant-roles */
19132
- ;
19133
  }
 
 
 
 
 
19134
 
19135
- /* harmony default export */ var block_breadcrumb = (BlockBreadcrumb);
19136
  //# sourceMappingURL=index.js.map
19137
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-content-overlay/index.js
19138
-
19139
 
19140
 
19141
  /**
19142
- * WordPress dependencies
19143
  */
19144
 
19145
 
19146
  /**
19147
- * Internal dependencies
19148
  */
19149
 
19150
 
19151
- /**
19152
- * External dependencies
19153
- */
19154
 
19155
 
19156
- function BlockContentOverlay({
19157
- clientId,
19158
- tagName: TagName = 'div',
19159
- wrapperProps,
19160
- className
19161
- }) {
19162
- const baseClassName = 'block-editor-block-content-overlay';
19163
- const [isOverlayActive, setIsOverlayActive] = (0,external_wp_element_namespaceObject.useState)(true);
19164
- const [isHovered, setIsHovered] = (0,external_wp_element_namespaceObject.useState)(false);
19165
- const {
19166
- isParentSelected,
19167
- hasChildSelected,
19168
- isDraggingBlocks,
19169
- isParentHighlighted
19170
- } = (0,external_wp_data_namespaceObject.useSelect)(select => {
19171
- const {
19172
- isBlockSelected,
19173
- hasSelectedInnerBlock,
19174
- isDraggingBlocks: _isDraggingBlocks,
19175
- isBlockHighlighted
19176
- } = select(store);
19177
- return {
19178
- isParentSelected: isBlockSelected(clientId),
19179
- hasChildSelected: hasSelectedInnerBlock(clientId, true),
19180
- isDraggingBlocks: _isDraggingBlocks(),
19181
- isParentHighlighted: isBlockHighlighted(clientId)
19182
- };
19183
- }, [clientId]);
19184
- const classes = classnames_default()(baseClassName, wrapperProps === null || wrapperProps === void 0 ? void 0 : wrapperProps.className, className, {
19185
- 'overlay-active': isOverlayActive,
19186
- 'parent-highlighted': isParentHighlighted,
19187
- 'is-dragging-blocks': isDraggingBlocks
19188
- });
19189
- (0,external_wp_element_namespaceObject.useEffect)(() => {
19190
- // Reenable when blocks are not in use.
19191
- if (!isParentSelected && !hasChildSelected && !isOverlayActive) {
19192
- setIsOverlayActive(true);
19193
- } // Disable if parent selected by another means (such as list view).
19194
- // We check hover to ensure the overlay click interaction is not taking place.
19195
- // Trying to click the overlay will select the parent block via its 'focusin'
19196
- // listener on the wrapper, so if the block is selected while hovered we will
19197
- // let the mouseup disable the overlay instead.
19198
 
19199
 
19200
- if (isParentSelected && !isHovered && isOverlayActive) {
19201
- setIsOverlayActive(false);
19202
- } // Ensure overlay is disabled if a child block is selected.
19203
 
 
 
 
19204
 
19205
- if (hasChildSelected && isOverlayActive) {
19206
- setIsOverlayActive(false);
19207
- }
19208
- }, [isParentSelected, hasChildSelected, isOverlayActive, isHovered]); // Disabled because the overlay div doesn't actually have a role or functionality
19209
- // as far as the a11y is concerned. We're just catching the first click so that
19210
- // the block can be selected without interacting with its contents.
19211
 
19212
- /* eslint-disable jsx-a11y/no-static-element-interactions */
19213
 
19214
- return (0,external_wp_element_namespaceObject.createElement)(TagName, _extends({}, wrapperProps, {
19215
- className: classes,
19216
- onMouseEnter: () => setIsHovered(true),
19217
- onMouseLeave: () => setIsHovered(false)
19218
- }), isOverlayActive && (0,external_wp_element_namespaceObject.createElement)("div", {
19219
- className: `${baseClassName}__overlay`,
19220
- onMouseUp: () => setIsOverlayActive(false)
19221
- }), wrapperProps === null || wrapperProps === void 0 ? void 0 : wrapperProps.children);
19222
- }
19223
- /* eslint-enable jsx-a11y/no-static-element-interactions */
19224
- //# sourceMappingURL=index.js.map
19225
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-context/index.js
19226
 
19227
 
19228
- /**
19229
- * WordPress dependencies
19230
- */
19231
 
19232
- /** @typedef {import('react').ReactNode} ReactNode */
19233
 
 
 
19234
  /**
19235
- * @typedef BlockContextProviderProps
19236
  *
19237
- * @property {Record<string,*>} value Context value to merge with current
19238
- * value.
19239
- * @property {ReactNode} children Component children.
 
19240
  */
19241
 
19242
- /** @type {import('react').Context<Record<string,*>>} */
 
 
 
19243
 
19244
- const block_context_Context = (0,external_wp_element_namespaceObject.createContext)({});
19245
- /**
19246
- * Component which merges passed value with current consumed block context.
19247
- *
19248
- * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-context/README.md
19249
- *
19250
- * @param {BlockContextProviderProps} props
19251
- */
19252
 
19253
- function BlockContextProvider({
19254
- value,
19255
- children
 
 
 
 
 
 
 
 
 
 
19256
  }) {
19257
- const context = (0,external_wp_element_namespaceObject.useContext)(block_context_Context);
19258
- const nextValue = (0,external_wp_element_namespaceObject.useMemo)(() => ({ ...context,
19259
- ...value
19260
- }), [context, value]);
19261
- return (0,external_wp_element_namespaceObject.createElement)(block_context_Context.Provider, {
19262
- value: nextValue,
19263
- children: children
19264
- });
19265
  }
19266
- /* harmony default export */ var block_context = (block_context_Context);
19267
- //# sourceMappingURL=index.js.map
19268
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/color-style-selector/index.js
19269
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19270
 
19271
- /**
19272
- * WordPress dependencies
19273
- */
19274
 
 
 
19275
 
 
 
 
 
 
 
19276
 
 
19277
 
19278
- const ColorSelectorSVGIcon = () => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SVG, {
19279
- xmlns: "https://www.w3.org/2000/svg",
19280
- viewBox: "0 0 20 20"
19281
- }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Path, {
19282
- d: "M7.434 5l3.18 9.16H8.538l-.692-2.184H4.628l-.705 2.184H2L5.18 5h2.254zm-1.13 1.904h-.115l-1.148 3.593H7.44L6.304 6.904zM14.348 7.006c1.853 0 2.9.876 2.9 2.374v4.78h-1.79v-.914h-.114c-.362.64-1.123 1.022-2.031 1.022-1.346 0-2.292-.826-2.292-2.108 0-1.27.972-2.006 2.71-2.107l1.696-.102V9.38c0-.584-.42-.914-1.18-.914-.667 0-1.112.228-1.264.647h-1.701c.12-1.295 1.307-2.107 3.066-2.107zm1.079 4.1l-1.416.09c-.793.056-1.18.342-1.18.844 0 .52.45.837 1.091.837.857 0 1.505-.545 1.505-1.256v-.515z"
19283
- }));
19284
- /**
19285
- * Color Selector Icon component.
19286
- *
19287
- * @param {Object} props Component properties.
19288
- * @param {Object} props.style Style object.
19289
- * @param {string} props.className Class name for component.
19290
- *
19291
- * @return {*} React Icon component.
19292
- */
 
 
 
 
 
 
 
 
 
19293
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19294
 
19295
- const ColorSelectorIcon = ({
19296
- style,
19297
- className
19298
  }) => {
19299
- return (0,external_wp_element_namespaceObject.createElement)("div", {
19300
- className: "block-library-colors-selector__icon-container"
19301
- }, (0,external_wp_element_namespaceObject.createElement)("div", {
19302
- className: `${className} block-library-colors-selector__state-selection`,
19303
- style: style
19304
- }, (0,external_wp_element_namespaceObject.createElement)(ColorSelectorSVGIcon, null)));
19305
- };
19306
- /**
19307
- * Renders the Colors Selector Toolbar with the icon button.
19308
- *
19309
- * @param {Object} props Component properties.
19310
- * @param {Object} props.TextColor Text color component that wraps icon.
19311
- * @param {Object} props.BackgroundColor Background color component that wraps icon.
19312
- *
19313
- * @return {*} React toggle button component.
19314
- */
19315
 
 
19316
 
19317
- const renderToggleComponent = ({
19318
- TextColor,
19319
- BackgroundColor
19320
- }) => ({
19321
- onToggle,
19322
- isOpen
19323
- }) => {
19324
- const openOnArrowDown = event => {
19325
- if (!isOpen && event.keyCode === external_wp_keycodes_namespaceObject.DOWN) {
19326
- event.preventDefault();
19327
- onToggle();
19328
- }
19329
- };
19330
 
19331
- return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarGroup, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, {
19332
- className: "components-toolbar__control block-library-colors-selector__toggle",
19333
- label: (0,external_wp_i18n_namespaceObject.__)('Open Colors Selector'),
19334
- onClick: onToggle,
19335
- onKeyDown: openOnArrowDown,
19336
- icon: (0,external_wp_element_namespaceObject.createElement)(BackgroundColor, null, (0,external_wp_element_namespaceObject.createElement)(TextColor, null, (0,external_wp_element_namespaceObject.createElement)(ColorSelectorIcon, null)))
19337
- }));
19338
- };
19339
 
19340
- const BlockColorsStyleSelector = ({
19341
- children,
19342
- ...other
19343
- }) => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Dropdown, {
19344
- position: "bottom right",
19345
- className: "block-library-colors-selector",
19346
- contentClassName: "block-library-colors-selector__popover",
19347
- renderToggle: renderToggleComponent(other),
19348
- renderContent: () => children
 
 
 
 
 
19349
  });
 
 
 
 
 
 
 
 
 
 
 
 
19350
 
19351
- /* harmony default export */ var color_style_selector = (BlockColorsStyleSelector);
19352
- //# sourceMappingURL=index.js.map
19353
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-edit/edit.js
 
 
 
 
 
 
 
 
 
19354
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19355
 
 
 
 
 
 
 
 
 
19356
 
19357
- /**
19358
- * External dependencies
19359
- */
19360
 
 
 
 
 
 
19361
 
19362
- /**
19363
- * WordPress dependencies
19364
- */
 
 
19365
 
 
 
 
 
19366
 
 
 
19367
 
 
 
 
19368
 
19369
- /**
19370
- * Internal dependencies
19371
- */
 
 
 
 
 
 
 
 
 
19372
 
19373
 
19374
  /**
19375
- * Default value used for blocks which do not define their own context needs,
19376
- * used to guarantee that a block's `context` prop will always be an object. It
19377
- * is assigned as a constant since it is always expected to be an empty object,
19378
- * and in order to avoid unnecessary React reconciliations of a changing object.
19379
- *
19380
- * @type {{}}
19381
  */
19382
 
19383
- const DEFAULT_BLOCK_CONTEXT = {};
19384
- const Edit = props => {
19385
- const {
19386
- attributes = {},
19387
- name
19388
- } = props;
19389
- const blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(name);
19390
- const blockContext = (0,external_wp_element_namespaceObject.useContext)(block_context); // Assign context values using the block type's declared context needs.
19391
-
19392
- const context = (0,external_wp_element_namespaceObject.useMemo)(() => {
19393
- return blockType && blockType.usesContext ? (0,external_lodash_namespaceObject.pick)(blockContext, blockType.usesContext) : DEFAULT_BLOCK_CONTEXT;
19394
- }, [blockType, blockContext]);
19395
-
19396
- if (!blockType) {
19397
- return null;
19398
- } // `edit` and `save` are functions or components describing the markup
19399
- // with which a block is displayed. If `blockType` is valid, assign
19400
- // them preferentially as the render value for the block.
19401
-
19402
-
19403
- const Component = blockType.edit || blockType.save;
19404
-
19405
- if (blockType.apiVersion > 1 || (0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockType, 'lightBlockWrapper', false)) {
19406
- return (0,external_wp_element_namespaceObject.createElement)(Component, _extends({}, props, {
19407
- context: context
19408
- }));
19409
- } // Generate a class name for the block's editable form
19410
-
19411
-
19412
- const generatedClassName = (0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockType, 'className', true) ? (0,external_wp_blocks_namespaceObject.getBlockDefaultClassName)(name) : null;
19413
- const className = classnames_default()(generatedClassName, attributes.className);
19414
- return (0,external_wp_element_namespaceObject.createElement)(Component, _extends({}, props, {
19415
- context: context,
19416
- className: className
19417
- }));
19418
- };
19419
- /* harmony default export */ var edit = ((0,external_wp_components_namespaceObject.withFilters)('editor.BlockEdit')(Edit));
19420
- //# sourceMappingURL=edit.js.map
19421
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-edit/index.js
19422
 
19423
 
19424
  /**
19425
  * WordPress dependencies
19426
  */
19427
 
19428
- /**
19429
- * Internal dependencies
19430
- */
19431
-
19432
 
19433
 
 
 
 
 
 
 
 
19434
 
19435
- function BlockEdit(props) {
19436
- const {
19437
- name,
19438
- isSelected,
19439
- clientId
19440
- } = props;
19441
- const context = {
19442
- name,
19443
- isSelected,
19444
- clientId
19445
- };
19446
- return (0,external_wp_element_namespaceObject.createElement)(Provider // It is important to return the same object if props haven't
19447
- // changed to avoid unnecessary rerenders.
19448
- // See https://reactjs.org/docs/context.html#caveats.
19449
- , {
19450
- value: (0,external_wp_element_namespaceObject.useMemo)(() => context, Object.values(context))
19451
- }, (0,external_wp_element_namespaceObject.createElement)(edit, props));
19452
  }
19453
- //# sourceMappingURL=index.js.map
19454
- ;// CONCATENATED MODULE: ./packages/icons/build-module/library/list-view.js
19455
-
19456
-
19457
- /**
19458
- * WordPress dependencies
19459
- */
19460
 
19461
- const listView = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
19462
- viewBox: "0 0 24 24",
19463
- xmlns: "http://www.w3.org/2000/svg"
19464
- }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
19465
- d: "M13.8 5.2H3v1.5h10.8V5.2zm-3.6 12v1.5H21v-1.5H10.2zm7.2-6H6.6v1.5h10.8v-1.5z"
19466
- }));
19467
- /* harmony default export */ var list_view = (listView);
19468
- //# sourceMappingURL=list-view.js.map
19469
- ;// CONCATENATED MODULE: ./packages/icons/build-module/library/more-vertical.js
19470
 
19471
 
19472
  /**
19473
  * WordPress dependencies
19474
  */
19475
 
19476
- const moreVertical = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
19477
  xmlns: "http://www.w3.org/2000/svg",
19478
  viewBox: "0 0 24 24"
19479
  }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
19480
- d: "M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z"
19481
  }));
19482
- /* harmony default export */ var more_vertical = (moreVertical);
19483
- //# sourceMappingURL=more-vertical.js.map
19484
- // EXTERNAL MODULE: ./node_modules/react-spring/web.cjs.js
19485
- var web_cjs = __webpack_require__(8088);
19486
- ;// CONCATENATED MODULE: external ["wp","dom"]
19487
- var external_wp_dom_namespaceObject = window["wp"]["dom"];
19488
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/use-moving-animation/index.js
19489
  /**
19490
  * External dependencies
19491
  */
@@ -19496,170 +19267,83 @@ var external_wp_dom_namespaceObject = window["wp"]["dom"];
19496
 
19497
 
19498
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19499
 
19500
  /**
19501
- * Simple reducer used to increment a counter.
19502
- *
19503
- * @param {number} state Previous counter value.
19504
- * @return {number} New state value.
19505
  */
19506
 
19507
- const counterReducer = state => state + 1;
19508
-
19509
- const getAbsolutePosition = element => {
19510
- return {
19511
- top: element.offsetTop,
19512
- left: element.offsetLeft
19513
- };
19514
- };
19515
  /**
19516
- * Hook used to compute the styles required to move a div into a new position.
19517
- *
19518
- * The way this animation works is the following:
19519
- * - It first renders the element as if there was no animation.
19520
- * - It takes a snapshot of the position of the block to use it
19521
- * as a destination point for the animation.
19522
- * - It restores the element to the previous position using a CSS transform
19523
- * - It uses the "resetAnimation" flag to reset the animation
19524
- * from the beginning in order to animate to the new destination point.
19525
- *
19526
- * @param {Object} $1 Options
19527
- * @param {boolean} $1.isSelected Whether it's the current block or not.
19528
- * @param {boolean} $1.adjustScrolling Adjust the scroll position to the current block.
19529
- * @param {boolean} $1.enableAnimation Enable/Disable animation.
19530
- * @param {*} $1.triggerAnimationOnChange Variable used to trigger the animation if it changes.
19531
  */
19532
 
19533
 
19534
- function useMovingAnimation({
19535
- isSelected,
19536
- adjustScrolling,
19537
- enableAnimation,
19538
- triggerAnimationOnChange
19539
- }) {
19540
- const ref = (0,external_wp_element_namespaceObject.useRef)();
19541
- const prefersReducedMotion = (0,external_wp_compose_namespaceObject.useReducedMotion)() || !enableAnimation;
19542
- const [triggeredAnimation, triggerAnimation] = (0,external_wp_element_namespaceObject.useReducer)(counterReducer, 0);
19543
- const [finishedAnimation, endAnimation] = (0,external_wp_element_namespaceObject.useReducer)(counterReducer, 0);
19544
- const [transform, setTransform] = (0,external_wp_element_namespaceObject.useState)({
19545
- x: 0,
19546
- y: 0
19547
- });
19548
- const previous = (0,external_wp_element_namespaceObject.useMemo)(() => ref.current ? getAbsolutePosition(ref.current) : null, [triggerAnimationOnChange]); // Calculate the previous position of the block relative to the viewport and
19549
- // return a function to maintain that position by scrolling.
19550
-
19551
- const preserveScrollPosition = (0,external_wp_element_namespaceObject.useMemo)(() => {
19552
- if (!adjustScrolling || !ref.current) {
19553
- return () => {};
19554
- }
19555
-
19556
- const scrollContainer = (0,external_wp_dom_namespaceObject.getScrollContainer)(ref.current);
19557
-
19558
- if (!scrollContainer) {
19559
- return () => {};
19560
- }
19561
-
19562
- const prevRect = ref.current.getBoundingClientRect();
19563
- return () => {
19564
- const blockRect = ref.current.getBoundingClientRect();
19565
- const diff = blockRect.top - prevRect.top;
19566
-
19567
- if (diff) {
19568
- scrollContainer.scrollTop += diff;
19569
- }
19570
- };
19571
- }, [triggerAnimationOnChange, adjustScrolling]);
19572
- (0,external_wp_element_namespaceObject.useLayoutEffect)(() => {
19573
- if (triggeredAnimation) {
19574
- endAnimation();
19575
- }
19576
- }, [triggeredAnimation]);
19577
- (0,external_wp_element_namespaceObject.useLayoutEffect)(() => {
19578
- if (!previous) {
19579
- return;
19580
- }
19581
-
19582
- if (prefersReducedMotion) {
19583
- // if the animation is disabled and the scroll needs to be adjusted,
19584
- // just move directly to the final scroll position.
19585
- preserveScrollPosition();
19586
- return;
19587
- }
19588
 
19589
- ref.current.style.transform = '';
19590
- const destination = getAbsolutePosition(ref.current);
19591
- triggerAnimation();
19592
- setTransform({
19593
- x: Math.round(previous.left - destination.left),
19594
- y: Math.round(previous.top - destination.top)
 
 
 
 
19595
  });
19596
- }, [triggerAnimationOnChange]); // Only called when either the x or y value changes.
19597
-
19598
- function onFrameChange({
19599
- x,
19600
- y
19601
- }) {
19602
- if (!ref.current) {
19603
- return;
19604
- }
19605
-
19606
- const isMoving = x === 0 && y === 0;
19607
- ref.current.style.transformOrigin = isMoving ? '' : 'center';
19608
- ref.current.style.transform = isMoving ? '' : `translate3d(${x}px,${y}px,0)`;
19609
- ref.current.style.zIndex = !isSelected || isMoving ? '' : '1';
19610
- preserveScrollPosition();
19611
- } // Called for every frame computed by useSpring.
19612
-
19613
-
19614
- function onFrame({
19615
- x,
19616
- y
19617
- }) {
19618
- x = Math.round(x);
19619
- y = Math.round(y);
19620
-
19621
- if (x !== onFrame.x || y !== onFrame.y) {
19622
- onFrameChange({
19623
- x,
19624
- y
19625
- });
19626
- onFrame.x = x;
19627
- onFrame.y = y;
19628
- }
19629
  }
19630
 
19631
- onFrame.x = 0;
19632
- onFrame.y = 0;
19633
- (0,web_cjs/* useSpring */.q_)({
19634
- from: {
19635
- x: transform.x,
19636
- y: transform.y
19637
- },
19638
- to: {
19639
- x: 0,
19640
- y: 0
19641
- },
19642
- reset: triggeredAnimation !== finishedAnimation,
19643
- config: {
19644
- mass: 5,
19645
- tension: 2000,
19646
- friction: 200
19647
- },
19648
- immediate: prefersReducedMotion,
19649
- onFrame
19650
- });
19651
- return ref;
19652
  }
19653
 
19654
- /* harmony default export */ var use_moving_animation = (useMovingAnimation);
19655
  //# sourceMappingURL=index.js.map
19656
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/list-view/leaf.js
19657
-
19658
-
19659
 
19660
- /**
19661
- * External dependencies
19662
- */
19663
 
19664
 
19665
  /**
@@ -19667,609 +19351,524 @@ function useMovingAnimation({
19667
  */
19668
 
19669
 
 
19670
  /**
19671
  * Internal dependencies
19672
  */
19673
 
19674
 
19675
- const AnimatedTreeGridRow = (0,web_cjs/* animated */.q)(external_wp_components_namespaceObject.__experimentalTreeGridRow);
19676
- function ListViewLeaf({
19677
- isSelected,
19678
- position,
19679
- level,
19680
- rowCount,
19681
- children,
19682
- className,
19683
- path,
19684
- ...props
19685
- }) {
19686
- const ref = use_moving_animation({
19687
- isSelected,
19688
- adjustScrolling: false,
19689
- enableAnimation: true,
19690
- triggerAnimationOnChange: path.join('_')
19691
- });
19692
- return (0,external_wp_element_namespaceObject.createElement)(AnimatedTreeGridRow, _extends({
19693
- ref: ref,
19694
- className: classnames_default()('block-editor-list-view-leaf', className),
19695
- level: level,
19696
- positionInSet: position,
19697
- setSize: rowCount
19698
- }, props), children);
19699
- }
19700
- //# sourceMappingURL=leaf.js.map
19701
- ;// CONCATENATED MODULE: ./packages/icons/build-module/library/chevron-right.js
19702
-
19703
 
19704
- /**
19705
- * WordPress dependencies
19706
- */
 
 
 
 
 
 
 
 
19707
 
19708
- const chevronRight = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
19709
- xmlns: "http://www.w3.org/2000/svg",
19710
- viewBox: "0 0 24 24"
19711
- }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
19712
- d: "M10.6 6L9.4 7l4.6 5-4.6 5 1.2 1 5.4-6z"
19713
- }));
19714
- /* harmony default export */ var chevron_right = (chevronRight);
19715
- //# sourceMappingURL=chevron-right.js.map
19716
- ;// CONCATENATED MODULE: ./packages/icons/build-module/library/chevron-left.js
19717
 
 
 
 
19718
 
 
 
 
 
 
 
 
 
 
 
19719
  /**
19720
- * WordPress dependencies
19721
  */
19722
 
19723
- const chevronLeft = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
19724
- xmlns: "http://www.w3.org/2000/svg",
19725
- viewBox: "0 0 24 24"
19726
- }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
19727
- d: "M14.6 7l-1.2-1L8 12l5.4 6 1.2-1-4.6-5z"
19728
- }));
19729
- /* harmony default export */ var chevron_left = (chevronLeft);
19730
- //# sourceMappingURL=chevron-left.js.map
19731
- ;// CONCATENATED MODULE: ./packages/icons/build-module/library/chevron-up.js
19732
-
19733
-
19734
  /**
19735
  * WordPress dependencies
19736
  */
19737
 
19738
- const chevronUp = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
19739
- viewBox: "0 0 24 24",
19740
- xmlns: "http://www.w3.org/2000/svg"
19741
- }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
19742
- d: "M6.5 12.4L12 8l5.5 4.4-.9 1.2L12 10l-4.5 3.6-1-1.2z"
19743
- }));
19744
- /* harmony default export */ var chevron_up = (chevronUp);
19745
- //# sourceMappingURL=chevron-up.js.map
19746
- ;// CONCATENATED MODULE: ./packages/icons/build-module/library/chevron-down.js
19747
 
19748
 
19749
  /**
19750
- * WordPress dependencies
19751
  */
19752
 
19753
- const chevronDown = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
19754
- viewBox: "0 0 24 24",
19755
- xmlns: "http://www.w3.org/2000/svg"
19756
- }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
19757
- d: "M17.5 11.6L12 16l-5.5-4.4.9-1.2L12 14l4.5-3.6 1 1.2z"
19758
- }));
19759
- /* harmony default export */ var chevron_down = (chevronDown);
19760
- //# sourceMappingURL=chevron-down.js.map
19761
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-mover/mover-description.js
19762
  /**
19763
- * WordPress dependencies
 
 
 
 
 
 
19764
  */
19765
 
19766
  /**
19767
- * Return a label for the block movement controls depending on block position.
 
 
 
19768
  *
19769
- * @param {number} selectedCount Number of blocks selected.
19770
- * @param {string} type Block type - in the case of a single block, should
19771
- * define its 'type'. I.e. 'Text', 'Heading', 'Image' etc.
19772
- * @param {number} firstIndex The index (position - 1) of the first block selected.
19773
- * @param {boolean} isFirst This is the first block.
19774
- * @param {boolean} isLast This is the last block.
19775
- * @param {number} dir Direction of movement (> 0 is considered to be going
19776
- * down, < 0 is up).
19777
- * @param {string} orientation The orientation of the block movers, vertical or
19778
- * horizontal.
19779
  *
19780
- * @return {string} Label for the block movement controls.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19781
  */
19782
 
19783
- function getBlockMoverDescription(selectedCount, type, firstIndex, isFirst, isLast, dir, orientation) {
19784
- const position = firstIndex + 1;
19785
-
19786
- const getMovementDirection = moveDirection => {
19787
- if (moveDirection === 'up') {
19788
- if (orientation === 'horizontal') {
19789
- return (0,external_wp_i18n_namespaceObject.isRTL)() ? 'right' : 'left';
19790
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19791
 
19792
- return 'up';
19793
- } else if (moveDirection === 'down') {
19794
- if (orientation === 'horizontal') {
19795
- return (0,external_wp_i18n_namespaceObject.isRTL)() ? 'left' : 'right';
19796
- }
 
19797
 
19798
- return 'down';
19799
- }
19800
 
19801
- return null;
19802
- };
19803
 
19804
- if (selectedCount > 1) {
19805
- return getMultiBlockMoverDescription(selectedCount, firstIndex, isFirst, isLast, dir);
19806
- }
19807
 
19808
- if (isFirst && isLast) {
19809
- return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: %s: Type of block (i.e. Text, Image etc)
19810
- (0,external_wp_i18n_namespaceObject.__)('Block %s is the only block, and cannot be moved'), type);
19811
- }
19812
 
19813
- if (dir > 0 && !isLast) {
19814
- // moving down
19815
- const movementDirection = getMovementDirection('down');
19816
 
19817
- if (movementDirection === 'down') {
19818
- return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: 1: Type of block (i.e. Text, Image etc), 2: Position of selected block, 3: New position
19819
- (0,external_wp_i18n_namespaceObject.__)('Move %1$s block from position %2$d down to position %3$d'), type, position, position + 1);
19820
- }
19821
 
19822
- if (movementDirection === 'left') {
19823
- return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: 1: Type of block (i.e. Text, Image etc), 2: Position of selected block, 3: New position
19824
- (0,external_wp_i18n_namespaceObject.__)('Move %1$s block from position %2$d left to position %3$d'), type, position, position + 1);
19825
- }
 
19826
 
19827
- if (movementDirection === 'right') {
19828
- return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: 1: Type of block (i.e. Text, Image etc), 2: Position of selected block, 3: New position
19829
- (0,external_wp_i18n_namespaceObject.__)('Move %1$s block from position %2$d right to position %3$d'), type, position, position + 1);
19830
  }
19831
- }
 
 
 
19832
 
19833
- if (dir > 0 && isLast) {
19834
- // moving down, and is the last item
19835
- const movementDirection = getMovementDirection('down');
19836
 
19837
- if (movementDirection === 'down') {
19838
- return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: 1: Type of block (i.e. Text, Image etc)
19839
- (0,external_wp_i18n_namespaceObject.__)('Block %1$s is at the end of the content and can’t be moved down'), type);
19840
- }
 
 
19841
 
19842
- if (movementDirection === 'left') {
19843
- return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: 1: Type of block (i.e. Text, Image etc)
19844
- (0,external_wp_i18n_namespaceObject.__)('Block %1$s is at the end of the content and can’t be moved left'), type);
19845
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19846
 
19847
- if (movementDirection === 'right') {
19848
- return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: 1: Type of block (i.e. Text, Image etc)
19849
- (0,external_wp_i18n_namespaceObject.__)('Block %1$s is at the end of the content and can’t be moved right'), type);
19850
  }
19851
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19852
 
19853
- if (dir < 0 && !isFirst) {
19854
- // moving up
19855
- const movementDirection = getMovementDirection('up');
 
 
 
 
19856
 
19857
- if (movementDirection === 'up') {
19858
- return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: 1: Type of block (i.e. Text, Image etc), 2: Position of selected block, 3: New position
19859
- (0,external_wp_i18n_namespaceObject.__)('Move %1$s block from position %2$d up to position %3$d'), type, position, position - 1);
19860
- }
19861
 
19862
- if (movementDirection === 'left') {
19863
- return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: 1: Type of block (i.e. Text, Image etc), 2: Position of selected block, 3: New position
19864
- (0,external_wp_i18n_namespaceObject.__)('Move %1$s block from position %2$d left to position %3$d'), type, position, position - 1);
19865
- }
19866
 
19867
- if (movementDirection === 'right') {
19868
- return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: 1: Type of block (i.e. Text, Image etc), 2: Position of selected block, 3: New position
19869
- (0,external_wp_i18n_namespaceObject.__)('Move %1$s block from position %2$d right to position %3$d'), type, position, position - 1);
19870
- }
19871
- }
19872
 
19873
- if (dir < 0 && isFirst) {
19874
- // moving up, and is the first item
19875
- const movementDirection = getMovementDirection('up');
19876
 
19877
- if (movementDirection === 'up') {
19878
- return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: 1: Type of block (i.e. Text, Image etc)
19879
- (0,external_wp_i18n_namespaceObject.__)('Block %1$s is at the beginning of the content and can’t be moved up'), type);
19880
- }
19881
-
19882
- if (movementDirection === 'left') {
19883
- return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: 1: Type of block (i.e. Text, Image etc)
19884
- (0,external_wp_i18n_namespaceObject.__)('Block %1$s is at the beginning of the content and can’t be moved left'), type);
19885
- }
19886
 
19887
- if (movementDirection === 'right') {
19888
- return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: 1: Type of block (i.e. Text, Image etc)
19889
- (0,external_wp_i18n_namespaceObject.__)('Block %1$s is at the beginning of the content and can’t be moved right'), type);
19890
- }
19891
- }
19892
  }
 
 
 
 
19893
  /**
19894
- * Return a label for the block movement controls depending on block position.
19895
- *
19896
- * @param {number} selectedCount Number of blocks selected.
19897
- * @param {number} firstIndex The index (position - 1) of the first block selected.
19898
- * @param {boolean} isFirst This is the first block.
19899
- * @param {boolean} isLast This is the last block.
19900
- * @param {number} dir Direction of movement (> 0 is considered to be going
19901
- * down, < 0 is up).
19902
- *
19903
- * @return {string} Label for the block movement controls.
19904
  */
19905
 
19906
- function getMultiBlockMoverDescription(selectedCount, firstIndex, isFirst, isLast, dir) {
19907
- const position = firstIndex + 1;
19908
 
19909
- if (dir < 0 && isFirst) {
19910
- return (0,external_wp_i18n_namespaceObject.__)('Blocks cannot be moved up as they are already at the top');
19911
- }
 
19912
 
19913
- if (dir > 0 && isLast) {
19914
- return (0,external_wp_i18n_namespaceObject.__)('Blocks cannot be moved down as they are already at the bottom');
19915
- }
19916
 
19917
- if (dir < 0 && !isFirst) {
19918
- return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: 1: Number of selected blocks, 2: Position of selected blocks
19919
- (0,external_wp_i18n_namespaceObject._n)('Move %1$d block from position %2$d up by one place', 'Move %1$d blocks from position %2$d up by one place', selectedCount), selectedCount, position);
19920
- }
19921
 
19922
- if (dir > 0 && !isLast) {
19923
- return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: 1: Number of selected blocks, 2: Position of selected blocks
19924
- (0,external_wp_i18n_namespaceObject._n)('Move %1$d block from position %2$d down by one place', 'Move %1$d blocks from position %2$d down by one place', selectedCount), selectedCount, position);
19925
- }
19926
- }
19927
- //# sourceMappingURL=mover-description.js.map
19928
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-mover/button.js
19929
 
 
19930
 
 
 
 
 
 
 
 
 
 
 
 
19931
 
19932
- /**
19933
- * External dependencies
19934
- */
 
 
 
 
19935
 
19936
 
19937
  /**
19938
  * WordPress dependencies
19939
  */
19940
 
19941
-
19942
-
19943
-
19944
-
19945
-
19946
-
19947
  /**
19948
  * Internal dependencies
19949
  */
19950
 
19951
 
 
 
 
 
 
 
 
 
 
 
 
 
19952
 
19953
 
19954
 
19955
- const getArrowIcon = (direction, orientation) => {
19956
- if (direction === 'up') {
19957
- if (orientation === 'horizontal') {
19958
- return (0,external_wp_i18n_namespaceObject.isRTL)() ? chevron_right : chevron_left;
19959
- }
19960
-
19961
- return chevron_up;
19962
- } else if (direction === 'down') {
19963
- if (orientation === 'horizontal') {
19964
- return (0,external_wp_i18n_namespaceObject.isRTL)() ? chevron_left : chevron_right;
19965
- }
19966
-
19967
- return chevron_down;
19968
- }
19969
-
19970
- return null;
19971
- };
19972
 
19973
- const getMovementDirectionLabel = (moveDirection, orientation) => {
19974
- if (moveDirection === 'up') {
19975
- if (orientation === 'horizontal') {
19976
- return (0,external_wp_i18n_namespaceObject.isRTL)() ? (0,external_wp_i18n_namespaceObject.__)('Move right') : (0,external_wp_i18n_namespaceObject.__)('Move left');
19977
- }
19978
 
19979
- return (0,external_wp_i18n_namespaceObject.__)('Move up');
19980
- } else if (moveDirection === 'down') {
19981
- if (orientation === 'horizontal') {
19982
- return (0,external_wp_i18n_namespaceObject.isRTL)() ? (0,external_wp_i18n_namespaceObject.__)('Move left') : (0,external_wp_i18n_namespaceObject.__)('Move right');
19983
- }
19984
 
19985
- return (0,external_wp_i18n_namespaceObject.__)('Move down');
19986
- }
19987
 
19988
- return null;
19989
- };
 
 
 
 
 
19990
 
19991
- const BlockMoverButton = (0,external_wp_element_namespaceObject.forwardRef)(({
19992
- clientIds,
19993
- direction,
19994
- orientation: moverOrientation,
19995
- ...props
19996
- }, ref) => {
19997
- const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(BlockMoverButton);
19998
- const blocksCount = (0,external_lodash_namespaceObject.castArray)(clientIds).length;
19999
  const {
20000
- blockType,
20001
- isDisabled,
20002
- rootClientId,
20003
- isFirst,
20004
- isLast,
20005
- firstIndex,
20006
- orientation = 'vertical'
20007
- } = (0,external_wp_data_namespaceObject.useSelect)(select => {
20008
- const {
20009
- getBlockIndex,
20010
- getBlockRootClientId,
20011
- getBlockOrder,
20012
- getBlock,
20013
- getBlockListSettings
20014
- } = select(store);
20015
- const normalizedClientIds = (0,external_lodash_namespaceObject.castArray)(clientIds);
20016
- const firstClientId = (0,external_lodash_namespaceObject.first)(normalizedClientIds);
20017
- const blockRootClientId = getBlockRootClientId(firstClientId);
20018
- const firstBlockIndex = getBlockIndex(firstClientId, blockRootClientId);
20019
- const lastBlockIndex = getBlockIndex((0,external_lodash_namespaceObject.last)(normalizedClientIds), blockRootClientId);
20020
- const blockOrder = getBlockOrder(blockRootClientId);
20021
- const block = getBlock(firstClientId);
20022
- const isFirstBlock = firstBlockIndex === 0;
20023
- const isLastBlock = lastBlockIndex === blockOrder.length - 1;
20024
- const {
20025
- orientation: blockListOrientation
20026
- } = getBlockListSettings(blockRootClientId) || {};
20027
- return {
20028
- blockType: block ? (0,external_wp_blocks_namespaceObject.getBlockType)(block.name) : null,
20029
- isDisabled: direction === 'up' ? isFirstBlock : isLastBlock,
20030
- rootClientId: blockRootClientId,
20031
- firstIndex: firstBlockIndex,
20032
- isFirst: isFirstBlock,
20033
- isLast: isLastBlock,
20034
- orientation: moverOrientation || blockListOrientation
20035
- };
20036
- }, [clientIds, direction]);
20037
  const {
20038
- moveBlocksDown,
20039
- moveBlocksUp
20040
  } = (0,external_wp_data_namespaceObject.useDispatch)(store);
20041
- const moverFunction = direction === 'up' ? moveBlocksUp : moveBlocksDown;
 
 
 
 
20042
 
20043
- const onClick = event => {
20044
- moverFunction(clientIds, rootClientId);
20045
 
20046
- if (props.onClick) {
20047
- props.onClick(event);
 
 
 
20048
  }
20049
- };
20050
 
20051
- const descriptionId = `block-editor-block-mover-button__description-${instanceId}`;
20052
- return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, _extends({
20053
- ref: ref,
20054
- className: classnames_default()('block-editor-block-mover-button', `is-${direction}-button`),
20055
- icon: getArrowIcon(direction, orientation),
20056
- label: getMovementDirectionLabel(direction, orientation),
20057
- "aria-describedby": descriptionId
20058
- }, props, {
20059
- onClick: isDisabled ? null : onClick,
20060
- "aria-disabled": isDisabled
20061
- })), (0,external_wp_element_namespaceObject.createElement)("span", {
20062
- id: descriptionId,
20063
- className: "block-editor-block-mover-button__description"
20064
- }, getBlockMoverDescription(blocksCount, blockType && blockType.title, firstIndex, isFirst, isLast, direction === 'up' ? -1 : 1, orientation)));
20065
- });
20066
- const BlockMoverUpButton = (0,external_wp_element_namespaceObject.forwardRef)((props, ref) => {
20067
- return (0,external_wp_element_namespaceObject.createElement)(BlockMoverButton, _extends({
20068
- direction: "up",
20069
- ref: ref
20070
- }, props));
20071
- });
20072
- const BlockMoverDownButton = (0,external_wp_element_namespaceObject.forwardRef)((props, ref) => {
20073
- return (0,external_wp_element_namespaceObject.createElement)(BlockMoverButton, _extends({
20074
- direction: "down",
20075
- ref: ref
20076
  }, props));
20077
- });
20078
- //# sourceMappingURL=button.js.map
20079
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/list-view/context.js
20080
  /**
20081
- * WordPress dependencies
20082
  */
20083
 
20084
- const ListViewContext = (0,external_wp_element_namespaceObject.createContext)({
20085
- __experimentalFeatures: false,
20086
- __experimentalPersistentListViewFeatures: false
20087
- });
20088
- const useListViewContext = () => (0,external_wp_element_namespaceObject.useContext)(ListViewContext);
20089
- //# sourceMappingURL=context.js.map
20090
- ;// CONCATENATED MODULE: ./packages/icons/build-module/library/more-horizontal.js
20091
-
20092
-
20093
  /**
20094
  * WordPress dependencies
20095
  */
20096
 
20097
- const moreHorizontal = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
20098
- xmlns: "http://www.w3.org/2000/svg",
20099
- viewBox: "0 0 24 24"
20100
- }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
20101
- d: "M11 13h2v-2h-2v2zm-6 0h2v-2H5v2zm12-2v2h2v-2h-2z"
20102
- }));
20103
- /* harmony default export */ var more_horizontal = (moreHorizontal);
20104
- //# sourceMappingURL=more-horizontal.js.map
20105
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/warning/index.js
20106
-
20107
 
20108
- /**
20109
- * External dependencies
20110
- */
20111
 
20112
  /**
20113
- * WordPress dependencies
20114
  */
20115
 
20116
 
20117
 
20118
 
20119
-
20120
-
20121
- function Warning({
20122
- className,
20123
- actions,
20124
- children,
20125
- secondaryActions
20126
- }) {
20127
- return (0,external_wp_element_namespaceObject.createElement)("div", {
20128
- className: classnames_default()(className, 'block-editor-warning')
20129
- }, (0,external_wp_element_namespaceObject.createElement)("div", {
20130
- className: "block-editor-warning__contents"
20131
- }, (0,external_wp_element_namespaceObject.createElement)("p", {
20132
- className: "block-editor-warning__message"
20133
- }, children), (external_wp_element_namespaceObject.Children.count(actions) > 0 || secondaryActions) && (0,external_wp_element_namespaceObject.createElement)("div", {
20134
- className: "block-editor-warning__actions"
20135
- }, external_wp_element_namespaceObject.Children.count(actions) > 0 && external_wp_element_namespaceObject.Children.map(actions, (action, i) => (0,external_wp_element_namespaceObject.createElement)("span", {
20136
- key: i,
20137
- className: "block-editor-warning__action"
20138
- }, action)), secondaryActions && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.DropdownMenu, {
20139
- className: "block-editor-warning__secondary",
20140
- icon: more_horizontal,
20141
- label: (0,external_wp_i18n_namespaceObject.__)('More options'),
20142
- popoverProps: {
20143
- position: 'bottom left',
20144
- className: 'block-editor-warning__dropdown'
20145
- },
20146
- noIcons: true
20147
- }, () => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, null, secondaryActions.map((item, pos) => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
20148
- onClick: item.onClick,
20149
- key: pos
20150
- }, item.title)))))));
20151
  }
20152
  /**
20153
- * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/warning/README.md
 
 
 
 
20154
  */
20155
 
20156
 
20157
- /* harmony default export */ var warning = (Warning);
20158
- //# sourceMappingURL=index.js.map
20159
- // EXTERNAL MODULE: ./node_modules/diff/lib/diff/character.js
20160
- var character = __webpack_require__(7630);
20161
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-compare/block-view.js
20162
-
20163
 
20164
- /**
20165
- * WordPress dependencies
20166
- */
20167
 
 
 
 
 
20168
 
 
 
20169
 
20170
- function BlockView({
20171
- title,
20172
- rawContent,
20173
- renderedContent,
20174
- action,
20175
- actionText,
20176
- className
20177
- }) {
20178
- return (0,external_wp_element_namespaceObject.createElement)("div", {
20179
- className: className
20180
- }, (0,external_wp_element_namespaceObject.createElement)("div", {
20181
- className: "block-editor-block-compare__content"
20182
- }, (0,external_wp_element_namespaceObject.createElement)("h2", {
20183
- className: "block-editor-block-compare__heading"
20184
- }, title), (0,external_wp_element_namespaceObject.createElement)("div", {
20185
- className: "block-editor-block-compare__html"
20186
- }, rawContent), (0,external_wp_element_namespaceObject.createElement)("div", {
20187
- className: "block-editor-block-compare__preview edit-post-visual-editor"
20188
- }, (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.RawHTML, null, (0,external_wp_dom_namespaceObject.safeHTML)(renderedContent)))), (0,external_wp_element_namespaceObject.createElement)("div", {
20189
- className: "block-editor-block-compare__action"
20190
- }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
20191
- variant: "secondary",
20192
- tabIndex: "0",
20193
- onClick: action
20194
- }, actionText)));
20195
  }
20196
- //# sourceMappingURL=block-view.js.map
20197
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-compare/index.js
20198
 
 
 
 
 
 
 
 
 
20199
 
20200
- /**
20201
- * External dependencies
20202
- */
 
 
 
20203
 
20204
- // diff doesn't tree-shake correctly, so we import from the individual
20205
- // module here, to avoid including too much of the library
 
 
 
 
 
20206
 
 
 
 
 
20207
 
20208
- /**
20209
- * WordPress dependencies
20210
- */
20211
 
 
 
 
 
 
 
20212
 
 
 
 
 
20213
 
20214
- /**
20215
- * Internal dependencies
20216
- */
20217
 
 
 
 
20218
 
 
 
 
 
20219
 
20220
- function BlockCompare({
20221
- block,
20222
- onKeep,
20223
- onConvert,
20224
- convertor,
20225
- convertButtonText
20226
- }) {
20227
- function getDifference(originalContent, newContent) {
20228
- const difference = (0,character/* diffChars */.Kx)(originalContent, newContent);
20229
- return difference.map((item, pos) => {
20230
- const classes = classnames_default()({
20231
- 'block-editor-block-compare__added': item.added,
20232
- 'block-editor-block-compare__removed': item.removed
20233
- });
20234
- return (0,external_wp_element_namespaceObject.createElement)("span", {
20235
- key: pos,
20236
- className: classes
20237
- }, item.value);
20238
- });
20239
- }
20240
 
20241
- function getConvertedContent(convertedBlock) {
20242
- // The convertor may return an array of items or a single item
20243
- const newBlocks = (0,external_lodash_namespaceObject.castArray)(convertedBlock); // Get converted block details
 
 
20244
 
20245
- const newContent = newBlocks.map(item => (0,external_wp_blocks_namespaceObject.getSaveContent)(item.name, item.attributes, item.innerBlocks));
20246
- return newContent.join('');
20247
- }
 
20248
 
20249
- const converted = getConvertedContent(convertor(block));
20250
- const difference = getDifference(block.originalContent, converted);
20251
- return (0,external_wp_element_namespaceObject.createElement)("div", {
20252
- className: "block-editor-block-compare__wrapper"
20253
- }, (0,external_wp_element_namespaceObject.createElement)(BlockView, {
20254
- title: (0,external_wp_i18n_namespaceObject.__)('Current'),
20255
- className: "block-editor-block-compare__current",
20256
- action: onKeep,
20257
- actionText: (0,external_wp_i18n_namespaceObject.__)('Convert to HTML'),
20258
- rawContent: block.originalContent,
20259
- renderedContent: block.originalContent
20260
- }), (0,external_wp_element_namespaceObject.createElement)(BlockView, {
20261
- title: (0,external_wp_i18n_namespaceObject.__)('After Conversion'),
20262
- className: "block-editor-block-compare__converted",
20263
- action: onConvert,
20264
- actionText: convertButtonText,
20265
- rawContent: difference,
20266
- renderedContent: converted
20267
- }));
20268
  }
20269
-
20270
- /* harmony default export */ var block_compare = (BlockCompare);
20271
- //# sourceMappingURL=index.js.map
20272
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-list/block-invalid-warning.js
20273
 
20274
 
20275
  /**
@@ -20280,282 +19879,182 @@ function BlockCompare({
20280
 
20281
 
20282
 
20283
-
20284
  /**
20285
  * Internal dependencies
20286
  */
20287
 
20288
 
20289
 
20290
-
20291
- function BlockInvalidWarning({
20292
- convertToHTML,
20293
- convertToBlocks,
20294
- convertToClassic,
20295
- attemptBlockRecovery,
20296
- block
20297
- }) {
20298
- const hasHTMLBlock = !!(0,external_wp_blocks_namespaceObject.getBlockType)('core/html');
20299
- const [compare, setCompare] = (0,external_wp_element_namespaceObject.useState)(false);
20300
- const onCompare = (0,external_wp_element_namespaceObject.useCallback)(() => setCompare(true), []);
20301
- const onCompareClose = (0,external_wp_element_namespaceObject.useCallback)(() => setCompare(false), []); // We memo the array here to prevent the children components from being updated unexpectedly
20302
-
20303
- const hiddenActions = (0,external_wp_element_namespaceObject.useMemo)(() => [{
20304
- // translators: Button to fix block content
20305
- title: (0,external_wp_i18n_namespaceObject._x)('Resolve', 'imperative verb'),
20306
- onClick: onCompare
20307
- }, hasHTMLBlock && {
20308
- title: (0,external_wp_i18n_namespaceObject.__)('Convert to HTML'),
20309
- onClick: convertToHTML
20310
- }, {
20311
- title: (0,external_wp_i18n_namespaceObject.__)('Convert to Classic Block'),
20312
- onClick: convertToClassic
20313
- }].filter(Boolean), [onCompare, convertToHTML, convertToClassic]);
20314
- return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(warning, {
20315
- actions: [(0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
20316
- key: "recover",
20317
- onClick: attemptBlockRecovery,
20318
- variant: "primary"
20319
- }, (0,external_wp_i18n_namespaceObject.__)('Attempt Block Recovery'))],
20320
- secondaryActions: hiddenActions
20321
- }, (0,external_wp_i18n_namespaceObject.__)('This block contains unexpected or invalid content.')), compare && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Modal, {
20322
- title: // translators: Dialog title to fix block content
20323
- (0,external_wp_i18n_namespaceObject.__)('Resolve Block'),
20324
- onRequestClose: onCompareClose,
20325
- className: "block-editor-block-compare"
20326
- }, (0,external_wp_element_namespaceObject.createElement)(block_compare, {
20327
- block: block,
20328
- onKeep: convertToHTML,
20329
- onConvert: convertToBlocks,
20330
- convertor: blockToBlocks,
20331
- convertButtonText: (0,external_wp_i18n_namespaceObject.__)('Convert to Blocks')
20332
- })));
20333
  }
20334
 
20335
- const blockToClassic = block => (0,external_wp_blocks_namespaceObject.createBlock)('core/freeform', {
20336
- content: block.originalContent
20337
- });
20338
-
20339
- const blockToHTML = block => (0,external_wp_blocks_namespaceObject.createBlock)('core/html', {
20340
- content: block.originalContent
20341
- });
20342
-
20343
- const blockToBlocks = block => (0,external_wp_blocks_namespaceObject.rawHandler)({
20344
- HTML: block.originalContent
20345
- });
20346
-
20347
- const recoverBlock = ({
20348
- name,
20349
- attributes,
20350
- innerBlocks
20351
- }) => (0,external_wp_blocks_namespaceObject.createBlock)(name, attributes, innerBlocks);
20352
-
20353
- /* harmony default export */ var block_invalid_warning = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)((select, {
20354
- clientId
20355
- }) => ({
20356
- block: select(store).getBlock(clientId)
20357
- })), (0,external_wp_data_namespaceObject.withDispatch)((dispatch, {
20358
- block
20359
- }) => {
20360
  const {
20361
- replaceBlock
20362
- } = dispatch(store);
20363
- return {
20364
- convertToClassic() {
20365
- replaceBlock(block.clientId, blockToClassic(block));
20366
- },
20367
-
20368
- convertToHTML() {
20369
- replaceBlock(block.clientId, blockToHTML(block));
20370
- },
20371
-
20372
- convertToBlocks() {
20373
- replaceBlock(block.clientId, blockToBlocks(block));
20374
- },
20375
-
20376
- attemptBlockRecovery() {
20377
- replaceBlock(block.clientId, recoverBlock(block));
20378
- }
20379
-
20380
- };
20381
- })])(BlockInvalidWarning));
20382
- //# sourceMappingURL=block-invalid-warning.js.map
20383
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-list/block-crash-warning.js
20384
-
20385
-
20386
- /**
20387
- * WordPress dependencies
20388
- */
20389
-
20390
- /**
20391
- * Internal dependencies
20392
- */
20393
-
20394
-
20395
- const block_crash_warning_warning = (0,external_wp_element_namespaceObject.createElement)(warning, {
20396
- className: "block-editor-block-list__block-crash-warning"
20397
- }, (0,external_wp_i18n_namespaceObject.__)('This block has encountered an error and cannot be previewed.'));
20398
- /* harmony default export */ var block_crash_warning = (() => block_crash_warning_warning);
20399
- //# sourceMappingURL=block-crash-warning.js.map
20400
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-list/block-crash-boundary.js
20401
- /**
20402
- * WordPress dependencies
20403
- */
20404
-
20405
 
20406
- class BlockCrashBoundary extends external_wp_element_namespaceObject.Component {
20407
- constructor() {
20408
- super(...arguments);
20409
- this.state = {
20410
- hasError: false
20411
- };
20412
- }
20413
 
20414
- componentDidCatch() {
20415
- this.setState({
20416
- hasError: true
20417
- });
20418
- }
20419
 
20420
- render() {
20421
- if (this.state.hasError) {
20422
- return this.props.fallback;
 
 
 
 
 
 
 
 
 
 
 
20423
  }
20424
-
20425
- return this.props.children;
20426
  }
20427
 
20428
- }
20429
-
20430
- /* harmony default export */ var block_crash_boundary = (BlockCrashBoundary);
20431
- //# sourceMappingURL=block-crash-boundary.js.map
20432
- // EXTERNAL MODULE: ./node_modules/react-autosize-textarea/lib/index.js
20433
- var lib = __webpack_require__(4042);
20434
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-list/block-html.js
20435
-
20436
-
20437
- /**
20438
- * External dependencies
20439
- */
20440
-
20441
- /**
20442
- * WordPress dependencies
20443
- */
20444
 
 
 
 
 
 
 
 
 
 
 
20445
 
20446
 
 
 
 
20447
 
20448
- /**
20449
- * Internal dependencies
20450
- */
20451
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20452
 
20453
 
20454
- function BlockHTML({
20455
- clientId
20456
- }) {
20457
- const [html, setHtml] = (0,external_wp_element_namespaceObject.useState)('');
20458
- const block = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).getBlock(clientId), [clientId]);
20459
- const {
20460
- updateBlock
20461
- } = (0,external_wp_data_namespaceObject.useDispatch)(store);
20462
 
20463
- const onChange = () => {
20464
- const blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(block.name);
20465
- const attributes = (0,external_wp_blocks_namespaceObject.getBlockAttributes)(blockType, html, block.attributes); // If html is empty we reset the block to the default HTML and mark it as valid to avoid triggering an error
20466
 
20467
- const content = html ? html : (0,external_wp_blocks_namespaceObject.getSaveContent)(blockType, attributes);
20468
- const isValid = html ? (0,external_wp_blocks_namespaceObject.isValidBlockContent)(blockType, attributes, content) : true;
20469
- updateBlock(clientId, {
20470
- attributes,
20471
- originalContent: content,
20472
- isValid
20473
- }); // Ensure the state is updated if we reset so it displays the default content
20474
 
20475
- if (!html) {
20476
- setHtml({
20477
- content
20478
  });
20479
  }
20480
- };
20481
 
20482
- (0,external_wp_element_namespaceObject.useEffect)(() => {
20483
- setHtml((0,external_wp_blocks_namespaceObject.getBlockContent)(block));
20484
- }, [block]);
20485
- return (0,external_wp_element_namespaceObject.createElement)(lib/* default */.Z, {
20486
- className: "block-editor-block-list__block-html-textarea",
20487
- value: html,
20488
- onBlur: onChange,
20489
- onChange: event => setHtml(event.target.value)
20490
- });
20491
- }
20492
 
20493
- /* harmony default export */ var block_html = (BlockHTML);
20494
- //# sourceMappingURL=block-html.js.map
20495
- ;// CONCATENATED MODULE: external ["wp","warning"]
20496
- var external_wp_warning_namespaceObject = window["wp"]["warning"];
20497
- var external_wp_warning_default = /*#__PURE__*/__webpack_require__.n(external_wp_warning_namespaceObject);
20498
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/utils/dom.js
20499
- const BLOCK_SELECTOR = '.block-editor-block-list__block';
20500
- const APPENDER_SELECTOR = '.block-list-appender';
20501
- /**
20502
- * Returns true if two elements are contained within the same block.
20503
- *
20504
- * @param {Element} a First element.
20505
- * @param {Element} b Second element.
20506
- *
20507
- * @return {boolean} Whether elements are in the same block.
20508
- */
20509
 
20510
- function isInSameBlock(a, b) {
20511
- return a.closest(BLOCK_SELECTOR) === b.closest(BLOCK_SELECTOR);
20512
- }
20513
- /**
20514
- * Returns true if an element is considered part of the block and not its inner
20515
- * blocks or appender.
20516
- *
20517
- * @param {Element} blockElement Block container element.
20518
- * @param {Element} element Element.
20519
- *
20520
- * @return {boolean} Whether an element is considered part of the block and not
20521
- * its inner blocks or appender.
20522
- */
20523
 
20524
- function isInsideRootBlock(blockElement, element) {
20525
- const parentBlock = element.closest([BLOCK_SELECTOR, APPENDER_SELECTOR].join(','));
20526
- return parentBlock === blockElement;
20527
- }
20528
- /**
20529
- * Finds the block client ID given any DOM node inside the block.
20530
- *
20531
- * @param {Node?} node DOM node.
20532
- *
20533
- * @return {string|undefined} Client ID or undefined if the node is not part of
20534
- * a block.
20535
- */
20536
 
20537
- function getBlockClientId(node) {
20538
- while (node && node.nodeType !== node.ELEMENT_NODE) {
20539
- node = node.parentNode;
20540
- }
20541
 
20542
- if (!node) {
20543
- return;
20544
- }
20545
 
20546
- const elementNode =
20547
- /** @type {Element} */
20548
- node;
20549
- const blockNode = elementNode.closest(BLOCK_SELECTOR);
20550
 
20551
- if (!blockNode) {
20552
- return;
20553
- }
 
 
 
 
20554
 
20555
- return blockNode.id.slice('block-'.length);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20556
  }
20557
- //# sourceMappingURL=dom.js.map
20558
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-list/use-block-props/use-focus-first-element.js
20559
  /**
20560
  * External dependencies
20561
  */
@@ -20567,285 +20066,273 @@ function getBlockClientId(node) {
20567
 
20568
 
20569
 
 
20570
  /**
20571
  * Internal dependencies
20572
  */
20573
 
20574
 
20575
 
20576
- /** @typedef {import('@wordpress/element').RefObject} RefObject */
20577
-
20578
  /**
20579
- * Returns the initial position if the block needs to be focussed, `undefined`
20580
- * otherwise. The initial position is either 0 (start) or -1 (end).
20581
  *
20582
- * @param {string} clientId Block client ID.
 
 
20583
  *
20584
- * @return {number} The initial position, either 0 (start) or -1 (end).
20585
  */
20586
 
20587
- function useInitialPosition(clientId) {
20588
- return (0,external_wp_data_namespaceObject.useSelect)(select => {
20589
- const {
20590
- getSelectedBlocksInitialCaretPosition,
20591
- isMultiSelecting,
20592
- isNavigationMode,
20593
- isBlockSelected
20594
- } = select(store);
20595
-
20596
- if (!isBlockSelected(clientId)) {
20597
- return;
20598
- }
20599
 
20600
- if (isMultiSelecting() || isNavigationMode()) {
20601
- return;
20602
- } // If there's no initial position, return 0 to focus the start.
20603
 
20604
 
20605
- return getSelectedBlocksInitialCaretPosition();
20606
- }, [clientId]);
 
 
20607
  }
20608
  /**
20609
- * Transitions focus to the block or inner tabbable when the block becomes
20610
- * selected and an initial position is set.
 
20611
  *
20612
- * @param {string} clientId Block client ID.
 
 
 
 
 
20613
  *
20614
- * @return {RefObject} React ref with the block element.
20615
  */
20616
 
 
 
 
 
20617
 
20618
- function useFocusFirstElement(clientId) {
20619
- const ref = (0,external_wp_element_namespaceObject.useRef)();
20620
- const initialPosition = useInitialPosition(clientId);
20621
- (0,external_wp_element_namespaceObject.useEffect)(() => {
20622
- if (initialPosition === undefined || initialPosition === null) {
20623
- return;
20624
- }
20625
-
20626
- if (!ref.current) {
20627
- return;
20628
- }
20629
 
20630
- const {
20631
- ownerDocument
20632
- } = ref.current; // Do not focus the block if it already contains the active element.
20633
 
20634
- if (ref.current.contains(ownerDocument.activeElement)) {
20635
- return;
20636
- } // Find all tabbables within node.
20637
 
 
 
 
20638
 
20639
- const textInputs = external_wp_dom_namespaceObject.focus.tabbable.find(ref.current).filter(node => (0,external_wp_dom_namespaceObject.isTextField)(node)); // If reversed (e.g. merge via backspace), use the last in the set of
20640
- // tabbables.
 
 
 
20641
 
20642
- const isReverse = -1 === initialPosition;
20643
- const target = (isReverse ? external_lodash_namespaceObject.last : external_lodash_namespaceObject.first)(textInputs) || ref.current;
20644
 
20645
- if (!isInsideRootBlock(ref.current, target)) {
20646
- ref.current.focus();
20647
- return;
20648
  }
20649
 
20650
- (0,external_wp_dom_namespaceObject.placeCaretAtHorizontalEdge)(target, isReverse);
20651
- }, [initialPosition]);
20652
- return ref;
20653
- }
20654
- //# sourceMappingURL=use-focus-first-element.js.map
20655
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-list/use-block-props/use-is-hovered.js
20656
- /**
20657
- * WordPress dependencies
20658
- */
20659
-
20660
-
20661
- /**
20662
- * Internal dependencies
20663
- */
20664
-
20665
 
 
 
 
 
20666
 
20667
- function listener(event) {
20668
- if (event.defaultPrevented) {
20669
- return;
20670
  }
20671
 
20672
- const action = event.type === 'mouseover' ? 'add' : 'remove';
20673
- event.preventDefault();
20674
- event.currentTarget.classList[action]('is-hovered');
20675
  }
20676
- /**
20677
- * Adds `is-hovered` class when the block is hovered and in navigation or
20678
- * outline mode.
20679
- */
20680
-
20681
-
20682
- function useIsHovered() {
20683
- const isEnabled = (0,external_wp_data_namespaceObject.useSelect)(select => {
20684
- const {
20685
- isNavigationMode,
20686
- getSettings
20687
- } = select(store);
20688
- return isNavigationMode() || getSettings().outlineMode;
20689
- }, []);
 
 
20690
  return (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
20691
- if (isEnabled) {
20692
- node.addEventListener('mouseout', listener);
20693
- node.addEventListener('mouseover', listener);
20694
- return () => {
20695
- node.removeEventListener('mouseout', listener);
20696
- node.removeEventListener('mouseover', listener); // Remove class in case it lingers.
20697
 
20698
- node.classList.remove('is-hovered');
20699
- };
20700
  }
20701
- }, [isEnabled]);
20702
- }
20703
- //# sourceMappingURL=use-is-hovered.js.map
20704
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-list/use-block-props/use-block-class-names.js
20705
- /**
20706
- * External dependencies
20707
- */
20708
-
20709
- /**
20710
- * WordPress dependencies
20711
- */
20712
-
20713
 
 
 
 
 
 
 
 
20714
 
20715
- /**
20716
- * Internal dependencies
20717
- */
 
 
 
 
 
20718
 
 
 
 
 
20719
 
20720
- /**
20721
- * Returns the class names used for the different states of the block.
20722
- *
20723
- * @param {string} clientId The block client ID.
20724
- *
20725
- * @return {string} The class names.
20726
- */
 
 
 
 
 
 
 
 
20727
 
20728
- function useBlockClassNames(clientId) {
20729
- return (0,external_wp_data_namespaceObject.useSelect)(select => {
20730
- const {
20731
- isBlockBeingDragged,
20732
- isBlockHighlighted,
20733
- isBlockSelected,
20734
- isBlockMultiSelected,
20735
- getBlockName,
20736
- getSettings,
20737
- hasSelectedInnerBlock,
20738
- isTyping,
20739
- __experimentalGetActiveBlockIdByBlockNames: getActiveBlockIdByBlockNames
20740
- } = select(store);
20741
- const {
20742
- __experimentalSpotlightEntityBlocks: spotlightEntityBlocks,
20743
- outlineMode
20744
- } = getSettings();
20745
- const isDragging = isBlockBeingDragged(clientId);
20746
- const isSelected = isBlockSelected(clientId);
20747
- const name = getBlockName(clientId);
20748
- const checkDeep = true; // "ancestor" is the more appropriate label due to "deep" check
20749
 
20750
- const isAncestorOfSelectedBlock = hasSelectedInnerBlock(clientId, checkDeep);
20751
- const activeEntityBlockId = getActiveBlockIdByBlockNames(spotlightEntityBlocks);
20752
- return classnames_default()({
20753
- 'is-selected': isSelected,
20754
- 'is-highlighted': isBlockHighlighted(clientId),
20755
- 'is-multi-selected': isBlockMultiSelected(clientId),
20756
- 'is-reusable': (0,external_wp_blocks_namespaceObject.isReusableBlock)((0,external_wp_blocks_namespaceObject.getBlockType)(name)),
20757
- 'is-dragging': isDragging,
20758
- 'has-child-selected': isAncestorOfSelectedBlock,
20759
- 'has-active-entity': activeEntityBlockId,
20760
- // Determine if there is an active entity area to spotlight.
20761
- 'is-active-entity': activeEntityBlockId === clientId,
20762
- 'remove-outline': isSelected && outlineMode && isTyping()
20763
- });
20764
- }, [clientId]);
20765
- }
20766
- //# sourceMappingURL=use-block-class-names.js.map
20767
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-list/use-block-props/use-block-default-class-name.js
20768
- /**
20769
- * WordPress dependencies
20770
- */
20771
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20772
 
20773
- /**
20774
- * Internal dependencies
20775
- */
 
 
 
20776
 
 
 
 
 
 
 
 
 
20777
 
20778
- /**
20779
- * Returns the default class name if the block is a light block and it supports
20780
- * `className`.
20781
- *
20782
- * @param {string} clientId The block client ID.
20783
- *
20784
- * @return {string} The class name, e.g. `wp-block-paragraph`.
20785
- */
20786
 
20787
- function useBlockDefaultClassName(clientId) {
20788
- return (0,external_wp_data_namespaceObject.useSelect)(select => {
20789
- const name = select(store).getBlockName(clientId);
20790
- const blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(name);
20791
- const hasLightBlockWrapper = blockType.apiVersion > 1 || (0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockType, 'lightBlockWrapper', false);
 
20792
 
20793
- if (!hasLightBlockWrapper) {
20794
- return;
20795
- }
20796
 
20797
- return (0,external_wp_blocks_namespaceObject.getBlockDefaultClassName)(name);
20798
- }, [clientId]);
20799
- }
20800
- //# sourceMappingURL=use-block-default-class-name.js.map
20801
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-list/use-block-props/use-block-custom-class-name.js
20802
- /**
20803
- * WordPress dependencies
20804
- */
20805
 
 
 
 
 
20806
 
20807
- /**
20808
- * Internal dependencies
20809
- */
20810
 
 
 
 
 
20811
 
20812
- /**
20813
- * Returns the custom class name if the block is a light block.
20814
- *
20815
- * @param {string} clientId The block client ID.
20816
- *
20817
- * @return {string} The custom class name.
20818
- */
20819
 
20820
- function useBlockCustomClassName(clientId) {
20821
- // It's good for this to be a separate selector because it will be executed
20822
- // on every attribute change, while the other selectors are not re-evaluated
20823
- // as much.
20824
- return (0,external_wp_data_namespaceObject.useSelect)(select => {
20825
- const {
20826
- getBlockName,
20827
- getBlockAttributes
20828
- } = select(store);
20829
- const {
20830
- className
20831
- } = getBlockAttributes(clientId);
20832
 
20833
- if (!className) {
20834
- return;
20835
- }
 
20836
 
20837
- const blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(getBlockName(clientId));
20838
- const hasLightBlockWrapper = blockType.apiVersion > 1 || (0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockType, 'lightBlockWrapper', false);
 
 
 
 
 
 
 
20839
 
20840
- if (!hasLightBlockWrapper) {
20841
- return;
 
 
 
 
 
 
 
20842
  }
20843
 
20844
- return className;
20845
- }, [clientId]);
 
 
 
 
 
20846
  }
20847
- //# sourceMappingURL=use-block-custom-class-name.js.map
20848
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-list/use-block-props/use-block-moving-mode-class-names.js
 
 
20849
  /**
20850
  * External dependencies
20851
  */
@@ -20855,50 +20342,7 @@ function useBlockCustomClassName(clientId) {
20855
  */
20856
 
20857
 
20858
- /**
20859
- * Internal dependencies
20860
- */
20861
-
20862
-
20863
- /**
20864
- * Returns the class names used for block moving mode.
20865
- *
20866
- * @param {string} clientId The block client ID to insert above.
20867
- *
20868
- * @return {string} The class names.
20869
- */
20870
-
20871
- function useBlockMovingModeClassNames(clientId) {
20872
- return (0,external_wp_data_namespaceObject.useSelect)(select => {
20873
- const {
20874
- hasBlockMovingClientId,
20875
- canInsertBlockType,
20876
- getBlockName,
20877
- getBlockRootClientId,
20878
- isBlockSelected
20879
- } = select(store); // The classes are only relevant for the selected block. Avoid
20880
- // re-rendering all blocks!
20881
-
20882
- if (!isBlockSelected(clientId)) {
20883
- return;
20884
- }
20885
-
20886
- const movingClientId = hasBlockMovingClientId();
20887
-
20888
- if (!movingClientId) {
20889
- return;
20890
- }
20891
 
20892
- return classnames_default()('is-block-moving-mode', {
20893
- 'can-insert-moving-block': canInsertBlockType(getBlockName(movingClientId), getBlockRootClientId(clientId))
20894
- });
20895
- }, [clientId]);
20896
- }
20897
- //# sourceMappingURL=use-block-moving-mode-class-names.js.map
20898
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-list/use-block-props/use-focus-handler.js
20899
- /**
20900
- * WordPress dependencies
20901
- */
20902
 
20903
 
20904
  /**
@@ -20906,59 +20350,62 @@ function useBlockMovingModeClassNames(clientId) {
20906
  */
20907
 
20908
 
20909
-
20910
- /**
20911
- * Selects the block if it receives focus.
20912
- *
20913
- * @param {string} clientId Block client ID.
20914
- */
20915
-
20916
- function useFocusHandler(clientId) {
20917
  const {
20918
- isBlockSelected
 
 
20919
  } = (0,external_wp_data_namespaceObject.useSelect)(store);
20920
  const {
20921
- selectBlock,
20922
- selectionChange
20923
  } = (0,external_wp_data_namespaceObject.useDispatch)(store);
 
20924
  return (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
20925
- /**
20926
- * Marks the block as selected when focused and not already
20927
- * selected. This specifically handles the case where block does not
20928
- * set focus on its own (via `setFocus`), typically if there is no
20929
- * focusable input in the block.
20930
- *
20931
- * @param {FocusEvent} event Focus event.
20932
- */
20933
- function onFocus(event) {
20934
- // Check synchronously because a non-selected block might be
20935
- // getting data through `useSelect` asynchronously.
20936
- if (isBlockSelected(clientId)) {
20937
- // Potentially change selection away from rich text.
20938
- if (!event.target.isContentEditable) {
20939
- selectionChange(clientId);
20940
- }
20941
 
 
20942
  return;
20943
- } // If an inner block is focussed, that block is resposible for
20944
- // setting the selected block.
 
 
 
 
 
20945
 
 
 
 
20946
 
20947
- if (!isInsideRootBlock(node, event.target)) {
 
 
 
20948
  return;
20949
  }
20950
 
20951
- selectBlock(clientId);
 
20952
  }
20953
 
20954
- node.addEventListener('focusin', onFocus);
20955
  return () => {
20956
- node.removeEventListener('focusin', onFocus);
20957
  };
20958
- }, [isBlockSelected, selectBlock]);
20959
  }
20960
- //# sourceMappingURL=use-focus-handler.js.map
20961
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.js
 
 
 
 
 
 
 
20962
  /**
20963
  * WordPress dependencies
20964
  */
@@ -20966,1902 +20413,1683 @@ function useFocusHandler(clientId) {
20966
 
20967
 
20968
 
 
20969
  /**
20970
  * Internal dependencies
20971
  */
20972
 
20973
 
20974
- /**
20975
- * Adds block behaviour:
20976
- * - Removes the block on BACKSPACE.
20977
- * - Inserts a default block on ENTER.
20978
- * - Disables dragging of block contents.
20979
- *
20980
- * @param {string} clientId Block client ID.
20981
- */
20982
 
20983
- function useEventHandlers(clientId) {
20984
- const isSelected = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).isBlockSelected(clientId), [clientId]);
20985
- const {
20986
- getBlockRootClientId,
20987
- getBlockIndex
20988
- } = (0,external_wp_data_namespaceObject.useSelect)(store);
20989
- const {
20990
- insertDefaultBlock,
20991
- removeBlock
20992
- } = (0,external_wp_data_namespaceObject.useDispatch)(store);
20993
- return (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
20994
- if (!isSelected) {
20995
  return;
20996
  }
20997
- /**
20998
- * Interprets keydown event intent to remove or insert after block if
20999
- * key event occurs on wrapper node. This can occur when the block has
21000
- * no text fields of its own, particularly after initial insertion, to
21001
- * allow for easy deletion and continuous writing flow to add additional
21002
- * content.
21003
- *
21004
- * @param {KeyboardEvent} event Keydown event.
21005
- */
21006
 
 
 
 
 
 
 
21007
 
21008
- function onKeyDown(event) {
21009
- const {
21010
- keyCode,
21011
- target
21012
- } = event;
21013
-
21014
- if (keyCode !== external_wp_keycodes_namespaceObject.ENTER && keyCode !== external_wp_keycodes_namespaceObject.BACKSPACE && keyCode !== external_wp_keycodes_namespaceObject.DELETE) {
21015
- return;
21016
- }
 
 
 
 
 
 
 
 
21017
 
21018
- if (target !== node || (0,external_wp_dom_namespaceObject.isTextField)(target)) {
21019
- return;
21020
- }
21021
 
21022
- event.preventDefault();
 
 
21023
 
21024
- if (keyCode === external_wp_keycodes_namespaceObject.ENTER) {
21025
- insertDefaultBlock({}, getBlockRootClientId(clientId), getBlockIndex(clientId) + 1);
21026
- } else {
21027
- removeBlock(clientId);
21028
- }
21029
- }
21030
- /**
21031
- * Prevents default dragging behavior within a block. To do: we must
21032
- * handle this in the future and clean up the drag target.
21033
- *
21034
- * @param {DragEvent} event Drag event.
21035
- */
21036
 
21037
 
21038
- function onDragStart(event) {
21039
- event.preventDefault();
21040
- }
21041
 
21042
- node.addEventListener('keydown', onKeyDown);
21043
- node.addEventListener('dragstart', onDragStart);
21044
- return () => {
21045
- node.removeEventListener('keydown', onKeyDown);
21046
- node.removeEventListener('dragstart', onDragStart);
21047
- };
21048
- }, [clientId, isSelected, getBlockRootClientId, getBlockIndex, insertDefaultBlock, removeBlock]);
21049
- }
21050
- //# sourceMappingURL=use-selected-block-event-handlers.js.map
21051
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-list/use-block-props/use-nav-mode-exit.js
21052
  /**
21053
  * WordPress dependencies
21054
  */
21055
 
21056
 
 
 
 
21057
  /**
21058
  * Internal dependencies
21059
  */
21060
 
21061
 
21062
- /**
21063
- * Allows navigation mode to be exited by clicking in the selected block.
21064
- *
21065
- * @param {string} clientId Block client ID.
21066
- */
21067
-
21068
- function useNavModeExit(clientId) {
21069
- const {
21070
- isNavigationMode,
21071
- isBlockSelected
21072
- } = (0,external_wp_data_namespaceObject.useSelect)(store);
21073
- const {
21074
- setNavigationMode,
21075
- selectBlock
21076
- } = (0,external_wp_data_namespaceObject.useDispatch)(store);
21077
- return (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
21078
- function onMouseDown(event) {
21079
- // Don't select a block if it's already handled by a child
21080
- // block.
21081
- if (isNavigationMode() && !event.defaultPrevented) {
21082
- // Prevent focus from moving to the block.
21083
- event.preventDefault(); // When clicking on a selected block, exit navigation mode.
21084
-
21085
- if (isBlockSelected(clientId)) {
21086
- setNavigationMode(false);
21087
- } else {
21088
- selectBlock(clientId);
21089
- }
21090
- }
21091
- }
21092
-
21093
- node.addEventListener('mousedown', onMouseDown);
21094
- return () => {
21095
- node.addEventListener('mousedown', onMouseDown);
21096
- };
21097
- }, [clientId, isNavigationMode, isBlockSelected, setNavigationMode]);
21098
- }
21099
- //# sourceMappingURL=use-nav-mode-exit.js.map
21100
- // EXTERNAL MODULE: ./node_modules/dom-scroll-into-view/lib/index.js
21101
- var dom_scroll_into_view_lib = __webpack_require__(4979);
21102
- var lib_default = /*#__PURE__*/__webpack_require__.n(dom_scroll_into_view_lib);
21103
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-list/use-block-props/use-scroll-into-view.js
21104
- /**
21105
- * External dependencies
21106
- */
21107
-
21108
- /**
21109
- * WordPress dependencies
21110
- */
21111
-
21112
- /**
21113
- * WordPress dependencies
21114
- */
21115
-
21116
-
21117
-
21118
 
 
 
21119
  /**
21120
- * Internal dependencies
 
 
 
 
 
 
 
21121
  */
21122
 
21123
-
21124
- function useScrollIntoView(clientId) {
21125
- const ref = (0,external_wp_element_namespaceObject.useRef)();
21126
- const isSelectionEnd = (0,external_wp_data_namespaceObject.useSelect)(select => {
21127
- const {
21128
- isBlockSelected,
21129
- getBlockSelectionEnd
21130
- } = select(store);
21131
- return isBlockSelected(clientId) || getBlockSelectionEnd() === clientId;
21132
- }, [clientId]); // Note that we can't use `useRefEffect` here, since an element change does
21133
- // not mean we can scroll. `isSelectionEnd` should be the sole dependency,
21134
- // while with `useRefEffect`, the element is a dependency as well.
21135
-
21136
- (0,external_wp_element_namespaceObject.useEffect)(() => {
21137
- if (!isSelectionEnd) {
21138
  return;
21139
  }
21140
 
21141
- const extentNode = ref.current;
 
 
 
21142
 
21143
- if (!extentNode) {
21144
  return;
21145
- } // If the block is focused, the browser will already have scrolled into
21146
- // view if necessary.
21147
 
21148
 
21149
- if (extentNode.contains(extentNode.ownerDocument.activeElement)) {
21150
  return;
21151
- }
 
 
21152
 
21153
- const scrollContainer = (0,external_wp_dom_namespaceObject.getScrollContainer)(extentNode) || extentNode.ownerDocument.defaultView; // If there's no scroll container, it follows that there's no scrollbar
21154
- // and thus there's no need to try to scroll into view.
21155
 
21156
- if (!scrollContainer) {
21157
  return;
21158
  }
21159
 
21160
- lib_default()(extentNode, scrollContainer, {
21161
- onlyScrollIfNeeded: true
21162
- });
21163
- }, [isSelectionEnd]);
21164
- return ref;
21165
- }
21166
- //# sourceMappingURL=use-scroll-into-view.js.map
21167
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-list/use-block-props/use-multi-selection.js
21168
- /**
21169
- * WordPress dependencies
21170
- */
21171
-
21172
-
21173
- /**
21174
- * Internal dependencies
21175
- */
21176
-
21177
 
 
 
 
 
 
 
21178
 
 
 
21179
 
21180
- function toggleRichText(container, toggle) {
21181
- Array.from(container.closest('.is-root-container').querySelectorAll('.rich-text')).forEach(node => {
21182
- if (toggle) {
21183
- node.setAttribute('contenteditable', true);
21184
- } else {
21185
- node.removeAttribute('contenteditable');
21186
  }
21187
  });
21188
  }
21189
  /**
21190
- * Sets a multi-selection based on the native selection across blocks.
 
21191
  *
21192
- * @param {string} clientId Block client ID.
 
 
 
 
21193
  */
21194
 
21195
 
21196
- function useMultiSelection(clientId) {
21197
  const {
21198
- startMultiSelect,
21199
- stopMultiSelect,
21200
- multiSelect,
21201
- selectBlock
21202
- } = (0,external_wp_data_namespaceObject.useDispatch)(store);
21203
  const {
21204
- isSelectionEnabled,
21205
- isBlockSelected,
21206
- getBlockParents,
21207
- getBlockSelectionStart,
21208
- hasMultiSelection
21209
- } = (0,external_wp_data_namespaceObject.useSelect)(store);
21210
- return (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
21211
- const {
21212
- ownerDocument
21213
- } = node;
21214
- const {
21215
- defaultView
21216
- } = ownerDocument;
21217
- let anchorElement;
21218
- let rafId;
21219
 
21220
- function onSelectionChange({
21221
- isSelectionEnd
21222
- }) {
21223
- const selection = defaultView.getSelection(); // If no selection is found, end multi selection and enable all rich
21224
- // text areas.
21225
 
21226
- if (!selection.rangeCount || selection.isCollapsed) {
21227
- toggleRichText(node, true);
21228
- return;
21229
- }
21230
 
21231
- const endClientId = getBlockClientId(selection.focusNode);
21232
- const isSingularSelection = clientId === endClientId;
 
 
 
21233
 
21234
- if (isSingularSelection) {
21235
- selectBlock(clientId); // If the selection is complete (on mouse up), and no
21236
- // multiple blocks have been selected, set focus back to the
21237
- // anchor element. if the anchor element contains the
21238
- // selection. Additionally, rich text elements that were
21239
- // previously disabled can now be enabled again.
21240
 
21241
- if (isSelectionEnd) {
21242
- toggleRichText(node, true);
 
 
21243
 
21244
- if (selection.rangeCount) {
21245
- const {
21246
- commonAncestorContainer
21247
- } = selection.getRangeAt(0);
21248
 
21249
- if (anchorElement.contains(commonAncestorContainer)) {
21250
- anchorElement.focus();
21251
- }
21252
- }
21253
- }
21254
- } else {
21255
- const startPath = [...getBlockParents(clientId), clientId];
21256
- const endPath = [...getBlockParents(endClientId), endClientId];
21257
- const depth = Math.min(startPath.length, endPath.length) - 1;
21258
- multiSelect(startPath[depth], endPath[depth]);
21259
- }
21260
- }
21261
 
21262
- function onSelectionEnd() {
21263
- ownerDocument.removeEventListener('selectionchange', onSelectionChange); // Equivalent to attaching the listener once.
 
 
 
 
 
21264
 
21265
- defaultView.removeEventListener('mouseup', onSelectionEnd); // The browser selection won't have updated yet at this point,
21266
- // so wait until the next animation frame to get the browser
21267
- // selection.
 
 
 
 
21268
 
21269
- rafId = defaultView.requestAnimationFrame(() => {
21270
- onSelectionChange({
21271
- isSelectionEnd: true
21272
- });
21273
- stopMultiSelect();
21274
- });
 
 
21275
  }
21276
 
21277
- function onMouseLeave({
21278
- buttons
21279
- }) {
21280
- // The primary button must be pressed to initiate selection.
21281
- // See https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
21282
- if (buttons !== 1) {
21283
- return;
21284
- }
21285
 
21286
- if (!isSelectionEnabled() || !isBlockSelected(clientId)) {
21287
- return;
21288
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21289
 
21290
- anchorElement = ownerDocument.activeElement;
21291
- startMultiSelect(); // `onSelectionStart` is called after `mousedown` and
21292
- // `mouseleave` (from a block). The selection ends when
21293
- // `mouseup` happens anywhere in the window.
21294
 
21295
- ownerDocument.addEventListener('selectionchange', onSelectionChange);
21296
- defaultView.addEventListener('mouseup', onSelectionEnd); // Removing the contenteditable attributes within the block
21297
- // editor is essential for selection to work across editable
21298
- // areas. The edible hosts are removed, allowing selection to be
21299
- // extended outside the DOM element. `startMultiSelect` sets a
21300
- // flag in the store so the rich text components are updated,
21301
- // but the rerender may happen very slowly, especially in Safari
21302
- // for the blocks that are asynchonously rendered. To ensure the
21303
- // browser instantly removes the selection boundaries, we remove
21304
- // the contenteditable attributes manually.
21305
 
21306
- toggleRichText(node, false);
 
 
 
 
21307
  }
21308
 
21309
- function onMouseDown(event) {
21310
- // The main button.
21311
- // https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button
21312
- if (!isSelectionEnabled() || event.button !== 0) {
21313
- return;
21314
- }
21315
 
21316
- if (event.shiftKey) {
21317
- const blockSelectionStart = getBlockSelectionStart();
21318
 
21319
- if (blockSelectionStart !== clientId) {
21320
- toggleRichText(node, false);
21321
- multiSelect(blockSelectionStart, clientId);
21322
- event.preventDefault();
21323
- }
21324
- } else if (hasMultiSelection()) {
21325
- // Allow user to escape out of a multi-selection to a
21326
- // singular selection of a block via click. This is handled
21327
- // here since focus handling excludes blocks when there is
21328
- // multiselection, as focus can be incurred by starting a
21329
- // multiselection (focus moved to first block's multi-
21330
- // controls).
21331
- selectBlock(clientId);
21332
- }
 
21333
  }
 
 
 
 
 
 
 
 
 
 
21334
 
21335
- node.addEventListener('mousedown', onMouseDown);
21336
- node.addEventListener('mouseleave', onMouseLeave);
21337
- return () => {
21338
- node.removeEventListener('mousedown', onMouseDown);
21339
- node.removeEventListener('mouseleave', onMouseLeave);
21340
- ownerDocument.removeEventListener('selectionchange', onSelectionChange);
21341
- defaultView.removeEventListener('mouseup', onSelectionEnd);
21342
- defaultView.cancelAnimationFrame(rafId);
21343
- };
21344
- }, [clientId, startMultiSelect, stopMultiSelect, multiSelect, selectBlock, isSelectionEnabled, isBlockSelected, getBlockParents]);
21345
- }
21346
- //# sourceMappingURL=use-multi-selection.js.map
21347
- ;// CONCATENATED MODULE: external ["wp","htmlEntities"]
21348
- var external_wp_htmlEntities_namespaceObject = window["wp"]["htmlEntities"];
21349
- ;// CONCATENATED MODULE: ./packages/icons/build-module/library/plus.js
21350
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21351
 
21352
- /**
21353
- * WordPress dependencies
21354
- */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21355
 
21356
- const plus = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
21357
- xmlns: "http://www.w3.org/2000/svg",
21358
- viewBox: "0 0 24 24"
21359
- }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
21360
- d: "M18 11.2h-5.2V6h-1.6v5.2H6v1.6h5.2V18h1.6v-5.2H18z"
21361
- }));
21362
- /* harmony default export */ var library_plus = (plus);
21363
- //# sourceMappingURL=plus.js.map
21364
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/inserter/tips.js
21365
 
 
 
21366
 
21367
- /**
21368
- * WordPress dependencies
21369
- */
21370
 
 
21371
 
 
 
 
 
 
21372
 
21373
- const globalTips = [(0,external_wp_element_namespaceObject.createInterpolateElement)((0,external_wp_i18n_namespaceObject.__)('While writing, you can press <kbd>/</kbd> to quickly insert new blocks.'), {
21374
- kbd: (0,external_wp_element_namespaceObject.createElement)("kbd", null)
21375
- }), (0,external_wp_element_namespaceObject.createInterpolateElement)((0,external_wp_i18n_namespaceObject.__)('Indent a list by pressing <kbd>space</kbd> at the beginning of a line.'), {
21376
- kbd: (0,external_wp_element_namespaceObject.createElement)("kbd", null)
21377
- }), (0,external_wp_element_namespaceObject.createInterpolateElement)((0,external_wp_i18n_namespaceObject.__)('Outdent a list by pressing <kbd>backspace</kbd> at the beginning of a line.'), {
21378
- kbd: (0,external_wp_element_namespaceObject.createElement)("kbd", null)
21379
- }), (0,external_wp_i18n_namespaceObject.__)('Drag files into the editor to automatically insert media blocks.'), (0,external_wp_i18n_namespaceObject.__)("Change a block's type by pressing the block icon on the toolbar.")];
21380
 
21381
- function Tips() {
21382
- const [randomIndex] = (0,external_wp_element_namespaceObject.useState)( // Disable Reason: I'm not generating an HTML id.
21383
- // eslint-disable-next-line no-restricted-syntax
21384
- Math.floor(Math.random() * globalTips.length));
21385
- return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Tip, null, globalTips[randomIndex]);
21386
- }
 
 
 
 
 
 
 
 
21387
 
21388
- /* harmony default export */ var tips = (Tips);
21389
- //# sourceMappingURL=tips.js.map
21390
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-card/index.js
21391
 
 
 
 
 
 
 
 
 
 
 
 
21392
 
21393
- /**
21394
- * WordPress dependencies
21395
- */
21396
 
21397
- /**
21398
- * Internal dependencies
21399
- */
 
21400
 
 
21401
 
 
 
 
 
 
 
 
21402
 
21403
- function BlockCard({
21404
- title,
21405
- icon,
21406
- description,
21407
- blockType
21408
- }) {
21409
- if (blockType) {
21410
- external_wp_deprecated_default()('`blockType` property in `BlockCard component`', {
21411
- since: '5.7',
21412
- alternative: '`title, icon and description` properties'
21413
- });
21414
- ({
21415
- title,
21416
- icon,
21417
- description
21418
- } = blockType);
21419
  }
 
 
 
21420
 
21421
- return (0,external_wp_element_namespaceObject.createElement)("div", {
21422
- className: "block-editor-block-card"
21423
- }, (0,external_wp_element_namespaceObject.createElement)(BlockIcon, {
21424
- icon: icon,
21425
- showColors: true
21426
- }), (0,external_wp_element_namespaceObject.createElement)("div", {
21427
- className: "block-editor-block-card__content"
21428
- }, (0,external_wp_element_namespaceObject.createElement)("h2", {
21429
- className: "block-editor-block-card__title"
21430
- }, title), (0,external_wp_element_namespaceObject.createElement)("span", {
21431
- className: "block-editor-block-card__description"
21432
- }, description)));
21433
- }
21434
 
21435
- /* harmony default export */ var block_card = (BlockCard);
21436
- //# sourceMappingURL=index.js.map
21437
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/provider/with-registry-provider.js
 
 
 
 
 
 
 
 
 
 
 
21438
 
21439
 
 
 
 
 
 
 
21440
 
21441
- /**
21442
- * WordPress dependencies
21443
- */
21444
 
 
 
 
 
 
 
21445
 
21446
 
21447
- /**
21448
- * Internal dependencies
21449
- */
 
 
21450
 
 
 
 
 
 
 
21451
 
 
 
 
 
 
21452
 
21453
- const withRegistryProvider = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(WrappedComponent => {
21454
- return (0,external_wp_data_namespaceObject.withRegistry)(({
21455
- useSubRegistry = true,
21456
- registry,
21457
- ...props
21458
- }) => {
21459
- if (!useSubRegistry) {
21460
- return (0,external_wp_element_namespaceObject.createElement)(WrappedComponent, _extends({
21461
- registry: registry
21462
- }, props));
21463
- }
21464
 
21465
- const [subRegistry, setSubRegistry] = (0,external_wp_element_namespaceObject.useState)(null);
21466
- (0,external_wp_element_namespaceObject.useEffect)(() => {
21467
- const newRegistry = (0,external_wp_data_namespaceObject.createRegistry)({}, registry);
21468
- newRegistry.registerStore(STORE_NAME, storeConfig);
21469
- setSubRegistry(newRegistry);
21470
- }, [registry]);
21471
 
21472
- if (!subRegistry) {
21473
- return null;
21474
  }
21475
 
21476
- return (0,external_wp_element_namespaceObject.createElement)(external_wp_data_namespaceObject.RegistryProvider, {
21477
- value: subRegistry
21478
- }, (0,external_wp_element_namespaceObject.createElement)(WrappedComponent, _extends({
21479
- registry: subRegistry
21480
- }, props)));
21481
- });
21482
- }, 'withRegistryProvider');
21483
- /* harmony default export */ var with_registry_provider = (withRegistryProvider);
21484
- //# sourceMappingURL=with-registry-provider.js.map
21485
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/provider/use-block-sync.js
21486
- /**
21487
- * External dependencies
21488
- */
21489
-
21490
- /**
21491
- * WordPress dependencies
21492
- */
21493
 
21494
 
 
 
 
 
 
 
21495
 
21496
 
21497
- /**
21498
- * Internal dependencies
21499
- */
21500
 
 
 
 
 
 
21501
 
21502
- /**
21503
- * A function to call when the block value has been updated in the block-editor
21504
- * store.
21505
- *
21506
- * @callback onBlockUpdate
21507
- * @param {Object[]} blocks The updated blocks.
21508
- * @param {Object} options The updated block options, such as selectionStart
21509
- * and selectionEnd.
21510
- */
21511
 
21512
- /**
21513
- * useBlockSync is a side effect which handles bidirectional sync between the
21514
- * block-editor store and a controlling data source which provides blocks. This
21515
- * is most commonly used by the BlockEditorProvider to synchronize the contents
21516
- * of the block-editor store with the root entity, like a post.
21517
- *
21518
- * Another example would be the template part block, which provides blocks from
21519
- * a separate entity data source than a root entity. This hook syncs edits to
21520
- * the template part in the block editor back to the entity and vice-versa.
21521
- *
21522
- * Here are some of its basic functions:
21523
- * - Initalizes the block-editor store for the given clientID to the blocks
21524
- * given via props.
21525
- * - Adds incoming changes (like undo) to the block-editor store.
21526
- * - Adds outgoing changes (like editing content) to the controlling entity,
21527
- * determining if a change should be considered persistent or not.
21528
- * - Handles edge cases and race conditions which occur in those operations.
21529
- * - Ignores changes which happen to other entities (like nested inner block
21530
- * controllers.
21531
- * - Passes selection state from the block-editor store to the controlling entity.
21532
- *
21533
- * @param {Object} props Props for the block sync hook
21534
- * @param {string} props.clientId The client ID of the inner block controller.
21535
- * If none is passed, then it is assumed to be a
21536
- * root controller rather than an inner block
21537
- * controller.
21538
- * @param {Object[]} props.value The control value for the blocks. This value
21539
- * is used to initalize the block-editor store
21540
- * and for resetting the blocks to incoming
21541
- * changes like undo.
21542
- * @param {Object} props.selection The selection state responsible to restore the selection on undo/redo.
21543
- * @param {onBlockUpdate} props.onChange Function to call when a persistent
21544
- * change has been made in the block-editor blocks
21545
- * for the given clientId. For example, after
21546
- * this function is called, an entity is marked
21547
- * dirty because it has changes to save.
21548
- * @param {onBlockUpdate} props.onInput Function to call when a non-persistent
21549
- * change has been made in the block-editor blocks
21550
- * for the given clientId. When this is called,
21551
- * controlling sources do not become dirty.
21552
- */
21553
 
21554
- function useBlockSync({
21555
- clientId = null,
21556
- value: controlledBlocks,
21557
- selection: controlledSelection,
21558
- onChange = external_lodash_namespaceObject.noop,
21559
- onInput = external_lodash_namespaceObject.noop
21560
- }) {
21561
- const registry = (0,external_wp_data_namespaceObject.useRegistry)();
21562
- const {
21563
- resetBlocks,
21564
- resetSelection,
21565
- replaceInnerBlocks,
21566
- setHasControlledInnerBlocks,
21567
- __unstableMarkNextChangeAsNotPersistent
21568
- } = registry.dispatch(store);
21569
- const {
21570
- getBlockName,
21571
- getBlocks
21572
- } = registry.select(store);
21573
- const pendingChanges = (0,external_wp_element_namespaceObject.useRef)({
21574
- incoming: null,
21575
- outgoing: []
21576
- });
21577
- const subscribed = (0,external_wp_element_namespaceObject.useRef)(false);
21578
 
21579
- const setControlledBlocks = () => {
21580
- if (!controlledBlocks) {
21581
  return;
21582
- } // We don't need to persist this change because we only replace
21583
- // controlled inner blocks when the change was caused by an entity,
21584
- // and so it would already be persisted.
21585
 
 
21586
 
21587
- __unstableMarkNextChangeAsNotPersistent();
 
 
21588
 
21589
- if (clientId) {
21590
- setHasControlledInnerBlocks(clientId, true);
21591
 
21592
- __unstableMarkNextChangeAsNotPersistent();
 
 
21593
 
21594
- const storeBlocks = controlledBlocks.map(block => (0,external_wp_blocks_namespaceObject.cloneBlock)(block));
 
 
 
 
 
 
 
 
 
 
 
 
21595
 
21596
- if (subscribed.current) {
21597
- pendingChanges.current.incoming = storeBlocks;
21598
- }
21599
 
21600
- replaceInnerBlocks(clientId, storeBlocks);
21601
- } else {
21602
- if (subscribed.current) {
21603
- pendingChanges.current.incoming = controlledBlocks;
21604
- }
21605
 
21606
- resetBlocks(controlledBlocks);
21607
- }
21608
- }; // Add a subscription to the block-editor registry to detect when changes
21609
- // have been made. This lets us inform the data source of changes. This
21610
- // is an effect so that the subscriber can run synchronously without
21611
- // waiting for React renders for changes.
21612
 
21613
 
21614
- const onInputRef = (0,external_wp_element_namespaceObject.useRef)(onInput);
21615
- const onChangeRef = (0,external_wp_element_namespaceObject.useRef)(onChange);
21616
- (0,external_wp_element_namespaceObject.useEffect)(() => {
21617
- onInputRef.current = onInput;
21618
- onChangeRef.current = onChange;
21619
- }, [onInput, onChange]); // Determine if blocks need to be reset when they change.
 
 
 
21620
 
21621
- (0,external_wp_element_namespaceObject.useEffect)(() => {
21622
- if (pendingChanges.current.outgoing.includes(controlledBlocks)) {
21623
- // Skip block reset if the value matches expected outbound sync
21624
- // triggered by this component by a preceding change detection.
21625
- // Only skip if the value matches expectation, since a reset should
21626
- // still occur if the value is modified (not equal by reference),
21627
- // to allow that the consumer may apply modifications to reflect
21628
- // back on the editor.
21629
- if ((0,external_lodash_namespaceObject.last)(pendingChanges.current.outgoing) === controlledBlocks) {
21630
- pendingChanges.current.outgoing = [];
21631
- }
21632
- } else if (getBlocks(clientId) !== controlledBlocks) {
21633
- // Reset changing value in all other cases than the sync described
21634
- // above. Since this can be reached in an update following an out-
21635
- // bound sync, unset the outbound value to avoid considering it in
21636
- // subsequent renders.
21637
- pendingChanges.current.outgoing = [];
21638
- setControlledBlocks();
21639
 
21640
- if (controlledSelection) {
21641
- resetSelection(controlledSelection.selectionStart, controlledSelection.selectionEnd, controlledSelection.initialPosition);
21642
- }
21643
- }
21644
- }, [controlledBlocks, clientId]);
21645
- (0,external_wp_element_namespaceObject.useEffect)(() => {
21646
- const {
21647
- getSelectionStart,
21648
- getSelectionEnd,
21649
- getSelectedBlocksInitialCaretPosition,
21650
- isLastBlockChangePersistent,
21651
- __unstableIsLastBlockChangeIgnored
21652
- } = registry.select(store);
21653
- let blocks = getBlocks(clientId);
21654
- let isPersistent = isLastBlockChangePersistent();
21655
- let previousAreBlocksDifferent = false;
21656
- subscribed.current = true;
21657
- const unsubscribe = registry.subscribe(() => {
21658
- // Sometimes, when changing block lists, lingering subscriptions
21659
- // might trigger before they are cleaned up. If the block for which
21660
- // the subscription runs is no longer in the store, this would clear
21661
- // its parent entity's block list. To avoid this, we bail out if
21662
- // the subscription is triggering for a block (`clientId !== null`)
21663
- // and its block name can't be found because it's not on the list.
21664
- // (`getBlockName( clientId ) === null`).
21665
- if (clientId !== null && getBlockName(clientId) === null) return;
21666
- const newIsPersistent = isLastBlockChangePersistent();
21667
- const newBlocks = getBlocks(clientId);
21668
- const areBlocksDifferent = newBlocks !== blocks;
21669
- blocks = newBlocks;
21670
 
21671
- if (areBlocksDifferent && (pendingChanges.current.incoming || __unstableIsLastBlockChangeIgnored())) {
21672
- pendingChanges.current.incoming = null;
21673
- isPersistent = newIsPersistent;
21674
- return;
21675
- } // Since we often dispatch an action to mark the previous action as
21676
- // persistent, we need to make sure that the blocks changed on the
21677
- // previous action before committing the change.
21678
 
 
 
 
21679
 
21680
- const didPersistenceChange = previousAreBlocksDifferent && !areBlocksDifferent && newIsPersistent && !isPersistent;
21681
 
21682
- if (areBlocksDifferent || didPersistenceChange) {
21683
- isPersistent = newIsPersistent; // We know that onChange/onInput will update controlledBlocks.
21684
- // We need to be aware that it was caused by an outgoing change
21685
- // so that we do not treat it as an incoming change later on,
21686
- // which would cause a block reset.
21687
 
21688
- pendingChanges.current.outgoing.push(blocks); // Inform the controlling entity that changes have been made to
21689
- // the block-editor store they should be aware about.
21690
 
21691
- const updateParent = isPersistent ? onChangeRef.current : onInputRef.current;
21692
- updateParent(blocks, {
21693
- selection: {
21694
- selectionStart: getSelectionStart(),
21695
- selectionEnd: getSelectionEnd(),
21696
- initialPosition: getSelectedBlocksInitialCaretPosition()
21697
- }
21698
- });
21699
- }
21700
 
21701
- previousAreBlocksDifferent = areBlocksDifferent;
21702
- });
21703
- return () => unsubscribe();
21704
- }, [registry, clientId]);
21705
- }
21706
- //# sourceMappingURL=use-block-sync.js.map
21707
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/provider/index.js
21708
 
21709
 
21710
- /**
21711
- * WordPress dependencies
21712
- */
21713
 
 
 
 
21714
 
21715
- /**
21716
- * Internal dependencies
21717
- */
21718
 
 
21719
 
 
 
 
 
 
 
21720
 
 
 
 
21721
 
 
 
 
 
 
21722
 
21723
- /** @typedef {import('@wordpress/data').WPDataRegistry} WPDataRegistry */
21724
 
21725
- function BlockEditorProvider(props) {
21726
- const {
21727
- children,
21728
- settings
21729
- } = props;
21730
- const {
21731
- updateSettings
21732
- } = (0,external_wp_data_namespaceObject.useDispatch)(store);
21733
- (0,external_wp_element_namespaceObject.useEffect)(() => {
21734
- updateSettings(settings);
21735
- }, [settings]); // Syncs the entity provider with changes in the block-editor store.
21736
 
21737
- useBlockSync(props);
21738
- return (0,external_wp_element_namespaceObject.createElement)(BlockRefsProvider, null, children);
21739
- }
 
21740
 
21741
- /* harmony default export */ var provider = (with_registry_provider(BlockEditorProvider));
21742
- //# sourceMappingURL=index.js.map
21743
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-preview/live.js
21744
 
 
 
 
 
 
 
 
 
 
21745
 
21746
- /**
21747
- * WordPress dependencies
21748
- */
21749
 
21750
- /**
21751
- * Internal dependencies
21752
- */
21753
 
 
 
 
21754
 
21755
- function LiveBlockPreview({
21756
- onClick
21757
- }) {
21758
- return (0,external_wp_element_namespaceObject.createElement)("div", {
21759
- tabIndex: 0,
21760
- role: "button",
21761
- onClick: onClick,
21762
- onKeyPress: onClick
21763
- }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Disabled, null, (0,external_wp_element_namespaceObject.createElement)(BlockList, null)));
21764
- }
21765
- //# sourceMappingURL=live.js.map
21766
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-preview/auto.js
21767
 
 
21768
 
21769
- /**
21770
- * WordPress dependencies
21771
- */
21772
 
 
21773
 
21774
- /**
21775
- * Internal dependencies
21776
- */
21777
 
21778
- // This is used to avoid rendering the block list if the sizes change.
 
21779
 
21780
- let MemoizedBlockList;
 
 
 
21781
 
21782
- function AutoBlockPreview({
21783
- viewportWidth,
21784
- __experimentalPadding
21785
- }) {
21786
- const [containerResizeListener, {
21787
- width: containerWidth
21788
- }] = (0,external_wp_compose_namespaceObject.useResizeObserver)();
21789
- const [containtResizeListener, {
21790
- height: contentHeight
21791
- }] = (0,external_wp_compose_namespaceObject.useResizeObserver)(); // Initialize on render instead of module top level, to avoid circular dependency issues.
21792
-
21793
- MemoizedBlockList = MemoizedBlockList || (0,external_wp_compose_namespaceObject.pure)(BlockList);
21794
- const scale = (containerWidth - 2 * __experimentalPadding) / viewportWidth;
21795
- return (0,external_wp_element_namespaceObject.createElement)("div", {
21796
- className: "block-editor-block-preview__container editor-styles-wrapper",
21797
- "aria-hidden": true,
21798
- style: {
21799
- height: contentHeight * scale + 2 * __experimentalPadding
21800
  }
21801
- }, containerResizeListener, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Disabled, {
21802
- style: {
21803
- transform: `scale(${scale})`,
21804
- width: viewportWidth,
21805
- left: __experimentalPadding,
21806
- right: __experimentalPadding,
21807
- top: __experimentalPadding
21808
- },
21809
- className: "block-editor-block-preview__content"
21810
- }, containtResizeListener, (0,external_wp_element_namespaceObject.createElement)(MemoizedBlockList, null)));
21811
- }
21812
 
21813
- /* harmony default export */ var auto = (AutoBlockPreview);
21814
- //# sourceMappingURL=auto.js.map
21815
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-preview/index.js
 
 
 
 
 
 
 
21816
 
21817
 
21818
- /**
21819
- * External dependencies
21820
- */
21821
 
21822
- /**
21823
- * WordPress dependencies
21824
- */
 
 
21825
 
 
 
 
21826
 
 
21827
 
21828
- /**
21829
- * Internal dependencies
21830
- */
21831
 
 
 
 
 
 
 
 
 
 
21832
 
21833
 
 
 
 
21834
 
 
 
 
21835
 
21836
- function BlockPreview({
21837
- blocks,
21838
- __experimentalPadding = 0,
21839
- viewportWidth = 1200,
21840
- __experimentalLive = false,
21841
- __experimentalOnClick
21842
- }) {
21843
- const originalSettings = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).getSettings(), []);
21844
- const settings = (0,external_wp_element_namespaceObject.useMemo)(() => {
21845
- const _settings = { ...originalSettings
21846
- };
21847
- _settings.__experimentalBlockPatterns = [];
21848
- return _settings;
21849
- }, [originalSettings]);
21850
- const renderedBlocks = (0,external_wp_element_namespaceObject.useMemo)(() => (0,external_lodash_namespaceObject.castArray)(blocks), [blocks]);
21851
 
21852
- if (!blocks || blocks.length === 0) {
21853
- return null;
21854
- }
21855
 
21856
- return (0,external_wp_element_namespaceObject.createElement)(provider, {
21857
- value: renderedBlocks,
21858
- settings: settings
21859
- }, __experimentalLive ? (0,external_wp_element_namespaceObject.createElement)(LiveBlockPreview, {
21860
- onClick: __experimentalOnClick
21861
- }) : (0,external_wp_element_namespaceObject.createElement)(auto, {
21862
- viewportWidth: viewportWidth,
21863
- __experimentalPadding: __experimentalPadding
21864
- }));
21865
- }
21866
- /**
21867
- * BlockPreview renders a preview of a block or array of blocks.
21868
- *
21869
- * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-preview/README.md
21870
- *
21871
- * @param {Object} preview options for how the preview should be shown
21872
- * @param {Array|Object} preview.blocks A block instance (object) or an array of blocks to be previewed.
21873
- * @param {number} preview.viewportWidth Width of the preview container in pixels. Controls at what size the blocks will be rendered inside the preview. Default: 700.
21874
- *
21875
- * @return {WPComponent} The component to be rendered.
21876
- */
21877
 
21878
- /* harmony default export */ var block_preview = ((0,external_wp_element_namespaceObject.memo)(BlockPreview));
21879
- //# sourceMappingURL=index.js.map
21880
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/inserter/preview-panel.js
 
 
 
 
 
21881
 
21882
 
21883
- /**
21884
- * WordPress dependencies
21885
- */
21886
 
 
 
 
21887
 
21888
- /**
21889
- * Internal dependencies
21890
- */
21891
 
 
 
 
21892
 
 
21893
 
 
 
 
21894
 
21895
- function InserterPreviewPanel({
21896
- item
21897
- }) {
21898
- var _hoveredItemBlockType, _hoveredItemBlockType2;
 
 
 
 
 
21899
 
21900
- const {
21901
- name,
21902
- title,
21903
- icon,
21904
- description,
21905
- initialAttributes
21906
- } = item;
21907
- const hoveredItemBlockType = (0,external_wp_blocks_namespaceObject.getBlockType)(name);
21908
- const isReusable = (0,external_wp_blocks_namespaceObject.isReusableBlock)(item);
21909
- return (0,external_wp_element_namespaceObject.createElement)("div", {
21910
- className: "block-editor-inserter__preview-container"
21911
- }, (0,external_wp_element_namespaceObject.createElement)("div", {
21912
- className: "block-editor-inserter__preview"
21913
- }, isReusable || hoveredItemBlockType.example ? (0,external_wp_element_namespaceObject.createElement)("div", {
21914
- className: "block-editor-inserter__preview-content"
21915
- }, (0,external_wp_element_namespaceObject.createElement)(block_preview, {
21916
- __experimentalPadding: 16,
21917
- viewportWidth: (_hoveredItemBlockType = (_hoveredItemBlockType2 = hoveredItemBlockType.example) === null || _hoveredItemBlockType2 === void 0 ? void 0 : _hoveredItemBlockType2.viewportWidth) !== null && _hoveredItemBlockType !== void 0 ? _hoveredItemBlockType : 500,
21918
- blocks: hoveredItemBlockType.example ? (0,external_wp_blocks_namespaceObject.getBlockFromExample)(item.name, {
21919
- attributes: { ...hoveredItemBlockType.example.attributes,
21920
- ...initialAttributes
21921
- },
21922
- innerBlocks: hoveredItemBlockType.example.innerBlocks
21923
- }) : (0,external_wp_blocks_namespaceObject.createBlock)(name, initialAttributes)
21924
- })) : (0,external_wp_element_namespaceObject.createElement)("div", {
21925
- className: "block-editor-inserter__preview-content-missing"
21926
- }, (0,external_wp_i18n_namespaceObject.__)('No Preview Available.'))), !isReusable && (0,external_wp_element_namespaceObject.createElement)(block_card, {
21927
- title: title,
21928
- icon: icon,
21929
- description: description
21930
- }));
21931
- }
21932
 
21933
- /* harmony default export */ var preview_panel = (InserterPreviewPanel);
21934
- //# sourceMappingURL=preview-panel.js.map
21935
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/inserter-listbox/context.js
21936
- /**
21937
- * WordPress dependencies
21938
- */
21939
 
21940
- const InserterListboxContext = (0,external_wp_element_namespaceObject.createContext)();
21941
- /* harmony default export */ var inserter_listbox_context = (InserterListboxContext);
21942
- //# sourceMappingURL=context.js.map
21943
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/inserter-listbox/item.js
21944
 
 
 
 
 
 
 
 
 
 
21945
 
21946
 
21947
- /**
21948
- * WordPress dependencies
21949
- */
21950
 
 
 
 
21951
 
21952
- /**
21953
- * Internal dependencies
21954
- */
21955
 
 
 
 
21956
 
 
21957
 
21958
- function InserterListboxItem({
21959
- isFirst,
21960
- as: Component,
21961
- children,
21962
- ...props
21963
- }, ref) {
21964
- const state = (0,external_wp_element_namespaceObject.useContext)(inserter_listbox_context);
21965
- return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableCompositeItem, _extends({
21966
- ref: ref,
21967
- state: state,
21968
- role: "option" // Use the CompositeItem `focusable` prop over Button's
21969
- // isFocusable. The latter was shown to cause an issue
21970
- // with tab order in the inserter list.
21971
- ,
21972
- focusable: true
21973
- }, props), htmlProps => {
21974
- const propsWithTabIndex = { ...htmlProps,
21975
- tabIndex: isFirst ? 0 : htmlProps.tabIndex
21976
- };
21977
 
21978
- if (Component) {
21979
- return (0,external_wp_element_namespaceObject.createElement)(Component, propsWithTabIndex, children);
 
21980
  }
21981
 
21982
- if (typeof children === 'function') {
21983
- return children(propsWithTabIndex);
21984
  }
21985
 
21986
- return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, propsWithTabIndex, children);
21987
- });
21988
- }
 
 
 
 
 
 
21989
 
21990
- /* harmony default export */ var inserter_listbox_item = ((0,external_wp_element_namespaceObject.forwardRef)(InserterListboxItem));
21991
- //# sourceMappingURL=item.js.map
21992
- ;// CONCATENATED MODULE: ./packages/icons/build-module/library/drag-handle.js
21993
 
 
 
 
21994
 
21995
- /**
21996
- * WordPress dependencies
21997
- */
21998
 
21999
- const dragHandle = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
22000
- width: "18",
22001
- height: "18",
22002
- xmlns: "http://www.w3.org/2000/svg",
22003
- viewBox: "0 0 18 18"
22004
- }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
22005
- d: "M5 4h2V2H5v2zm6-2v2h2V2h-2zm-6 8h2V8H5v2zm6 0h2V8h-2v2zm-6 6h2v-2H5v2zm6 0h2v-2h-2v2z"
22006
- }));
22007
- /* harmony default export */ var drag_handle = (dragHandle);
22008
- //# sourceMappingURL=drag-handle.js.map
22009
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-draggable/draggable-chip.js
22010
 
 
 
 
22011
 
22012
- /**
22013
- * WordPress dependencies
22014
- */
22015
 
 
 
 
22016
 
 
 
 
 
 
 
 
 
 
 
22017
 
22018
- /**
22019
- * Internal dependencies
22020
- */
22021
 
 
 
 
22022
 
22023
- function BlockDraggableChip({
22024
- count,
22025
- icon
22026
- }) {
22027
- return (0,external_wp_element_namespaceObject.createElement)("div", {
22028
- className: "block-editor-block-draggable-chip-wrapper"
22029
- }, (0,external_wp_element_namespaceObject.createElement)("div", {
22030
- className: "block-editor-block-draggable-chip"
22031
- }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Flex, {
22032
- justify: "center",
22033
- className: "block-editor-block-draggable-chip__content"
22034
- }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, icon ? (0,external_wp_element_namespaceObject.createElement)(BlockIcon, {
22035
- icon: icon
22036
- }) : (0,external_wp_i18n_namespaceObject.sprintf)(
22037
- /* translators: %d: Number of blocks. */
22038
- (0,external_wp_i18n_namespaceObject._n)('%d block', '%d blocks', count), count)), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_element_namespaceObject.createElement)(BlockIcon, {
22039
- icon: drag_handle
22040
- })))));
22041
- }
22042
- //# sourceMappingURL=draggable-chip.js.map
22043
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/inserter-draggable-blocks/index.js
22044
 
 
 
 
22045
 
22046
- /**
22047
- * WordPress dependencies
22048
- */
22049
 
22050
- /**
22051
- * Internal dependencies
22052
- */
22053
 
 
 
 
 
22054
 
 
 
 
22055
 
22056
- const InserterDraggableBlocks = ({
22057
- isEnabled,
22058
- blocks,
22059
- icon,
22060
- children
22061
- }) => {
22062
- const transferData = {
22063
- type: 'inserter',
22064
- blocks
22065
- };
22066
- return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Draggable, {
22067
- __experimentalTransferDataType: "wp-blocks",
22068
- transferData: transferData,
22069
- __experimentalDragComponent: (0,external_wp_element_namespaceObject.createElement)(BlockDraggableChip, {
22070
- count: blocks.length,
22071
- icon: icon
22072
- })
22073
- }, ({
22074
- onDraggableStart,
22075
- onDraggableEnd
22076
- }) => {
22077
- return children({
22078
- draggable: isEnabled,
22079
- onDragStart: isEnabled ? onDraggableStart : undefined,
22080
- onDragEnd: isEnabled ? onDraggableEnd : undefined
22081
  });
22082
- });
22083
- };
 
 
22084
 
22085
- /* harmony default export */ var inserter_draggable_blocks = (InserterDraggableBlocks);
22086
- //# sourceMappingURL=index.js.map
22087
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/inserter-list-item/index.js
22088
 
 
 
 
 
22089
 
22090
 
22091
- /**
22092
- * External dependencies
22093
- */
 
22094
 
22095
- /**
22096
- * WordPress dependencies
22097
- */
22098
 
 
 
 
 
22099
 
22100
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22101
 
22102
- /**
22103
- * Internal dependencies
22104
- */
22105
 
 
 
 
22106
 
 
 
 
22107
 
 
 
 
 
 
 
 
22108
 
 
 
22109
  /**
22110
- * Return true if platform is MacOS.
22111
- *
22112
- * @param {Object} _window window object by default; used for DI testing.
22113
- *
22114
- * @return {boolean} True if MacOS; false otherwise.
22115
  */
22116
 
22117
- function isAppleOS(_window = window) {
22118
- const {
22119
- platform
22120
- } = _window.navigator;
22121
- return platform.indexOf('Mac') !== -1 || ['iPad', 'iPhone'].includes(platform);
22122
  }
 
 
 
22123
 
22124
- function InserterListItem({
22125
- className,
22126
- isFirst,
22127
- item,
22128
- onSelect,
22129
- onHover,
22130
- isDraggable,
22131
- ...props
22132
- }) {
22133
- const isDragging = (0,external_wp_element_namespaceObject.useRef)(false);
22134
- const itemIconStyle = item.icon ? {
22135
- backgroundColor: item.icon.background,
22136
- color: item.icon.foreground
22137
- } : {};
22138
- const blocks = (0,external_wp_element_namespaceObject.useMemo)(() => {
22139
- return [(0,external_wp_blocks_namespaceObject.createBlock)(item.name, item.initialAttributes, (0,external_wp_blocks_namespaceObject.createBlocksFromInnerBlocksTemplate)(item.innerBlocks))];
22140
- }, [item.name, item.initialAttributes, item.initialAttributes]);
22141
- return (0,external_wp_element_namespaceObject.createElement)(inserter_draggable_blocks, {
22142
- isEnabled: isDraggable && !item.disabled,
22143
- blocks: blocks,
22144
- icon: item.icon
22145
- }, ({
22146
- draggable,
22147
- onDragStart,
22148
- onDragEnd
22149
- }) => (0,external_wp_element_namespaceObject.createElement)("div", {
22150
- className: "block-editor-block-types-list__list-item",
22151
- draggable: draggable,
22152
- onDragStart: event => {
22153
- isDragging.current = true;
22154
 
22155
- if (onDragStart) {
22156
- onHover(null);
22157
- onDragStart(event);
22158
- }
22159
- },
22160
- onDragEnd: event => {
22161
- isDragging.current = false;
22162
 
22163
- if (onDragEnd) {
22164
- onDragEnd(event);
22165
- }
22166
- }
22167
- }, (0,external_wp_element_namespaceObject.createElement)(inserter_listbox_item, _extends({
22168
- isFirst: isFirst,
22169
- className: classnames_default()('block-editor-block-types-list__item', className),
22170
- disabled: item.isDisabled,
22171
- onClick: event => {
22172
- event.preventDefault();
22173
- onSelect(item, isAppleOS() ? event.metaKey : event.ctrlKey);
22174
- onHover(null);
22175
- },
22176
- onKeyDown: event => {
22177
- const {
22178
- keyCode
22179
- } = event;
22180
 
22181
- if (keyCode === external_wp_keycodes_namespaceObject.ENTER) {
22182
- event.preventDefault();
22183
- onSelect(item, isAppleOS() ? event.metaKey : event.ctrlKey);
22184
- onHover(null);
22185
- }
22186
- },
22187
- onFocus: () => {
22188
- if (isDragging.current) {
22189
- return;
22190
- }
22191
 
22192
- onHover(item);
22193
- },
22194
- onMouseEnter: () => {
22195
- if (isDragging.current) {
22196
- return;
22197
- }
 
 
22198
 
22199
- onHover(item);
22200
- },
22201
- onMouseLeave: () => onHover(null),
22202
- onBlur: () => onHover(null)
22203
- }, props), (0,external_wp_element_namespaceObject.createElement)("span", {
22204
- className: "block-editor-block-types-list__item-icon",
22205
- style: itemIconStyle
22206
- }, (0,external_wp_element_namespaceObject.createElement)(BlockIcon, {
22207
- icon: item.icon,
22208
- showColors: true
22209
- })), (0,external_wp_element_namespaceObject.createElement)("span", {
22210
- className: "block-editor-block-types-list__item-title"
22211
- }, item.title))));
22212
  }
 
 
 
 
 
 
 
 
22213
 
22214
- /* harmony default export */ var inserter_list_item = ((0,external_wp_element_namespaceObject.memo)(InserterListItem));
22215
- //# sourceMappingURL=index.js.map
22216
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/inserter-listbox/group.js
 
 
 
 
22217
 
 
 
 
 
 
 
22218
 
22219
 
 
 
 
22220
  /**
22221
- * WordPress dependencies
22222
  */
22223
 
22224
 
 
 
 
 
 
 
22225
 
22226
 
22227
- function InserterListboxGroup(props, ref) {
22228
- const [shouldSpeak, setShouldSpeak] = (0,external_wp_element_namespaceObject.useState)(false);
22229
- (0,external_wp_element_namespaceObject.useEffect)(() => {
22230
- if (shouldSpeak) {
22231
- (0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.__)('Use left and right arrow keys to move through blocks'));
22232
- }
22233
- }, [shouldSpeak]);
22234
- return (0,external_wp_element_namespaceObject.createElement)("div", _extends({
22235
- ref: ref,
22236
- role: "listbox",
22237
- "aria-orientation": "horizontal",
22238
- onFocus: () => {
22239
- setShouldSpeak(true);
22240
- },
22241
- onBlur: event => {
22242
- const focusingOutsideGroup = !event.currentTarget.contains(event.relatedTarget);
22243
-
22244
- if (focusingOutsideGroup) {
22245
- setShouldSpeak(false);
22246
- }
22247
- }
22248
- }, props));
22249
- }
22250
 
22251
- /* harmony default export */ var group = ((0,external_wp_element_namespaceObject.forwardRef)(InserterListboxGroup));
22252
- //# sourceMappingURL=group.js.map
22253
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/inserter-listbox/row.js
22254
 
 
 
 
 
22255
 
 
 
 
 
 
 
22256
 
22257
  /**
22258
- * WordPress dependencies
22259
  */
22260
 
22261
-
22262
  /**
22263
  * Internal dependencies
22264
  */
22265
 
22266
 
 
 
 
22267
 
22268
- function InserterListboxRow(props, ref) {
22269
- const state = (0,external_wp_element_namespaceObject.useContext)(inserter_listbox_context);
22270
- return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableCompositeGroup, _extends({
22271
- state: state,
22272
- role: "presentation",
22273
- ref: ref
22274
- }, props));
22275
- }
22276
 
22277
- /* harmony default export */ var inserter_listbox_row = ((0,external_wp_element_namespaceObject.forwardRef)(InserterListboxRow));
22278
- //# sourceMappingURL=row.js.map
22279
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-types-list/index.js
 
 
 
22280
 
22281
 
 
22282
  /**
22283
- * WordPress dependencies
22284
  */
22285
 
 
 
 
22286
  /**
22287
- * Internal dependencies
22288
  */
22289
 
22290
 
 
 
 
 
 
 
22291
 
22292
 
22293
- function chunk(array, size) {
22294
- const chunks = [];
 
 
 
 
22295
 
22296
- for (let i = 0, j = array.length; i < j; i += size) {
22297
- chunks.push(array.slice(i, i + size));
22298
- }
22299
 
22300
- return chunks;
22301
- }
 
 
 
 
22302
 
22303
- function BlockTypesList({
22304
- items = [],
22305
- onSelect,
22306
- onHover = () => {},
22307
- children,
22308
- label,
22309
- isDraggable = true
22310
- }) {
22311
- return (0,external_wp_element_namespaceObject.createElement)(group, {
22312
- className: "block-editor-block-types-list",
22313
- "aria-label": label
22314
- }, chunk(items, 3).map((row, i) => (0,external_wp_element_namespaceObject.createElement)(inserter_listbox_row, {
22315
- key: i
22316
- }, row.map((item, j) => (0,external_wp_element_namespaceObject.createElement)(inserter_list_item, {
22317
- key: item.id,
22318
- item: item,
22319
- className: (0,external_wp_blocks_namespaceObject.getBlockMenuDefaultClassName)(item.id),
22320
- onSelect: onSelect,
22321
- onHover: onHover,
22322
- isDraggable: isDraggable,
22323
- isFirst: i === 0 && j === 0
22324
- })))), children);
22325
- }
22326
 
22327
- /* harmony default export */ var block_types_list = (BlockTypesList);
22328
- //# sourceMappingURL=index.js.map
22329
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/inserter/panel.js
 
 
 
 
22330
 
22331
 
 
 
 
22332
  /**
22333
- * WordPress dependencies
22334
  */
22335
 
22336
 
22337
- function InserterPanel({
22338
- title,
22339
- icon,
22340
- children
22341
- }) {
22342
- return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("div", {
22343
- className: "block-editor-inserter__panel-header"
22344
- }, (0,external_wp_element_namespaceObject.createElement)("h2", {
22345
- className: "block-editor-inserter__panel-title"
22346
- }, title), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Icon, {
22347
- icon: icon
22348
- })), (0,external_wp_element_namespaceObject.createElement)("div", {
22349
- className: "block-editor-inserter__panel-content"
22350
- }, children));
22351
- }
22352
-
22353
- /* harmony default export */ var panel = (InserterPanel);
22354
- //# sourceMappingURL=panel.js.map
22355
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/inserter-listbox/index.js
22356
 
22357
 
 
 
 
22358
  /**
22359
- * WordPress dependencies
22360
  */
22361
 
 
 
 
 
22362
  /**
22363
- * Internal dependencies
22364
  */
22365
 
22366
 
 
 
 
 
 
 
 
22367
 
22368
 
 
 
 
 
 
 
 
22369
 
22370
 
22371
- function InserterListbox({
22372
- children
22373
- }) {
22374
- const compositeState = (0,external_wp_components_namespaceObject.__unstableUseCompositeState)({
22375
- shift: true,
22376
- wrap: 'horizontal'
22377
- });
22378
- return (0,external_wp_element_namespaceObject.createElement)(inserter_listbox_context.Provider, {
22379
- value: compositeState
22380
- }, children);
22381
- }
22382
-
22383
- /* harmony default export */ var inserter_listbox = (InserterListbox);
22384
- //# sourceMappingURL=index.js.map
22385
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/inserter/block-types-tab.js
22386
 
22387
 
 
 
 
22388
  /**
22389
- * External dependencies
22390
  */
22391
 
 
 
 
 
22392
  /**
22393
- * WordPress dependencies
22394
  */
22395
 
22396
 
 
 
22397
 
 
 
 
22398
 
 
 
22399
  /**
22400
- * Internal dependencies
22401
  */
22402
 
22403
 
 
 
 
 
 
 
 
 
22404
 
 
 
 
22405
 
 
 
 
22406
 
22407
 
22408
- const getBlockNamespace = item => item.name.split('/')[0];
22409
-
22410
- const MAX_SUGGESTED_ITEMS = 6;
22411
  /**
22412
- * Shared reference to an empty array for cases where it is important to avoid
22413
- * returning a new array reference on every invocation and rerendering the component.
22414
- *
22415
- * @type {Array}
22416
  */
22417
 
22418
- const block_types_tab_EMPTY_ARRAY = [];
22419
- function BlockTypesTab({
22420
- rootClientId,
22421
- onInsert,
22422
- onHover,
22423
- showMostUsedBlocks
22424
- }) {
22425
- const [items, categories, collections, onSelectItem] = use_block_types_state(rootClientId, onInsert);
22426
- const suggestedItems = (0,external_wp_element_namespaceObject.useMemo)(() => {
22427
- return (0,external_lodash_namespaceObject.orderBy)(items, ['frecency'], ['desc']).slice(0, MAX_SUGGESTED_ITEMS);
22428
- }, [items]);
22429
- const uncategorizedItems = (0,external_wp_element_namespaceObject.useMemo)(() => {
22430
- return items.filter(item => !item.category);
22431
- }, [items]);
22432
- const itemsPerCategory = (0,external_wp_element_namespaceObject.useMemo)(() => {
22433
- return (0,external_lodash_namespaceObject.flow)(itemList => itemList.filter(item => item.category && item.category !== 'reusable'), itemList => (0,external_lodash_namespaceObject.groupBy)(itemList, 'category'))(items);
22434
- }, [items]);
22435
- const itemsPerCollection = (0,external_wp_element_namespaceObject.useMemo)(() => {
22436
- // Create a new Object to avoid mutating collection.
22437
- const result = { ...collections
22438
- };
22439
- Object.keys(collections).forEach(namespace => {
22440
- result[namespace] = items.filter(item => getBlockNamespace(item) === namespace);
22441
 
22442
- if (result[namespace].length === 0) {
22443
- delete result[namespace];
22444
- }
22445
- });
22446
- return result;
22447
- }, [items, collections]); // Hide block preview on unmount.
 
 
22448
 
22449
- (0,external_wp_element_namespaceObject.useEffect)(() => () => onHover(null), []);
22450
- /**
22451
- * The inserter contains a big number of blocks and opening it is a costful operation.
22452
- * The rendering is the most costful part of it, in order to improve the responsiveness
22453
- * of the "opening" action, these lazy lists allow us to render the inserter category per category,
22454
- * once all the categories are rendered, we start rendering the collections and the uncategorized block types.
22455
- */
22456
 
22457
- const currentlyRenderedCategories = (0,external_wp_compose_namespaceObject.useAsyncList)(categories);
22458
- const didRenderAllCategories = categories.length === currentlyRenderedCategories.length; // Async List requires an array
 
 
22459
 
22460
- const collectionEntries = (0,external_wp_element_namespaceObject.useMemo)(() => {
22461
- return Object.entries(collections);
22462
- }, [collections]);
22463
- const currentlyRenderedCollections = (0,external_wp_compose_namespaceObject.useAsyncList)(didRenderAllCategories ? collectionEntries : block_types_tab_EMPTY_ARRAY);
22464
- return (0,external_wp_element_namespaceObject.createElement)(inserter_listbox, null, (0,external_wp_element_namespaceObject.createElement)("div", null, showMostUsedBlocks && !!suggestedItems.length && (0,external_wp_element_namespaceObject.createElement)(panel, {
22465
- title: (0,external_wp_i18n_namespaceObject._x)('Most used', 'blocks')
22466
- }, (0,external_wp_element_namespaceObject.createElement)(block_types_list, {
22467
- items: suggestedItems,
22468
- onSelect: onSelectItem,
22469
- onHover: onHover,
22470
- label: (0,external_wp_i18n_namespaceObject._x)('Most used', 'blocks')
22471
- })), (0,external_lodash_namespaceObject.map)(currentlyRenderedCategories, category => {
22472
- const categoryItems = itemsPerCategory[category.slug];
22473
 
22474
- if (!categoryItems || !categoryItems.length) {
22475
- return null;
22476
- }
22477
 
22478
- return (0,external_wp_element_namespaceObject.createElement)(panel, {
22479
- key: category.slug,
22480
- title: category.title,
22481
- icon: category.icon
22482
- }, (0,external_wp_element_namespaceObject.createElement)(block_types_list, {
22483
- items: categoryItems,
22484
- onSelect: onSelectItem,
22485
- onHover: onHover,
22486
- label: category.title
22487
- }));
22488
- }), didRenderAllCategories && uncategorizedItems.length > 0 && (0,external_wp_element_namespaceObject.createElement)(panel, {
22489
- className: "block-editor-inserter__uncategorized-blocks-panel",
22490
- title: (0,external_wp_i18n_namespaceObject.__)('Uncategorized')
22491
- }, (0,external_wp_element_namespaceObject.createElement)(block_types_list, {
22492
- items: uncategorizedItems,
22493
- onSelect: onSelectItem,
22494
- onHover: onHover,
22495
- label: (0,external_wp_i18n_namespaceObject.__)('Uncategorized')
22496
- })), (0,external_lodash_namespaceObject.map)(currentlyRenderedCollections, ([namespace, collection]) => {
22497
- const collectionItems = itemsPerCollection[namespace];
22498
 
22499
- if (!collectionItems || !collectionItems.length) {
22500
- return null;
22501
- }
22502
 
22503
- return (0,external_wp_element_namespaceObject.createElement)(panel, {
22504
- key: namespace,
22505
- title: collection.title,
22506
- icon: collection.icon
22507
- }, (0,external_wp_element_namespaceObject.createElement)(block_types_list, {
22508
- items: collectionItems,
22509
- onSelect: onSelectItem,
22510
- onHover: onHover,
22511
- label: collection.title
22512
- }));
22513
- })));
22514
- }
22515
- /* harmony default export */ var block_types_tab = (BlockTypesTab);
22516
- //# sourceMappingURL=block-types-tab.js.map
22517
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/inserter/pattern-panel.js
22518
 
22519
 
 
 
 
22520
  /**
22521
- * External dependencies
22522
  */
22523
 
 
 
 
 
22524
  /**
22525
- * WordPress dependencies
22526
  */
22527
 
22528
 
 
 
 
 
 
 
 
22529
 
22530
 
22531
- function PatternInserterPanel({
22532
- selectedCategory,
22533
- patternCategories,
22534
- onClickCategory,
22535
- children
22536
- }) {
22537
- const categoryOptions = () => {
22538
- const options = [];
22539
- patternCategories.map(patternCategory => {
22540
- return options.push({
22541
- value: patternCategory.name,
22542
- label: patternCategory.label
22543
- });
22544
- });
22545
- return options;
22546
- };
22547
 
22548
- const onChangeSelect = selected => {
22549
- onClickCategory(patternCategories.find(patternCategory => selected === patternCategory.name));
22550
- };
22551
 
22552
- const getPanelHeaderClassName = () => {
22553
- return classnames_default()('block-editor-inserter__panel-header', 'block-editor-inserter__panel-header-patterns');
22554
- }; // In iOS-based mobile devices, the onBlur will fire when selecting an option
22555
- // from a Select element. To prevent closing the useDialog on iOS devices, we
22556
- // stop propagating the onBlur event if there is no relatedTarget, which means
22557
- // that the user most likely did not click on an element within the editor canvas.
22558
 
22559
 
22560
- const onBlur = event => {
22561
- if (!(event !== null && event !== void 0 && event.relatedTarget)) {
22562
- event.stopPropagation();
22563
- }
22564
- };
 
22565
 
22566
- return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("div", {
22567
- className: getPanelHeaderClassName()
22568
- }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SelectControl, {
22569
- className: "block-editor-inserter__panel-dropdown",
22570
- label: (0,external_wp_i18n_namespaceObject.__)('Filter patterns'),
22571
- hideLabelFromVision: true,
22572
- value: selectedCategory.name,
22573
- onChange: onChangeSelect,
22574
- onBlur: onBlur,
22575
- options: categoryOptions()
22576
- })), (0,external_wp_element_namespaceObject.createElement)("div", {
22577
- className: "block-editor-inserter__panel-content"
22578
- }, children));
22579
- }
22580
 
22581
- /* harmony default export */ var pattern_panel = (PatternInserterPanel);
22582
- //# sourceMappingURL=pattern-panel.js.map
22583
- ;// CONCATENATED MODULE: external ["wp","notices"]
22584
- var external_wp_notices_namespaceObject = window["wp"]["notices"];
22585
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/inserter/hooks/use-patterns-state.js
22586
  /**
22587
- * External dependencies
22588
  */
22589
 
 
 
 
 
 
22590
  /**
22591
- * WordPress dependencies
22592
  */
22593
 
22594
 
 
 
 
 
 
 
 
22595
 
22596
 
 
 
 
 
 
 
22597
 
22598
 
 
 
 
22599
  /**
22600
- * Internal dependencies
22601
  */
22602
 
22603
 
 
 
 
22604
  /**
22605
- * Retrieves the block patterns inserter state.
22606
- *
22607
- * @param {Function} onInsert function called when inserter a list of blocks.
22608
- * @param {string=} rootClientId Insertion's root client ID.
22609
- *
22610
- * @return {Array} Returns the patterns state. (patterns, categories, onSelect handler)
22611
  */
22612
 
22613
- const usePatternsState = (onInsert, rootClientId) => {
22614
- const {
22615
- patternCategories,
22616
- patterns
22617
- } = (0,external_wp_data_namespaceObject.useSelect)(select => {
22618
- const {
22619
- __experimentalGetAllowedPatterns,
22620
- getSettings
22621
- } = select(store);
22622
- return {
22623
- patterns: __experimentalGetAllowedPatterns(rootClientId),
22624
- patternCategories: getSettings().__experimentalBlockPatternCategories
22625
- };
22626
- }, [rootClientId]);
22627
- const {
22628
- createSuccessNotice
22629
- } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
22630
- const onClickPattern = (0,external_wp_element_namespaceObject.useCallback)((pattern, blocks) => {
22631
- onInsert((0,external_lodash_namespaceObject.map)(blocks, block => (0,external_wp_blocks_namespaceObject.cloneBlock)(block)), pattern.name);
22632
- createSuccessNotice((0,external_wp_i18n_namespaceObject.sprintf)(
22633
- /* translators: %s: block pattern title. */
22634
- (0,external_wp_i18n_namespaceObject.__)('Block pattern "%s" inserted.'), pattern.title), {
22635
- type: 'snackbar'
22636
- });
22637
- }, []);
22638
- return [patterns, patternCategories, onClickPattern];
22639
- };
22640
 
22641
- /* harmony default export */ var use_patterns_state = (usePatternsState);
22642
- //# sourceMappingURL=use-patterns-state.js.map
22643
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-patterns-list/index.js
 
 
 
 
22644
 
 
 
 
 
 
 
 
22645
 
22646
 
 
 
 
22647
  /**
22648
- * WordPress dependencies
22649
  */
22650
 
22651
 
 
 
 
 
 
 
 
22652
 
 
 
 
 
 
 
 
22653
 
22654
  /**
22655
  * Internal dependencies
22656
  */
22657
 
22658
 
 
 
 
 
 
 
 
 
 
 
 
 
22659
 
 
 
 
 
 
 
 
 
 
 
 
22660
 
 
 
 
22661
 
22662
- function BlockPattern({
22663
- isDraggable,
22664
- pattern,
22665
- onClick,
22666
- composite
22667
- }) {
22668
- const {
22669
- name,
22670
- viewportWidth
22671
- } = pattern;
22672
- const {
22673
- blocks
22674
- } = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).__experimentalGetParsedPattern(name), [name]);
22675
- const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(BlockPattern);
22676
- const descriptionId = `block-editor-block-patterns-list__item-description-${instanceId}`;
22677
- return (0,external_wp_element_namespaceObject.createElement)(inserter_draggable_blocks, {
22678
- isEnabled: isDraggable,
22679
- blocks: blocks
22680
- }, ({
22681
- draggable,
22682
- onDragStart,
22683
- onDragEnd
22684
- }) => (0,external_wp_element_namespaceObject.createElement)("div", {
22685
- className: "block-editor-block-patterns-list__list-item",
22686
- "aria-label": pattern.title,
22687
- "aria-describedby": pattern.description ? descriptionId : undefined,
22688
- draggable: draggable,
22689
- onDragStart: onDragStart,
22690
- onDragEnd: onDragEnd
22691
- }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableCompositeItem, _extends({
22692
- role: "option",
22693
- as: "div"
22694
- }, composite, {
22695
- className: "block-editor-block-patterns-list__item",
22696
- onClick: () => onClick(pattern, blocks)
22697
- }), (0,external_wp_element_namespaceObject.createElement)(block_preview, {
22698
- blocks: blocks,
22699
- viewportWidth: viewportWidth
22700
- }), (0,external_wp_element_namespaceObject.createElement)("div", {
22701
- className: "block-editor-block-patterns-list__item-title"
22702
- }, pattern.title), !!pattern.description && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, {
22703
- id: descriptionId
22704
- }, pattern.description))));
22705
- }
22706
 
22707
- function BlockPatternPlaceholder() {
22708
- return (0,external_wp_element_namespaceObject.createElement)("div", {
22709
- className: "block-editor-block-patterns-list__item is-placeholder"
22710
- });
22711
- }
22712
 
22713
- function BlockPatternList({
22714
- isDraggable,
22715
- blockPatterns,
22716
- shownPatterns,
22717
- onClickPattern,
22718
- orientation,
22719
- label = (0,external_wp_i18n_namespaceObject.__)('Block Patterns')
22720
- }) {
22721
- const composite = (0,external_wp_components_namespaceObject.__unstableUseCompositeState)({
22722
- orientation
22723
- });
22724
- return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableComposite, _extends({}, composite, {
22725
- role: "listbox",
22726
- className: "block-editor-block-patterns-list",
22727
- "aria-label": label
22728
- }), blockPatterns.map(pattern => {
22729
- const isShown = shownPatterns.includes(pattern);
22730
- return isShown ? (0,external_wp_element_namespaceObject.createElement)(BlockPattern, {
22731
- key: pattern.name,
22732
- pattern: pattern,
22733
- onClick: onClickPattern,
22734
- isDraggable: isDraggable,
22735
- composite: composite
22736
- }) : (0,external_wp_element_namespaceObject.createElement)(BlockPatternPlaceholder, {
22737
- key: pattern.name
22738
  });
22739
- }));
 
 
 
 
 
22740
  }
22741
 
22742
- /* harmony default export */ var block_patterns_list = (BlockPatternList);
22743
- //# sourceMappingURL=index.js.map
22744
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/inserter/block-patterns-tab.js
22745
-
22746
-
22747
  /**
22748
- * External dependencies
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22749
  */
22750
 
 
 
 
 
22751
  /**
22752
- * WordPress dependencies
 
 
 
 
22753
  */
22754
 
22755
 
 
 
 
 
 
 
 
 
 
 
22756
 
 
 
 
22757
 
 
 
22758
  /**
22759
- * Internal dependencies
 
 
 
 
 
22760
  */
22761
 
22762
 
 
 
 
 
 
 
 
 
 
 
22763
 
22764
 
 
 
 
 
 
 
 
 
 
 
 
 
22765
 
22766
- function BlockPatternsCategory({
22767
- rootClientId,
22768
- onInsert,
22769
- selectedCategory,
22770
- onClickCategory
22771
- }) {
22772
- const [allPatterns, allCategories, onClick] = use_patterns_state(onInsert, rootClientId); // Remove any empty categories
22773
 
22774
- const populatedCategories = (0,external_wp_element_namespaceObject.useMemo)(() => allCategories.filter(category => allPatterns.some(pattern => {
22775
- var _pattern$categories;
 
 
22776
 
22777
- return (_pattern$categories = pattern.categories) === null || _pattern$categories === void 0 ? void 0 : _pattern$categories.includes(category.name);
22778
- })), [allPatterns, allCategories]);
22779
- const patternCategory = selectedCategory ? selectedCategory : populatedCategories[0];
22780
- (0,external_wp_element_namespaceObject.useEffect)(() => {
22781
- if (allPatterns.some(pattern => getPatternIndex(pattern) === Infinity) && !populatedCategories.find(category => category.name === 'uncategorized')) {
22782
- populatedCategories.push({
22783
- name: 'uncategorized',
22784
- label: (0,external_wp_i18n_namespaceObject._x)('Uncategorized')
22785
- });
22786
- }
22787
- }, [populatedCategories, allPatterns]);
22788
- const getPatternIndex = (0,external_wp_element_namespaceObject.useCallback)(pattern => {
22789
- if (!pattern.categories || !pattern.categories.length) {
22790
- return Infinity;
22791
- }
22792
 
22793
- const indexedCategories = (0,external_lodash_namespaceObject.fromPairs)(populatedCategories.map(({
22794
- name
22795
- }, index) => [name, index]));
22796
- return Math.min(...pattern.categories.map(cat => indexedCategories[cat] !== undefined ? indexedCategories[cat] : Infinity));
22797
- }, [populatedCategories]);
22798
- const currentCategoryPatterns = (0,external_wp_element_namespaceObject.useMemo)(() => allPatterns.filter(pattern => patternCategory.name === 'uncategorized' ? getPatternIndex(pattern) === Infinity : pattern.categories && pattern.categories.includes(patternCategory.name)), [allPatterns, patternCategory]); // Ordering the patterns is important for the async rendering.
22799
 
22800
- const orderedPatterns = (0,external_wp_element_namespaceObject.useMemo)(() => {
22801
- return currentCategoryPatterns.sort((a, b) => {
22802
- return getPatternIndex(a) - getPatternIndex(b);
22803
- });
22804
- }, [currentCategoryPatterns, getPatternIndex]);
22805
- const currentShownPatterns = (0,external_wp_compose_namespaceObject.useAsyncList)(orderedPatterns);
22806
- return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, !!currentCategoryPatterns.length && (0,external_wp_element_namespaceObject.createElement)(pattern_panel, {
22807
- selectedCategory: patternCategory,
22808
- patternCategories: populatedCategories,
22809
- onClickCategory: onClickCategory
22810
- }, (0,external_wp_element_namespaceObject.createElement)(block_patterns_list, {
22811
- shownPatterns: currentShownPatterns,
22812
- blockPatterns: currentCategoryPatterns,
22813
- onClickPattern: onClick,
22814
- label: patternCategory.label,
22815
- orientation: "vertical",
22816
- isDraggable: true
22817
- })));
22818
  }
 
 
 
 
 
 
 
 
22819
 
22820
- function BlockPatternsTabs({
22821
- rootClientId,
22822
- onInsert,
22823
- onClickCategory,
22824
- selectedCategory
22825
- }) {
22826
- return (0,external_wp_element_namespaceObject.createElement)(BlockPatternsCategory, {
22827
- rootClientId: rootClientId,
22828
- selectedCategory: selectedCategory,
22829
- onInsert: onInsert,
22830
- onClickCategory: onClickCategory
22831
  });
 
22832
  }
22833
 
22834
- /* harmony default export */ var block_patterns_tab = (BlockPatternsTabs);
22835
- //# sourceMappingURL=block-patterns-tab.js.map
22836
- ;// CONCATENATED MODULE: external ["wp","url"]
22837
- var external_wp_url_namespaceObject = window["wp"]["url"];
22838
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/inserter/no-results.js
 
 
22839
 
 
 
22840
 
 
 
 
22841
  /**
22842
- * WordPress dependencies
22843
  */
 
22844
 
 
 
 
 
 
22845
 
22846
 
22847
- function InserterNoResults() {
22848
- return (0,external_wp_element_namespaceObject.createElement)("div", {
22849
- className: "block-editor-inserter__no-results"
22850
- }, (0,external_wp_element_namespaceObject.createElement)(icon, {
22851
- className: "block-editor-inserter__no-results-icon",
22852
- icon: block_default
22853
- }), (0,external_wp_element_namespaceObject.createElement)("p", null, (0,external_wp_i18n_namespaceObject.__)('No results found.')));
22854
- }
22855
 
22856
- /* harmony default export */ var no_results = (InserterNoResults);
22857
- //# sourceMappingURL=no-results.js.map
22858
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/inserter/reusable-blocks-tab.js
22859
 
 
 
 
 
 
 
 
 
22860
 
 
 
 
22861
  /**
22862
- * WordPress dependencies
22863
  */
22864
 
 
 
 
22865
 
22866
 
22867
  /**
@@ -22871,79 +22099,43 @@ function InserterNoResults() {
22871
 
22872
 
22873
 
 
 
 
 
 
 
 
22874
 
 
 
 
 
 
 
 
22875
 
22876
- function ReusableBlocksList({
22877
- onHover,
22878
- onInsert,
22879
- rootClientId
22880
- }) {
22881
- const [items,,, onSelectItem] = use_block_types_state(rootClientId, onInsert);
22882
- const filteredItems = (0,external_wp_element_namespaceObject.useMemo)(() => {
22883
- return items.filter(({
22884
- category
22885
- }) => category === 'reusable');
22886
- }, [items]);
22887
 
22888
- if (filteredItems.length === 0) {
22889
- return (0,external_wp_element_namespaceObject.createElement)(no_results, null);
22890
- }
22891
 
22892
- return (0,external_wp_element_namespaceObject.createElement)(panel, {
22893
- title: (0,external_wp_i18n_namespaceObject.__)('Reusable blocks')
22894
- }, (0,external_wp_element_namespaceObject.createElement)(block_types_list, {
22895
- items: filteredItems,
22896
- onSelect: onSelectItem,
22897
- onHover: onHover,
22898
- label: (0,external_wp_i18n_namespaceObject.__)('Reusable blocks')
22899
- }));
22900
- } // The unwrapped component is only exported for use by unit tests.
22901
 
22902
- /**
22903
- * List of reusable blocks shown in the "Reusable" tab of the inserter.
22904
- *
22905
- * @param {Object} props Component props.
22906
- * @param {?string} props.rootClientId Client id of block to insert into.
22907
- * @param {Function} props.onInsert Callback to run when item is inserted.
22908
- * @param {Function} props.onHover Callback to run when item is hovered.
22909
- *
22910
- * @return {WPComponent} The component.
22911
- */
22912
 
 
 
 
22913
 
22914
- function ReusableBlocksTab({
22915
- rootClientId,
22916
- onInsert,
22917
- onHover
22918
- }) {
22919
- return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(ReusableBlocksList, {
22920
- onHover: onHover,
22921
- onInsert: onInsert,
22922
- rootClientId: rootClientId
22923
- }), (0,external_wp_element_namespaceObject.createElement)("div", {
22924
- className: "block-editor-inserter__manage-reusable-blocks-container"
22925
- }, (0,external_wp_element_namespaceObject.createElement)("a", {
22926
- className: "block-editor-inserter__manage-reusable-blocks",
22927
- href: (0,external_wp_url_namespaceObject.addQueryArgs)('edit.php', {
22928
- post_type: 'wp_block'
22929
- })
22930
- }, (0,external_wp_i18n_namespaceObject.__)('Manage Reusable blocks'))));
22931
- }
22932
- /* harmony default export */ var reusable_blocks_tab = (ReusableBlocksTab);
22933
- //# sourceMappingURL=reusable-blocks-tab.js.map
22934
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/inserter-menu-extension/index.js
22935
- /**
22936
- * WordPress dependencies
22937
- */
22938
 
22939
- const {
22940
- Fill: __unstableInserterMenuExtension,
22941
- Slot: inserter_menu_extension_Slot
22942
- } = (0,external_wp_components_namespaceObject.createSlotFill)('__unstableInserterMenuExtension');
22943
- __unstableInserterMenuExtension.Slot = inserter_menu_extension_Slot;
22944
- /* harmony default export */ var inserter_menu_extension = (__unstableInserterMenuExtension);
22945
- //# sourceMappingURL=index.js.map
22946
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/inserter/hooks/use-insertion-point.js
22947
  /**
22948
  * External dependencies
22949
  */
@@ -22953,122 +22145,64 @@ __unstableInserterMenuExtension.Slot = inserter_menu_extension_Slot;
22953
  */
22954
 
22955
 
22956
-
22957
-
22958
-
22959
-
22960
  /**
22961
  * Internal dependencies
22962
  */
22963
 
22964
 
22965
- /**
22966
- * @typedef WPInserterConfig
22967
- *
22968
- * @property {string=} rootClientId If set, insertion will be into the
22969
- * block with this ID.
22970
- * @property {number=} insertionIndex If set, insertion will be into this
22971
- * explicit position.
22972
- * @property {string=} clientId If set, insertion will be after the
22973
- * block with this ID.
22974
- * @property {boolean=} isAppender Whether the inserter is an appender
22975
- * or not.
22976
- * @property {Function=} onSelect Called after insertion.
22977
- */
22978
-
22979
- /**
22980
- * Returns the insertion point state given the inserter config.
22981
- *
22982
- * @param {WPInserterConfig} config Inserter Config.
22983
- * @return {Array} Insertion Point State (rootClientID, onInsertBlocks and onToggle).
22984
- */
22985
-
22986
- function useInsertionPoint({
22987
- rootClientId = '',
22988
- insertionIndex,
22989
- clientId,
22990
- isAppender,
22991
- onSelect,
22992
- shouldFocusBlock = true
22993
- }) {
22994
- const {
22995
- getSelectedBlock
22996
- } = (0,external_wp_data_namespaceObject.useSelect)(store);
22997
- const {
22998
- destinationRootClientId,
22999
- destinationIndex
23000
- } = (0,external_wp_data_namespaceObject.useSelect)(select => {
23001
- const {
23002
- getSelectedBlockClientId,
23003
- getBlockRootClientId,
23004
- getBlockIndex,
23005
- getBlockOrder
23006
- } = select(store);
23007
- const selectedBlockClientId = getSelectedBlockClientId();
23008
- let _destinationRootClientId = rootClientId;
23009
-
23010
- let _destinationIndex;
23011
 
23012
- if (insertionIndex !== undefined) {
23013
- // Insert into a specific index.
23014
- _destinationIndex = insertionIndex;
23015
- } else if (clientId) {
23016
- // Insert after a specific client ID.
23017
- _destinationIndex = getBlockIndex(clientId, _destinationRootClientId);
23018
- } else if (!isAppender && selectedBlockClientId) {
23019
- _destinationRootClientId = getBlockRootClientId(selectedBlockClientId);
23020
- _destinationIndex = getBlockIndex(selectedBlockClientId, _destinationRootClientId) + 1;
23021
- } else {
23022
- // Insert at the end of the list.
23023
- _destinationIndex = getBlockOrder(_destinationRootClientId).length;
23024
  }
23025
 
23026
- return {
23027
- destinationRootClientId: _destinationRootClientId,
23028
- destinationIndex: _destinationIndex
23029
- };
23030
- }, [rootClientId, insertionIndex, clientId, isAppender]);
23031
- const {
23032
- replaceBlocks,
23033
- insertBlocks,
23034
- showInsertionPoint,
23035
- hideInsertionPoint
23036
- } = (0,external_wp_data_namespaceObject.useDispatch)(store);
23037
- const onInsertBlocks = (0,external_wp_element_namespaceObject.useCallback)((blocks, meta, shouldForceFocusBlock = false) => {
23038
- const selectedBlock = getSelectedBlock();
23039
 
23040
- if (!isAppender && selectedBlock && (0,external_wp_blocks_namespaceObject.isUnmodifiedDefaultBlock)(selectedBlock)) {
23041
- replaceBlocks(selectedBlock.clientId, blocks, null, shouldFocusBlock || shouldForceFocusBlock ? 0 : null, meta);
 
 
 
 
 
 
 
23042
  } else {
23043
- insertBlocks(blocks, destinationIndex, destinationRootClientId, true, shouldFocusBlock || shouldForceFocusBlock ? 0 : null, meta);
23044
- }
23045
 
23046
- const message = (0,external_wp_i18n_namespaceObject.sprintf)( // translators: %d: the name of the block that has been added
23047
- (0,external_wp_i18n_namespaceObject._n)('%d block added.', '%d blocks added.', (0,external_lodash_namespaceObject.castArray)(blocks).length), (0,external_lodash_namespaceObject.castArray)(blocks).length);
23048
- (0,external_wp_a11y_namespaceObject.speak)(message);
23049
 
23050
- if (onSelect) {
23051
- onSelect();
23052
- }
23053
- }, [isAppender, getSelectedBlock, replaceBlocks, insertBlocks, destinationRootClientId, destinationIndex, onSelect, shouldFocusBlock]);
23054
- const onToggleInsertionPoint = (0,external_wp_element_namespaceObject.useCallback)(show => {
23055
- if (show) {
23056
- showInsertionPoint(destinationRootClientId, destinationIndex);
23057
  } else {
23058
- hideInsertionPoint();
23059
  }
23060
- }, [showInsertionPoint, hideInsertionPoint, destinationRootClientId, destinationIndex]);
23061
- return [destinationRootClientId, onInsertBlocks, onToggleInsertionPoint];
23062
  }
23063
 
23064
- /* harmony default export */ var use_insertion_point = (useInsertionPoint);
23065
- //# sourceMappingURL=use-insertion-point.js.map
23066
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/inserter/search-results.js
23067
-
 
 
 
 
 
 
 
 
23068
 
23069
- /**
23070
- * External dependencies
23071
- */
23072
 
23073
  /**
23074
  * WordPress dependencies
@@ -23076,9 +22210,6 @@ function useInsertionPoint({
23076
 
23077
 
23078
 
23079
-
23080
-
23081
-
23082
  /**
23083
  * Internal dependencies
23084
  */
@@ -23086,116 +22217,129 @@ function useInsertionPoint({
23086
 
23087
 
23088
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23089
 
 
 
 
23090
 
23091
 
 
 
 
23092
 
 
 
 
23093
 
23094
 
23095
 
23096
- const INITIAL_INSERTER_RESULTS = 9;
23097
  /**
23098
- * Shared reference to an empty array for cases where it is important to avoid
23099
- * returning a new array reference on every invocation and rerendering the component.
23100
- *
23101
- * @type {Array}
23102
  */
23103
 
23104
- const search_results_EMPTY_ARRAY = [];
23105
 
23106
- function InserterSearchResults({
23107
- filterValue,
23108
- onSelect,
23109
- onHover,
23110
- rootClientId,
23111
- clientId,
23112
- isAppender,
23113
- __experimentalInsertionIndex,
23114
- maxBlockPatterns,
23115
- maxBlockTypes,
23116
- showBlockDirectory = false,
23117
- isDraggable = true,
23118
- shouldFocusBlock = true
23119
- }) {
23120
- const debouncedSpeak = (0,external_wp_compose_namespaceObject.useDebounce)(external_wp_a11y_namespaceObject.speak, 500);
23121
- const [destinationRootClientId, onInsertBlocks] = use_insertion_point({
23122
- onSelect,
23123
- rootClientId,
23124
- clientId,
23125
- isAppender,
23126
- insertionIndex: __experimentalInsertionIndex,
23127
- shouldFocusBlock
23128
- });
23129
- const [blockTypes, blockTypeCategories, blockTypeCollections, onSelectBlockType] = use_block_types_state(destinationRootClientId, onInsertBlocks);
23130
- const [patterns,, onSelectBlockPattern] = use_patterns_state(onInsertBlocks, destinationRootClientId);
23131
- const filteredBlockTypes = (0,external_wp_element_namespaceObject.useMemo)(() => {
23132
- const results = searchBlockItems((0,external_lodash_namespaceObject.orderBy)(blockTypes, ['frecency'], ['desc']), blockTypeCategories, blockTypeCollections, filterValue);
23133
- return maxBlockTypes !== undefined ? results.slice(0, maxBlockTypes) : results;
23134
- }, [filterValue, blockTypes, blockTypeCategories, blockTypeCollections, maxBlockTypes]);
23135
- const filteredBlockPatterns = (0,external_wp_element_namespaceObject.useMemo)(() => {
23136
- const results = searchItems(patterns, filterValue);
23137
- return maxBlockPatterns !== undefined ? results.slice(0, maxBlockPatterns) : results;
23138
- }, [filterValue, patterns, maxBlockPatterns]); // Announce search results on change
23139
 
23140
- (0,external_wp_element_namespaceObject.useEffect)(() => {
23141
- if (!filterValue) {
23142
- return;
23143
- }
23144
 
23145
- const count = filteredBlockTypes.length + filteredBlockPatterns.length;
23146
- const resultsFoundMessage = (0,external_wp_i18n_namespaceObject.sprintf)(
23147
- /* translators: %d: number of results. */
23148
- (0,external_wp_i18n_namespaceObject._n)('%d result found.', '%d results found.', count), count);
23149
- debouncedSpeak(resultsFoundMessage);
23150
- }, [filterValue, debouncedSpeak]);
23151
- const currentShownBlockTypes = (0,external_wp_compose_namespaceObject.useAsyncList)(filteredBlockTypes, {
23152
- step: INITIAL_INSERTER_RESULTS
23153
- });
23154
- const currentShownPatterns = (0,external_wp_compose_namespaceObject.useAsyncList)(currentShownBlockTypes.length === filteredBlockTypes.length ? filteredBlockPatterns : search_results_EMPTY_ARRAY);
23155
- const hasItems = !(0,external_lodash_namespaceObject.isEmpty)(filteredBlockTypes) || !(0,external_lodash_namespaceObject.isEmpty)(filteredBlockPatterns);
23156
- return (0,external_wp_element_namespaceObject.createElement)(inserter_listbox, null, !showBlockDirectory && !hasItems && (0,external_wp_element_namespaceObject.createElement)(no_results, null), !!filteredBlockTypes.length && (0,external_wp_element_namespaceObject.createElement)(panel, {
23157
- title: (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, null, (0,external_wp_i18n_namespaceObject.__)('Blocks'))
23158
- }, (0,external_wp_element_namespaceObject.createElement)(block_types_list, {
23159
- items: currentShownBlockTypes,
23160
- onSelect: onSelectBlockType,
23161
- onHover: onHover,
23162
- label: (0,external_wp_i18n_namespaceObject.__)('Blocks'),
23163
- isDraggable: isDraggable
23164
- })), !!filteredBlockTypes.length && !!filteredBlockPatterns.length && (0,external_wp_element_namespaceObject.createElement)("div", {
23165
- className: "block-editor-inserter__quick-inserter-separator"
23166
- }), !!filteredBlockPatterns.length && (0,external_wp_element_namespaceObject.createElement)(panel, {
23167
- title: (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, null, (0,external_wp_i18n_namespaceObject.__)('Block Patterns'))
23168
- }, (0,external_wp_element_namespaceObject.createElement)("div", {
23169
- className: "block-editor-inserter__quick-inserter-patterns"
23170
- }, (0,external_wp_element_namespaceObject.createElement)(block_patterns_list, {
23171
- shownPatterns: currentShownPatterns,
23172
- blockPatterns: filteredBlockPatterns,
23173
- onClickPattern: onSelectBlockPattern,
23174
- isDraggable: isDraggable
23175
- }))), showBlockDirectory && (0,external_wp_element_namespaceObject.createElement)(inserter_menu_extension.Slot, {
23176
- fillProps: {
23177
- onSelect: onSelectBlockType,
23178
- onHover,
23179
- filterValue,
23180
- hasItems,
23181
- rootClientId: destinationRootClientId
23182
- }
23183
- }, fills => {
23184
- if (fills.length) {
23185
- return fills;
23186
- }
23187
 
23188
- if (!hasItems) {
23189
- return (0,external_wp_element_namespaceObject.createElement)(no_results, null);
23190
- }
 
 
 
 
 
 
 
 
 
 
 
 
23191
 
 
23192
  return null;
 
 
 
 
 
 
 
 
 
 
23193
  }));
23194
  }
 
 
 
 
 
 
 
 
 
 
 
23195
 
23196
- /* harmony default export */ var search_results = (InserterSearchResults);
23197
- //# sourceMappingURL=search-results.js.map
23198
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/inserter/tabs.js
23199
 
23200
 
23201
  /**
@@ -23203,198 +22347,207 @@ function InserterSearchResults({
23203
  */
23204
 
23205
 
 
 
 
23206
 
23207
- const blocksTab = {
23208
- name: 'blocks',
23209
-
23210
- /* translators: Blocks tab title in the block inserter. */
23211
- title: (0,external_wp_i18n_namespaceObject.__)('Blocks')
23212
- };
23213
- const patternsTab = {
23214
- name: 'patterns',
23215
 
23216
- /* translators: Patterns tab title in the block inserter. */
23217
- title: (0,external_wp_i18n_namespaceObject.__)('Patterns')
23218
- };
23219
- const reusableBlocksTab = {
23220
- name: 'reusable',
23221
 
23222
- /* translators: Reusable blocks tab title in the block inserter. */
23223
- title: (0,external_wp_i18n_namespaceObject.__)('Reusable')
23224
- };
23225
 
23226
- function InserterTabs({
23227
- children,
23228
- showPatterns = false,
23229
- showReusableBlocks = false,
23230
- onSelect
23231
  }) {
23232
- const tabs = (0,external_wp_element_namespaceObject.useMemo)(() => {
23233
- const tempTabs = [blocksTab];
23234
-
23235
- if (showPatterns) {
23236
- tempTabs.push(patternsTab);
23237
- }
23238
-
23239
- if (showReusableBlocks) {
23240
- tempTabs.push(reusableBlocksTab);
23241
- }
23242
 
23243
- return tempTabs;
23244
- }, [blocksTab, showPatterns, patternsTab, showReusableBlocks, reusableBlocksTab]);
23245
- return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TabPanel, {
23246
- className: "block-editor-inserter__tabs",
23247
- tabs: tabs,
23248
- onSelect: onSelect
23249
- }, children);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23250
  }
23251
 
23252
- /* harmony default export */ var tabs = (InserterTabs);
23253
- //# sourceMappingURL=tabs.js.map
23254
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/inserter/menu.js
23255
-
23256
-
23257
  /**
23258
  * WordPress dependencies
23259
  */
23260
 
 
 
 
 
23261
 
23262
 
23263
 
23264
  /**
23265
- * Internal dependencies
23266
  */
23267
 
23268
 
 
 
 
23269
 
23270
 
23271
 
23272
-
23273
-
23274
-
23275
-
23276
-
23277
-
23278
- function InserterMenu({
23279
- rootClientId,
23280
- clientId,
23281
- isAppender,
23282
- __experimentalInsertionIndex,
23283
- onSelect,
23284
- showInserterHelpPanel,
23285
- showMostUsedBlocks,
23286
- shouldFocusBlock = true
23287
- }) {
23288
- const [filterValue, setFilterValue] = (0,external_wp_element_namespaceObject.useState)('');
23289
- const [hoveredItem, setHoveredItem] = (0,external_wp_element_namespaceObject.useState)(null);
23290
- const [selectedPatternCategory, setSelectedPatternCategory] = (0,external_wp_element_namespaceObject.useState)(null);
23291
- const [destinationRootClientId, onInsertBlocks, onToggleInsertionPoint] = use_insertion_point({
23292
- rootClientId,
23293
- clientId,
23294
- isAppender,
23295
- insertionIndex: __experimentalInsertionIndex,
23296
- shouldFocusBlock
23297
- });
23298
- const {
23299
- showPatterns,
23300
- hasReusableBlocks
23301
- } = (0,external_wp_data_namespaceObject.useSelect)(select => {
23302
- var _getSettings$__experi;
23303
-
23304
- const {
23305
- __experimentalGetAllowedPatterns,
23306
- getSettings
23307
- } = select(store);
23308
- return {
23309
- showPatterns: !!__experimentalGetAllowedPatterns(destinationRootClientId).length,
23310
- hasReusableBlocks: !!((_getSettings$__experi = getSettings().__experimentalReusableBlocks) !== null && _getSettings$__experi !== void 0 && _getSettings$__experi.length)
23311
  };
23312
- }, [destinationRootClientId]);
23313
- const onInsert = (0,external_wp_element_namespaceObject.useCallback)((blocks, meta, shouldForceFocusBlock) => {
23314
- onInsertBlocks(blocks, meta, shouldForceFocusBlock);
23315
- onSelect();
23316
- }, [onInsertBlocks, onSelect]);
23317
- const onInsertPattern = (0,external_wp_element_namespaceObject.useCallback)((blocks, patternName) => {
23318
- onInsertBlocks(blocks, {
23319
- patternName
23320
- });
23321
- onSelect();
23322
- }, [onInsertBlocks, onSelect]);
23323
- const onHover = (0,external_wp_element_namespaceObject.useCallback)(item => {
23324
- onToggleInsertionPoint(!!item);
23325
- setHoveredItem(item);
23326
- }, [onToggleInsertionPoint, setHoveredItem]);
23327
- const onClickPatternCategory = (0,external_wp_element_namespaceObject.useCallback)(patternCategory => {
23328
- setSelectedPatternCategory(patternCategory);
23329
- }, [setSelectedPatternCategory]);
23330
- const blocksTab = (0,external_wp_element_namespaceObject.useMemo)(() => (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("div", {
23331
- className: "block-editor-inserter__block-list"
23332
- }, (0,external_wp_element_namespaceObject.createElement)(block_types_tab, {
23333
- rootClientId: destinationRootClientId,
23334
- onInsert: onInsert,
23335
- onHover: onHover,
23336
- showMostUsedBlocks: showMostUsedBlocks
23337
- })), showInserterHelpPanel && (0,external_wp_element_namespaceObject.createElement)("div", {
23338
- className: "block-editor-inserter__tips"
23339
- }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, {
23340
- as: "h2"
23341
- }, (0,external_wp_i18n_namespaceObject.__)('A tip for using the block editor')), (0,external_wp_element_namespaceObject.createElement)(tips, null))), [destinationRootClientId, onInsert, onHover, filterValue, showMostUsedBlocks, showInserterHelpPanel]);
23342
- const patternsTab = (0,external_wp_element_namespaceObject.useMemo)(() => (0,external_wp_element_namespaceObject.createElement)(block_patterns_tab, {
23343
- rootClientId: destinationRootClientId,
23344
- onInsert: onInsertPattern,
23345
- onClickCategory: onClickPatternCategory,
23346
- selectedCategory: selectedPatternCategory
23347
- }), [destinationRootClientId, onInsertPattern, onClickPatternCategory, selectedPatternCategory]);
23348
- const reusableBlocksTab = (0,external_wp_element_namespaceObject.useMemo)(() => (0,external_wp_element_namespaceObject.createElement)(reusable_blocks_tab, {
23349
- rootClientId: destinationRootClientId,
23350
- onInsert: onInsert,
23351
- onHover: onHover
23352
- }), [destinationRootClientId, onInsert, onHover]);
23353
- const getCurrentTab = (0,external_wp_element_namespaceObject.useCallback)(tab => {
23354
- if (tab.name === 'blocks') {
23355
- return blocksTab;
23356
- } else if (tab.name === 'patterns') {
23357
- return patternsTab;
23358
  }
23359
 
23360
- return reusableBlocksTab;
23361
- }, [blocksTab, patternsTab, reusableBlocksTab]);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23362
  return (0,external_wp_element_namespaceObject.createElement)("div", {
23363
- className: "block-editor-inserter__menu"
23364
- }, (0,external_wp_element_namespaceObject.createElement)("div", {
23365
- className: "block-editor-inserter__main-area"
23366
  }, (0,external_wp_element_namespaceObject.createElement)("div", {
23367
- className: "block-editor-inserter__content"
23368
- }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SearchControl, {
23369
- className: "block-editor-inserter__search",
23370
- onChange: value => {
23371
- if (hoveredItem) setHoveredItem(null);
23372
- setFilterValue(value);
23373
- },
23374
- value: filterValue,
23375
- label: (0,external_wp_i18n_namespaceObject.__)('Search for blocks and patterns'),
23376
- placeholder: (0,external_wp_i18n_namespaceObject.__)('Search')
23377
- }), !!filterValue && (0,external_wp_element_namespaceObject.createElement)(search_results, {
23378
- filterValue: filterValue,
23379
- onSelect: onSelect,
23380
- onHover: onHover,
23381
- rootClientId: rootClientId,
23382
- clientId: clientId,
23383
- isAppender: isAppender,
23384
- __experimentalInsertionIndex: __experimentalInsertionIndex,
23385
- showBlockDirectory: true,
23386
- shouldFocusBlock: shouldFocusBlock
23387
- }), !filterValue && (showPatterns || hasReusableBlocks) && (0,external_wp_element_namespaceObject.createElement)(tabs, {
23388
- showPatterns: showPatterns,
23389
- showReusableBlocks: hasReusableBlocks
23390
- }, getCurrentTab), !filterValue && !showPatterns && !hasReusableBlocks && blocksTab)), showInserterHelpPanel && hoveredItem && (0,external_wp_element_namespaceObject.createElement)(preview_panel, {
23391
- item: hoveredItem
23392
- }));
23393
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23394
 
23395
- /* harmony default export */ var menu = (InserterMenu);
23396
- //# sourceMappingURL=menu.js.map
23397
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/inserter/quick-inserter.js
23398
 
23399
 
23400
  /**
@@ -23408,7 +22561,6 @@ function InserterMenu({
23408
 
23409
 
23410
 
23411
-
23412
  /**
23413
  * Internal dependencies
23414
  */
@@ -23416,95 +22568,115 @@ function InserterMenu({
23416
 
23417
 
23418
 
 
 
 
 
 
 
 
23419
 
 
 
 
 
 
 
23420
 
23421
- const SEARCH_THRESHOLD = 6;
23422
- const quick_inserter_SHOWN_BLOCK_TYPES = 6;
23423
- const SHOWN_BLOCK_PATTERNS = 2;
23424
- function QuickInserter({
23425
  onSelect,
23426
- rootClientId,
23427
- clientId,
23428
- isAppender
23429
  }) {
23430
- const [filterValue, setFilterValue] = (0,external_wp_element_namespaceObject.useState)('');
23431
- const [destinationRootClientId, onInsertBlocks] = use_insertion_point({
23432
- onSelect,
23433
- rootClientId,
23434
- clientId,
23435
- isAppender
23436
- });
23437
- const [blockTypes] = use_block_types_state(destinationRootClientId, onInsertBlocks);
23438
- const [patterns] = use_patterns_state(onInsertBlocks, destinationRootClientId);
23439
- const showPatterns = patterns.length && !!filterValue;
23440
- const showSearch = showPatterns && patterns.length > SEARCH_THRESHOLD || blockTypes.length > SEARCH_THRESHOLD;
23441
- const {
23442
- setInserterIsOpened,
23443
- insertionIndex
23444
- } = (0,external_wp_data_namespaceObject.useSelect)(select => {
23445
- const {
23446
- getSettings,
23447
- getBlockIndex,
23448
- getBlockCount
23449
- } = select(store);
23450
- const index = getBlockIndex(clientId, rootClientId);
23451
- return {
23452
- setInserterIsOpened: getSettings().__experimentalSetIsInserterOpened,
23453
- insertionIndex: index === -1 ? getBlockCount() : index
23454
- };
23455
- }, [clientId, rootClientId]);
23456
- (0,external_wp_element_namespaceObject.useEffect)(() => {
23457
- if (setInserterIsOpened) {
23458
- setInserterIsOpened(false);
 
 
 
 
23459
  }
23460
- }, [setInserterIsOpened]); // When clicking Browse All select the appropriate block so as
23461
- // the insertion point can work as expected
 
 
 
 
 
 
 
 
 
 
 
23462
 
23463
- const onBrowseAll = () => {
23464
- setInserterIsOpened({
23465
- rootClientId,
23466
- insertionIndex
23467
- });
23468
- };
 
 
 
 
23469
 
23470
- return (0,external_wp_element_namespaceObject.createElement)("div", {
23471
- className: classnames_default()('block-editor-inserter__quick-inserter', {
23472
- 'has-search': showSearch,
23473
- 'has-expand': setInserterIsOpened
23474
- })
23475
- }, showSearch && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SearchControl, {
23476
- className: "block-editor-inserter__search",
23477
- value: filterValue,
23478
- onChange: value => {
23479
- setFilterValue(value);
23480
  },
23481
- label: (0,external_wp_i18n_namespaceObject.__)('Search for blocks and patterns'),
23482
- placeholder: (0,external_wp_i18n_namespaceObject.__)('Search')
23483
- }), (0,external_wp_element_namespaceObject.createElement)("div", {
23484
- className: "block-editor-inserter__quick-inserter-results"
23485
- }, (0,external_wp_element_namespaceObject.createElement)(search_results, {
23486
- filterValue: filterValue,
23487
- onSelect: onSelect,
23488
- rootClientId: rootClientId,
23489
- clientId: clientId,
23490
- isAppender: isAppender,
23491
- maxBlockPatterns: showPatterns ? SHOWN_BLOCK_PATTERNS : 0,
23492
- maxBlockTypes: quick_inserter_SHOWN_BLOCK_TYPES,
23493
- isDraggable: false
23494
- })), setInserterIsOpened && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
23495
- className: "block-editor-inserter__quick-inserter-expand",
23496
- onClick: onBrowseAll,
23497
- "aria-label": (0,external_wp_i18n_namespaceObject.__)('Browse all. This will open the main inserter panel in the editor toolbar.')
23498
- }, (0,external_wp_i18n_namespaceObject.__)('Browse all')));
23499
- }
23500
- //# sourceMappingURL=quick-inserter.js.map
23501
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/inserter/index.js
23502
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23503
 
 
 
 
23504
 
23505
- /**
23506
- * External dependencies
23507
- */
23508
 
23509
 
23510
  /**
@@ -23514,9 +22686,39 @@ function QuickInserter({
23514
 
23515
 
23516
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23517
 
23518
 
23519
 
 
 
 
23520
 
23521
 
23522
  /**
@@ -23525,277 +22727,176 @@ function QuickInserter({
23525
 
23526
 
23527
 
 
 
 
 
 
 
 
 
23528
 
 
 
 
23529
 
23530
- const defaultRenderToggle = ({
23531
- onToggle,
23532
- disabled,
23533
- isOpen,
23534
- blockTitle,
23535
- hasSingleBlockType,
23536
- toggleProps = {}
23537
- }) => {
23538
- let label;
23539
 
23540
- if (hasSingleBlockType) {
23541
- label = (0,external_wp_i18n_namespaceObject.sprintf)( // translators: %s: the name of the block when there is only one
23542
- (0,external_wp_i18n_namespaceObject._x)('Add %s', 'directly add the only allowed block'), blockTitle);
23543
- } else {
23544
- label = (0,external_wp_i18n_namespaceObject._x)('Add block', 'Generic label for block inserter button');
23545
- }
23546
 
23547
- const {
23548
- onClick,
23549
- ...rest
23550
- } = toggleProps; // Handle both onClick functions from the toggle and the parent component
23551
 
23552
- function handleClick(event) {
23553
- if (onToggle) {
23554
- onToggle(event);
23555
- }
23556
 
23557
- if (onClick) {
23558
- onClick(event);
23559
- }
23560
- }
23561
 
23562
- return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, _extends({
23563
- icon: library_plus,
23564
- label: label,
23565
- tooltipPosition: "bottom",
23566
- onClick: handleClick,
23567
- className: "block-editor-inserter__toggle",
23568
- "aria-haspopup": !hasSingleBlockType ? 'true' : false,
23569
- "aria-expanded": !hasSingleBlockType ? isOpen : false,
23570
- disabled: disabled
23571
- }, rest));
23572
- };
23573
 
23574
- class Inserter extends external_wp_element_namespaceObject.Component {
23575
- constructor() {
23576
- super(...arguments);
23577
- this.onToggle = this.onToggle.bind(this);
23578
- this.renderToggle = this.renderToggle.bind(this);
23579
- this.renderContent = this.renderContent.bind(this);
23580
  }
23581
 
23582
- onToggle(isOpen) {
23583
- const {
23584
- onToggle
23585
- } = this.props; // Surface toggle callback to parent component
23586
 
23587
- if (onToggle) {
23588
- onToggle(isOpen);
23589
- }
23590
- }
23591
- /**
23592
- * Render callback to display Dropdown toggle element.
23593
- *
23594
- * @param {Object} options
23595
- * @param {Function} options.onToggle Callback to invoke when toggle is
23596
- * pressed.
23597
- * @param {boolean} options.isOpen Whether dropdown is currently open.
23598
- *
23599
- * @return {WPElement} Dropdown toggle element.
23600
- */
23601
-
23602
-
23603
- renderToggle({
23604
- onToggle,
23605
- isOpen
23606
- }) {
23607
- const {
23608
- disabled,
23609
- blockTitle,
23610
- hasSingleBlockType,
23611
- toggleProps,
23612
- hasItems,
23613
- renderToggle = defaultRenderToggle
23614
- } = this.props;
23615
- return renderToggle({
23616
- onToggle,
23617
- isOpen,
23618
- disabled: disabled || !hasItems,
23619
- blockTitle,
23620
- hasSingleBlockType,
23621
- toggleProps
23622
- });
23623
- }
23624
- /**
23625
- * Render callback to display Dropdown content element.
23626
- *
23627
- * @param {Object} options
23628
- * @param {Function} options.onClose Callback to invoke when dropdown is
23629
- * closed.
23630
- *
23631
- * @return {WPElement} Dropdown content element.
23632
- */
23633
-
23634
-
23635
- renderContent({
23636
- onClose
23637
- }) {
23638
- const {
23639
- rootClientId,
23640
- clientId,
23641
- isAppender,
23642
- showInserterHelpPanel,
23643
- // This prop is experimental to give some time for the quick inserter to mature
23644
- // Feel free to make them stable after a few releases.
23645
- __experimentalIsQuick: isQuick
23646
- } = this.props;
23647
-
23648
- if (isQuick) {
23649
- return (0,external_wp_element_namespaceObject.createElement)(QuickInserter, {
23650
- onSelect: () => {
23651
- onClose();
23652
- },
23653
- rootClientId: rootClientId,
23654
- clientId: clientId,
23655
- isAppender: isAppender
23656
- });
23657
- }
23658
 
23659
- return (0,external_wp_element_namespaceObject.createElement)(menu, {
23660
- onSelect: () => {
23661
- onClose();
23662
- },
23663
- rootClientId: rootClientId,
23664
- clientId: clientId,
23665
- isAppender: isAppender,
23666
- showInserterHelpPanel: showInserterHelpPanel
23667
- });
23668
- }
23669
 
23670
- render() {
23671
- const {
23672
- position,
23673
- hasSingleBlockType,
23674
- insertOnlyAllowedBlock,
23675
- __experimentalIsQuick: isQuick,
23676
- onSelectOrClose
23677
- } = this.props;
23678
 
23679
- if (hasSingleBlockType) {
23680
- return this.renderToggle({
23681
- onToggle: insertOnlyAllowedBlock
23682
- });
23683
- }
23684
 
23685
- return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Dropdown, {
23686
- className: "block-editor-inserter",
23687
- contentClassName: classnames_default()('block-editor-inserter__popover', {
23688
- 'is-quick': isQuick
23689
- }),
23690
- position: position,
23691
- onToggle: this.onToggle,
23692
- expandOnMobile: true,
23693
- headerTitle: (0,external_wp_i18n_namespaceObject.__)('Add a block'),
23694
- renderToggle: this.renderToggle,
23695
- renderContent: this.renderContent,
23696
- onClose: onSelectOrClose
23697
- });
23698
- }
23699
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23700
  }
23701
 
23702
- /* harmony default export */ var inserter = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)((select, {
23703
- clientId,
23704
- rootClientId
23705
- }) => {
23706
- const {
23707
- getBlockRootClientId,
23708
- hasInserterItems,
23709
- __experimentalGetAllowedBlocks
23710
- } = select(store);
23711
- const {
23712
- getBlockVariations
23713
- } = select(external_wp_blocks_namespaceObject.store);
23714
- rootClientId = rootClientId || getBlockRootClientId(clientId) || undefined;
23715
 
23716
- const allowedBlocks = __experimentalGetAllowedBlocks(rootClientId);
23717
 
23718
- const hasSingleBlockType = (0,external_lodash_namespaceObject.size)(allowedBlocks) === 1 && (0,external_lodash_namespaceObject.size)(getBlockVariations(allowedBlocks[0].name, 'inserter')) === 0;
23719
- let allowedBlockType = false;
23720
 
23721
- if (hasSingleBlockType) {
23722
- allowedBlockType = allowedBlocks[0];
23723
- }
23724
 
23725
- return {
23726
- hasItems: hasInserterItems(rootClientId),
23727
- hasSingleBlockType,
23728
- blockTitle: allowedBlockType ? allowedBlockType.title : '',
23729
- allowedBlockType,
23730
- rootClientId
23731
- };
23732
- }), (0,external_wp_data_namespaceObject.withDispatch)((dispatch, ownProps, {
23733
- select
23734
- }) => {
23735
- return {
23736
- insertOnlyAllowedBlock() {
23737
- const {
23738
- rootClientId,
23739
- clientId,
23740
- isAppender,
23741
- hasSingleBlockType,
23742
- allowedBlockType,
23743
- onSelectOrClose
23744
- } = ownProps;
23745
 
23746
- if (!hasSingleBlockType) {
23747
- return;
23748
- }
 
 
 
 
23749
 
23750
- function getInsertionIndex() {
23751
- const {
23752
- getBlockIndex,
23753
- getBlockSelectionEnd,
23754
- getBlockOrder,
23755
- getBlockRootClientId
23756
- } = select(store); // If the clientId is defined, we insert at the position of the block.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23757
 
23758
- if (clientId) {
23759
- return getBlockIndex(clientId, rootClientId);
23760
- } // If there a selected block, we insert after the selected block.
23761
 
23762
 
23763
- const end = getBlockSelectionEnd();
 
 
23764
 
23765
- if (!isAppender && end && getBlockRootClientId(end) === rootClientId) {
23766
- return getBlockIndex(end, rootClientId) + 1;
23767
- } // Otherwise, we insert at the end of the current rootClientId
23768
 
23769
 
23770
- return getBlockOrder(rootClientId).length;
23771
- }
23772
 
23773
- const {
23774
- insertBlock
23775
- } = dispatch(store);
23776
- const blockToInsert = (0,external_wp_blocks_namespaceObject.createBlock)(allowedBlockType.name);
23777
- insertBlock(blockToInsert, getInsertionIndex(), rootClientId);
23778
 
23779
- if (onSelectOrClose) {
23780
- onSelectOrClose();
23781
- }
23782
 
23783
- const message = (0,external_wp_i18n_namespaceObject.sprintf)( // translators: %s: the name of the block that has been added
23784
- (0,external_wp_i18n_namespaceObject.__)('%s block added'), allowedBlockType.title);
23785
- (0,external_wp_a11y_namespaceObject.speak)(message);
23786
- }
23787
 
23788
- };
23789
- }), // The global inserter should always be visible, we are using ( ! isAppender && ! rootClientId && ! clientId ) as
23790
- // a way to detect the global Inserter.
23791
- (0,external_wp_compose_namespaceObject.ifCondition)(({
23792
- hasItems,
23793
- isAppender,
23794
- rootClientId,
23795
- clientId
23796
- }) => hasItems || !isAppender && !rootClientId && !clientId)])(Inserter));
 
 
 
 
23797
  //# sourceMappingURL=index.js.map
23798
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/default-block-appender/index.js
23799
 
23800
 
23801
  /**
@@ -23809,100 +22910,125 @@ class Inserter extends external_wp_element_namespaceObject.Component {
23809
 
23810
 
23811
 
23812
-
23813
-
23814
  /**
23815
  * Internal dependencies
23816
  */
23817
 
23818
 
23819
 
 
 
 
 
 
 
23820
  /**
23821
- * Zero width non-breaking space, used as padding for the paragraph when it is
23822
- * empty.
 
 
23823
  */
23824
 
23825
- const ZWNBSP = '\ufeff';
23826
- function DefaultBlockAppender({
23827
- isLocked,
23828
- isVisible,
23829
- onAppend,
23830
- showPrompt,
23831
- placeholder,
23832
- rootClientId
23833
  }) {
23834
- if (isLocked || !isVisible) {
23835
- return null;
23836
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
23837
 
23838
- const value = (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(placeholder) || (0,external_wp_i18n_namespaceObject.__)('Type / to choose a block');
 
 
 
 
 
23839
 
23840
- return (0,external_wp_element_namespaceObject.createElement)("div", {
23841
- "data-root-client-id": rootClientId || '',
23842
- className: classnames_default()('block-editor-default-block-appender', {
23843
- 'has-visible-prompt': showPrompt
23844
- })
23845
- }, (0,external_wp_element_namespaceObject.createElement)("p", {
23846
- tabIndex: "0" // Only necessary for `useCanvasClickRedirect` to consider it
23847
- // as a target. Ideally it should consider any tabbable target,
23848
- // but the inserter is rendered in place while it should be
23849
- // rendered in a popover, just like it does for an empty
23850
- // paragraph block.
23851
- ,
23852
- contentEditable: true,
23853
- suppressContentEditableWarning: true // We want this element to be styled as a paragraph by themes.
23854
- // eslint-disable-next-line jsx-a11y/no-noninteractive-element-to-interactive-role
23855
- ,
23856
- role: "button",
23857
- "aria-label": (0,external_wp_i18n_namespaceObject.__)('Add block') // The wp-block className is important for editor styles.
23858
- ,
23859
- className: "wp-block block-editor-default-block-appender__content",
23860
- onFocus: onAppend
23861
- }, showPrompt ? value : ZWNBSP), (0,external_wp_element_namespaceObject.createElement)(inserter, {
23862
- rootClientId: rootClientId,
23863
- position: "bottom right",
23864
- isAppender: true,
23865
- __experimentalIsQuick: true
23866
- }));
23867
- }
23868
- /* harmony default export */ var default_block_appender = ((0,external_wp_compose_namespaceObject.compose)((0,external_wp_data_namespaceObject.withSelect)((select, ownProps) => {
23869
- const {
23870
- getBlockCount,
23871
- getBlockName,
23872
- isBlockValid,
23873
- getSettings,
23874
- getTemplateLock
23875
- } = select(store);
23876
- const isEmpty = !getBlockCount(ownProps.rootClientId);
23877
- const isLastBlockDefault = getBlockName(ownProps.lastBlockClientId) === (0,external_wp_blocks_namespaceObject.getDefaultBlockName)();
23878
- const isLastBlockValid = isBlockValid(ownProps.lastBlockClientId);
23879
- const {
23880
- bodyPlaceholder
23881
- } = getSettings();
23882
- return {
23883
- isVisible: isEmpty || !isLastBlockDefault || !isLastBlockValid,
23884
- showPrompt: isEmpty,
23885
- isLocked: !!getTemplateLock(ownProps.rootClientId),
23886
- placeholder: bodyPlaceholder
23887
- };
23888
- }), (0,external_wp_data_namespaceObject.withDispatch)((dispatch, ownProps) => {
23889
- const {
23890
- insertDefaultBlock,
23891
- startTyping
23892
- } = dispatch(store);
23893
- return {
23894
- onAppend() {
23895
- const {
23896
- rootClientId
23897
- } = ownProps;
23898
- insertDefaultBlock(undefined, rootClientId);
23899
- startTyping();
23900
  }
23901
 
23902
- };
23903
- }))(DefaultBlockAppender));
23904
- //# sourceMappingURL=index.js.map
23905
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/button-block-appender/index.js
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23906
 
23907
 
23908
  /**
@@ -23916,93 +23042,120 @@ function DefaultBlockAppender({
23916
 
23917
 
23918
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23919
 
 
 
 
23920
 
23921
- /**
23922
- * Internal dependencies
23923
- */
 
 
 
23924
 
23925
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23926
 
23927
- function ButtonBlockAppender({
23928
- rootClientId,
23929
- className,
23930
- onFocus,
23931
- tabIndex
23932
- }, ref) {
23933
- return (0,external_wp_element_namespaceObject.createElement)(inserter, {
23934
- position: "bottom center",
23935
- rootClientId: rootClientId,
23936
- __experimentalIsQuick: true,
23937
- renderToggle: ({
23938
- onToggle,
23939
- disabled,
23940
- isOpen,
23941
- blockTitle,
23942
- hasSingleBlockType
23943
- }) => {
23944
- let label;
23945
 
23946
- if (hasSingleBlockType) {
23947
- label = (0,external_wp_i18n_namespaceObject.sprintf)( // translators: %s: the name of the block when there is only one
23948
- (0,external_wp_i18n_namespaceObject._x)('Add %s', 'directly add the only allowed block'), blockTitle);
23949
- } else {
23950
- label = (0,external_wp_i18n_namespaceObject._x)('Add block', 'Generic label for block inserter button');
23951
- }
23952
 
23953
- const isToggleButton = !hasSingleBlockType;
23954
- let inserterButton = (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
23955
- ref: ref,
23956
- onFocus: onFocus,
23957
- tabIndex: tabIndex,
23958
- className: classnames_default()(className, 'block-editor-button-block-appender'),
23959
- onClick: onToggle,
23960
- "aria-haspopup": isToggleButton ? 'true' : undefined,
23961
- "aria-expanded": isToggleButton ? isOpen : undefined,
23962
- disabled: disabled,
23963
- label: label
23964
- }, !hasSingleBlockType && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, {
23965
- as: "span"
23966
- }, label), (0,external_wp_element_namespaceObject.createElement)(icon, {
23967
- icon: library_plus
23968
- }));
23969
 
23970
- if (isToggleButton || hasSingleBlockType) {
23971
- inserterButton = (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Tooltip, {
23972
- text: label
23973
- }, inserterButton);
23974
- }
23975
 
23976
- return inserterButton;
23977
- },
23978
- isAppender: true
23979
- });
23980
- }
23981
  /**
23982
- * Use `ButtonBlockAppender` instead.
23983
- *
23984
- * @deprecated
23985
  */
23986
 
23987
 
23988
- const ButtonBlockerAppender = (0,external_wp_element_namespaceObject.forwardRef)((props, ref) => {
23989
- external_wp_deprecated_default()(`wp.blockEditor.ButtonBlockerAppender`, {
23990
- alternative: 'wp.blockEditor.ButtonBlockAppender'
23991
- });
23992
- return ButtonBlockAppender(props, ref);
23993
- });
23994
  /**
23995
- * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/button-block-appender/README.md
 
 
 
 
 
23996
  */
23997
 
23998
- /* harmony default export */ var button_block_appender = ((0,external_wp_element_namespaceObject.forwardRef)(ButtonBlockAppender));
23999
- //# sourceMappingURL=index.js.map
24000
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-list-appender/index.js
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24001
 
 
 
 
24002
 
24003
- /**
24004
- * External dependencies
24005
- */
24006
 
24007
 
24008
  /**
@@ -24011,6 +23164,7 @@ const ButtonBlockerAppender = (0,external_wp_element_namespaceObject.forwardRef)
24011
 
24012
 
24013
 
 
24014
  /**
24015
  * Internal dependencies
24016
  */
@@ -24019,354 +23173,295 @@ const ButtonBlockerAppender = (0,external_wp_element_namespaceObject.forwardRef)
24019
 
24020
 
24021
 
24022
- function BlockListAppender({
24023
- blockClientIds,
24024
- rootClientId,
24025
- canInsertDefaultBlock,
24026
- isLocked,
24027
- renderAppender: CustomAppender,
24028
- className,
24029
- selectedBlockClientId,
24030
- tagName: TagName = 'div'
24031
  }) {
24032
- if (isLocked || CustomAppender === false) {
24033
- return null;
24034
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24035
 
24036
- let appender;
 
 
 
 
24037
 
24038
- if (CustomAppender) {
24039
- // Prefer custom render prop if provided.
24040
- appender = (0,external_wp_element_namespaceObject.createElement)(CustomAppender, null);
24041
- } else {
24042
- const isDocumentAppender = !rootClientId;
24043
- const isParentSelected = selectedBlockClientId === rootClientId;
24044
- const isAnotherDefaultAppenderAlreadyDisplayed = selectedBlockClientId && !blockClientIds.includes(selectedBlockClientId);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24045
 
24046
- if (!isDocumentAppender && !isParentSelected && (!selectedBlockClientId || isAnotherDefaultAppenderAlreadyDisplayed)) {
24047
- return null;
24048
- }
24049
 
24050
- if (canInsertDefaultBlock) {
24051
- // Render the default block appender when renderAppender has not been
24052
- // provided and the context supports use of the default appender.
24053
- appender = (0,external_wp_element_namespaceObject.createElement)(default_block_appender, {
24054
- rootClientId: rootClientId,
24055
- lastBlockClientId: (0,external_lodash_namespaceObject.last)(blockClientIds)
24056
- });
24057
- } else {
24058
- // Fallback in the case no renderAppender has been provided and the
24059
- // default block can't be inserted.
24060
- appender = (0,external_wp_element_namespaceObject.createElement)(button_block_appender, {
24061
- rootClientId: rootClientId,
24062
- className: "block-list-appender__toggle"
24063
- });
24064
- }
24065
- }
24066
 
24067
- return (0,external_wp_element_namespaceObject.createElement)(TagName // A `tabIndex` is used on the wrapping `div` element in order to
24068
- // force a focus event to occur when an appender `button` element
24069
- // is clicked. In some browsers (Firefox, Safari), button clicks do
24070
- // not emit a focus event, which could cause this event to propagate
24071
- // unexpectedly. The `tabIndex` ensures that the interaction is
24072
- // captured as a focus, without also adding an extra tab stop.
24073
- //
24074
- // See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus
24075
- , {
24076
- tabIndex: -1,
24077
- className: classnames_default()('block-list-appender wp-block', className)
24078
- }, appender);
24079
- }
24080
 
24081
- /* harmony default export */ var block_list_appender = ((0,external_wp_data_namespaceObject.withSelect)((select, {
24082
- rootClientId
24083
- }) => {
24084
- const {
24085
- getBlockOrder,
24086
- canInsertBlockType,
24087
- getTemplateLock,
24088
- getSelectedBlockClientId
24089
- } = select(store);
24090
- return {
24091
- isLocked: !!getTemplateLock(rootClientId),
24092
- blockClientIds: getBlockOrder(rootClientId),
24093
- canInsertDefaultBlock: canInsertBlockType((0,external_wp_blocks_namespaceObject.getDefaultBlockName)(), rootClientId),
24094
- selectedBlockClientId: getSelectedBlockClientId()
24095
- };
24096
- })(BlockListAppender));
24097
- //# sourceMappingURL=index.js.map
24098
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/use-on-block-drop/index.js
24099
  /**
24100
  * WordPress dependencies
24101
  */
24102
 
24103
 
24104
 
 
24105
  /**
24106
  * Internal dependencies
24107
  */
24108
 
24109
 
24110
- /** @typedef {import('@wordpress/element').WPSyntheticEvent} WPSyntheticEvent */
24111
 
24112
- /**
24113
- * Retrieve the data for a block drop event.
24114
- *
24115
- * @param {WPSyntheticEvent} event The drop event.
24116
- *
24117
- * @return {Object} An object with block drag and drop data.
24118
- */
24119
 
24120
- function parseDropEvent(event) {
24121
- let result = {
24122
- srcRootClientId: null,
24123
- srcClientIds: null,
24124
- srcIndex: null,
24125
- type: null,
24126
- blocks: null
24127
- };
24128
 
24129
- if (!event.dataTransfer) {
24130
- return result;
24131
- }
 
 
 
 
24132
 
24133
- try {
24134
- result = Object.assign(result, JSON.parse(event.dataTransfer.getData('wp-blocks')));
24135
- } catch (err) {
24136
- return result;
24137
- }
24138
 
24139
- return result;
24140
- }
24141
- /**
24142
- * A function that returns an event handler function for block drop events.
24143
- *
24144
- * @param {string} targetRootClientId The root client id where the block(s) will be inserted.
24145
- * @param {number} targetBlockIndex The index where the block(s) will be inserted.
24146
- * @param {Function} getBlockIndex A function that gets the index of a block.
24147
- * @param {Function} getClientIdsOfDescendants A function that gets the client ids of descendant blocks.
24148
- * @param {Function} moveBlocksToPosition A function that moves blocks.
24149
- * @param {Function} insertBlocks A function that inserts blocks.
24150
- * @param {Function} clearSelectedBlock A function that clears block selection.
24151
- * @return {Function} The event handler for a block drop event.
24152
- */
 
24153
 
24154
- function onBlockDrop(targetRootClientId, targetBlockIndex, getBlockIndex, getClientIdsOfDescendants, moveBlocksToPosition, insertBlocks, clearSelectedBlock) {
24155
- return event => {
24156
- const {
24157
- srcRootClientId: sourceRootClientId,
24158
- srcClientIds: sourceClientIds,
24159
- type: dropType,
24160
- blocks
24161
- } = parseDropEvent(event); // If the user is inserting a block
24162
 
24163
- if (dropType === 'inserter') {
24164
- clearSelectedBlock();
24165
- insertBlocks(blocks, targetBlockIndex, targetRootClientId, true, null);
24166
- } // If the user is moving a block
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24167
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24168
 
24169
- if (dropType === 'block') {
24170
- const sourceBlockIndex = getBlockIndex(sourceClientIds[0], sourceRootClientId); // If the user is dropping to the same position, return early.
 
 
 
24171
 
24172
- if (sourceRootClientId === targetRootClientId && sourceBlockIndex === targetBlockIndex) {
24173
- return;
24174
- } // If the user is attempting to drop a block within its own
24175
- // nested blocks, return early as this would create infinite
24176
- // recursion.
24177
 
 
 
 
24178
 
24179
- if (sourceClientIds.includes(targetRootClientId) || getClientIdsOfDescendants(sourceClientIds).some(id => id === targetRootClientId)) {
24180
- return;
24181
- }
24182
 
24183
- const isAtSameLevel = sourceRootClientId === targetRootClientId;
24184
- const draggedBlockCount = sourceClientIds.length; // If the block is kept at the same level and moved downwards,
24185
- // subtract to take into account that the blocks being dragged
24186
- // were removed from the block list above the insertion point.
24187
 
24188
- const insertIndex = isAtSameLevel && sourceBlockIndex < targetBlockIndex ? targetBlockIndex - draggedBlockCount : targetBlockIndex;
24189
- moveBlocksToPosition(sourceClientIds, sourceRootClientId, targetRootClientId, insertIndex);
24190
- }
24191
- };
 
 
 
24192
  }
24193
- /**
24194
- * A function that returns an event handler function for block-related file drop events.
24195
- *
24196
- * @param {string} targetRootClientId The root client id where the block(s) will be inserted.
24197
- * @param {number} targetBlockIndex The index where the block(s) will be inserted.
24198
- * @param {boolean} hasUploadPermissions Whether the user has upload permissions.
24199
- * @param {Function} updateBlockAttributes A function that updates a block's attributes.
24200
- * @param {Function} canInsertBlockType A function that returns checks whether a block type can be inserted.
24201
- * @param {Function} insertBlocks A function that inserts blocks.
24202
- *
24203
- * @return {Function} The event handler for a block-related file drop event.
24204
- */
24205
 
24206
- function onFilesDrop(targetRootClientId, targetBlockIndex, hasUploadPermissions, updateBlockAttributes, canInsertBlockType, insertBlocks) {
24207
- return files => {
24208
- if (!hasUploadPermissions) {
24209
- return;
24210
- }
24211
 
24212
- const transformation = (0,external_wp_blocks_namespaceObject.findTransform)((0,external_wp_blocks_namespaceObject.getBlockTransforms)('from'), transform => transform.type === 'files' && canInsertBlockType(transform.blockName, targetRootClientId) && transform.isMatch(files));
24213
 
24214
- if (transformation) {
24215
- const blocks = transformation.transform(files, updateBlockAttributes);
24216
- insertBlocks(blocks, targetBlockIndex, targetRootClientId);
24217
- }
24218
- };
24219
- }
24220
  /**
24221
- * A function that returns an event handler function for block-related HTML drop events.
24222
- *
24223
- * @param {string} targetRootClientId The root client id where the block(s) will be inserted.
24224
- * @param {number} targetBlockIndex The index where the block(s) will be inserted.
24225
- * @param {Function} insertBlocks A function that inserts blocks.
24226
- *
24227
- * @return {Function} The event handler for a block-related HTML drop event.
24228
  */
24229
 
24230
- function onHTMLDrop(targetRootClientId, targetBlockIndex, insertBlocks) {
24231
- return HTML => {
24232
- const blocks = (0,external_wp_blocks_namespaceObject.pasteHandler)({
24233
- HTML,
24234
- mode: 'BLOCKS'
24235
- });
24236
 
24237
- if (blocks.length) {
24238
- insertBlocks(blocks, targetBlockIndex, targetRootClientId);
24239
- }
24240
- };
24241
- }
24242
  /**
24243
- * A React hook for handling block drop events.
24244
- *
24245
- * @param {string} targetRootClientId The root client id where the block(s) will be inserted.
24246
- * @param {number} targetBlockIndex The index where the block(s) will be inserted.
24247
- *
24248
- * @return {Object} An object that contains the event handlers `onDrop`, `onFilesDrop` and `onHTMLDrop`.
24249
  */
24250
 
24251
- function useOnBlockDrop(targetRootClientId, targetBlockIndex) {
24252
- const hasUploadPermissions = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).getSettings().mediaUpload, []);
24253
- const {
24254
- canInsertBlockType,
24255
- getBlockIndex,
24256
- getClientIdsOfDescendants
24257
- } = (0,external_wp_data_namespaceObject.useSelect)(store);
24258
- const {
24259
- insertBlocks,
24260
- moveBlocksToPosition,
24261
- updateBlockAttributes,
24262
- clearSelectedBlock
24263
- } = (0,external_wp_data_namespaceObject.useDispatch)(store);
24264
 
24265
- const _onDrop = onBlockDrop(targetRootClientId, targetBlockIndex, getBlockIndex, getClientIdsOfDescendants, moveBlocksToPosition, insertBlocks, clearSelectedBlock);
24266
 
24267
- const _onFilesDrop = onFilesDrop(targetRootClientId, targetBlockIndex, hasUploadPermissions, updateBlockAttributes, canInsertBlockType, insertBlocks);
24268
 
24269
- const _onHTMLDrop = onHTMLDrop(targetRootClientId, targetBlockIndex, insertBlocks);
24270
 
24271
- return event => {
24272
- const files = (0,external_wp_dom_namespaceObject.getFilesFromDataTransfer)(event.dataTransfer);
24273
- const html = event.dataTransfer.getData('text/html');
24274
 
24275
- if (files.length) {
24276
- _onFilesDrop(files);
24277
- } else if (html) {
24278
- _onHTMLDrop(html);
24279
- } else {
24280
- _onDrop(event);
24281
- }
24282
- };
24283
- }
24284
- //# sourceMappingURL=index.js.map
24285
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/utils/math.js
24286
- /**
24287
- * A string representing the name of an edge.
24288
- *
24289
- * @typedef {'top'|'right'|'bottom'|'left'} WPEdgeName
24290
- */
24291
 
24292
- /**
24293
- * @typedef {Object} WPPoint
24294
- * @property {number} x The horizontal position.
24295
- * @property {number} y The vertical position.
24296
- */
 
 
 
 
 
 
 
 
24297
 
24298
  /**
24299
- * Given a point, a DOMRect and the name of an edge, returns the distance to
24300
- * that edge of the rect.
24301
- *
24302
- * This function works for edges that are horizontal or vertical (e.g. not
24303
- * rotated), the following terms are used so that the function works in both
24304
- * orientations:
24305
  *
24306
- * - Forward, meaning the axis running horizontally when an edge is vertical
24307
- * and vertically when an edge is horizontal.
24308
- * - Lateral, meaning the axis running vertically when an edge is vertical
24309
- * and horizontally when an edge is horizontal.
24310
  *
24311
- * @param {WPPoint} point The point to measure distance from.
24312
- * @param {DOMRect} rect A DOM Rect containing edge positions.
24313
- * @param {WPEdgeName} edge The edge to measure to.
24314
  */
24315
- function getDistanceFromPointToEdge(point, rect, edge) {
24316
- const isHorizontal = edge === 'top' || edge === 'bottom';
24317
- const {
24318
- x,
24319
- y
24320
- } = point;
24321
- const pointLateralPosition = isHorizontal ? x : y;
24322
- const pointForwardPosition = isHorizontal ? y : x;
24323
- const edgeStart = isHorizontal ? rect.left : rect.top;
24324
- const edgeEnd = isHorizontal ? rect.right : rect.bottom;
24325
- const edgeForwardPosition = rect[edge]; // Measure the straight line distance to the edge of the rect, when the
24326
- // point is adjacent to the edge.
24327
- // Else, if the point is positioned diagonally to the edge of the rect,
24328
- // measure diagonally to the nearest corner that the edge meets.
24329
-
24330
- let edgeLateralPosition;
24331
 
24332
- if (pointLateralPosition >= edgeStart && pointLateralPosition <= edgeEnd) {
24333
- edgeLateralPosition = pointLateralPosition;
24334
- } else if (pointLateralPosition < edgeEnd) {
24335
- edgeLateralPosition = edgeStart;
24336
- } else {
24337
- edgeLateralPosition = edgeEnd;
24338
- }
24339
 
24340
- return Math.sqrt((pointLateralPosition - edgeLateralPosition) ** 2 + (pointForwardPosition - edgeForwardPosition) ** 2);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24341
  }
 
 
 
24342
  /**
24343
- * Given a point, a DOMRect and a list of allowed edges returns the name of and
24344
- * distance to the nearest edge.
24345
- *
24346
- * @param {WPPoint} point The point to measure distance from.
24347
- * @param {DOMRect} rect A DOM Rect containing edge positions.
24348
- * @param {WPEdgeName[]} allowedEdges A list of the edges included in the
24349
- * calculation. Defaults to all edges.
24350
- *
24351
- * @return {[number, string]} An array where the first value is the distance
24352
- * and a second is the edge name.
24353
  */
24354
 
24355
- function getDistanceToNearestEdge(point, rect, allowedEdges = ['top', 'bottom', 'left', 'right']) {
24356
- let candidateDistance;
24357
- let candidateEdge;
24358
- allowedEdges.forEach(edge => {
24359
- const distance = getDistanceFromPointToEdge(point, rect, edge);
 
 
 
 
 
 
24360
 
24361
- if (candidateDistance === undefined || distance < candidateDistance) {
24362
- candidateDistance = distance;
24363
- candidateEdge = edge;
24364
- }
24365
- });
24366
- return [candidateDistance, candidateEdge];
24367
- }
24368
- //# sourceMappingURL=math.js.map
24369
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/use-block-drop-zone/index.js
24370
  /**
24371
  * WordPress dependencies
24372
  */
@@ -24374,169 +23469,272 @@ function getDistanceToNearestEdge(point, rect, allowedEdges = ['top', 'bottom',
24374
 
24375
 
24376
 
 
 
24377
  /**
24378
  * Internal dependencies
24379
  */
24380
 
24381
 
24382
-
24383
-
24384
- /** @typedef {import('../../utils/math').WPPoint} WPPoint */
24385
-
24386
  /**
24387
- * The orientation of a block list.
24388
  *
24389
- * @typedef {'horizontal'|'vertical'|undefined} WPBlockListOrientation
 
 
 
 
 
 
 
 
24390
  */
24391
 
24392
  /**
24393
- * Given a list of block DOM elements finds the index that a block should be dropped
24394
- * at.
24395
- *
24396
- * @param {Element[]} elements Array of DOM elements that represent each block in a block list.
24397
- * @param {WPPoint} position The position of the item being dragged.
24398
- * @param {WPBlockListOrientation} orientation The orientation of a block list.
24399
  *
24400
- * @return {number|undefined} The block index that's closest to the drag position.
 
24401
  */
24402
 
24403
- function getNearestBlockIndex(elements, position, orientation) {
24404
- const allowedEdges = orientation === 'horizontal' ? ['left', 'right'] : ['top', 'bottom'];
24405
- const isRightToLeft = (0,external_wp_i18n_namespaceObject.isRTL)();
24406
- let candidateIndex;
24407
- let candidateDistance;
24408
- elements.forEach((element, index) => {
24409
- const rect = element.getBoundingClientRect();
24410
- const [distance, edge] = getDistanceToNearestEdge(position, rect, allowedEdges);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24411
 
24412
- if (candidateDistance === undefined || distance < candidateDistance) {
24413
- // If the user is dropping to the trailing edge of the block
24414
- // add 1 to the index to represent dragging after.
24415
- // Take RTL languages into account where the left edge is
24416
- // the trailing edge.
24417
- const isTrailingEdge = edge === 'bottom' || !isRightToLeft && edge === 'right' || isRightToLeft && edge === 'left';
24418
- const offset = isTrailingEdge ? 1 : 0; // Update the currently known best candidate.
24419
 
24420
- candidateDistance = distance;
24421
- candidateIndex = index + offset;
 
 
 
 
 
 
 
 
 
 
24422
  }
24423
- });
24424
- return candidateIndex;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24425
  }
 
 
 
 
24426
  /**
24427
- * @typedef {Object} WPBlockDropZoneConfig
24428
- * @property {string} rootClientId The root client id for the block list.
24429
  */
 
 
 
 
 
24430
 
 
 
 
 
 
 
 
24431
  /**
24432
- * A React hook that can be used to make a block list handle drag and drop.
24433
  *
24434
- * @param {WPBlockDropZoneConfig} dropZoneConfig configuration data for the drop zone.
 
 
24435
  */
24436
 
24437
- function useBlockDropZone({
24438
- // An undefined value represents a top-level block. Default to an empty
24439
- // string for this so that `targetRootClientId` can be easily compared to
24440
- // values returned by the `getRootBlockClientId` selector, which also uses
24441
- // an empty string to represent top-level blocks.
24442
- rootClientId: targetRootClientId = ''
24443
- } = {}) {
24444
- const [targetBlockIndex, setTargetBlockIndex] = (0,external_wp_element_namespaceObject.useState)(null);
24445
- const isLockedAll = (0,external_wp_data_namespaceObject.useSelect)(select => {
24446
- const {
24447
- getTemplateLock
24448
- } = select(store);
24449
- return getTemplateLock(targetRootClientId) === 'all';
24450
- }, [targetRootClientId]);
24451
- const {
24452
- getBlockListSettings
24453
- } = (0,external_wp_data_namespaceObject.useSelect)(store);
24454
- const {
24455
- showInsertionPoint,
24456
- hideInsertionPoint
24457
- } = (0,external_wp_data_namespaceObject.useDispatch)(store);
24458
- const onBlockDrop = useOnBlockDrop(targetRootClientId, targetBlockIndex);
24459
- const throttled = (0,external_wp_compose_namespaceObject.useThrottle)((0,external_wp_element_namespaceObject.useCallback)((event, currentTarget) => {
24460
- var _getBlockListSettings;
24461
 
24462
- const blockElements = Array.from(currentTarget.children).filter( // Ensure the element is a block. It should have the `wp-block` class.
24463
- element => element.classList.contains('wp-block'));
24464
- const targetIndex = getNearestBlockIndex(blockElements, {
24465
- x: event.clientX,
24466
- y: event.clientY
24467
- }, (_getBlockListSettings = getBlockListSettings(targetRootClientId)) === null || _getBlockListSettings === void 0 ? void 0 : _getBlockListSettings.orientation);
24468
- setTargetBlockIndex(targetIndex === undefined ? 0 : targetIndex);
24469
 
24470
- if (targetIndex !== null) {
24471
- showInsertionPoint(targetRootClientId, targetIndex);
24472
- }
24473
- }, []), 200);
24474
- return (0,external_wp_compose_namespaceObject.__experimentalUseDropZone)({
24475
- isDisabled: isLockedAll,
24476
- onDrop: onBlockDrop,
24477
 
24478
- onDragOver(event) {
24479
- // `currentTarget` is only available while the event is being
24480
- // handled, so get it now and pass it to the thottled function.
24481
- // https://developer.mozilla.org/en-US/docs/Web/API/Event/currentTarget
24482
- throttled(event, event.currentTarget);
24483
- },
 
 
 
 
24484
 
24485
- onDragLeave() {
24486
- throttled.cancel();
24487
- hideInsertionPoint();
24488
- setTargetBlockIndex(null);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24489
  },
 
 
24490
 
24491
- onDragEnd() {
24492
- throttled.cancel();
24493
- hideInsertionPoint();
24494
- setTargetBlockIndex(null);
24495
  }
24496
-
24497
- });
24498
- }
24499
- //# sourceMappingURL=index.js.map
24500
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-tools/use-popover-scroll.js
24501
  /**
24502
- * WordPress dependencies
 
 
 
 
 
 
24503
  */
24504
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24505
  /**
24506
- * Allow scrolling "through" popovers over the canvas. This is only called for
24507
- * as long as the pointer is over a popover. Do not use React events because it
24508
- * will bubble through portals.
24509
  *
24510
- * @param {Object} scrollableRef
 
 
 
 
24511
  */
24512
 
24513
- function usePopoverScroll(scrollableRef) {
24514
- return (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
24515
- if (!scrollableRef) {
24516
- return;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24517
  }
 
24518
 
24519
- function onWheel(event) {
24520
- const {
24521
- deltaX,
24522
- deltaY
24523
- } = event;
24524
- scrollableRef.current.scrollBy(deltaX, deltaY);
24525
- } // Tell the browser that we do not call event.preventDefault
24526
- // See https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#improving_scrolling_performance_with_passive_listeners
24527
 
 
 
 
24528
 
24529
- const options = {
24530
- passive: true
24531
- };
24532
- node.addEventListener('wheel', onWheel, options);
24533
- return () => {
24534
- node.removeEventListener('wheel', onWheel, options);
24535
- };
24536
- }, [scrollableRef]);
24537
  }
24538
- //# sourceMappingURL=use-popover-scroll.js.map
24539
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-tools/insertion-point.js
24540
 
24541
 
24542
  /**
@@ -24551,6 +23749,7 @@ function usePopoverScroll(scrollableRef) {
24551
 
24552
 
24553
 
 
24554
  /**
24555
  * Internal dependencies
24556
  */
@@ -24559,502 +23758,434 @@ function usePopoverScroll(scrollableRef) {
24559
 
24560
 
24561
 
24562
- const InsertionPointOpenRef = (0,external_wp_element_namespaceObject.createContext)();
24563
 
24564
- function InsertionPointPopover({
24565
- __unstablePopoverSlot,
24566
- __unstableContentRef
24567
- }) {
24568
- const {
24569
- selectBlock
24570
- } = (0,external_wp_data_namespaceObject.useDispatch)(store);
24571
- const openRef = (0,external_wp_element_namespaceObject.useContext)(InsertionPointOpenRef);
24572
- const ref = (0,external_wp_element_namespaceObject.useRef)();
24573
- const {
24574
- orientation,
24575
- previousClientId,
24576
- nextClientId,
24577
- rootClientId,
24578
- isInserterShown
24579
- } = (0,external_wp_data_namespaceObject.useSelect)(select => {
24580
- var _getBlockListSettings;
24581
 
24582
- const {
24583
- getBlockOrder,
24584
- getBlockListSettings,
24585
- getBlockInsertionPoint,
24586
- isBlockBeingDragged,
24587
- getPreviousBlockClientId,
24588
- getNextBlockClientId
24589
- } = select(store);
24590
- const insertionPoint = getBlockInsertionPoint();
24591
- const order = getBlockOrder(insertionPoint.rootClientId);
24592
 
24593
- if (!order.length) {
24594
- return {};
24595
- }
24596
 
24597
- let _previousClientId = order[insertionPoint.index - 1];
24598
- let _nextClientId = order[insertionPoint.index];
24599
 
24600
- while (isBlockBeingDragged(_previousClientId)) {
24601
- _previousClientId = getPreviousBlockClientId(_previousClientId);
24602
- }
24603
 
24604
- while (isBlockBeingDragged(_nextClientId)) {
24605
- _nextClientId = getNextBlockClientId(_nextClientId);
24606
- }
 
 
 
 
24607
 
24608
- return {
24609
- previousClientId: _previousClientId,
24610
- nextClientId: _nextClientId,
24611
- orientation: ((_getBlockListSettings = getBlockListSettings(insertionPoint.rootClientId)) === null || _getBlockListSettings === void 0 ? void 0 : _getBlockListSettings.orientation) || 'vertical',
24612
- rootClientId: insertionPoint.rootClientId,
24613
- isInserterShown: insertionPoint === null || insertionPoint === void 0 ? void 0 : insertionPoint.__unstableWithInserter
24614
- };
24615
- }, []);
24616
- const previousElement = useBlockElement(previousClientId);
24617
- const nextElement = useBlockElement(nextClientId);
24618
- const style = (0,external_wp_element_namespaceObject.useMemo)(() => {
24619
- if (!previousElement && !nextElement) {
24620
- return {};
24621
- }
24622
 
24623
- const previousRect = previousElement ? previousElement.getBoundingClientRect() : null;
24624
- const nextRect = nextElement ? nextElement.getBoundingClientRect() : null;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24625
 
24626
- if (orientation === 'vertical') {
24627
- return {
24628
- width: previousElement ? previousElement.offsetWidth : nextElement.offsetWidth,
24629
- height: nextRect && previousRect ? nextRect.top - previousRect.bottom : 0
24630
- };
24631
  }
24632
 
24633
- let width = 0;
24634
-
24635
- if (previousRect && nextRect) {
24636
- width = (0,external_wp_i18n_namespaceObject.isRTL)() ? previousRect.left - nextRect.right : nextRect.left - previousRect.right;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24637
  }
24638
 
24639
- return {
24640
- width,
24641
- height: previousElement ? previousElement.offsetHeight : nextElement.offsetHeight
24642
- };
24643
- }, [previousElement, nextElement]);
24644
- const getAnchorRect = (0,external_wp_element_namespaceObject.useCallback)(() => {
24645
- if (!previousElement && !nextElement) {
24646
- return {};
24647
  }
24648
 
24649
- const {
24650
- ownerDocument
24651
- } = previousElement || nextElement;
24652
- const previousRect = previousElement ? previousElement.getBoundingClientRect() : null;
24653
- const nextRect = nextElement ? nextElement.getBoundingClientRect() : null;
24654
 
24655
- if (orientation === 'vertical') {
24656
- if ((0,external_wp_i18n_namespaceObject.isRTL)()) {
24657
- return {
24658
- top: previousRect ? previousRect.bottom : nextRect.top,
24659
- left: previousRect ? previousRect.right : nextRect.right,
24660
- right: previousRect ? previousRect.left : nextRect.left,
24661
- bottom: nextRect ? nextRect.top : previousRect.bottom,
24662
- ownerDocument
24663
- };
24664
- }
24665
 
24666
- return {
24667
- top: previousRect ? previousRect.bottom : nextRect.top,
24668
- left: previousRect ? previousRect.left : nextRect.left,
24669
- right: previousRect ? previousRect.right : nextRect.right,
24670
- bottom: nextRect ? nextRect.top : previousRect.bottom,
24671
- ownerDocument
24672
- };
24673
- }
24674
 
24675
- if ((0,external_wp_i18n_namespaceObject.isRTL)()) {
24676
- return {
24677
- top: previousRect ? previousRect.top : nextRect.top,
24678
- left: previousRect ? previousRect.left : nextRect.right,
24679
- right: nextRect ? nextRect.right : previousRect.left,
24680
- bottom: previousRect ? previousRect.bottom : nextRect.bottom,
24681
- ownerDocument
24682
- };
24683
- }
24684
 
24685
- return {
24686
- top: previousRect ? previousRect.top : nextRect.top,
24687
- left: previousRect ? previousRect.right : nextRect.left,
24688
- right: nextRect ? nextRect.left : previousRect.right,
24689
- bottom: previousRect ? previousRect.bottom : nextRect.bottom,
24690
- ownerDocument
24691
- };
24692
- }, [previousElement, nextElement]);
24693
- const popoverScrollRef = usePopoverScroll(__unstableContentRef);
24694
- const className = classnames_default()('block-editor-block-list__insertion-point', 'is-' + orientation);
24695
 
24696
- function onClick(event) {
24697
- if (event.target === ref.current && nextClientId) {
24698
- selectBlock(nextClientId, -1);
24699
- }
24700
- }
24701
 
24702
- function onFocus(event) {
24703
- // Only handle click on the wrapper specifically, and not an event
24704
- // bubbled from the inserter itself.
24705
- if (event.target !== ref.current) {
24706
- openRef.current = true;
24707
- }
24708
- } // Only show the in-between inserter between blocks, so when there's a
24709
- // previous and a next element.
24710
 
 
 
 
 
 
24711
 
24712
- const showInsertionPointInserter = previousElement && nextElement && isInserterShown;
24713
- /* eslint-disable jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */
24714
- // While ideally it would be enough to capture the
24715
- // bubbling focus event from the Inserter, due to the
24716
- // characteristics of click focusing of `button`s in
24717
- // Firefox and Safari, it is not reliable.
24718
- //
24719
- // See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus
24720
 
24721
- return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Popover, {
24722
- ref: popoverScrollRef,
24723
- noArrow: true,
24724
- animate: false,
24725
- getAnchorRect: getAnchorRect,
24726
- focusOnMount: false,
24727
- className: "block-editor-block-list__insertion-point-popover" // Render in the old slot if needed for backward compatibility,
24728
- // otherwise render in place (not in the the default popover slot).
24729
- ,
24730
- __unstableSlotName: __unstablePopoverSlot || null
24731
- }, (0,external_wp_element_namespaceObject.createElement)("div", {
24732
- ref: ref,
24733
- tabIndex: -1,
24734
- onClick: onClick,
24735
- onFocus: onFocus,
24736
- className: classnames_default()(className, {
24737
- 'is-with-inserter': showInsertionPointInserter
24738
- }),
24739
- style: style
24740
- }, (0,external_wp_element_namespaceObject.createElement)("div", {
24741
- className: "block-editor-block-list__insertion-point-indicator"
24742
- }), showInsertionPointInserter && (0,external_wp_element_namespaceObject.createElement)("div", {
24743
- className: classnames_default()('block-editor-block-list__insertion-point-inserter')
24744
- }, (0,external_wp_element_namespaceObject.createElement)(inserter, {
24745
- position: "bottom center",
24746
- clientId: nextClientId,
24747
- rootClientId: rootClientId,
24748
- __experimentalIsQuick: true,
24749
- onToggle: isOpen => {
24750
- openRef.current = isOpen;
24751
- },
24752
- onSelectOrClose: () => {
24753
- openRef.current = false;
24754
- }
24755
- }))));
24756
- /* eslint-enable jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */
24757
- }
24758
 
24759
- function InsertionPoint({
24760
  children,
24761
- __unstablePopoverSlot,
24762
- __unstableContentRef
 
24763
  }) {
24764
- const isVisible = (0,external_wp_data_namespaceObject.useSelect)(select => {
24765
- return select(store).isBlockInsertionPointVisible();
24766
- }, []);
24767
- return (0,external_wp_element_namespaceObject.createElement)(InsertionPointOpenRef.Provider, {
24768
- value: (0,external_wp_element_namespaceObject.useRef)(false)
24769
- }, isVisible && (0,external_wp_element_namespaceObject.createElement)(InsertionPointPopover, {
24770
- __unstablePopoverSlot: __unstablePopoverSlot,
24771
- __unstableContentRef: __unstableContentRef
24772
- }), children);
 
 
 
 
 
 
 
 
 
24773
  }
24774
- //# sourceMappingURL=insertion-point.js.map
24775
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-list/use-in-between-inserter.js
 
 
 
 
24776
  /**
24777
  * WordPress dependencies
24778
  */
24779
 
24780
 
24781
 
 
24782
  /**
24783
  * Internal dependencies
24784
  */
24785
 
24786
 
24787
 
24788
- function useInBetweenInserter() {
24789
- const openRef = (0,external_wp_element_namespaceObject.useContext)(InsertionPointOpenRef);
24790
- const hasReducedUI = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).getSettings().hasReducedUI, []);
24791
- const {
24792
- getBlockListSettings,
24793
- getBlockRootClientId,
24794
- getBlockIndex,
24795
- isBlockInsertionPointVisible,
24796
- isMultiSelecting,
24797
- getSelectedBlockClientIds,
24798
- getTemplateLock
24799
- } = (0,external_wp_data_namespaceObject.useSelect)(store);
24800
- const {
24801
- showInsertionPoint,
24802
- hideInsertionPoint
24803
- } = (0,external_wp_data_namespaceObject.useDispatch)(store);
24804
- return (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
24805
- if (hasReducedUI) {
24806
- return;
24807
- }
24808
-
24809
- function onMouseMove(event) {
24810
- var _getBlockListSettings;
24811
 
24812
- if (openRef.current) {
24813
- return;
24814
- }
24815
 
24816
- if (isMultiSelecting()) {
24817
- return;
24818
- }
24819
 
24820
- if (!event.target.classList.contains('block-editor-block-list__layout')) {
24821
- if (isBlockInsertionPointVisible()) {
24822
- hideInsertionPoint();
24823
- }
24824
 
24825
- return;
24826
- }
24827
 
24828
- let rootClientId;
24829
 
24830
- if (!event.target.classList.contains('is-root-container')) {
24831
- const blockElement = !!event.target.getAttribute('data-block') ? event.target : event.target.closest('[data-block]');
24832
- rootClientId = blockElement.getAttribute('data-block');
24833
- } // Don't set the insertion point if the template is locked.
24834
 
24835
 
24836
- if (getTemplateLock(rootClientId)) {
24837
- return;
24838
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24839
 
24840
- const orientation = ((_getBlockListSettings = getBlockListSettings(rootClientId)) === null || _getBlockListSettings === void 0 ? void 0 : _getBlockListSettings.orientation) || 'vertical';
24841
- const rect = event.target.getBoundingClientRect();
24842
- const offsetTop = event.clientY - rect.top;
24843
- const offsetLeft = event.clientX - rect.left;
24844
- const children = Array.from(event.target.children);
24845
- let element = children.find(blockEl => {
24846
- return blockEl.classList.contains('wp-block') && orientation === 'vertical' && blockEl.offsetTop > offsetTop || blockEl.classList.contains('wp-block') && orientation === 'horizontal' && blockEl.offsetLeft > offsetLeft;
24847
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24848
 
24849
- if (!element) {
24850
- return;
24851
- } // The block may be in an alignment wrapper, so check the first direct
24852
- // child if the element has no ID.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24853
 
 
 
 
24854
 
24855
- if (!element.id) {
24856
- element = element.firstElementChild;
24857
 
24858
- if (!element) {
24859
- return;
24860
- }
24861
- }
24862
 
24863
- const clientId = element.id.slice('block-'.length);
 
 
24864
 
24865
- if (!clientId) {
24866
- return;
24867
- } // Don't show the inserter when hovering above (conflicts with
24868
- // block toolbar) or inside selected block(s).
24869
 
24870
 
24871
- if (getSelectedBlockClientIds().includes(clientId)) {
24872
- return;
24873
- }
24874
 
24875
- const elementRect = element.getBoundingClientRect();
24876
 
24877
- if (orientation === 'horizontal' && (event.clientY > elementRect.bottom || event.clientY < elementRect.top) || orientation === 'vertical' && (event.clientX > elementRect.right || event.clientX < elementRect.left)) {
24878
- if (isBlockInsertionPointVisible()) {
24879
- hideInsertionPoint();
24880
- }
24881
 
24882
- return;
24883
- }
24884
 
24885
- const index = getBlockIndex(clientId, rootClientId); // Don't show the in-between inserter before the first block in
24886
- // the list (preserves the original behaviour).
24887
 
24888
- if (index === 0) {
24889
- if (isBlockInsertionPointVisible()) {
24890
- hideInsertionPoint();
24891
- }
24892
 
24893
- return;
24894
- }
24895
 
24896
- showInsertionPoint(rootClientId, index, {
24897
- __unstableWithInserter: true
24898
- });
24899
- }
24900
 
24901
- node.addEventListener('mousemove', onMouseMove);
24902
- return () => {
24903
- node.removeEventListener('mousemove', onMouseMove);
24904
- };
24905
- }, [openRef, getBlockListSettings, getBlockRootClientId, getBlockIndex, isBlockInsertionPointVisible, isMultiSelecting, showInsertionPoint, hideInsertionPoint, getSelectedBlockClientIds]);
24906
- }
24907
- //# sourceMappingURL=use-in-between-inserter.js.map
24908
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/utils/pre-parse-patterns.js
24909
- /**
24910
- * WordPress dependencies
24911
- */
24912
-
24913
-
24914
- /**
24915
- * Internal dependencies
24916
- */
24917
-
24918
-
24919
-
24920
- const requestIdleCallback = (() => {
24921
- if (typeof window === 'undefined') {
24922
- return callback => {
24923
- setTimeout(() => callback(Date.now()), 0);
 
 
 
 
 
 
 
 
 
 
24924
  };
24925
- }
24926
-
24927
- return window.requestIdleCallback || window.requestAnimationFrame;
24928
- })();
24929
-
24930
- const cancelIdleCallback = (() => {
24931
- if (typeof window === 'undefined') {
24932
- return clearTimeout;
24933
- }
24934
-
24935
- return window.cancelIdleCallback || window.cancelAnimationFrame;
24936
- })();
24937
-
24938
- function usePreParsePatterns() {
24939
- const patterns = (0,external_wp_data_namespaceObject.useSelect)(_select => _select(store).getSettings().__experimentalBlockPatterns, []);
24940
  (0,external_wp_element_namespaceObject.useEffect)(() => {
24941
- if (!(patterns !== null && patterns !== void 0 && patterns.length)) {
24942
- return;
24943
  }
 
 
24944
 
24945
- let handle;
24946
- let index = -1;
24947
-
24948
- const callback = () => {
24949
- index++;
 
24950
 
24951
- if (index >= patterns.length) {
24952
- return;
24953
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24954
 
24955
- (0,external_wp_data_namespaceObject.select)(store).__experimentalGetParsedPattern(patterns[index].name);
24956
 
24957
- handle = requestIdleCallback(callback);
24958
- };
24959
 
24960
- handle = requestIdleCallback(callback);
24961
- return () => cancelIdleCallback(handle);
24962
- }, [patterns]);
24963
- return null;
24964
- }
24965
- //# sourceMappingURL=pre-parse-patterns.js.map
24966
- ;// CONCATENATED MODULE: external ["wp","keyboardShortcuts"]
24967
- var external_wp_keyboardShortcuts_namespaceObject = window["wp"]["keyboardShortcuts"];
24968
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-draggable/use-scroll-when-dragging.js
24969
  /**
24970
- * WordPress dependencies
24971
  */
24972
 
24973
 
24974
- const SCROLL_INACTIVE_DISTANCE_PX = 50;
24975
- const SCROLL_INTERVAL_MS = 25;
24976
- const PIXELS_PER_SECOND_PER_PERCENTAGE = 1000;
24977
- const VELOCITY_MULTIPLIER = PIXELS_PER_SECOND_PER_PERCENTAGE * (SCROLL_INTERVAL_MS / 1000);
24978
  /**
24979
- * React hook that scrolls the scroll container when a block is being dragged.
24980
- *
24981
- * @return {Function[]} `startScrolling`, `scrollOnDragOver`, `stopScrolling`
24982
- * functions to be called in `onDragStart`, `onDragOver`
24983
- * and `onDragEnd` events respectively.
24984
  */
24985
 
24986
- function useScrollWhenDragging() {
24987
- const dragStartY = (0,external_wp_element_namespaceObject.useRef)(null);
24988
- const velocityY = (0,external_wp_element_namespaceObject.useRef)(null);
24989
- const scrollParentY = (0,external_wp_element_namespaceObject.useRef)(null);
24990
- const scrollEditorInterval = (0,external_wp_element_namespaceObject.useRef)(null); // Clear interval when unmounting.
24991
-
24992
- (0,external_wp_element_namespaceObject.useEffect)(() => () => {
24993
- if (scrollEditorInterval.current) {
24994
- clearInterval(scrollEditorInterval.current);
24995
- scrollEditorInterval.current = null;
24996
- }
24997
- }, []);
24998
- const startScrolling = (0,external_wp_element_namespaceObject.useCallback)(event => {
24999
- dragStartY.current = event.clientY; // Find nearest parent(s) to scroll.
25000
-
25001
- scrollParentY.current = (0,external_wp_dom_namespaceObject.getScrollContainer)(event.target);
25002
- scrollEditorInterval.current = setInterval(() => {
25003
- if (scrollParentY.current && velocityY.current) {
25004
- const newTop = scrollParentY.current.scrollTop + velocityY.current; // Setting `behavior: 'smooth'` as a scroll property seems to hurt performance.
25005
- // Better to use a small scroll interval.
25006
-
25007
- scrollParentY.current.scroll({
25008
- top: newTop
25009
- });
25010
- }
25011
- }, SCROLL_INTERVAL_MS);
25012
- }, []);
25013
- const scrollOnDragOver = (0,external_wp_element_namespaceObject.useCallback)(event => {
25014
- if (!scrollParentY.current) {
25015
- return;
25016
- }
25017
-
25018
- const scrollParentHeight = scrollParentY.current.offsetHeight;
25019
- const offsetDragStartPosition = dragStartY.current - scrollParentY.current.offsetTop;
25020
- const offsetDragPosition = event.clientY - scrollParentY.current.offsetTop;
25021
-
25022
- if (event.clientY > offsetDragStartPosition) {
25023
- // User is dragging downwards.
25024
- const moveableDistance = Math.max(scrollParentHeight - offsetDragStartPosition - SCROLL_INACTIVE_DISTANCE_PX, 0);
25025
- const dragDistance = Math.max(offsetDragPosition - offsetDragStartPosition - SCROLL_INACTIVE_DISTANCE_PX, 0);
25026
- const distancePercentage = dragDistance / moveableDistance;
25027
- velocityY.current = VELOCITY_MULTIPLIER * distancePercentage;
25028
- } else if (event.clientY < offsetDragStartPosition) {
25029
- // User is dragging upwards.
25030
- const moveableDistance = Math.max(offsetDragStartPosition - SCROLL_INACTIVE_DISTANCE_PX, 0);
25031
- const dragDistance = Math.max(offsetDragStartPosition - offsetDragPosition - SCROLL_INACTIVE_DISTANCE_PX, 0);
25032
- const distancePercentage = dragDistance / moveableDistance;
25033
- velocityY.current = -VELOCITY_MULTIPLIER * distancePercentage;
25034
- } else {
25035
- velocityY.current = 0;
25036
- }
25037
- }, []);
25038
-
25039
- const stopScrolling = () => {
25040
- dragStartY.current = null;
25041
- scrollParentY.current = null;
25042
 
25043
- if (scrollEditorInterval.current) {
25044
- clearInterval(scrollEditorInterval.current);
25045
- scrollEditorInterval.current = null;
25046
- }
25047
- };
25048
 
25049
- return [startScrolling, scrollOnDragOver, stopScrolling];
25050
- }
25051
- //# sourceMappingURL=use-scroll-when-dragging.js.map
25052
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-draggable/index.js
25053
 
25054
 
25055
- /**
25056
- * WordPress dependencies
25057
- */
25058
 
25059
 
25060
 
@@ -25067,344 +24198,387 @@ function useScrollWhenDragging() {
25067
 
25068
 
25069
 
25070
- const BlockDraggable = ({
25071
- children,
25072
- clientIds,
25073
- cloneClassname,
25074
- onDragStart,
25075
- onDragEnd
 
25076
  }) => {
25077
- const {
25078
- srcRootClientId,
25079
- isDraggable,
25080
- icon
25081
- } = (0,external_wp_data_namespaceObject.useSelect)(select => {
25082
- var _getBlockType;
 
 
25083
 
25084
- const {
25085
- getBlockRootClientId,
25086
- getTemplateLock,
25087
- getBlockName
25088
- } = select(store);
25089
- const rootClientId = getBlockRootClientId(clientIds[0]);
25090
- const templateLock = rootClientId ? getTemplateLock(rootClientId) : null;
25091
- const blockName = getBlockName(clientIds[0]);
25092
- return {
25093
- srcRootClientId: rootClientId,
25094
- isDraggable: 'all' !== templateLock,
25095
- icon: (_getBlockType = (0,external_wp_blocks_namespaceObject.getBlockType)(blockName)) === null || _getBlockType === void 0 ? void 0 : _getBlockType.icon
25096
- };
25097
- }, [clientIds]);
25098
- const isDragging = (0,external_wp_element_namespaceObject.useRef)(false);
25099
- const [startScrolling, scrollOnDragOver, stopScrolling] = useScrollWhenDragging();
25100
  const {
25101
- startDraggingBlocks,
25102
- stopDraggingBlocks
25103
- } = (0,external_wp_data_namespaceObject.useDispatch)(store); // Stop dragging blocks if the block draggable is unmounted
25104
 
25105
- (0,external_wp_element_namespaceObject.useEffect)(() => {
25106
- return () => {
25107
- if (isDragging.current) {
25108
- stopDraggingBlocks();
25109
- }
25110
- };
25111
- }, []);
25112
 
25113
- if (!isDraggable) {
25114
- return children({
25115
- isDraggable: false
25116
- });
25117
  }
25118
 
25119
- const transferData = {
25120
- type: 'block',
25121
- srcClientIds: clientIds,
25122
- srcRootClientId
25123
- };
25124
- return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Draggable, {
25125
- cloneClassname: cloneClassname,
25126
- __experimentalTransferDataType: "wp-blocks",
25127
- transferData: transferData,
25128
- onDragStart: event => {
25129
- startDraggingBlocks(clientIds);
25130
- isDragging.current = true;
25131
- startScrolling(event);
25132
 
25133
- if (onDragStart) {
25134
- onDragStart();
25135
- }
25136
- },
25137
- onDragOver: scrollOnDragOver,
25138
- onDragEnd: () => {
25139
- stopDraggingBlocks();
25140
- isDragging.current = false;
25141
- stopScrolling();
25142
 
25143
- if (onDragEnd) {
25144
- onDragEnd();
25145
- }
25146
- },
25147
- __experimentalDragComponent: (0,external_wp_element_namespaceObject.createElement)(BlockDraggableChip, {
25148
- count: clientIds.length,
25149
- icon: icon
25150
- })
25151
- }, ({
25152
- onDraggableStart,
25153
- onDraggableEnd
25154
- }) => {
25155
- return children({
25156
- draggable: true,
25157
- onDragStart: onDraggableStart,
25158
- onDragEnd: onDraggableEnd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25159
  });
25160
- });
25161
- };
 
 
 
 
 
 
 
 
25162
 
25163
- /* harmony default export */ var block_draggable = (BlockDraggable);
25164
- //# sourceMappingURL=index.js.map
25165
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-tools/block-selection-button.js
25166
 
 
 
 
 
 
 
 
 
 
 
 
 
25167
 
 
 
 
 
 
 
 
 
 
 
25168
 
25169
- /**
25170
- * External dependencies
25171
- */
 
 
 
 
 
 
 
25172
 
25173
- /**
25174
- * WordPress dependencies
25175
- */
 
 
 
 
 
25176
 
 
 
 
 
 
25177
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25178
 
 
25179
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25180
 
 
25181
 
 
 
25182
 
 
 
 
25183
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25184
 
 
 
 
25185
 
25186
- /**
25187
- * Internal dependencies
25188
- */
 
 
 
 
25189
 
 
 
 
25190
 
25191
 
 
25192
 
 
 
 
25193
 
25194
 
25195
- /**
25196
- * Block selection button component, displaying the label of the block. If the block
25197
- * descends from a root block, a button is displayed enabling the user to select
25198
- * the root block.
25199
- *
25200
- * @param {string} props Component props.
25201
- * @param {string} props.clientId Client ID of block.
25202
- *
25203
- * @return {WPComponent} The component to be rendered.
25204
- */
25205
-
25206
- function BlockSelectionButton({
25207
- clientId,
25208
- rootClientId,
25209
- blockElement
25210
- }) {
25211
- const blockInformation = useBlockDisplayInformation(clientId);
25212
- const selected = (0,external_wp_data_namespaceObject.useSelect)(select => {
25213
- var _getBlockListSettings;
25214
-
25215
- const {
25216
- __unstableGetBlockWithoutInnerBlocks,
25217
- getBlockIndex,
25218
- hasBlockMovingClientId,
25219
- getBlockListSettings
25220
- } = select(store);
25221
- const index = getBlockIndex(clientId, rootClientId);
25222
-
25223
- const {
25224
- name,
25225
- attributes
25226
- } = __unstableGetBlockWithoutInnerBlocks(clientId);
25227
-
25228
- const blockMovingMode = hasBlockMovingClientId();
25229
- return {
25230
- index,
25231
- name,
25232
- attributes,
25233
- blockMovingMode,
25234
- orientation: (_getBlockListSettings = getBlockListSettings(rootClientId)) === null || _getBlockListSettings === void 0 ? void 0 : _getBlockListSettings.orientation
25235
- };
25236
- }, [clientId, rootClientId]);
25237
- const {
25238
- index,
25239
- name,
25240
- attributes,
25241
- blockMovingMode,
25242
- orientation
25243
- } = selected;
25244
- const {
25245
- setNavigationMode,
25246
- removeBlock
25247
- } = (0,external_wp_data_namespaceObject.useDispatch)(store);
25248
- const ref = (0,external_wp_element_namespaceObject.useRef)();
25249
- const blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(name);
25250
- const label = (0,external_wp_blocks_namespaceObject.__experimentalGetAccessibleBlockLabel)(blockType, attributes, index + 1, orientation); // Focus the breadcrumb in navigation mode.
25251
 
25252
- (0,external_wp_element_namespaceObject.useEffect)(() => {
25253
- ref.current.focus();
25254
- (0,external_wp_a11y_namespaceObject.speak)(label);
25255
- }, [label]);
25256
- const {
25257
- hasBlockMovingClientId,
25258
- getBlockIndex,
25259
- getBlockRootClientId,
25260
- getClientIdsOfDescendants,
25261
- getSelectedBlockClientId,
25262
- getMultiSelectedBlocksEndClientId,
25263
- getPreviousBlockClientId,
25264
- getNextBlockClientId
25265
- } = (0,external_wp_data_namespaceObject.useSelect)(store);
25266
- const {
25267
- selectBlock,
25268
- clearSelectedBlock,
25269
- setBlockMovingClientId,
25270
- moveBlockToPosition
25271
- } = (0,external_wp_data_namespaceObject.useDispatch)(store);
25272
 
25273
- function onKeyDown(event) {
25274
- const {
25275
- keyCode
25276
- } = event;
25277
- const isUp = keyCode === external_wp_keycodes_namespaceObject.UP;
25278
- const isDown = keyCode === external_wp_keycodes_namespaceObject.DOWN;
25279
- const isLeft = keyCode === external_wp_keycodes_namespaceObject.LEFT;
25280
- const isRight = keyCode === external_wp_keycodes_namespaceObject.RIGHT;
25281
- const isTab = keyCode === external_wp_keycodes_namespaceObject.TAB;
25282
- const isEscape = keyCode === external_wp_keycodes_namespaceObject.ESCAPE;
25283
- const isEnter = keyCode === external_wp_keycodes_namespaceObject.ENTER;
25284
- const isSpace = keyCode === external_wp_keycodes_namespaceObject.SPACE;
25285
- const isShift = event.shiftKey;
25286
 
25287
- if (keyCode === external_wp_keycodes_namespaceObject.BACKSPACE || keyCode === external_wp_keycodes_namespaceObject.DELETE) {
25288
- removeBlock(clientId);
25289
- event.preventDefault();
25290
- return;
25291
  }
25292
 
25293
- const selectedBlockClientId = getSelectedBlockClientId();
25294
- const selectionEndClientId = getMultiSelectedBlocksEndClientId();
25295
- const selectionBeforeEndClientId = getPreviousBlockClientId(selectionEndClientId || selectedBlockClientId);
25296
- const selectionAfterEndClientId = getNextBlockClientId(selectionEndClientId || selectedBlockClientId);
25297
- const navigateUp = isTab && isShift || isUp;
25298
- const navigateDown = isTab && !isShift || isDown; // Move out of current nesting level (no effect if at root level).
25299
-
25300
- const navigateOut = isLeft; // Move into next nesting level (no effect if the current block has no innerBlocks).
 
 
 
25301
 
25302
- const navigateIn = isRight;
25303
- let focusedBlockUid;
25304
 
25305
- if (navigateUp) {
25306
- focusedBlockUid = selectionBeforeEndClientId;
25307
- } else if (navigateDown) {
25308
- focusedBlockUid = selectionAfterEndClientId;
25309
- } else if (navigateOut) {
25310
- var _getBlockRootClientId;
25311
 
25312
- focusedBlockUid = (_getBlockRootClientId = getBlockRootClientId(selectedBlockClientId)) !== null && _getBlockRootClientId !== void 0 ? _getBlockRootClientId : selectedBlockClientId;
25313
- } else if (navigateIn) {
25314
- var _getClientIdsOfDescen;
25315
 
25316
- focusedBlockUid = (_getClientIdsOfDescen = getClientIdsOfDescendants([selectedBlockClientId])[0]) !== null && _getClientIdsOfDescen !== void 0 ? _getClientIdsOfDescen : selectedBlockClientId;
25317
- }
25318
 
25319
- const startingBlockClientId = hasBlockMovingClientId();
25320
 
25321
- if (isEscape && startingBlockClientId && !event.defaultPrevented) {
25322
- setBlockMovingClientId(null);
25323
- event.preventDefault();
25324
- }
25325
 
25326
- if ((isEnter || isSpace) && startingBlockClientId) {
25327
- const sourceRoot = getBlockRootClientId(startingBlockClientId);
25328
- const destRoot = getBlockRootClientId(selectedBlockClientId);
25329
- const sourceBlockIndex = getBlockIndex(startingBlockClientId, sourceRoot);
25330
- let destinationBlockIndex = getBlockIndex(selectedBlockClientId, destRoot);
25331
 
25332
- if (sourceBlockIndex < destinationBlockIndex && sourceRoot === destRoot) {
25333
- destinationBlockIndex -= 1;
25334
- }
25335
 
25336
- moveBlockToPosition(startingBlockClientId, sourceRoot, destRoot, destinationBlockIndex);
25337
- selectBlock(startingBlockClientId);
25338
- setBlockMovingClientId(null);
25339
- }
25340
 
25341
- if (navigateDown || navigateUp || navigateOut || navigateIn) {
25342
- if (focusedBlockUid) {
25343
- event.preventDefault();
25344
- selectBlock(focusedBlockUid);
25345
- } else if (isTab && selectedBlockClientId) {
25346
- let nextTabbable;
25347
 
25348
- if (navigateDown) {
25349
- nextTabbable = external_wp_dom_namespaceObject.focus.tabbable.findNext(blockElement);
25350
 
25351
- if (!nextTabbable) {
25352
- nextTabbable = blockElement.ownerDocument.defaultView.frameElement;
25353
- nextTabbable = external_wp_dom_namespaceObject.focus.tabbable.findNext(nextTabbable);
25354
- }
25355
- } else {
25356
- nextTabbable = external_wp_dom_namespaceObject.focus.tabbable.findPrevious(blockElement);
25357
- }
25358
 
25359
- if (nextTabbable) {
25360
- event.preventDefault();
25361
- nextTabbable.focus();
25362
- clearSelectedBlock();
25363
- }
25364
- }
25365
- }
 
 
 
 
25366
  }
25367
 
25368
- const classNames = classnames_default()('block-editor-block-list__block-selection-button', {
25369
- 'is-block-moving-mode': !!blockMovingMode
25370
- });
25371
-
25372
- const dragHandleLabel = (0,external_wp_i18n_namespaceObject.__)('Drag');
25373
 
25374
  return (0,external_wp_element_namespaceObject.createElement)("div", {
25375
- className: classNames
25376
- }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Flex, {
25377
- justify: "center",
25378
- className: "block-editor-block-list__block-selection-button__content"
25379
- }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_element_namespaceObject.createElement)(BlockIcon, {
25380
- icon: blockInformation === null || blockInformation === void 0 ? void 0 : blockInformation.icon,
25381
- showColors: true
25382
- })), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_element_namespaceObject.createElement)(block_draggable, {
25383
- clientIds: [clientId]
25384
- }, draggableProps => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, _extends({
25385
- icon: drag_handle,
25386
- className: "block-selection-button_drag-handle",
25387
- "aria-hidden": "true",
25388
- label: dragHandleLabel // Should not be able to tab to drag handle as this
25389
- // button can only be used with a pointer device.
25390
  ,
25391
- tabIndex: "-1"
25392
- }, draggableProps)))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
25393
- ref: ref,
25394
- onClick: () => setNavigationMode(false),
25395
- onKeyDown: onKeyDown,
25396
- label: label,
25397
- className: "block-selection-button_select-button"
25398
- }, (0,external_wp_element_namespaceObject.createElement)(BlockTitle, {
25399
- clientId: clientId
25400
- })))));
 
 
 
 
 
25401
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25402
 
25403
- /* harmony default export */ var block_selection_button = (BlockSelectionButton);
25404
- //# sourceMappingURL=block-selection-button.js.map
25405
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/navigable-toolbar/index.js
 
25406
 
25407
 
 
 
 
25408
 
25409
  /**
25410
  * WordPress dependencies
@@ -25415,149 +24589,86 @@ function BlockSelectionButton({
25415
 
25416
 
25417
 
25418
- function hasOnlyToolbarItem(elements) {
25419
- const dataProp = 'toolbarItem';
25420
- return !elements.some(element => !(dataProp in element.dataset));
25421
- }
25422
-
25423
- function getAllToolbarItemsIn(container) {
25424
- return Array.from(container.querySelectorAll('[data-toolbar-item]'));
25425
- }
25426
-
25427
- function hasFocusWithin(container) {
25428
- return container.contains(container.ownerDocument.activeElement);
25429
- }
25430
-
25431
- function focusFirstTabbableIn(container) {
25432
- const [firstTabbable] = external_wp_dom_namespaceObject.focus.tabbable.find(container);
25433
 
25434
- if (firstTabbable) {
25435
- firstTabbable.focus();
25436
- }
25437
- }
25438
 
25439
- function useIsAccessibleToolbar(ref) {
25440
- /*
25441
- * By default, we'll assume the starting accessible state of the Toolbar
25442
- * is true, as it seems to be the most common case.
25443
- *
25444
- * Transitioning from an (initial) false to true state causes the
25445
- * <Toolbar /> component to mount twice, which is causing undesired
25446
- * side-effects. These side-effects appear to only affect certain
25447
- * E2E tests.
25448
- *
25449
- * This was initial discovered in this pull-request:
25450
- * https://github.com/WordPress/gutenberg/pull/23425
25451
- */
25452
- const initialAccessibleToolbarState = true; // By default, it's gonna render NavigableMenu. If all the tabbable elements
25453
- // inside the toolbar are ToolbarItem components (or derived components like
25454
- // ToolbarButton), then we can wrap them with the accessible Toolbar
25455
- // component.
25456
 
25457
- const [isAccessibleToolbar, setIsAccessibleToolbar] = (0,external_wp_element_namespaceObject.useState)(initialAccessibleToolbarState);
25458
- const determineIsAccessibleToolbar = (0,external_wp_element_namespaceObject.useCallback)(() => {
25459
- const tabbables = external_wp_dom_namespaceObject.focus.tabbable.find(ref.current);
25460
- const onlyToolbarItem = hasOnlyToolbarItem(tabbables);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25461
 
25462
- if (!onlyToolbarItem) {
25463
- external_wp_deprecated_default()('Using custom components as toolbar controls', {
25464
- since: '5.6',
25465
- alternative: 'ToolbarItem, ToolbarButton or ToolbarDropdownMenu components',
25466
- link: 'https://developer.wordpress.org/block-editor/components/toolbar-button/#inside-blockcontrols'
25467
- });
25468
- }
25469
 
25470
- setIsAccessibleToolbar(onlyToolbarItem);
25471
- }, []);
25472
- (0,external_wp_element_namespaceObject.useLayoutEffect)(() => {
25473
- // Toolbar buttons may be rendered asynchronously, so we use
25474
- // MutationObserver to check if the toolbar subtree has been modified
25475
- const observer = new window.MutationObserver(determineIsAccessibleToolbar);
25476
- observer.observe(ref.current, {
25477
- childList: true,
25478
- subtree: true
25479
- });
25480
- return () => observer.disconnect();
25481
- }, [isAccessibleToolbar]);
25482
- return isAccessibleToolbar;
25483
- }
 
 
25484
 
25485
- function useToolbarFocus(ref, focusOnMount, isAccessibleToolbar, defaultIndex, onIndexChange) {
25486
- // Make sure we don't use modified versions of this prop
25487
- const [initialFocusOnMount] = (0,external_wp_element_namespaceObject.useState)(focusOnMount);
25488
- const [initialIndex] = (0,external_wp_element_namespaceObject.useState)(defaultIndex);
25489
- const focusToolbar = (0,external_wp_element_namespaceObject.useCallback)(() => {
25490
- focusFirstTabbableIn(ref.current);
25491
- }, []); // Focus on toolbar when pressing alt+F10 when the toolbar is visible
25492
 
25493
- (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/block-editor/focus-toolbar', focusToolbar, {
25494
- bindGlobal: true,
25495
- eventName: 'keydown'
25496
  });
25497
- (0,external_wp_element_namespaceObject.useEffect)(() => {
25498
- if (initialFocusOnMount) {
25499
- focusToolbar();
25500
- }
25501
- }, [isAccessibleToolbar, initialFocusOnMount, focusToolbar]);
25502
- (0,external_wp_element_namespaceObject.useEffect)(() => {
25503
- // If initialIndex is passed, we focus on that toolbar item when the
25504
- // toolbar gets mounted and initial focus is not forced.
25505
- // We have to wait for the next browser paint because block controls aren't
25506
- // rendered right away when the toolbar gets mounted.
25507
- let raf = 0;
25508
-
25509
- if (initialIndex && !initialFocusOnMount) {
25510
- raf = window.requestAnimationFrame(() => {
25511
- const items = getAllToolbarItemsIn(ref.current);
25512
- const index = initialIndex || 0;
25513
-
25514
- if (items[index] && hasFocusWithin(ref.current)) {
25515
- items[index].focus();
25516
- }
25517
- });
25518
- }
25519
-
25520
- return () => {
25521
- window.cancelAnimationFrame(raf);
25522
- if (!onIndexChange || !ref.current) return; // When the toolbar element is unmounted and onIndexChange is passed, we
25523
- // pass the focused toolbar item index so it can be hydrated later.
25524
-
25525
- const items = getAllToolbarItemsIn(ref.current);
25526
- const index = items.findIndex(item => item.tabIndex === 0);
25527
- onIndexChange(index);
25528
- };
25529
- }, [initialIndex, initialFocusOnMount]);
25530
  }
 
 
 
 
 
25531
 
25532
- function NavigableToolbar({
25533
- children,
25534
- focusOnMount,
25535
- __experimentalInitialIndex: initialIndex,
25536
- __experimentalOnIndexChange: onIndexChange,
25537
- ...props
25538
- }) {
25539
- const ref = (0,external_wp_element_namespaceObject.useRef)();
25540
- const isAccessibleToolbar = useIsAccessibleToolbar(ref);
25541
- useToolbarFocus(ref, focusOnMount, isAccessibleToolbar, initialIndex, onIndexChange);
25542
-
25543
- if (isAccessibleToolbar) {
25544
- return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Toolbar, _extends({
25545
- label: props['aria-label'],
25546
- ref: ref
25547
- }, props), children);
25548
- }
25549
 
25550
- return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.NavigableMenu, _extends({
25551
- orientation: "horizontal",
25552
- role: "toolbar",
25553
- ref: ref
25554
- }, props), children);
25555
- }
 
 
 
25556
 
25557
- /* harmony default export */ var navigable_toolbar = (NavigableToolbar);
25558
  //# sourceMappingURL=index.js.map
25559
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-mover/index.js
25560
-
25561
 
25562
 
25563
  /**
@@ -25571,10 +24682,6 @@ function NavigableToolbar({
25571
 
25572
 
25573
 
25574
-
25575
-
25576
-
25577
-
25578
  /**
25579
  * Internal dependencies
25580
  */
@@ -25583,266 +24690,127 @@ function NavigableToolbar({
25583
 
25584
 
25585
 
25586
- function BlockMover({
25587
- isFirst,
25588
- isLast,
25589
- clientIds,
25590
- isLocked,
25591
- isHidden,
25592
  rootClientId,
25593
- orientation,
25594
- hideDragHandle
25595
- }) {
25596
- const [isFocused, setIsFocused] = (0,external_wp_element_namespaceObject.useState)(false);
25597
-
25598
- const onFocus = () => setIsFocused(true);
25599
-
25600
- const onBlur = () => setIsFocused(false);
25601
-
25602
- if (isLocked || isFirst && isLast && !rootClientId) {
25603
  return null;
25604
  }
25605
 
25606
- const dragHandleLabel = (0,external_wp_i18n_namespaceObject.__)('Drag'); // We emulate a disabled state because forcefully applying the `disabled`
25607
- // attribute on the buttons while it has focus causes the screen to change
25608
- // to an unfocused state (body as active element) without firing blur on,
25609
- // the rendering parent, leaving it unable to react to focus out.
25610
 
 
 
 
 
 
 
 
25611
 
25612
- return (0,external_wp_element_namespaceObject.createElement)("div", {
25613
- className: classnames_default()('block-editor-block-mover', {
25614
- 'is-visible': isFocused || !isHidden,
25615
- 'is-horizontal': orientation === 'horizontal'
25616
- })
25617
- }, !hideDragHandle && (0,external_wp_element_namespaceObject.createElement)(block_draggable, {
25618
- clientIds: clientIds,
25619
- cloneClassname: "block-editor-block-mover__drag-clone"
25620
- }, draggableProps => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, _extends({
25621
- icon: drag_handle,
25622
- className: "block-editor-block-mover__drag-handle",
25623
- "aria-hidden": "true",
25624
- label: dragHandleLabel // Should not be able to tab to drag handle as this
25625
- // button can only be used with a pointer device.
25626
- ,
25627
- tabIndex: "-1"
25628
- }, draggableProps))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarGroup, {
25629
- className: "block-editor-block-mover__move-button-container"
25630
- }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarItem, {
25631
- onFocus: onFocus,
25632
- onBlur: onBlur
25633
- }, itemProps => (0,external_wp_element_namespaceObject.createElement)(BlockMoverUpButton, _extends({
25634
- clientIds: clientIds
25635
- }, itemProps))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarItem, {
25636
- onFocus: onFocus,
25637
- onBlur: onBlur
25638
- }, itemProps => (0,external_wp_element_namespaceObject.createElement)(BlockMoverDownButton, _extends({
25639
- clientIds: clientIds
25640
- }, itemProps)))));
 
 
 
 
25641
  }
25642
 
25643
- /* harmony default export */ var block_mover = ((0,external_wp_data_namespaceObject.withSelect)((select, {
25644
- clientIds
25645
  }) => {
25646
- var _getBlockListSettings;
25647
-
25648
  const {
25649
- getBlock,
25650
- getBlockIndex,
25651
- getBlockListSettings,
25652
- getTemplateLock,
25653
  getBlockOrder,
25654
- getBlockRootClientId
 
 
25655
  } = select(store);
25656
- const normalizedClientIds = (0,external_lodash_namespaceObject.castArray)(clientIds);
25657
- const firstClientId = (0,external_lodash_namespaceObject.first)(normalizedClientIds);
25658
- const block = getBlock(firstClientId);
25659
- const rootClientId = getBlockRootClientId((0,external_lodash_namespaceObject.first)(normalizedClientIds));
25660
- const firstIndex = getBlockIndex(firstClientId, rootClientId);
25661
- const lastIndex = getBlockIndex((0,external_lodash_namespaceObject.last)(normalizedClientIds), rootClientId);
25662
- const blockOrder = getBlockOrder(rootClientId);
25663
- const isFirst = firstIndex === 0;
25664
- const isLast = lastIndex === blockOrder.length - 1;
25665
  return {
25666
- blockType: block ? (0,external_wp_blocks_namespaceObject.getBlockType)(block.name) : null,
25667
- isLocked: getTemplateLock(rootClientId) === 'all',
25668
- rootClientId,
25669
- firstIndex,
25670
- isFirst,
25671
- isLast,
25672
- orientation: (_getBlockListSettings = getBlockListSettings(rootClientId)) === null || _getBlockListSettings === void 0 ? void 0 : _getBlockListSettings.orientation
25673
  };
25674
- })(BlockMover));
25675
  //# sourceMappingURL=index.js.map
25676
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-toolbar/utils.js
25677
- /**
25678
- * External dependencies
25679
- */
25680
-
25681
  /**
25682
  * WordPress dependencies
25683
  */
25684
 
25685
-
25686
- const {
25687
- clearTimeout: utils_clearTimeout,
25688
- setTimeout: utils_setTimeout
25689
- } = window;
25690
- const DEBOUNCE_TIMEOUT = 200;
25691
  /**
25692
- * Hook that creates a showMover state, as well as debounced show/hide callbacks.
 
 
25693
  *
25694
- * @param {Object} props Component props.
25695
- * @param {Object} props.ref Element reference.
25696
- * @param {boolean} props.isFocused Whether the component has current focus.
25697
- * @param {number} [props.debounceTimeout=250] Debounce timeout in milliseconds.
25698
- * @param {Function} [props.onChange=noop] Callback function.
25699
  */
25700
 
25701
- function useDebouncedShowMovers({
25702
- ref,
25703
- isFocused,
25704
- debounceTimeout = DEBOUNCE_TIMEOUT,
25705
- onChange = external_lodash_namespaceObject.noop
25706
- }) {
25707
- const [showMovers, setShowMovers] = (0,external_wp_element_namespaceObject.useState)(false);
25708
- const timeoutRef = (0,external_wp_element_namespaceObject.useRef)();
25709
-
25710
- const handleOnChange = nextIsFocused => {
25711
- if (ref !== null && ref !== void 0 && ref.current) {
25712
- setShowMovers(nextIsFocused);
25713
- }
25714
-
25715
- onChange(nextIsFocused);
25716
- };
25717
-
25718
- const getIsHovered = () => {
25719
- return (ref === null || ref === void 0 ? void 0 : ref.current) && ref.current.matches(':hover');
25720
- };
25721
-
25722
- const shouldHideMovers = () => {
25723
- const isHovered = getIsHovered();
25724
- return !isFocused && !isHovered;
25725
- };
25726
-
25727
- const clearTimeoutRef = () => {
25728
- const timeout = timeoutRef.current;
25729
-
25730
- if (timeout && utils_clearTimeout) {
25731
- utils_clearTimeout(timeout);
25732
- }
25733
- };
25734
-
25735
- const debouncedShowMovers = event => {
25736
- if (event) {
25737
- event.stopPropagation();
25738
- }
25739
-
25740
- clearTimeoutRef();
25741
-
25742
- if (!showMovers) {
25743
- handleOnChange(true);
25744
- }
25745
- };
25746
-
25747
- const debouncedHideMovers = event => {
25748
- if (event) {
25749
- event.stopPropagation();
25750
  }
25751
 
25752
- clearTimeoutRef();
25753
- timeoutRef.current = utils_setTimeout(() => {
25754
- if (shouldHideMovers()) {
25755
- handleOnChange(false);
25756
- }
25757
- }, debounceTimeout);
25758
- };
25759
-
25760
- (0,external_wp_element_namespaceObject.useEffect)(() => () => clearTimeoutRef(), []);
25761
- return {
25762
- showMovers,
25763
- debouncedShowMovers,
25764
- debouncedHideMovers
25765
- };
25766
- }
25767
- /**
25768
- * Hook that provides a showMovers state and gesture events for DOM elements
25769
- * that interact with the showMovers state.
25770
- *
25771
- * @param {Object} props Component props.
25772
- * @param {Object} props.ref Element reference.
25773
- * @param {number} [props.debounceTimeout=250] Debounce timeout in milliseconds.
25774
- * @param {Function} [props.onChange=noop] Callback function.
25775
- */
25776
-
25777
- function useShowMoversGestures({
25778
- ref,
25779
- debounceTimeout = DEBOUNCE_TIMEOUT,
25780
- onChange = external_lodash_namespaceObject.noop
25781
- }) {
25782
- const [isFocused, setIsFocused] = (0,external_wp_element_namespaceObject.useState)(false);
25783
- const {
25784
- showMovers,
25785
- debouncedShowMovers,
25786
- debouncedHideMovers
25787
- } = useDebouncedShowMovers({
25788
- ref,
25789
- debounceTimeout,
25790
- isFocused,
25791
- onChange
25792
- });
25793
- const registerRef = (0,external_wp_element_namespaceObject.useRef)(false);
25794
-
25795
- const isFocusedWithin = () => {
25796
- return (ref === null || ref === void 0 ? void 0 : ref.current) && ref.current.contains(ref.current.ownerDocument.activeElement);
25797
- };
25798
-
25799
- (0,external_wp_element_namespaceObject.useEffect)(() => {
25800
- const node = ref.current;
25801
 
25802
- const handleOnFocus = () => {
25803
- if (isFocusedWithin()) {
25804
- setIsFocused(true);
25805
- debouncedShowMovers();
25806
- }
25807
- };
25808
 
25809
- const handleOnBlur = () => {
25810
- if (!isFocusedWithin()) {
25811
- setIsFocused(false);
25812
- debouncedHideMovers();
25813
- }
25814
  };
25815
- /**
25816
- * Events are added via DOM events (vs. React synthetic events),
25817
- * as the child React components swallow mouse events.
25818
- */
25819
-
25820
-
25821
- if (node && !registerRef.current) {
25822
- node.addEventListener('focus', handleOnFocus, true);
25823
- node.addEventListener('blur', handleOnBlur, true);
25824
- registerRef.current = true;
25825
- }
25826
-
25827
  return () => {
25828
- if (node) {
25829
- node.removeEventListener('focus', handleOnFocus);
25830
- node.removeEventListener('blur', handleOnBlur);
25831
- }
25832
  };
25833
- }, [ref, registerRef, setIsFocused, debouncedShowMovers, debouncedHideMovers]);
25834
- return {
25835
- showMovers,
25836
- gestures: {
25837
- onMouseMove: debouncedShowMovers,
25838
- onMouseLeave: debouncedHideMovers
25839
- }
25840
- };
25841
  }
25842
- //# sourceMappingURL=utils.js.map
25843
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-parent-selector/index.js
25844
 
25845
 
 
 
 
25846
 
25847
  /**
25848
  * WordPress dependencies
@@ -25860,619 +24828,651 @@ function useShowMoversGestures({
25860
 
25861
 
25862
 
25863
- /**
25864
- * Block parent selector component, displaying the hierarchy of the
25865
- * current block selection as a single icon to "go up" a level.
25866
- *
25867
- * @return {WPComponent} Parent block selector.
25868
- */
25869
 
25870
- function BlockParentSelector() {
 
 
 
25871
  const {
25872
- selectBlock,
25873
- toggleBlockHighlight
25874
  } = (0,external_wp_data_namespaceObject.useDispatch)(store);
 
 
25875
  const {
25876
- firstParentClientId,
25877
- shouldHide,
25878
- hasReducedUI
 
 
25879
  } = (0,external_wp_data_namespaceObject.useSelect)(select => {
 
 
25880
  const {
25881
- getBlockName,
25882
- getBlockParents,
25883
- getSelectedBlockClientId,
25884
- getSettings
 
 
25885
  } = select(store);
25886
- const {
25887
- hasBlockSupport
25888
- } = select(external_wp_blocks_namespaceObject.store);
25889
- const selectedBlockClientId = getSelectedBlockClientId();
25890
- const parents = getBlockParents(selectedBlockClientId);
25891
- const _firstParentClientId = parents[parents.length - 1];
25892
- const parentBlockName = getBlockName(_firstParentClientId);
25893
 
25894
- const _parentBlockType = (0,external_wp_blocks_namespaceObject.getBlockType)(parentBlockName);
 
 
 
 
 
 
 
 
 
 
 
 
 
25895
 
25896
- const settings = getSettings();
25897
  return {
25898
- firstParentClientId: _firstParentClientId,
25899
- shouldHide: !hasBlockSupport(_parentBlockType, '__experimentalParentSelector', true),
25900
- hasReducedUI: settings.hasReducedUI
 
 
25901
  };
25902
  }, []);
25903
- const blockInformation = useBlockDisplayInformation(firstParentClientId); // Allows highlighting the parent block outline when focusing or hovering
25904
- // the parent block selector within the child.
25905
-
25906
- const nodeRef = (0,external_wp_element_namespaceObject.useRef)();
25907
- const {
25908
- gestures: showMoversGestures
25909
- } = useShowMoversGestures({
25910
- ref: nodeRef,
25911
 
25912
- onChange(isFocused) {
25913
- if (isFocused && hasReducedUI) {
25914
- return;
25915
- }
25916
 
25917
- toggleBlockHighlight(firstParentClientId, isFocused);
 
 
 
 
25918
  }
25919
 
25920
- });
25921
 
25922
- if (shouldHide || firstParentClientId === undefined) {
25923
- return null;
25924
- }
25925
 
25926
- return (0,external_wp_element_namespaceObject.createElement)("div", _extends({
25927
- className: "block-editor-block-parent-selector",
25928
- key: firstParentClientId,
25929
- ref: nodeRef
25930
- }, showMoversGestures), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, {
25931
- className: "block-editor-block-parent-selector__button",
25932
- onClick: () => selectBlock(firstParentClientId),
25933
- label: (0,external_wp_i18n_namespaceObject.sprintf)(
25934
- /* translators: %s: Name of the block's parent. */
25935
- (0,external_wp_i18n_namespaceObject.__)('Select %s'), blockInformation.title),
25936
- showTooltip: true,
25937
- icon: (0,external_wp_element_namespaceObject.createElement)(BlockIcon, {
25938
- icon: blockInformation.icon
25939
- })
25940
- }));
25941
- }
25942
- //# sourceMappingURL=index.js.map
25943
- ;// CONCATENATED MODULE: ./packages/icons/build-module/library/stack.js
25944
 
 
 
 
 
 
25945
 
25946
- /**
25947
- * WordPress dependencies
25948
- */
 
 
 
 
 
 
 
25949
 
25950
- const stack = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
25951
- xmlns: "http://www.w3.org/2000/svg",
25952
- viewBox: "0 0 24 24"
25953
- }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
25954
- d: "M20.2 8v11c0 .7-.6 1.2-1.2 1.2H6v1.5h13c1.5 0 2.7-1.2 2.7-2.8V8zM18 16.4V4.6c0-.9-.7-1.6-1.6-1.6H4.6C3.7 3 3 3.7 3 4.6v11.8c0 .9.7 1.6 1.6 1.6h11.8c.9 0 1.6-.7 1.6-1.6zm-13.5 0V4.6c0-.1.1-.1.1-.1h11.8c.1 0 .1.1.1.1v11.8c0 .1-.1.1-.1.1H4.6l-.1-.1z"
25955
- }));
25956
- /* harmony default export */ var library_stack = (stack);
25957
- //# sourceMappingURL=stack.js.map
25958
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-switcher/preview-block-popover.js
25959
 
 
 
 
 
 
 
 
 
 
25960
 
25961
- /**
25962
- * WordPress dependencies
25963
- */
 
 
 
 
 
 
 
25964
 
 
 
 
 
 
25965
 
25966
- /**
25967
- * Internal dependencies
25968
- */
 
 
 
 
 
25969
 
25970
 
25971
- function PreviewBlockPopover({
25972
- blocks
25973
- }) {
25974
- return (0,external_wp_element_namespaceObject.createElement)("div", {
25975
- className: "block-editor-block-switcher__popover__preview__parent"
25976
- }, (0,external_wp_element_namespaceObject.createElement)("div", {
25977
- className: "block-editor-block-switcher__popover__preview__container"
25978
- }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Popover, {
25979
- className: "block-editor-block-switcher__preview__popover",
25980
- position: "bottom right",
25981
- focusOnMount: false
 
 
 
 
 
 
 
 
25982
  }, (0,external_wp_element_namespaceObject.createElement)("div", {
25983
- className: "block-editor-block-switcher__preview"
 
 
 
 
 
 
 
25984
  }, (0,external_wp_element_namespaceObject.createElement)("div", {
25985
- className: "block-editor-block-switcher__preview-title"
25986
- }, (0,external_wp_i18n_namespaceObject.__)('Preview')), (0,external_wp_element_namespaceObject.createElement)(block_preview, {
25987
- viewportWidth: 500,
25988
- blocks: blocks
25989
- })))));
 
 
 
 
 
 
 
 
 
 
 
25990
  }
25991
- //# sourceMappingURL=preview-block-popover.js.map
25992
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-switcher/block-transformations-menu.js
25993
-
25994
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25995
  /**
25996
  * WordPress dependencies
25997
  */
25998
 
25999
 
26000
 
26001
-
26002
  /**
26003
  * Internal dependencies
26004
  */
26005
 
26006
 
26007
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26008
 
26009
- const BlockTransformationsMenu = ({
26010
- className,
26011
- possibleBlockTransformations,
26012
- onSelect,
26013
- blocks
26014
- }) => {
26015
- const [hoveredTransformItemName, setHoveredTransformItemName] = (0,external_wp_element_namespaceObject.useState)();
26016
- return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, {
26017
- label: (0,external_wp_i18n_namespaceObject.__)('Transform to'),
26018
- className: className
26019
- }, hoveredTransformItemName && (0,external_wp_element_namespaceObject.createElement)(PreviewBlockPopover, {
26020
- blocks: (0,external_wp_blocks_namespaceObject.switchToBlockType)(blocks, hoveredTransformItemName)
26021
- }), possibleBlockTransformations.map(item => {
26022
- const {
26023
- name,
26024
- icon,
26025
- title,
26026
- isDisabled
26027
- } = item;
26028
- return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
26029
- key: name,
26030
- className: (0,external_wp_blocks_namespaceObject.getBlockMenuDefaultClassName)(name),
26031
- onClick: event => {
26032
- event.preventDefault();
26033
- onSelect(name);
26034
- },
26035
- disabled: isDisabled,
26036
- onMouseLeave: () => setHoveredTransformItemName(null),
26037
- onMouseEnter: () => setHoveredTransformItemName(name)
26038
- }, (0,external_wp_element_namespaceObject.createElement)(BlockIcon, {
26039
- icon: icon,
26040
- showColors: true
26041
- }), title);
26042
- }));
26043
- };
26044
 
26045
- /* harmony default export */ var block_transformations_menu = (BlockTransformationsMenu);
26046
- //# sourceMappingURL=block-transformations-menu.js.map
26047
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-styles/utils.js
26048
- /**
26049
- * External dependencies
26050
- */
26051
 
26052
- /**
26053
- * WordPress dependencies
26054
- */
26055
 
 
 
 
 
26056
 
26057
- /**
26058
- * Returns the active style from the given className.
26059
- *
26060
- * @param {Array} styles Block style variations.
26061
- * @param {string} className Class name
26062
- *
26063
- * @return {Object?} The active style.
26064
- */
26065
 
26066
- function getActiveStyle(styles, className) {
26067
- for (const style of new (external_wp_tokenList_default())(className).values()) {
26068
- if (style.indexOf('is-style-') === -1) {
26069
- continue;
26070
- }
26071
 
26072
- const potentialStyleName = style.substring(9);
26073
- const activeStyle = (0,external_lodash_namespaceObject.find)(styles, {
26074
- name: potentialStyleName
26075
- });
26076
 
26077
- if (activeStyle) {
26078
- return activeStyle;
26079
- }
26080
- }
26081
 
26082
- return (0,external_lodash_namespaceObject.find)(styles, 'isDefault');
26083
- }
26084
- /**
26085
- * Replaces the active style in the block's className.
26086
- *
26087
- * @param {string} className Class name.
26088
- * @param {Object?} activeStyle The replaced style.
26089
- * @param {Object} newStyle The replacing style.
26090
- *
26091
- * @return {string} The updated className.
26092
- */
26093
 
26094
- function replaceActiveStyle(className, activeStyle, newStyle) {
26095
- const list = new (external_wp_tokenList_default())(className);
 
 
 
 
 
 
26096
 
26097
- if (activeStyle) {
26098
- list.remove('is-style-' + activeStyle.name);
26099
- }
 
26100
 
26101
- list.add('is-style-' + newStyle.name);
26102
- return list.value;
26103
- }
26104
- //# sourceMappingURL=utils.js.map
26105
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-styles/index.js
26106
 
 
 
26107
 
26108
- /**
26109
- * External dependencies
26110
- */
 
 
26111
 
26112
 
26113
- /**
26114
- * WordPress dependencies
26115
- */
26116
 
 
 
 
26117
 
 
26118
 
 
 
 
 
26119
 
26120
 
 
 
 
26121
 
26122
- /**
26123
- * Internal dependencies
26124
- */
26125
 
 
 
 
 
26126
 
 
 
26127
 
 
 
26128
 
26129
- const EMPTY_OBJECT = {};
 
 
 
26130
 
26131
- function useGenericPreviewBlock(block, type) {
26132
- return (0,external_wp_element_namespaceObject.useMemo)(() => {
26133
- const example = type === null || type === void 0 ? void 0 : type.example;
26134
- const blockName = type === null || type === void 0 ? void 0 : type.name;
26135
 
26136
- if (example && blockName) {
26137
- return (0,external_wp_blocks_namespaceObject.getBlockFromExample)(blockName, {
26138
- attributes: example.attributes,
26139
- innerBlocks: example.innerBlocks
26140
  });
26141
  }
26142
 
26143
- if (block) {
26144
- return (0,external_wp_blocks_namespaceObject.cloneBlock)(block);
26145
- }
26146
- }, [type !== null && type !== void 0 && type.example ? block === null || block === void 0 ? void 0 : block.name : block, type]);
 
26147
  }
 
 
 
 
 
26148
 
26149
- function BlockStyles({
26150
- clientId,
26151
- onSwitch = external_lodash_namespaceObject.noop,
26152
- onHoverClassName = external_lodash_namespaceObject.noop,
26153
- itemRole
26154
- }) {
26155
- const selector = select => {
26156
- const {
26157
- getBlock
26158
- } = select(store);
26159
- const block = getBlock(clientId);
26160
 
26161
- if (!block) {
26162
- return EMPTY_OBJECT;
26163
- }
26164
 
26165
- const blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(block.name);
26166
- const {
26167
- getBlockStyles
26168
- } = select(external_wp_blocks_namespaceObject.store);
26169
- return {
26170
- block,
26171
- type: blockType,
26172
- styles: getBlockStyles(block.name),
26173
- className: block.attributes.className || ''
26174
  };
26175
- };
26176
 
26177
- const {
26178
- styles,
26179
- block,
26180
- type,
26181
- className
26182
- } = (0,external_wp_data_namespaceObject.useSelect)(selector, [clientId]);
26183
- const {
26184
- updateBlockAttributes
26185
- } = (0,external_wp_data_namespaceObject.useDispatch)(store);
26186
- const genericPreviewBlock = useGenericPreviewBlock(block, type);
26187
 
26188
- if (!styles || styles.length === 0) {
26189
- return null;
 
26190
  }
26191
 
26192
- const renderedStyles = (0,external_lodash_namespaceObject.find)(styles, 'isDefault') ? styles : [{
26193
- name: 'default',
26194
- label: (0,external_wp_i18n_namespaceObject._x)('Default', 'block style'),
26195
- isDefault: true
26196
- }, ...styles];
26197
- const activeStyle = getActiveStyle(renderedStyles, className);
26198
- return (0,external_wp_element_namespaceObject.createElement)("div", {
26199
- className: "block-editor-block-styles"
26200
- }, renderedStyles.map(style => {
26201
- const styleClassName = replaceActiveStyle(className, activeStyle, style);
26202
- return (0,external_wp_element_namespaceObject.createElement)(BlockStyleItem, {
26203
- genericPreviewBlock: genericPreviewBlock,
26204
- className: className,
26205
- isActive: activeStyle === style,
26206
- key: style.name,
26207
- onSelect: () => {
26208
- updateBlockAttributes(clientId, {
26209
- className: styleClassName
26210
- });
26211
- onHoverClassName(null);
26212
- onSwitch();
26213
- },
26214
- onBlur: () => onHoverClassName(null),
26215
- onHover: () => onHoverClassName(styleClassName),
26216
- style: style,
26217
- styleClassName: styleClassName,
26218
- itemRole: itemRole
26219
- });
26220
- }));
26221
- }
26222
 
26223
- function BlockStyleItem({
26224
- genericPreviewBlock,
26225
- style,
26226
- isActive,
26227
- onBlur,
26228
- onHover,
26229
- onSelect,
26230
- styleClassName,
26231
- itemRole
26232
- }) {
26233
- const previewBlocks = (0,external_wp_element_namespaceObject.useMemo)(() => {
26234
- return { ...genericPreviewBlock,
26235
- attributes: { ...genericPreviewBlock.attributes,
26236
- className: styleClassName
26237
- }
26238
- };
26239
- }, [genericPreviewBlock, styleClassName]);
26240
- return (0,external_wp_element_namespaceObject.createElement)("div", {
26241
- key: style.name,
26242
- className: classnames_default()('block-editor-block-styles__item', {
26243
- 'is-active': isActive
26244
- }),
26245
- onClick: () => onSelect(),
26246
- onKeyDown: event => {
26247
- if (external_wp_keycodes_namespaceObject.ENTER === event.keyCode || external_wp_keycodes_namespaceObject.SPACE === event.keyCode) {
26248
- event.preventDefault();
26249
- onSelect();
26250
  }
26251
- },
26252
- onMouseEnter: onHover,
26253
- onMouseLeave: onBlur,
26254
- role: itemRole || 'button',
26255
- tabIndex: "0",
26256
- "aria-label": style.label || style.name
26257
- }, (0,external_wp_element_namespaceObject.createElement)("div", {
26258
- className: "block-editor-block-styles__item-preview"
26259
- }, (0,external_wp_element_namespaceObject.createElement)(block_preview, {
26260
- viewportWidth: 500,
26261
- blocks: previewBlocks
26262
- })), (0,external_wp_element_namespaceObject.createElement)("div", {
26263
- className: "block-editor-block-styles__item-label"
26264
- }, style.label || style.name));
26265
- }
26266
 
26267
- /* harmony default export */ var block_styles = (BlockStyles);
26268
- //# sourceMappingURL=index.js.map
26269
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-switcher/block-styles-menu.js
26270
 
 
 
26271
 
 
 
 
 
 
 
 
26272
  /**
26273
  * WordPress dependencies
26274
  */
26275
 
26276
 
26277
-
26278
-
26279
-
26280
  /**
26281
  * Internal dependencies
26282
  */
26283
 
26284
 
 
26285
 
26286
- function BlockStylesMenu({
26287
- hoveredBlock,
26288
- onSwitch
26289
- }) {
26290
- const {
26291
- name,
26292
- clientId
26293
- } = hoveredBlock;
26294
- const [hoveredClassName, setHoveredClassName] = (0,external_wp_element_namespaceObject.useState)();
26295
- const blockType = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_blocks_namespaceObject.store).getBlockType(name), [name]);
26296
- return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, {
26297
- label: (0,external_wp_i18n_namespaceObject.__)('Styles'),
26298
- className: "block-editor-block-switcher__styles__menugroup"
26299
- }, hoveredClassName && (0,external_wp_element_namespaceObject.createElement)(PreviewBlockPopover, {
26300
- blocks: blockType.example ? (0,external_wp_blocks_namespaceObject.getBlockFromExample)(blockType.name, {
26301
- attributes: { ...blockType.example.attributes,
26302
- className: hoveredClassName
26303
- },
26304
- innerBlocks: blockType.example.innerBlocks
26305
- }) : (0,external_wp_blocks_namespaceObject.cloneBlock)(hoveredBlock, {
26306
- className: hoveredClassName
26307
- })
26308
- }), (0,external_wp_element_namespaceObject.createElement)(block_styles, {
26309
- clientId: clientId,
26310
- onSwitch: onSwitch,
26311
- onHoverClassName: setHoveredClassName,
26312
- itemRole: "menuitem"
26313
- }));
26314
- }
26315
- //# sourceMappingURL=block-styles-menu.js.map
26316
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-switcher/utils.js
26317
  /**
26318
- * WordPress dependencies
 
 
 
 
 
 
26319
  */
26320
 
26321
  /**
26322
- * Try to find a matching block by a block's name in a provided
26323
- * block. We recurse through InnerBlocks and return the reference
26324
- * of the matched block (it could be an InnerBlock).
26325
- * If no match is found return nothing.
 
26326
  *
26327
- * @param {WPBlock} block The block to try to find a match.
26328
- * @param {string} selectedBlockName The block's name to use for matching condition.
26329
- * @param {Set} consumedBlocks A set holding the previously matched/consumed blocks.
26330
  *
26331
- * @return {WPBlock?} The matched block if found or nothing(`undefined`).
 
26332
  */
26333
 
26334
- const getMatchingBlockByName = (block, selectedBlockName, consumedBlocks = new Set()) => {
26335
- const {
26336
- clientId,
26337
- name,
26338
- innerBlocks = []
26339
- } = block; // Check if block has been consumed already.
26340
-
26341
- if (consumedBlocks.has(clientId)) return;
26342
- if (name === selectedBlockName) return block; // Try to find a matching block from InnerBlocks recursively.
26343
-
26344
- for (const innerBlock of innerBlocks) {
26345
- const match = getMatchingBlockByName(innerBlock, selectedBlockName, consumedBlocks);
26346
- if (match) return match;
26347
- }
26348
- };
26349
- /**
26350
- * Find and return the block attributes to retain through
26351
- * the transformation, based on Block Type's `role:content`
26352
- * attributes. If no `role:content` attributes exist,
26353
- * return selected block's attributes.
26354
- *
26355
- * @param {string} name Block type's namespaced name.
26356
- * @param {Object} attributes Selected block's attributes.
26357
- * @return {Object} The block's attributes to retain.
 
 
 
 
 
 
 
 
 
 
26358
  */
26359
 
26360
- const getRetainedBlockAttributes = (name, attributes) => {
26361
- const contentAttributes = (0,external_wp_blocks_namespaceObject.__experimentalGetBlockAttributesNamesByRole)(name, 'content');
26362
- if (!(contentAttributes !== null && contentAttributes !== void 0 && contentAttributes.length)) return attributes;
26363
- return contentAttributes.reduce((_accumulator, attribute) => {
26364
- if (attributes[attribute]) _accumulator[attribute] = attributes[attribute];
26365
- return _accumulator;
26366
- }, {});
26367
- };
26368
- //# sourceMappingURL=utils.js.map
26369
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-switcher/use-transformed-patterns.js
26370
  /**
26371
  * WordPress dependencies
26372
  */
26373
 
26374
 
 
26375
  /**
26376
  * Internal dependencies
26377
  */
26378
 
26379
 
26380
- /**
26381
- * Mutate the matched block's attributes by getting
26382
- * which block type's attributes to retain and prioritize
26383
- * them in the merging of the attributes.
26384
- *
26385
- * @param {WPBlock} match The matched block.
26386
- * @param {WPBlock} selectedBlock The selected block.
26387
- * @return {void}
26388
- */
26389
 
26390
- const transformMatchingBlock = (match, selectedBlock) => {
26391
- // Get the block attributes to retain through the transformation.
26392
- const retainedBlockAttributes = getRetainedBlockAttributes(selectedBlock.name, selectedBlock.attributes);
26393
- match.attributes = { ...match.attributes,
26394
- ...retainedBlockAttributes
26395
- };
26396
- };
26397
  /**
26398
- * By providing the selected blocks and pattern's blocks
26399
- * find the matching blocks, transform them and return them.
26400
- * If not all selected blocks are matched, return nothing.
26401
  *
26402
- * @param {WPBlock[]} selectedBlocks The selected blocks.
26403
- * @param {WPBlock[]} patternBlocks The pattern's blocks.
26404
- * @return {WPBlock[]|void} The transformed pattern's blocks or undefined if not all selected blocks have been matched.
 
 
 
 
 
 
 
26405
  */
26406
 
26407
- const getPatternTransformedBlocks = (selectedBlocks, patternBlocks) => {
26408
- // Clone Pattern's blocks to produce new clientIds and be able to mutate the matches.
26409
- const _patternBlocks = patternBlocks.map(block => (0,external_wp_blocks_namespaceObject.cloneBlock)(block));
26410
- /**
26411
- * Keep track of the consumed pattern blocks.
26412
- * This is needed because we loop the selected blocks
26413
- * and for example we may have selected two paragraphs and
26414
- * the pattern's blocks could have more `paragraphs`.
26415
- */
26416
-
26417
-
26418
- const consumedBlocks = new Set();
26419
-
26420
- for (const selectedBlock of selectedBlocks) {
26421
- let isMatch = false;
26422
-
26423
- for (const patternBlock of _patternBlocks) {
26424
- const match = getMatchingBlockByName(patternBlock, selectedBlock.name, consumedBlocks);
26425
- if (!match) continue;
26426
- isMatch = true;
26427
- consumedBlocks.add(match.clientId); // We update (mutate) the matching pattern block.
26428
 
26429
- transformMatchingBlock(match, selectedBlock); // No need to loop through other pattern's blocks.
 
 
 
 
 
26430
 
26431
- break;
26432
- } // Bail eary if a selected block has not been matched.
 
26433
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26434
 
26435
- if (!isMatch) return;
 
 
 
26436
  }
26437
 
26438
- return _patternBlocks;
26439
- };
 
 
26440
  /**
26441
- * @typedef {WPBlockPattern & {transformedBlocks: WPBlock[]}} TransformedBlockPattern
26442
  */
26443
 
 
 
 
 
 
26444
  /**
26445
- * Custom hook that accepts patterns from state and the selected
26446
- * blocks and tries to match these with the pattern's blocks.
26447
- * If all selected blocks are matched with a Pattern's block,
26448
- * we transform them by retaining block's attributes with `role:content`.
26449
- * The transformed pattern's blocks are set to a new pattern
26450
- * property `transformedBlocks`.
26451
  *
26452
- * @param {WPBlockPattern[]} patterns Patterns from state.
26453
- * @param {WPBlock[]} selectedBlocks The currently selected blocks.
26454
- * @return {TransformedBlockPattern[]} Returns the eligible matched patterns with all the selected blocks.
26455
  */
26456
- // TODO tests
26457
 
26458
- const useTransformedPatterns = (patterns, selectedBlocks) => {
26459
- return (0,external_wp_element_namespaceObject.useMemo)(() => patterns.reduce((accumulator, _pattern) => {
26460
- const transformedBlocks = getPatternTransformedBlocks(selectedBlocks, _pattern.blocks);
 
 
26461
 
26462
- if (transformedBlocks) {
26463
- accumulator.push({ ..._pattern,
26464
- transformedBlocks
26465
- });
26466
  }
 
 
 
26467
 
26468
- return accumulator;
26469
- }, []), [patterns, selectedBlocks]);
26470
- };
 
 
26471
 
26472
- /* harmony default export */ var use_transformed_patterns = (useTransformedPatterns);
26473
- //# sourceMappingURL=use-transformed-patterns.js.map
26474
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-switcher/pattern-transformations-menu.js
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26475
 
 
 
 
 
26476
 
26477
 
26478
  /**
@@ -26482,7 +25482,6 @@ const useTransformedPatterns = (patterns, selectedBlocks) => {
26482
 
26483
 
26484
 
26485
-
26486
  /**
26487
  * Internal dependencies
26488
  */
@@ -26490,97 +25489,104 @@ const useTransformedPatterns = (patterns, selectedBlocks) => {
26490
 
26491
 
26492
 
26493
- function PatternTransformationsMenu({
26494
- blocks,
26495
- patterns: statePatterns,
26496
- onSelect
26497
- }) {
26498
- const [showTransforms, setShowTransforms] = (0,external_wp_element_namespaceObject.useState)(false);
26499
- const patterns = use_transformed_patterns(statePatterns, blocks);
26500
- if (!patterns.length) return null;
26501
- return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, {
26502
- className: "block-editor-block-switcher__pattern__transforms__menugroup"
26503
- }, showTransforms && (0,external_wp_element_namespaceObject.createElement)(PreviewPatternsPopover, {
26504
- patterns: patterns,
26505
- onSelect: onSelect
26506
- }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
26507
- onClick: event => {
26508
- event.preventDefault();
26509
- setShowTransforms(!showTransforms);
26510
- },
26511
- icon: chevron_right
26512
- }, (0,external_wp_i18n_namespaceObject.__)('Patterns')));
26513
- }
26514
 
26515
- function PreviewPatternsPopover({
26516
- patterns,
26517
- onSelect
26518
- }) {
26519
- return (0,external_wp_element_namespaceObject.createElement)("div", {
26520
- className: "block-editor-block-switcher__popover__preview__parent"
26521
- }, (0,external_wp_element_namespaceObject.createElement)("div", {
26522
- className: "block-editor-block-switcher__popover__preview__container"
26523
- }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Popover, {
26524
- className: "block-editor-block-switcher__preview__popover",
26525
- position: "bottom right"
26526
- }, (0,external_wp_element_namespaceObject.createElement)("div", {
26527
- className: "block-editor-block-switcher__preview"
26528
- }, (0,external_wp_element_namespaceObject.createElement)("div", {
26529
- className: "block-editor-block-switcher__preview-title"
26530
- }, (0,external_wp_i18n_namespaceObject.__)('Preview')), (0,external_wp_element_namespaceObject.createElement)(BlockPatternsList, {
26531
- patterns: patterns,
26532
- onSelect: onSelect
26533
- })))));
26534
- }
26535
 
26536
- function BlockPatternsList({
26537
- patterns,
26538
- onSelect
26539
- }) {
26540
- const composite = (0,external_wp_components_namespaceObject.__unstableUseCompositeState)();
26541
- return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableComposite, _extends({}, composite, {
26542
- role: "listbox",
26543
- className: "block-editor-block-switcher__preview-patterns-container",
26544
- "aria-label": (0,external_wp_i18n_namespaceObject.__)('Patterns list')
26545
- }), patterns.map(pattern => (0,external_wp_element_namespaceObject.createElement)(pattern_transformations_menu_BlockPattern, {
26546
- key: pattern.name,
26547
- pattern: pattern,
26548
- onSelect: onSelect,
26549
- composite: composite
26550
- })));
26551
- }
 
 
 
 
26552
 
26553
- function pattern_transformations_menu_BlockPattern({
26554
- pattern,
26555
- onSelect,
26556
- composite
26557
- }) {
26558
- // TODO check pattern/preview width...
26559
- const baseClassName = 'block-editor-block-switcher__preview-patterns-container';
26560
- const descriptionId = (0,external_wp_compose_namespaceObject.useInstanceId)(pattern_transformations_menu_BlockPattern, `${baseClassName}-list__item-description`);
26561
- return (0,external_wp_element_namespaceObject.createElement)("div", {
26562
- className: `${baseClassName}-list__list-item`,
26563
- "aria-label": pattern.title,
26564
- "aria-describedby": pattern.description ? descriptionId : undefined
26565
- }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableCompositeItem, _extends({
26566
- role: "option",
26567
- as: "div"
26568
- }, composite, {
26569
- className: `${baseClassName}-list__item`,
26570
- onClick: () => onSelect(pattern.transformedBlocks)
26571
- }), (0,external_wp_element_namespaceObject.createElement)(block_preview, {
26572
- blocks: pattern.transformedBlocks,
26573
- viewportWidth: pattern.viewportWidth || 500
26574
- }), (0,external_wp_element_namespaceObject.createElement)("div", {
26575
- className: `${baseClassName}-list__item-title`
26576
- }, pattern.title)), !!pattern.description && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, {
26577
- id: descriptionId
26578
- }, pattern.description));
26579
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26580
 
26581
- /* harmony default export */ var pattern_transformations_menu = (PatternTransformationsMenu);
26582
- //# sourceMappingURL=pattern-transformations-menu.js.map
26583
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-switcher/index.js
26584
 
26585
 
26586
  /**
@@ -26596,6 +25602,10 @@ function pattern_transformations_menu_BlockPattern({
26596
 
26597
 
26598
 
 
 
 
 
26599
  /**
26600
  * Internal dependencies
26601
  */
@@ -26605,205 +25615,218 @@ function pattern_transformations_menu_BlockPattern({
26605
 
26606
 
26607
 
 
 
 
 
 
 
 
 
 
 
26608
 
 
 
 
 
 
 
 
 
26609
 
26610
- const BlockSwitcherDropdownMenu = ({
26611
- clientIds,
26612
- blocks
26613
- }) => {
26614
- const {
26615
- replaceBlocks
26616
- } = (0,external_wp_data_namespaceObject.useDispatch)(store);
26617
- const blockInformation = useBlockDisplayInformation(blocks[0].clientId);
26618
- const {
26619
- possibleBlockTransformations,
26620
- hasBlockStyles,
26621
- icon,
26622
- blockTitle,
26623
- patterns
26624
- } = (0,external_wp_data_namespaceObject.useSelect)(select => {
26625
  const {
26626
- getBlockRootClientId,
26627
- getBlockTransformItems,
26628
- __experimentalGetPatternTransformItems
 
26629
  } = select(store);
26630
- const {
26631
- getBlockStyles,
26632
- getBlockType
26633
- } = select(external_wp_blocks_namespaceObject.store);
26634
- const rootClientId = getBlockRootClientId((0,external_lodash_namespaceObject.castArray)(clientIds)[0]);
26635
- const [{
26636
- name: firstBlockName
26637
- }] = blocks;
26638
-
26639
- const _isSingleBlockSelected = blocks.length === 1;
26640
-
26641
- const styles = _isSingleBlockSelected && getBlockStyles(firstBlockName);
26642
-
26643
- let _icon;
26644
-
26645
- if (_isSingleBlockSelected) {
26646
- _icon = blockInformation === null || blockInformation === void 0 ? void 0 : blockInformation.icon; // Take into account active block variations.
26647
- } else {
26648
- var _getBlockType;
26649
-
26650
- const isSelectionOfSameType = (0,external_lodash_namespaceObject.uniq)(blocks.map(({
26651
- name
26652
- }) => name)).length === 1; // When selection consists of blocks of multiple types, display an
26653
- // appropriate icon to communicate the non-uniformity.
26654
 
26655
- _icon = isSelectionOfSameType ? (_getBlockType = getBlockType(firstBlockName)) === null || _getBlockType === void 0 ? void 0 : _getBlockType.icon : library_stack;
26656
- }
 
 
26657
 
 
26658
  return {
26659
- possibleBlockTransformations: getBlockTransformItems(blocks, rootClientId),
26660
- hasBlockStyles: !!(styles !== null && styles !== void 0 && styles.length),
26661
- icon: _icon,
26662
- blockTitle: getBlockType(firstBlockName).title,
26663
- patterns: __experimentalGetPatternTransformItems(blocks, rootClientId)
26664
- };
26665
- }, [clientIds, blocks, blockInformation === null || blockInformation === void 0 ? void 0 : blockInformation.icon]);
26666
- const isReusable = blocks.length === 1 && (0,external_wp_blocks_namespaceObject.isReusableBlock)(blocks[0]);
26667
- const isTemplate = blocks.length === 1 && (0,external_wp_blocks_namespaceObject.isTemplatePart)(blocks[0]); // Simple block tranformation based on the `Block Transforms` API.
 
 
 
 
 
 
 
 
 
 
 
 
26668
 
26669
- const onBlockTransform = name => replaceBlocks(clientIds, (0,external_wp_blocks_namespaceObject.switchToBlockType)(blocks, name)); // Pattern transformation through the `Patterns` API.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26670
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26671
 
26672
- const onPatternTransform = transformedBlocks => replaceBlocks(clientIds, transformedBlocks);
 
 
 
 
26673
 
26674
- const hasPossibleBlockTransformations = !!possibleBlockTransformations.length;
26675
- const hasPatternTransformation = !!(patterns !== null && patterns !== void 0 && patterns.length);
 
 
 
 
26676
 
26677
- if (!hasBlockStyles && !hasPossibleBlockTransformations) {
26678
- return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarGroup, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, {
26679
- disabled: true,
26680
- className: "block-editor-block-switcher__no-switcher-icon",
26681
- title: blockTitle,
26682
- icon: (0,external_wp_element_namespaceObject.createElement)(BlockIcon, {
26683
- icon: icon,
26684
- showColors: true
26685
- })
26686
- }));
26687
- }
26688
 
26689
- const blockSwitcherLabel = blockTitle;
26690
- const blockSwitcherDescription = 1 === blocks.length ? (0,external_wp_i18n_namespaceObject.sprintf)(
26691
- /* translators: %s: block title. */
26692
- (0,external_wp_i18n_namespaceObject.__)('%s: Change block type or style'), blockTitle) : (0,external_wp_i18n_namespaceObject.sprintf)(
26693
- /* translators: %d: number of blocks. */
26694
- (0,external_wp_i18n_namespaceObject._n)('Change type of %d block', 'Change type of %d blocks', blocks.length), blocks.length);
26695
- const showDropDown = hasBlockStyles || hasPossibleBlockTransformations || hasPatternTransformation;
26696
- return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarGroup, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarItem, null, toggleProps => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.DropdownMenu, {
26697
- className: "block-editor-block-switcher",
26698
- label: blockSwitcherLabel,
26699
- popoverProps: {
26700
- position: 'bottom right',
26701
- isAlternate: true,
26702
- className: 'block-editor-block-switcher__popover'
26703
- },
26704
- icon: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(BlockIcon, {
26705
- icon: icon,
26706
- className: "block-editor-block-switcher__toggle",
26707
- showColors: true
26708
- }), (isReusable || isTemplate) && (0,external_wp_element_namespaceObject.createElement)("span", {
26709
- className: "block-editor-block-switcher__toggle-text"
26710
- }, (0,external_wp_element_namespaceObject.createElement)(BlockTitle, {
26711
- clientId: clientIds
26712
- }))),
26713
- toggleProps: {
26714
- describedBy: blockSwitcherDescription,
26715
- ...toggleProps
26716
- },
26717
- menuProps: {
26718
- orientation: 'both'
26719
- }
26720
- }, ({
26721
- onClose
26722
- }) => showDropDown && (0,external_wp_element_namespaceObject.createElement)("div", {
26723
- className: "block-editor-block-switcher__container"
26724
- }, hasPatternTransformation && (0,external_wp_element_namespaceObject.createElement)(pattern_transformations_menu, {
26725
- blocks: blocks,
26726
- patterns: patterns,
26727
- onSelect: transformedBlocks => {
26728
- onPatternTransform(transformedBlocks);
26729
- onClose();
26730
  }
26731
- }), hasPossibleBlockTransformations && (0,external_wp_element_namespaceObject.createElement)(block_transformations_menu, {
26732
- className: "block-editor-block-switcher__transforms__menugroup",
26733
- possibleBlockTransformations: possibleBlockTransformations,
26734
- blocks: blocks,
26735
- onSelect: name => {
26736
- onBlockTransform(name);
26737
- onClose();
26738
  }
26739
- }), hasBlockStyles && (0,external_wp_element_namespaceObject.createElement)(BlockStylesMenu, {
26740
- hoveredBlock: blocks[0],
26741
- onSwitch: onClose
26742
- })))));
26743
- };
26744
- const BlockSwitcher = ({
26745
- clientIds
26746
- }) => {
26747
- const blocks = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).getBlocksByClientId(clientIds), [clientIds]);
26748
 
26749
- if (!blocks.length || blocks.some(block => !block)) {
26750
- return null;
26751
- }
 
 
26752
 
26753
- return (0,external_wp_element_namespaceObject.createElement)(BlockSwitcherDropdownMenu, {
26754
- clientIds: clientIds,
26755
- blocks: blocks
26756
- });
26757
- };
26758
- /* harmony default export */ var block_switcher = (BlockSwitcher);
26759
- //# sourceMappingURL=index.js.map
26760
- ;// CONCATENATED MODULE: external ["wp","blob"]
26761
- var external_wp_blob_namespaceObject = window["wp"]["blob"];
26762
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/utils/get-paste-event-data.js
26763
- /**
26764
- * WordPress dependencies
26765
- */
26766
 
 
 
 
 
26767
 
26768
- function getPasteEventData({
26769
- clipboardData
26770
- }) {
26771
- let plainText = '';
26772
- let html = ''; // IE11 only supports `Text` as an argument for `getData` and will
26773
- // otherwise throw an invalid argument error, so we try the standard
26774
- // arguments first, then fallback to `Text` if they fail.
26775
 
26776
- try {
26777
- plainText = clipboardData.getData('text/plain');
26778
- html = clipboardData.getData('text/html');
26779
- } catch (error1) {
26780
- try {
26781
- html = clipboardData.getData('Text');
26782
- } catch (error2) {
26783
- // Some browsers like UC Browser paste plain text by default and
26784
- // don't support clipboardData at all, so allow default
26785
- // behaviour.
26786
- return;
 
 
 
 
 
 
26787
  }
26788
  }
26789
 
26790
- const files = (0,external_wp_dom_namespaceObject.getFilesFromDataTransfer)(clipboardData).filter(({
26791
- type
26792
- }) => /^image\/(?:jpe?g|png|gif)$/.test(type)); // Only process files if no HTML is present.
26793
- // A pasted file may have the URL as plain text.
26794
 
26795
- if (files.length && !html) {
26796
- html = files.map(file => `<img src="${(0,external_wp_blob_namespaceObject.createBlobURL)(file)}">`).join('');
26797
- plainText = '';
26798
- }
26799
 
26800
- return {
26801
- html,
26802
- plainText
26803
- };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26804
  }
26805
- //# sourceMappingURL=get-paste-event-data.js.map
26806
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/copy-handler/index.js
 
 
 
26807
 
26808
 
26809
  /**
@@ -26815,400 +25838,389 @@ function getPasteEventData({
26815
 
26816
 
26817
 
 
 
 
 
26818
 
26819
- /**
26820
- * Internal dependencies
26821
- */
26822
-
26823
-
26824
 
26825
- function useNotifyCopy() {
26826
- const {
26827
- getBlockName
26828
- } = (0,external_wp_data_namespaceObject.useSelect)(store);
26829
- const {
26830
- getBlockType
26831
- } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_blocks_namespaceObject.store);
26832
- const {
26833
- createSuccessNotice
26834
- } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
26835
- return (0,external_wp_element_namespaceObject.useCallback)((eventType, selectedBlockClientIds) => {
26836
- let notice = '';
26837
 
26838
- if (selectedBlockClientIds.length === 1) {
26839
- const clientId = selectedBlockClientIds[0];
26840
- const {
26841
- title
26842
- } = getBlockType(getBlockName(clientId));
26843
- notice = eventType === 'copy' ? (0,external_wp_i18n_namespaceObject.sprintf)( // Translators: Name of the block being copied, e.g. "Paragraph".
26844
- (0,external_wp_i18n_namespaceObject.__)('Copied "%s" to clipboard.'), title) : (0,external_wp_i18n_namespaceObject.sprintf)( // Translators: Name of the block being cut, e.g. "Paragraph".
26845
- (0,external_wp_i18n_namespaceObject.__)('Moved "%s" to clipboard.'), title);
26846
- } else {
26847
- notice = eventType === 'copy' ? (0,external_wp_i18n_namespaceObject.sprintf)( // Translators: %d: Number of blocks being copied.
26848
- (0,external_wp_i18n_namespaceObject._n)('Copied %d block to clipboard.', 'Copied %d blocks to clipboard.', selectedBlockClientIds.length), selectedBlockClientIds.length) : (0,external_wp_i18n_namespaceObject.sprintf)( // Translators: %d: Number of blocks being cut.
26849
- (0,external_wp_i18n_namespaceObject._n)('Moved %d block to clipboard.', 'Moved %d blocks to clipboard.', selectedBlockClientIds.length), selectedBlockClientIds.length);
26850
- }
26851
 
26852
- createSuccessNotice(notice, {
26853
- type: 'snackbar'
26854
- });
26855
- }, []);
26856
  }
26857
- function useClipboardHandler() {
26858
- const {
26859
- getBlocksByClientId,
26860
- getSelectedBlockClientIds,
26861
- hasMultiSelection,
26862
- getSettings
26863
- } = (0,external_wp_data_namespaceObject.useSelect)(store);
26864
- const {
26865
- flashBlock,
26866
- removeBlocks,
26867
- replaceBlocks
26868
- } = (0,external_wp_data_namespaceObject.useDispatch)(store);
26869
- const notifyCopy = useNotifyCopy();
26870
- return (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
26871
- function handler(event) {
26872
- const selectedBlockClientIds = getSelectedBlockClientIds();
26873
 
26874
- if (selectedBlockClientIds.length === 0) {
26875
- return;
26876
- } // Always handle multiple selected blocks.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26877
 
 
 
 
 
26878
 
26879
- if (!hasMultiSelection()) {
26880
- const {
26881
- target
26882
- } = event;
26883
- const {
26884
- ownerDocument
26885
- } = target; // If copying, only consider actual text selection as selection.
26886
- // Otherwise, any focus on an input field is considered.
26887
 
26888
- const hasSelection = event.type === 'copy' || event.type === 'cut' ? (0,external_wp_dom_namespaceObject.documentHasUncollapsedSelection)(ownerDocument) : (0,external_wp_dom_namespaceObject.documentHasSelection)(ownerDocument); // Let native copy behaviour take over in input fields.
 
 
 
 
 
 
 
 
 
 
 
 
 
26889
 
26890
- if (hasSelection) {
26891
- return;
26892
- }
26893
- }
 
 
 
26894
 
26895
- if (!node.contains(event.target.ownerDocument.activeElement)) {
26896
- return;
26897
- }
 
 
 
 
 
 
 
 
 
 
 
 
26898
 
26899
- event.preventDefault();
 
 
 
26900
 
26901
- if (event.type === 'copy' || event.type === 'cut') {
26902
- if (selectedBlockClientIds.length === 1) {
26903
- flashBlock(selectedBlockClientIds[0]);
26904
  }
26905
-
26906
- notifyCopy(event.type, selectedBlockClientIds);
26907
- const blocks = getBlocksByClientId(selectedBlockClientIds);
26908
- const serialized = (0,external_wp_blocks_namespaceObject.serialize)(blocks);
26909
- event.clipboardData.setData('text/plain', serialized);
26910
- event.clipboardData.setData('text/html', serialized);
26911
- }
26912
-
26913
- if (event.type === 'cut') {
26914
- removeBlocks(selectedBlockClientIds);
26915
- } else if (event.type === 'paste') {
26916
- const {
26917
- __experimentalCanUserUseUnfilteredHTML: canUserUseUnfilteredHTML
26918
- } = getSettings();
26919
- const {
26920
- plainText,
26921
- html
26922
- } = getPasteEventData(event);
26923
- const blocks = (0,external_wp_blocks_namespaceObject.pasteHandler)({
26924
- HTML: html,
26925
- plainText,
26926
- mode: 'BLOCKS',
26927
- canUserUseUnfilteredHTML
26928
- });
26929
- replaceBlocks(selectedBlockClientIds, blocks, blocks.length - 1, -1);
26930
- }
26931
  }
26932
 
26933
- node.ownerDocument.addEventListener('copy', handler);
26934
- node.ownerDocument.addEventListener('cut', handler);
26935
- node.ownerDocument.addEventListener('paste', handler);
26936
  return () => {
26937
- node.ownerDocument.removeEventListener('copy', handler);
26938
- node.ownerDocument.removeEventListener('cut', handler);
26939
- node.ownerDocument.removeEventListener('paste', handler);
 
 
 
 
26940
  };
26941
- }, []);
26942
  }
26943
 
26944
- function CopyHandler({
26945
- children
 
 
 
 
26946
  }) {
26947
- return (0,external_wp_element_namespaceObject.createElement)("div", {
26948
- ref: useClipboardHandler()
26949
- }, children);
 
 
 
 
 
 
 
 
 
 
 
 
 
26950
  }
26951
 
26952
- /* harmony default export */ var copy_handler = (CopyHandler);
26953
  //# sourceMappingURL=index.js.map
26954
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-actions/index.js
26955
- /**
26956
- * External dependencies
26957
- */
26958
 
26959
  /**
26960
  * WordPress dependencies
26961
  */
26962
 
 
 
 
 
 
 
 
 
 
26963
 
26964
 
26965
  /**
26966
- * Internal dependencies
26967
  */
26968
 
 
 
 
 
 
 
 
 
 
26969
 
26970
 
26971
- function BlockActions({
26972
- clientIds,
26973
- children,
26974
- __experimentalUpdateSelection: updateSelection
26975
- }) {
26976
- const {
26977
- canInsertBlockType,
26978
- getBlockRootClientId,
26979
- getBlocksByClientId,
26980
- getTemplateLock
26981
- } = (0,external_wp_data_namespaceObject.useSelect)(select => select(store), []);
26982
- const {
26983
- getDefaultBlockName,
26984
- getGroupingBlockName
26985
- } = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_blocks_namespaceObject.store), []);
26986
- const blocks = getBlocksByClientId(clientIds);
26987
- const rootClientId = getBlockRootClientId(clientIds[0]);
26988
- const canDuplicate = (0,external_lodash_namespaceObject.every)(blocks, block => {
26989
- return !!block && (0,external_wp_blocks_namespaceObject.hasBlockSupport)(block.name, 'multiple', true) && canInsertBlockType(block.name, rootClientId);
26990
- });
26991
- const canInsertDefaultBlock = canInsertBlockType(getDefaultBlockName(), rootClientId);
26992
- const {
26993
- removeBlocks,
26994
- replaceBlocks,
26995
- duplicateBlocks,
26996
- insertAfterBlock,
26997
- insertBeforeBlock,
26998
- flashBlock,
26999
- setBlockMovingClientId,
27000
- setNavigationMode,
27001
- selectBlock
27002
- } = (0,external_wp_data_namespaceObject.useDispatch)(store);
27003
- const notifyCopy = useNotifyCopy();
27004
- return children({
27005
- canDuplicate,
27006
- canInsertDefaultBlock,
27007
- isLocked: !!getTemplateLock(rootClientId),
27008
- rootClientId,
27009
- blocks,
27010
-
27011
- onDuplicate() {
27012
- return duplicateBlocks(clientIds, updateSelection);
27013
- },
27014
-
27015
- onRemove() {
27016
- return removeBlocks(clientIds, updateSelection);
27017
- },
27018
 
27019
- onInsertBefore() {
27020
- insertBeforeBlock((0,external_lodash_namespaceObject.first)((0,external_lodash_namespaceObject.castArray)(clientIds)));
27021
- },
 
 
 
 
 
 
27022
 
27023
- onInsertAfter() {
27024
- insertAfterBlock((0,external_lodash_namespaceObject.last)((0,external_lodash_namespaceObject.castArray)(clientIds)));
27025
- },
27026
 
27027
- onMoveTo() {
27028
- setNavigationMode(true);
27029
- selectBlock(clientIds[0]);
27030
- setBlockMovingClientId(clientIds[0]);
27031
- },
27032
 
27033
- onGroup() {
27034
- if (!blocks.length) {
27035
- return;
27036
- }
 
 
 
 
 
 
 
 
27037
 
27038
- const groupingBlockName = getGroupingBlockName(); // Activate the `transform` on `core/group` which does the conversion
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27039
 
27040
- const newBlocks = (0,external_wp_blocks_namespaceObject.switchToBlockType)(blocks, groupingBlockName);
 
27041
 
27042
- if (!newBlocks) {
27043
- return;
 
 
27044
  }
27045
 
27046
- replaceBlocks(clientIds, newBlocks);
27047
- },
27048
-
27049
- onUngroup() {
27050
- if (!blocks.length) {
27051
- return;
27052
  }
27053
 
27054
- const innerBlocks = blocks[0].innerBlocks;
 
27055
 
27056
- if (!innerBlocks.length) {
27057
- return;
27058
- }
27059
 
27060
- replaceBlocks(clientIds, innerBlocks);
27061
- },
 
27062
 
27063
- onCopy() {
27064
- const selectedBlockClientIds = blocks.map(({
27065
- clientId
27066
- }) => clientId);
27067
 
27068
- if (blocks.length === 1) {
27069
- flashBlock(selectedBlockClientIds[0]);
27070
- }
27071
 
27072
- notifyCopy('copy', selectedBlockClientIds);
 
 
27073
  }
27074
 
27075
- });
27076
- }
27077
- //# sourceMappingURL=index.js.map
27078
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-settings-menu/block-mode-toggle.js
27079
-
27080
-
27081
- /**
27082
- * External dependencies
27083
- */
27084
 
27085
- /**
27086
- * WordPress dependencies
27087
- */
 
 
27088
 
 
 
 
27089
 
 
 
 
 
27090
 
 
 
 
 
27091
 
 
 
 
 
 
27092
 
 
 
 
27093
 
27094
- /**
27095
- * Internal dependencies
27096
- */
 
27097
 
 
 
 
 
27098
 
27099
- function BlockModeToggle({
27100
- blockType,
27101
- mode,
27102
- onToggleMode,
27103
- small = false,
27104
- isCodeEditingEnabled = true
27105
- }) {
27106
- if (!(0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockType, 'html', true) || !isCodeEditingEnabled) {
27107
- return null;
27108
  }
27109
 
27110
- const label = mode === 'visual' ? (0,external_wp_i18n_namespaceObject.__)('Edit as HTML') : (0,external_wp_i18n_namespaceObject.__)('Edit visually');
27111
- return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
27112
- onClick: onToggleMode
27113
- }, !small && label);
27114
- }
27115
- /* harmony default export */ var block_mode_toggle = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)((select, {
27116
- clientId
27117
- }) => {
27118
- const {
27119
- getBlock,
27120
- getBlockMode,
27121
- getSettings
27122
- } = select(store);
27123
- const block = getBlock(clientId);
27124
- const isCodeEditingEnabled = getSettings().codeEditingEnabled;
27125
- return {
27126
- mode: getBlockMode(clientId),
27127
- blockType: block ? (0,external_wp_blocks_namespaceObject.getBlockType)(block.name) : null,
27128
- isCodeEditingEnabled
27129
- };
27130
- }), (0,external_wp_data_namespaceObject.withDispatch)((dispatch, {
27131
- onToggle = external_lodash_namespaceObject.noop,
27132
- clientId
27133
- }) => ({
27134
- onToggleMode() {
27135
- dispatch(store).toggleBlockMode(clientId);
27136
- onToggle();
27137
- }
27138
 
27139
- }))])(BlockModeToggle));
27140
- //# sourceMappingURL=block-mode-toggle.js.map
27141
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-settings-menu/block-convert-button.js
 
27142
 
 
 
 
 
27143
 
 
 
 
 
 
 
27144
  /**
27145
- * WordPress dependencies
 
 
 
 
 
 
 
 
 
27146
  */
27147
 
 
 
27148
 
27149
- function BlockConvertButton({
27150
- shouldRender,
27151
- onClick,
27152
- small
27153
- }) {
27154
- if (!shouldRender) {
27155
- return null;
27156
  }
27157
 
27158
- const label = (0,external_wp_i18n_namespaceObject.__)('Convert to Blocks');
 
 
27159
 
27160
- return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
27161
- onClick: onClick
27162
- }, !small && label);
 
 
 
 
 
 
27163
  }
27164
- //# sourceMappingURL=block-convert-button.js.map
27165
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-settings-menu/block-html-convert-button.js
27166
- /**
27167
- * WordPress dependencies
27168
- */
27169
 
27170
 
27171
 
27172
  /**
27173
- * Internal dependencies
27174
  */
27175
 
27176
 
27177
-
27178
- /* harmony default export */ var block_html_convert_button = ((0,external_wp_compose_namespaceObject.compose)((0,external_wp_data_namespaceObject.withSelect)((select, {
27179
- clientId
27180
- }) => {
27181
- const block = select(store).getBlock(clientId);
27182
- return {
27183
- block,
27184
- shouldRender: block && block.name === 'core/html'
27185
- };
27186
- }), (0,external_wp_data_namespaceObject.withDispatch)((dispatch, {
27187
- block
27188
- }) => ({
27189
- onClick: () => dispatch(store).replaceBlocks(block.clientId, (0,external_wp_blocks_namespaceObject.rawHandler)({
27190
- HTML: (0,external_wp_blocks_namespaceObject.getBlockContent)(block)
27191
- }))
27192
- })))(BlockConvertButton));
27193
- //# sourceMappingURL=block-html-convert-button.js.map
27194
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-settings-menu/block-settings-menu-first-item.js
27195
  /**
27196
  * WordPress dependencies
27197
  */
27198
 
27199
- const {
27200
- Fill: __unstableBlockSettingsMenuFirstItem,
27201
- Slot: block_settings_menu_first_item_Slot
27202
- } = (0,external_wp_components_namespaceObject.createSlotFill)('__unstableBlockSettingsMenuFirstItem');
27203
- __unstableBlockSettingsMenuFirstItem.Slot = block_settings_menu_first_item_Slot;
27204
- /* harmony default export */ var block_settings_menu_first_item = (__unstableBlockSettingsMenuFirstItem);
27205
- //# sourceMappingURL=block-settings-menu-first-item.js.map
27206
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/convert-to-group-buttons/index.js
27207
 
27208
 
27209
- /**
27210
- * WordPress dependencies
27211
- */
27212
 
27213
 
27214
 
@@ -27220,144 +26232,132 @@ __unstableBlockSettingsMenuFirstItem.Slot = block_settings_menu_first_item_Slot;
27220
 
27221
 
27222
 
27223
- function ConvertToGroupButton({
27224
- clientIds,
27225
- isGroupable,
27226
- isUngroupable,
27227
- blocksSelection,
27228
- groupingBlockName,
27229
- onClose = () => {}
27230
- }) {
27231
- const {
27232
- replaceBlocks
27233
- } = (0,external_wp_data_namespaceObject.useDispatch)(store);
27234
-
27235
- const onConvertToGroup = () => {
27236
- // Activate the `transform` on the Grouping Block which does the conversion
27237
- const newBlocks = (0,external_wp_blocks_namespaceObject.switchToBlockType)(blocksSelection, groupingBlockName);
27238
 
27239
- if (newBlocks) {
27240
- replaceBlocks(clientIds, newBlocks);
 
 
27241
  }
27242
- };
27243
-
27244
- const onConvertFromGroup = () => {
27245
- const innerBlocks = blocksSelection[0].innerBlocks;
27246
 
27247
- if (!innerBlocks.length) {
27248
- return;
 
 
27249
  }
27250
 
27251
- replaceBlocks(clientIds, innerBlocks);
27252
- };
27253
-
27254
- if (!isGroupable && !isUngroupable) {
27255
- return null;
27256
  }
27257
 
27258
- return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, isGroupable && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
27259
- onClick: () => {
27260
- onConvertToGroup();
27261
- onClose();
27262
- }
27263
- }, (0,external_wp_i18n_namespaceObject._x)('Group', 'verb')), isUngroupable && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
27264
- onClick: () => {
27265
- onConvertFromGroup();
27266
- onClose();
27267
- }
27268
- }, (0,external_wp_i18n_namespaceObject._x)('Ungroup', 'Ungrouping blocks from within a Group block back into individual blocks within the Editor ')));
27269
- }
27270
-
27271
-
27272
- //# sourceMappingURL=index.js.map
27273
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.js
27274
- /**
27275
- * WordPress dependencies
27276
- */
27277
-
27278
 
27279
- /**
27280
- * Internal dependencies
27281
- */
 
 
27282
 
 
 
 
 
 
27283
 
27284
- /**
27285
- * Contains the properties `ConvertToGroupButton` component needs.
27286
- *
27287
- * @typedef {Object} ConvertToGroupButtonProps
27288
- * @property {string[]} clientIds An array of the selected client ids.
27289
- * @property {boolean} isGroupable Indicates if the selected blocks can be grouped.
27290
- * @property {boolean} isUngroupable Indicates if the selected blocks can be ungrouped.
27291
- * @property {WPBlock[]} blocksSelection An array of the selected blocks.
27292
- * @property {string} groupingBlockName The name of block used for handling grouping interactions.
27293
- */
27294
 
27295
- /**
27296
- * Returns the properties `ConvertToGroupButton` component needs to work properly.
27297
- * It is used in `BlockSettingsMenuControls` to know if `ConvertToGroupButton`
27298
- * should be rendered, to avoid ending up with an empty MenuGroup.
27299
- *
27300
- * @return {ConvertToGroupButtonProps} Returns the properties needed by `ConvertToGroupButton`.
27301
- */
27302
 
27303
- function useConvertToGroupButtonProps() {
 
 
 
 
 
 
 
27304
  const {
27305
- clientIds,
27306
- isGroupable,
27307
- isUngroupable,
27308
- blocksSelection,
27309
- groupingBlockName
 
 
27310
  } = (0,external_wp_data_namespaceObject.useSelect)(select => {
27311
- var _blocksSelection$;
27312
-
27313
  const {
 
27314
  getBlockRootClientId,
27315
- getBlocksByClientId,
27316
- canInsertBlockType,
27317
- getSelectedBlockClientIds
27318
  } = select(store);
 
 
 
 
 
 
 
 
 
27319
  const {
27320
- getGroupingBlockName
27321
- } = select(external_wp_blocks_namespaceObject.store);
27322
-
27323
- const _clientIds = getSelectedBlockClientIds();
27324
-
27325
- const _groupingBlockName = getGroupingBlockName();
27326
-
27327
- const rootClientId = !!(_clientIds !== null && _clientIds !== void 0 && _clientIds.length) ? getBlockRootClientId(_clientIds[0]) : undefined;
27328
- const groupingBlockAvailable = canInsertBlockType(_groupingBlockName, rootClientId);
27329
-
27330
- const _blocksSelection = getBlocksByClientId(_clientIds);
27331
-
27332
- const isSingleGroupingBlock = _blocksSelection.length === 1 && ((_blocksSelection$ = _blocksSelection[0]) === null || _blocksSelection$ === void 0 ? void 0 : _blocksSelection$.name) === _groupingBlockName; // Do we have
27333
- // 1. Grouping block available to be inserted?
27334
- // 2. One or more blocks selected
27335
- // (we allow single Blocks to become groups unless
27336
- // they are a soltiary group block themselves)
27337
-
27338
- const _isGroupable = groupingBlockAvailable && _blocksSelection.length && !isSingleGroupingBlock; // Do we have a single Group Block selected and does that group have inner blocks?
27339
-
27340
-
27341
- const _isUngroupable = isSingleGroupingBlock && !!_blocksSelection[0].innerBlocks.length;
27342
-
27343
  return {
27344
- clientIds: _clientIds,
27345
- isGroupable: _isGroupable,
27346
- isUngroupable: _isUngroupable,
27347
- blocksSelection: _blocksSelection,
27348
- groupingBlockName: _groupingBlockName
 
 
27349
  };
27350
- }, []);
27351
- return {
27352
- clientIds,
27353
- isGroupable,
27354
- isUngroupable,
27355
- blocksSelection,
27356
- groupingBlockName
 
 
 
 
 
 
27357
  };
27358
- }
27359
- //# sourceMappingURL=use-convert-to-group-button-props.js.map
27360
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-settings-menu-controls/index.js
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27361
 
27362
 
27363
 
@@ -27365,77 +26365,116 @@ function useConvertToGroupButtonProps() {
27365
  * External dependencies
27366
  */
27367
 
 
27368
  /**
27369
  * WordPress dependencies
27370
  */
27371
 
27372
 
27373
 
 
 
 
 
27374
  /**
27375
  * Internal dependencies
27376
  */
27377
 
27378
 
27379
 
27380
- const {
27381
- Fill: block_settings_menu_controls_Fill,
27382
- Slot: block_settings_menu_controls_Slot
27383
- } = (0,external_wp_components_namespaceObject.createSlotFill)('BlockSettingsMenuControls');
27384
 
27385
- const BlockSettingsMenuControlsSlot = ({
27386
- fillProps,
27387
- clientIds = null
27388
- }) => {
27389
- const selectedBlocks = (0,external_wp_data_namespaceObject.useSelect)(select => {
27390
- const {
27391
- getBlocksByClientId,
27392
- getSelectedBlockClientIds
27393
- } = select(store);
27394
- const ids = clientIds !== null ? clientIds : getSelectedBlockClientIds();
27395
- return (0,external_lodash_namespaceObject.map)((0,external_lodash_namespaceObject.compact)(getBlocksByClientId(ids)), block => block.name);
27396
- }, [clientIds]); // Check if current selection of blocks is Groupable or Ungroupable
27397
- // and pass this props down to ConvertToGroupButton.
27398
 
27399
- const convertToGroupButtonProps = useConvertToGroupButtonProps();
27400
- const {
27401
- isGroupable,
27402
- isUngroupable
27403
- } = convertToGroupButtonProps;
27404
- const showConvertToGroupButton = isGroupable || isUngroupable;
27405
- return (0,external_wp_element_namespaceObject.createElement)(block_settings_menu_controls_Slot, {
27406
- fillProps: { ...fillProps,
27407
- selectedBlocks
27408
- }
27409
- }, fills => {
27410
- if ((fills === null || fills === void 0 ? void 0 : fills.length) > 0 || showConvertToGroupButton) {
27411
- return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, null, fills, (0,external_wp_element_namespaceObject.createElement)(ConvertToGroupButton, _extends({}, convertToGroupButtonProps, {
27412
- onClose: fillProps === null || fillProps === void 0 ? void 0 : fillProps.onClose
27413
- })));
27414
- }
27415
- });
27416
- };
27417
- /**
27418
- * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-settings-menu-controls/README.md
27419
- *
27420
- * @param {Object} props Fill props.
27421
- * @return {WPElement} Element.
27422
- */
27423
 
 
27424
 
27425
- function BlockSettingsMenuControls({ ...props
27426
- }) {
27427
- return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalStyleProvider, {
27428
- document: document
27429
- }, (0,external_wp_element_namespaceObject.createElement)(block_settings_menu_controls_Fill, props));
27430
- }
27431
 
27432
- BlockSettingsMenuControls.Slot = BlockSettingsMenuControlsSlot;
27433
- /* harmony default export */ var block_settings_menu_controls = (BlockSettingsMenuControls);
27434
- //# sourceMappingURL=index.js.map
27435
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-settings-menu/block-settings-dropdown.js
 
 
 
 
27436
 
27437
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27438
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27439
  /**
27440
  * External dependencies
27441
  */
@@ -27445,160 +26484,166 @@ BlockSettingsMenuControls.Slot = BlockSettingsMenuControlsSlot;
27445
  */
27446
 
27447
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27448
 
 
 
 
 
 
 
 
 
27449
 
 
 
 
 
27450
 
 
 
27451
 
 
 
 
27452
 
 
 
 
 
27453
 
 
 
27454
 
27455
- /**
27456
- * Internal dependencies
27457
- */
27458
-
27459
-
27460
 
 
 
 
 
27461
 
 
27462
 
 
 
 
 
27463
 
 
 
 
 
27464
 
27465
- const block_settings_dropdown_POPOVER_PROPS = {
27466
- className: 'block-editor-block-settings-menu__popover',
27467
- position: 'bottom right',
27468
- isAlternate: true
27469
- };
 
 
27470
 
27471
- function CopyMenuItem({
27472
- blocks,
27473
- onCopy
27474
- }) {
27475
- const ref = (0,external_wp_compose_namespaceObject.useCopyToClipboard)(() => (0,external_wp_blocks_namespaceObject.serialize)(blocks), onCopy);
27476
- return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
27477
- ref: ref
27478
- }, (0,external_wp_i18n_namespaceObject.__)('Copy'));
27479
  }
 
 
 
 
 
 
 
 
 
27480
 
27481
- function BlockSettingsDropdown({
27482
- clientIds,
27483
- __experimentalSelectBlock,
27484
- children,
27485
- ...props
27486
  }) {
27487
- const blockClientIds = (0,external_lodash_namespaceObject.castArray)(clientIds);
27488
- const count = blockClientIds.length;
27489
- const firstBlockClientId = blockClientIds[0];
27490
- const onlyBlock = (0,external_wp_data_namespaceObject.useSelect)(select => 1 === select(store).getBlockCount(), []);
27491
- const shortcuts = (0,external_wp_data_namespaceObject.useSelect)(select => {
27492
- const {
27493
- getShortcutRepresentation
27494
- } = select(external_wp_keyboardShortcuts_namespaceObject.store);
27495
- return {
27496
- duplicate: getShortcutRepresentation('core/block-editor/duplicate'),
27497
- remove: getShortcutRepresentation('core/block-editor/remove'),
27498
- insertAfter: getShortcutRepresentation('core/block-editor/insert-after'),
27499
- insertBefore: getShortcutRepresentation('core/block-editor/insert-before')
27500
- };
27501
- }, []);
27502
- const updateSelection = (0,external_wp_element_namespaceObject.useCallback)(__experimentalSelectBlock ? async clientIdsPromise => {
27503
- const ids = await clientIdsPromise;
27504
 
27505
- if (ids && ids[0]) {
27506
- __experimentalSelectBlock(ids[0]);
27507
- }
27508
- } : external_lodash_namespaceObject.noop, [__experimentalSelectBlock]);
27509
- const removeBlockLabel = count === 1 ? (0,external_wp_i18n_namespaceObject.__)('Remove block') : (0,external_wp_i18n_namespaceObject.__)('Remove blocks');
27510
- return (0,external_wp_element_namespaceObject.createElement)(BlockActions, {
27511
- clientIds: clientIds,
27512
- __experimentalUpdateSelection: !__experimentalSelectBlock
27513
- }, ({
27514
- canDuplicate,
27515
- canInsertDefaultBlock,
27516
- isLocked,
27517
- onDuplicate,
27518
- onInsertAfter,
27519
- onInsertBefore,
27520
- onRemove,
27521
- onCopy,
27522
- onMoveTo,
27523
- blocks
27524
- }) => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.DropdownMenu, _extends({
27525
- icon: more_vertical,
27526
- label: (0,external_wp_i18n_namespaceObject.__)('Options'),
27527
- className: "block-editor-block-settings-menu",
27528
- popoverProps: block_settings_dropdown_POPOVER_PROPS,
27529
- noIcons: true
27530
- }, props), ({
27531
- onClose
27532
- }) => (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, null, (0,external_wp_element_namespaceObject.createElement)(block_settings_menu_first_item.Slot, {
27533
- fillProps: {
27534
- onClose
27535
- }
27536
- }), count === 1 && (0,external_wp_element_namespaceObject.createElement)(block_html_convert_button, {
27537
- clientId: firstBlockClientId
27538
- }), (0,external_wp_element_namespaceObject.createElement)(CopyMenuItem, {
27539
- blocks: blocks,
27540
- onCopy: onCopy
27541
- }), canDuplicate && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
27542
- onClick: (0,external_lodash_namespaceObject.flow)(onClose, onDuplicate, updateSelection),
27543
- shortcut: shortcuts.duplicate
27544
- }, (0,external_wp_i18n_namespaceObject.__)('Duplicate')), canInsertDefaultBlock && (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
27545
- onClick: (0,external_lodash_namespaceObject.flow)(onClose, onInsertBefore),
27546
- shortcut: shortcuts.insertBefore
27547
- }, (0,external_wp_i18n_namespaceObject.__)('Insert before')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
27548
- onClick: (0,external_lodash_namespaceObject.flow)(onClose, onInsertAfter),
27549
- shortcut: shortcuts.insertAfter
27550
- }, (0,external_wp_i18n_namespaceObject.__)('Insert after'))), !isLocked && !onlyBlock && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
27551
- onClick: (0,external_lodash_namespaceObject.flow)(onClose, onMoveTo)
27552
- }, (0,external_wp_i18n_namespaceObject.__)('Move to')), count === 1 && (0,external_wp_element_namespaceObject.createElement)(block_mode_toggle, {
27553
- clientId: firstBlockClientId,
27554
- onToggle: onClose
27555
- })), (0,external_wp_element_namespaceObject.createElement)(block_settings_menu_controls.Slot, {
27556
- fillProps: {
27557
- onClose
27558
- },
27559
- clientIds: clientIds
27560
- }), typeof children === 'function' ? children({
27561
- onClose
27562
- }) : external_wp_element_namespaceObject.Children.map(child => (0,external_wp_element_namespaceObject.cloneElement)(child, {
27563
- onClose
27564
- })), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, null, !isLocked && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
27565
- onClick: (0,external_lodash_namespaceObject.flow)(onClose, onRemove, updateSelection),
27566
- shortcut: shortcuts.remove
27567
- }, removeBlockLabel)))));
27568
- }
27569
- /* harmony default export */ var block_settings_dropdown = (BlockSettingsDropdown);
27570
- //# sourceMappingURL=block-settings-dropdown.js.map
27571
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-settings-menu/index.js
27572
 
 
 
27573
 
 
 
 
 
 
 
27574
 
27575
- /**
27576
- * WordPress dependencies
27577
- */
 
 
 
 
 
 
 
27578
 
27579
- /**
27580
- * Internal dependencies
27581
- */
27582
 
 
 
 
 
 
27583
 
27584
- function BlockSettingsMenu({
27585
- clientIds,
27586
- ...props
27587
- }) {
27588
- return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarGroup, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarItem, null, toggleProps => (0,external_wp_element_namespaceObject.createElement)(block_settings_dropdown, _extends({
27589
- clientIds: clientIds,
27590
- toggleProps: toggleProps
27591
- }, props))));
 
 
 
 
 
 
27592
  }
27593
- /* harmony default export */ var block_settings_menu = (BlockSettingsMenu);
27594
- //# sourceMappingURL=index.js.map
27595
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-toolbar/index.js
27596
-
27597
 
27598
 
27599
- /**
27600
- * External dependencies
27601
- */
27602
 
27603
  /**
27604
  * WordPress dependencies
@@ -27608,7 +26653,6 @@ function BlockSettingsMenu({
27608
 
27609
 
27610
 
27611
-
27612
  /**
27613
  * Internal dependencies
27614
  */
@@ -27617,52 +26661,51 @@ function BlockSettingsMenu({
27617
 
27618
 
27619
 
 
 
 
 
 
 
27620
 
27621
-
27622
-
27623
- function BlockToolbar({
27624
- hideDragHandle
27625
- }) {
27626
  const {
27627
- blockClientIds,
27628
- blockClientId,
27629
- blockType,
27630
- hasFixedToolbar,
27631
- hasReducedUI,
27632
- isValid,
27633
- isVisual
27634
  } = (0,external_wp_data_namespaceObject.useSelect)(select => {
27635
  const {
27636
  getBlockName,
27637
- getBlockMode,
27638
- getSelectedBlockClientIds,
27639
- isBlockValid,
27640
- getBlockRootClientId,
27641
  getSettings
27642
  } = select(store);
27643
- const selectedBlockClientIds = getSelectedBlockClientIds();
27644
- const selectedBlockClientId = selectedBlockClientIds[0];
27645
- const blockRootClientId = getBlockRootClientId(selectedBlockClientId);
 
 
 
 
 
 
 
27646
  const settings = getSettings();
27647
  return {
27648
- blockClientIds: selectedBlockClientIds,
27649
- blockClientId: selectedBlockClientId,
27650
- blockType: selectedBlockClientId && (0,external_wp_blocks_namespaceObject.getBlockType)(getBlockName(selectedBlockClientId)),
27651
- hasFixedToolbar: settings.hasFixedToolbar,
27652
- hasReducedUI: settings.hasReducedUI,
27653
- rootClientId: blockRootClientId,
27654
- isValid: selectedBlockClientIds.every(id => isBlockValid(id)),
27655
- isVisual: selectedBlockClientIds.every(id => getBlockMode(id) === 'visual')
27656
  };
27657
- }, []); // Handles highlighting the current block outline on hover or focus of the
27658
- // block type toolbar area.
 
27659
 
27660
- const {
27661
- toggleBlockHighlight
27662
- } = (0,external_wp_data_namespaceObject.useDispatch)(store);
27663
  const nodeRef = (0,external_wp_element_namespaceObject.useRef)();
27664
  const {
27665
- showMovers,
27666
  gestures: showMoversGestures
27667
  } = useShowMoversGestures({
27668
  ref: nodeRef,
@@ -27672,66 +26715,84 @@ function BlockToolbar({
27672
  return;
27673
  }
27674
 
27675
- toggleBlockHighlight(blockClientId, isFocused);
27676
- }
27677
-
27678
- }); // Account for the cases where the block toolbar is rendered within the
27679
- // header area and not contextually to the block.
27680
-
27681
- const displayHeaderToolbar = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<') || hasFixedToolbar;
27682
-
27683
- if (blockType) {
27684
- if (!(0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockType, '__experimentalToolbar', true)) {
27685
- return null;
27686
  }
27687
- }
27688
 
27689
- const shouldShowMovers = displayHeaderToolbar || showMovers;
27690
 
27691
- if (blockClientIds.length === 0) {
27692
  return null;
27693
  }
27694
 
27695
- const shouldShowVisualToolbar = isValid && isVisual;
27696
- const isMultiToolbar = blockClientIds.length > 1;
27697
- const classes = classnames_default()('block-editor-block-toolbar', shouldShowMovers && 'is-showing-movers');
27698
- return (0,external_wp_element_namespaceObject.createElement)("div", {
27699
- className: classes
27700
- }, !isMultiToolbar && !displayHeaderToolbar && (0,external_wp_element_namespaceObject.createElement)(BlockParentSelector, {
27701
- clientIds: blockClientIds
27702
- }), (0,external_wp_element_namespaceObject.createElement)("div", _extends({
27703
  ref: nodeRef
27704
- }, showMoversGestures), (shouldShowVisualToolbar || isMultiToolbar) && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarGroup, {
27705
- className: "block-editor-block-toolbar__block-controls"
27706
- }, (0,external_wp_element_namespaceObject.createElement)(block_switcher, {
27707
- clientIds: blockClientIds
27708
- }), (0,external_wp_element_namespaceObject.createElement)(block_mover, {
27709
- clientIds: blockClientIds,
27710
- hideDragHandle: hideDragHandle || hasReducedUI
27711
- }))), shouldShowVisualToolbar && (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(block_controls.Slot, {
27712
- group: "block",
27713
- className: "block-editor-block-toolbar__slot"
27714
- }), (0,external_wp_element_namespaceObject.createElement)(block_controls.Slot, {
27715
- className: "block-editor-block-toolbar__slot"
27716
- }), (0,external_wp_element_namespaceObject.createElement)(block_controls.Slot, {
27717
- group: "inline",
27718
- className: "block-editor-block-toolbar__slot"
27719
- }), (0,external_wp_element_namespaceObject.createElement)(block_controls.Slot, {
27720
- group: "other",
27721
- className: "block-editor-block-toolbar__slot"
27722
- })), (0,external_wp_element_namespaceObject.createElement)(block_settings_menu, {
27723
- clientIds: blockClientIds
27724
  }));
27725
  }
27726
  //# sourceMappingURL=index.js.map
27727
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-tools/block-contextual-toolbar.js
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27728
 
 
 
 
27729
 
27730
 
27731
  /**
27732
- * External dependencies
27733
  */
27734
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27735
  /**
27736
  * WordPress dependencies
27737
  */
@@ -27746,63 +26807,103 @@ function BlockToolbar({
27746
 
27747
 
27748
 
27749
-
27750
- function BlockContextualToolbar({
27751
- focusOnMount,
27752
- isFixed,
27753
- ...props
27754
- }) {
27755
- const {
27756
- blockType,
27757
- hasParents,
27758
- showParentSelector
27759
- } = (0,external_wp_data_namespaceObject.useSelect)(select => {
27760
- const {
27761
- getBlockName,
27762
- getBlockParents,
27763
- getSelectedBlockClientIds
27764
- } = select(store);
27765
  const {
27766
- getBlockType
27767
- } = select(external_wp_blocks_namespaceObject.store);
27768
- const selectedBlockClientIds = getSelectedBlockClientIds();
27769
- const selectedBlockClientId = selectedBlockClientIds[0];
27770
- const parents = getBlockParents(selectedBlockClientId);
27771
- const firstParentClientId = parents[parents.length - 1];
27772
- const parentBlockName = getBlockName(firstParentClientId);
27773
- const parentBlockType = getBlockType(parentBlockName);
27774
- return {
27775
- blockType: selectedBlockClientId && getBlockType(getBlockName(selectedBlockClientId)),
27776
- hasParents: parents.length,
27777
- showParentSelector: (0,external_wp_blocks_namespaceObject.hasBlockSupport)(parentBlockType, '__experimentalParentSelector', true)
27778
- };
27779
- }, []);
 
 
 
 
 
 
 
27780
 
27781
- if (blockType) {
27782
- if (!(0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockType, '__experimentalToolbar', true)) {
27783
- return null;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27784
  }
27785
- } // Shifts the toolbar to make room for the parent block selector.
27786
 
 
 
 
 
27787
 
27788
- const classes = classnames_default()('block-editor-block-contextual-toolbar', {
27789
- 'has-parent': hasParents && showParentSelector,
27790
- 'is-fixed': isFixed
27791
- });
27792
- return (0,external_wp_element_namespaceObject.createElement)(navigable_toolbar, _extends({
27793
- focusOnMount: focusOnMount,
27794
- className: classes
27795
- /* translators: accessibility text for the block toolbar */
27796
- ,
27797
- "aria-label": (0,external_wp_i18n_namespaceObject.__)('Block tools')
27798
- }, props), (0,external_wp_element_namespaceObject.createElement)(BlockToolbar, {
27799
- hideDragHandle: isFixed
27800
- }));
27801
  }
 
 
 
 
 
 
 
 
 
27802
 
27803
- /* harmony default export */ var block_contextual_toolbar = (BlockContextualToolbar);
27804
- //# sourceMappingURL=block-contextual-toolbar.js.map
27805
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-tools/block-popover.js
 
 
 
 
 
 
 
 
 
27806
 
27807
 
27808
  /**
@@ -27819,8 +26920,6 @@ function BlockContextualToolbar({
27819
 
27820
 
27821
 
27822
-
27823
-
27824
  /**
27825
  * Internal dependencies
27826
  */
@@ -27828,320 +26927,356 @@ function BlockContextualToolbar({
27828
 
27829
 
27830
 
 
27831
 
 
 
 
 
27832
 
 
 
 
 
 
 
27833
 
27834
-
27835
- function selector(select) {
27836
- const {
27837
- isNavigationMode,
27838
- isMultiSelecting,
27839
- hasMultiSelection,
27840
- isTyping,
27841
- isCaretWithinFormattedText,
27842
- getSettings,
27843
- getLastMultiSelectedBlockClientId
27844
- } = select(store);
27845
- return {
27846
- isNavigationMode: isNavigationMode(),
27847
- isMultiSelecting: isMultiSelecting(),
27848
- isTyping: isTyping(),
27849
- isCaretWithinFormattedText: isCaretWithinFormattedText(),
27850
- hasMultiSelection: hasMultiSelection(),
27851
- hasFixedToolbar: getSettings().hasFixedToolbar,
27852
- lastClientId: getLastMultiSelectedBlockClientId()
27853
- };
27854
  }
27855
 
27856
- function BlockPopover({
27857
  clientId,
27858
- rootClientId,
27859
- isValid,
27860
- isEmptyDefaultBlock,
27861
- capturingClientId,
27862
- __unstablePopoverSlot,
27863
- __unstableContentRef
27864
  }) {
27865
- const {
27866
- isNavigationMode,
27867
- isMultiSelecting,
27868
- isTyping,
27869
- isCaretWithinFormattedText,
27870
- hasMultiSelection,
27871
- hasFixedToolbar,
27872
- lastClientId
27873
- } = (0,external_wp_data_namespaceObject.useSelect)(selector, []);
27874
- const isInsertionPointVisible = (0,external_wp_data_namespaceObject.useSelect)(select => {
27875
  const {
27876
- isBlockInsertionPointVisible,
27877
- getBlockInsertionPoint,
27878
- getBlockOrder
27879
  } = select(store);
 
27880
 
27881
- if (!isBlockInsertionPointVisible()) {
27882
- return false;
27883
  }
27884
 
27885
- const insertionPoint = getBlockInsertionPoint();
27886
- const order = getBlockOrder(insertionPoint.rootClientId);
27887
- return order[insertionPoint.index] === clientId;
27888
- }, [clientId]);
27889
- const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium');
27890
- const [isToolbarForced, setIsToolbarForced] = (0,external_wp_element_namespaceObject.useState)(false);
27891
- const [isInserterShown, setIsInserterShown] = (0,external_wp_element_namespaceObject.useState)(false);
27892
- const {
27893
- stopTyping
27894
- } = (0,external_wp_data_namespaceObject.useDispatch)(store); // Controls when the side inserter on empty lines should
27895
- // be shown, including writing and selection modes.
27896
-
27897
- const showEmptyBlockSideInserter = !isTyping && !isNavigationMode && isEmptyDefaultBlock && isValid;
27898
- const shouldShowBreadcrumb = isNavigationMode;
27899
- const shouldShowContextualToolbar = !isNavigationMode && !hasFixedToolbar && isLargeViewport && !showEmptyBlockSideInserter && !isMultiSelecting && (!isTyping || isCaretWithinFormattedText);
27900
- const canFocusHiddenToolbar = !isNavigationMode && !shouldShowContextualToolbar && !hasFixedToolbar && !isEmptyDefaultBlock;
27901
- (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/block-editor/focus-toolbar', (0,external_wp_element_namespaceObject.useCallback)(() => {
27902
- setIsToolbarForced(true);
27903
- stopTyping(true);
27904
- }, []), {
27905
- bindGlobal: true,
27906
- eventName: 'keydown',
27907
- isDisabled: !canFocusHiddenToolbar
27908
- });
27909
- (0,external_wp_element_namespaceObject.useEffect)(() => {
27910
- if (!shouldShowContextualToolbar) {
27911
- setIsToolbarForced(false);
27912
- }
27913
- }, [shouldShowContextualToolbar]); // Stores the active toolbar item index so the block toolbar can return focus
27914
- // to it when re-mounting.
27915
 
27916
- const initialToolbarItemIndexRef = (0,external_wp_element_namespaceObject.useRef)();
27917
- const selectedElement = useBlockElement(clientId);
27918
- const lastSelectedElement = useBlockElement(lastClientId);
27919
- const capturingElement = useBlockElement(capturingClientId);
27920
- const popoverScrollRef = usePopoverScroll(__unstableContentRef);
 
 
 
 
 
27921
 
27922
- if (!shouldShowBreadcrumb && !shouldShowContextualToolbar && !isToolbarForced && !showEmptyBlockSideInserter) {
27923
  return null;
27924
  }
27925
 
27926
- let node = selectedElement;
 
 
 
 
 
 
 
 
 
27927
 
27928
- if (!node) {
27929
- return null;
27930
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27931
 
27932
- if (capturingClientId) {
27933
- node = capturingElement;
27934
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27935
 
27936
- let anchorRef = node;
 
 
27937
 
27938
- if (hasMultiSelection) {
27939
- // Wait to render the popover until the bottom reference is available
27940
- // as well.
27941
- if (!lastSelectedElement) {
27942
- return null;
27943
- }
27944
 
27945
- anchorRef = {
27946
- top: node,
27947
- bottom: lastSelectedElement
27948
- };
27949
- }
27950
 
27951
- function onFocus() {
27952
- setIsInserterShown(true);
27953
- }
27954
 
27955
- function onBlur() {
27956
- setIsInserterShown(false);
27957
- } // Position above the anchor, pop out towards the right, and position in the
27958
- // left corner. For the side inserter, pop out towards the left, and
27959
- // position in the right corner.
27960
- // To do: refactor `Popover` to make this prop clearer.
27961
 
27962
 
27963
- const popoverPosition = showEmptyBlockSideInserter ? 'top left right' : 'top right left';
27964
- const {
27965
- ownerDocument
27966
- } = node;
27967
- const stickyBoundaryElement = showEmptyBlockSideInserter ? undefined : // The sticky boundary element should be the boundary at which the
27968
- // the block toolbar becomes sticky when the block scolls out of view.
27969
- // In case of an iframe, this should be the iframe boundary, otherwise
27970
- // the scroll container.
27971
- ownerDocument.defaultView.frameElement || (0,external_wp_dom_namespaceObject.getScrollContainer)(node) || ownerDocument.body;
27972
- return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Popover, {
27973
- ref: popoverScrollRef,
27974
- noArrow: true,
27975
- animate: false,
27976
- position: popoverPosition,
27977
- focusOnMount: false,
27978
- anchorRef: anchorRef,
27979
- className: classnames_default()('block-editor-block-list__block-popover', {
27980
- 'is-insertion-point-visible': isInsertionPointVisible
27981
- }),
27982
- __unstableStickyBoundaryElement: stickyBoundaryElement // Render in the old slot if needed for backward compatibility,
27983
- // otherwise render in place (not in the the default popover slot).
27984
- ,
27985
- __unstableSlotName: __unstablePopoverSlot || null,
27986
- __unstableBoundaryParent: true // Observe movement for block animations (especially horizontal).
27987
- ,
27988
- __unstableObserveElement: node,
27989
- shouldAnchorIncludePadding: true
27990
- }, (shouldShowContextualToolbar || isToolbarForced) && (0,external_wp_element_namespaceObject.createElement)("div", {
27991
- onFocus: onFocus,
27992
- onBlur: onBlur // While ideally it would be enough to capture the
27993
- // bubbling focus event from the Inserter, due to the
27994
- // characteristics of click focusing of `button`s in
27995
- // Firefox and Safari, it is not reliable.
27996
- //
27997
- // See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus
27998
- ,
27999
- tabIndex: -1,
28000
- className: classnames_default()('block-editor-block-list__block-popover-inserter', {
28001
- 'is-visible': isInserterShown
28002
  })
28003
- }, (0,external_wp_element_namespaceObject.createElement)(inserter, {
28004
- clientId: clientId,
28005
- rootClientId: rootClientId,
28006
- __experimentalIsQuick: true
28007
- })), (shouldShowContextualToolbar || isToolbarForced) && (0,external_wp_element_namespaceObject.createElement)(block_contextual_toolbar // If the toolbar is being shown because of being forced
28008
- // it should focus the toolbar right after the mount.
28009
- , {
28010
- focusOnMount: isToolbarForced,
28011
- __experimentalInitialIndex: initialToolbarItemIndexRef.current,
28012
- __experimentalOnIndexChange: index => {
28013
- initialToolbarItemIndexRef.current = index;
28014
- } // Resets the index whenever the active block changes so
28015
- // this is not persisted. See https://github.com/WordPress/gutenberg/pull/25760#issuecomment-717906169
28016
- ,
28017
- key: clientId
28018
- }), shouldShowBreadcrumb && (0,external_wp_element_namespaceObject.createElement)(block_selection_button, {
28019
- clientId: clientId,
28020
- rootClientId: rootClientId,
28021
- blockElement: node
28022
- }), showEmptyBlockSideInserter && (0,external_wp_element_namespaceObject.createElement)("div", {
28023
- className: "block-editor-block-list__empty-block-inserter"
28024
- }, (0,external_wp_element_namespaceObject.createElement)(inserter, {
28025
- position: "bottom right",
28026
- rootClientId: rootClientId,
28027
  clientId: clientId,
28028
- __experimentalIsQuick: true
28029
- })));
 
 
28030
  }
 
 
 
 
 
28031
 
28032
- function wrapperSelector(select) {
 
 
 
 
 
 
 
 
 
 
 
 
 
28033
  const {
28034
- getSelectedBlockClientId,
28035
- getFirstMultiSelectedBlockClientId,
28036
- getBlockRootClientId,
28037
- __unstableGetBlockWithoutInnerBlocks,
28038
- getBlockParents,
28039
- __experimentalGetBlockListSettingsForBlocks
28040
- } = select(store);
28041
- const clientId = getSelectedBlockClientId() || getFirstMultiSelectedBlockClientId();
28042
 
28043
- if (!clientId) {
28044
- return;
 
 
 
 
28045
  }
 
 
 
 
 
 
 
 
 
 
 
28046
 
28047
- const {
28048
- name,
28049
- attributes = {},
28050
- isValid
28051
- } = __unstableGetBlockWithoutInnerBlocks(clientId) || {};
28052
- const blockParentsClientIds = getBlockParents(clientId); // Get Block List Settings for all ancestors of the current Block clientId
 
 
 
 
 
 
 
28053
 
28054
- const parentBlockListSettings = __experimentalGetBlockListSettingsForBlocks(blockParentsClientIds); // Get the clientId of the topmost parent with the capture toolbars setting.
28055
 
 
 
 
28056
 
28057
- const capturingClientId = (0,external_lodash_namespaceObject.find)(blockParentsClientIds, parentClientId => {
28058
- var _parentBlockListSetti;
28059
 
28060
- return (_parentBlockListSetti = parentBlockListSettings[parentClientId]) === null || _parentBlockListSetti === void 0 ? void 0 : _parentBlockListSetti.__experimentalCaptureToolbars;
28061
- });
28062
- return {
28063
- clientId,
28064
- rootClientId: getBlockRootClientId(clientId),
28065
- name,
28066
- isValid,
28067
- isEmptyDefaultBlock: name && (0,external_wp_blocks_namespaceObject.isUnmodifiedDefaultBlock)({
28068
- name,
28069
- attributes
28070
- }),
28071
- capturingClientId
 
 
 
28072
  };
28073
- }
 
 
 
 
 
 
 
 
 
28074
 
28075
- function WrappedBlockPopover({
28076
- __unstablePopoverSlot,
28077
- __unstableContentRef
28078
- }) {
28079
- const selected = (0,external_wp_data_namespaceObject.useSelect)(wrapperSelector, []);
 
 
 
 
28080
 
28081
- if (!selected) {
28082
- return null;
28083
- }
28084
 
28085
- const {
28086
- clientId,
28087
- rootClientId,
28088
- name,
28089
- isValid,
28090
- isEmptyDefaultBlock,
28091
- capturingClientId
28092
- } = selected;
28093
 
28094
- if (!name) {
28095
- return null;
28096
- }
28097
 
28098
- return (0,external_wp_element_namespaceObject.createElement)(BlockPopover, {
28099
- clientId: clientId,
28100
- rootClientId: rootClientId,
28101
- isValid: isValid,
28102
- isEmptyDefaultBlock: isEmptyDefaultBlock,
28103
- capturingClientId: capturingClientId,
28104
- __unstablePopoverSlot: __unstablePopoverSlot,
28105
- __unstableContentRef: __unstableContentRef
28106
- });
28107
- }
28108
- //# sourceMappingURL=block-popover.js.map
28109
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-tools/back-compat.js
28110
 
 
28111
 
28112
- /**
28113
- * WordPress dependencies
28114
- */
28115
 
28116
 
 
 
28117
 
 
 
28118
  /**
28119
- * Internal dependencies
28120
  */
28121
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28122
 
 
 
 
28123
 
28124
- function BlockToolsBackCompat({
28125
- children
28126
- }) {
28127
- const openRef = (0,external_wp_element_namespaceObject.useContext)(InsertionPointOpenRef);
28128
- const isDisabled = (0,external_wp_element_namespaceObject.useContext)(external_wp_components_namespaceObject.Disabled.Context); // If context is set, `BlockTools` is a parent component.
28129
 
28130
- if (openRef || isDisabled) {
28131
- return children;
28132
- }
28133
 
28134
- external_wp_deprecated_default()('wp.components.Popover.Slot name="block-toolbar"', {
28135
- alternative: 'wp.blockEditor.BlockTools'
28136
- });
28137
- return (0,external_wp_element_namespaceObject.createElement)(InsertionPoint, {
28138
- __unstablePopoverSlot: "block-toolbar"
28139
- }, (0,external_wp_element_namespaceObject.createElement)(WrappedBlockPopover, {
28140
- __unstablePopoverSlot: "block-toolbar"
28141
- }), children);
28142
- }
28143
- //# sourceMappingURL=back-compat.js.map
28144
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-selection-clearer/index.js
28145
 
28146
 
28147
 
@@ -28150,54 +27285,107 @@ function BlockToolsBackCompat({
28150
  */
28151
 
28152
 
28153
- /**
28154
- * Internal dependencies
28155
- */
28156
 
28157
 
28158
  /**
28159
- * Pass the returned ref callback to an element that should clear block
28160
- * selection. Selection will only be cleared if the element is clicked directly,
28161
- * not if a child element is clicked.
28162
- *
28163
- * @return {import('react').RefCallback} Ref callback.
28164
  */
28165
 
28166
- function useBlockSelectionClearer() {
28167
- const {
28168
- hasSelectedBlock,
28169
- hasMultiSelection
28170
- } = (0,external_wp_data_namespaceObject.useSelect)(store);
28171
- const {
28172
- clearSelectedBlock
28173
- } = (0,external_wp_data_namespaceObject.useDispatch)(store);
28174
- return (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
28175
- function onMouseDown(event) {
28176
- if (!hasSelectedBlock() && !hasMultiSelection()) {
28177
- return;
28178
- } // Only handle clicks on the element, not the children.
28179
 
28180
 
28181
- if (event.target !== node) {
28182
- return;
28183
- }
28184
 
28185
- clearSelectedBlock();
28186
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28187
 
28188
- node.addEventListener('mousedown', onMouseDown);
28189
- return () => {
28190
- node.removeEventListener('mousedown', onMouseDown);
28191
- };
28192
- }, [hasSelectedBlock, hasMultiSelection, clearSelectedBlock]);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28193
  }
28194
- function BlockSelectionClearer(props) {
28195
- return (0,external_wp_element_namespaceObject.createElement)("div", _extends({
28196
- ref: useBlockSelectionClearer()
28197
- }, props));
 
 
 
 
 
 
 
 
 
 
 
 
28198
  }
28199
- //# sourceMappingURL=index.js.map
28200
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-list/index.js
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28201
 
28202
 
28203
  /**
@@ -28211,6 +27399,8 @@ function BlockSelectionClearer(props) {
28211
 
28212
 
28213
 
 
 
28214
  /**
28215
  * Internal dependencies
28216
  */
@@ -28222,166 +27412,222 @@ function BlockSelectionClearer(props) {
28222
 
28223
 
28224
 
28225
-
28226
-
28227
-
28228
- const IntersectionObserver = (0,external_wp_element_namespaceObject.createContext)();
28229
-
28230
- function Root({
28231
- className,
28232
- children
28233
- }) {
28234
- const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium');
28235
  const {
28236
- isOutlineMode,
28237
- isFocusMode,
28238
- isNavigationMode
 
 
 
 
 
 
28239
  } = (0,external_wp_data_namespaceObject.useSelect)(select => {
28240
  const {
28241
- getSettings,
28242
- isNavigationMode: _isNavigationMode
 
28243
  } = select(store);
28244
  const {
28245
- outlineMode,
28246
- focusMode
28247
- } = getSettings();
28248
- return {
28249
- isOutlineMode: outlineMode,
28250
- isFocusMode: focusMode,
28251
- isNavigationMode: _isNavigationMode()
28252
- };
28253
- }, []);
28254
- return (0,external_wp_element_namespaceObject.createElement)(Head, null, (0,external_wp_element_namespaceObject.createElement)("div", {
28255
- ref: (0,external_wp_compose_namespaceObject.useMergeRefs)([useBlockSelectionClearer(), useBlockDropZone(), useInBetweenInserter()]),
28256
- className: classnames_default()('block-editor-block-list__layout is-root-container', className, {
28257
- 'is-outline-mode': isOutlineMode,
28258
- 'is-focus-mode': isFocusMode && isLargeViewport,
28259
- 'is-navigate-mode': isNavigationMode
28260
- })
28261
- }, children));
28262
- }
28263
 
28264
- function BlockList({
28265
- className,
28266
- ...props
28267
- }) {
28268
- usePreParsePatterns();
28269
- return (0,external_wp_element_namespaceObject.createElement)(BlockToolsBackCompat, null, (0,external_wp_element_namespaceObject.createElement)(Root, {
28270
- className: className
28271
- }, (0,external_wp_element_namespaceObject.createElement)(BlockListItems, props)));
28272
- }
28273
 
28274
- function Items({
28275
- placeholder,
28276
- rootClientId,
28277
- renderAppender,
28278
- __experimentalAppenderTagName,
28279
- __experimentalLayout: layout = defaultLayout
28280
- }) {
28281
- const [intersectingBlocks, setIntersectingBlocks] = (0,external_wp_element_namespaceObject.useState)(new Set());
28282
- const intersectionObserver = (0,external_wp_element_namespaceObject.useMemo)(() => {
28283
- const {
28284
- IntersectionObserver: Observer
28285
- } = window;
28286
 
28287
- if (!Observer) {
28288
- return;
28289
- }
28290
 
28291
- return new Observer(entries => {
28292
- setIntersectingBlocks(oldIntersectingBlocks => {
28293
- const newIntersectingBlocks = new Set(oldIntersectingBlocks);
 
28294
 
28295
- for (const entry of entries) {
28296
- const clientId = entry.target.getAttribute('data-block');
28297
- const action = entry.isIntersecting ? 'add' : 'delete';
28298
- newIntersectingBlocks[action](clientId);
28299
- }
 
 
28300
 
28301
- return newIntersectingBlocks;
28302
- });
28303
- });
28304
- }, [setIntersectingBlocks]);
28305
- const {
28306
- order,
28307
- selectedBlocks
28308
- } = (0,external_wp_data_namespaceObject.useSelect)(select => {
28309
- const {
28310
- getBlockOrder,
28311
- getSelectedBlockClientIds
28312
- } = select(store);
28313
  return {
28314
- order: getBlockOrder(rootClientId),
28315
- selectedBlocks: getSelectedBlockClientIds()
 
 
 
28316
  };
28317
- }, [rootClientId]);
28318
- return (0,external_wp_element_namespaceObject.createElement)(LayoutProvider, {
28319
- value: layout
28320
- }, (0,external_wp_element_namespaceObject.createElement)(IntersectionObserver.Provider, {
28321
- value: intersectionObserver
28322
- }, order.map(clientId => (0,external_wp_element_namespaceObject.createElement)(external_wp_data_namespaceObject.AsyncModeProvider, {
28323
- key: clientId,
28324
- value: // Only provide data asynchronously if the block is
28325
- // not visible and not selected.
28326
- !intersectingBlocks.has(clientId) && !selectedBlocks.includes(clientId)
28327
- }, (0,external_wp_element_namespaceObject.createElement)(block_list_block, {
28328
- rootClientId: rootClientId,
28329
- clientId: clientId
28330
- })))), order.length < 1 && placeholder, (0,external_wp_element_namespaceObject.createElement)(block_list_appender, {
28331
- tagName: __experimentalAppenderTagName,
28332
- rootClientId: rootClientId,
28333
- renderAppender: renderAppender
28334
- }));
28335
- }
28336
 
28337
- function BlockListItems(props) {
28338
- // This component needs to always be synchronous as it's the one changing
28339
- // the async mode depending on the block selection.
28340
- return (0,external_wp_element_namespaceObject.createElement)(external_wp_data_namespaceObject.AsyncModeProvider, {
28341
- value: false
28342
- }, (0,external_wp_element_namespaceObject.createElement)(Items, props));
28343
- }
28344
- //# sourceMappingURL=index.js.map
28345
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-list/use-block-props/use-intersection-observer.js
28346
- /**
28347
- * WordPress dependencies
28348
- */
28349
 
28350
 
28351
- /**
28352
- * Internal dependencies
28353
- */
28354
 
 
 
28355
 
28356
- function useIntersectionObserver() {
28357
- const observer = (0,external_wp_element_namespaceObject.useContext)(IntersectionObserver);
28358
- return (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
28359
- if (observer) {
28360
- observer.observe(node);
28361
- return () => {
28362
- observer.unobserve(node);
28363
- };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28364
  }
28365
- }, [observer]);
28366
- }
28367
- //# sourceMappingURL=use-intersection-observer.js.map
28368
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-list/use-block-props/index.js
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28369
  /**
28370
- * External dependencies
28371
  */
28372
 
 
 
 
 
 
 
 
 
 
 
 
28373
  /**
28374
  * WordPress dependencies
28375
  */
28376
 
28377
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28378
 
 
 
 
 
28379
 
 
 
 
 
28380
 
 
 
 
 
 
 
 
28381
 
28382
 
28383
  /**
28384
- * Internal dependencies
28385
  */
28386
 
28387
 
@@ -28390,428 +27636,268 @@ function useIntersectionObserver() {
28390
 
28391
 
28392
 
 
 
 
28393
 
28394
 
28395
 
 
 
 
 
 
 
 
 
 
 
 
 
28396
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28397
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28398
 
 
 
 
28399
 
28400
 
 
 
 
 
 
 
 
 
28401
 
 
28402
 
 
 
 
 
28403
 
28404
- /**
28405
- * If the block count exceeds the threshold, we disable the reordering animation
28406
- * to avoid laginess.
28407
- */
28408
-
28409
- const BLOCK_ANIMATION_THRESHOLD = 200;
28410
- /**
28411
- * This hook is used to lightly mark an element as a block element. The element
28412
- * should be the outermost element of a block. Call this hook and pass the
28413
- * returned props to the element to mark as a block. If you define a ref for the
28414
- * element, it is important to pass the ref to this hook, which the hook in turn
28415
- * will pass to the component through the props it returns. Optionally, you can
28416
- * also pass any other props through this hook, and they will be merged and
28417
- * returned.
28418
- *
28419
- * @param {Object} props Optional. Props to pass to the element. Must contain
28420
- * the ref if one is defined.
28421
- * @param {Object} options Options for internal use only.
28422
- * @param {boolean} options.__unstableIsHtml
28423
- *
28424
- * @return {Object} Props to pass to the element to mark as a block.
28425
- */
28426
 
28427
- function useBlockProps(props = {}, {
28428
- __unstableIsHtml
28429
- } = {}) {
28430
- const {
28431
- clientId,
28432
- className,
28433
- wrapperProps = {},
28434
- isAligned
28435
- } = (0,external_wp_element_namespaceObject.useContext)(BlockListBlockContext);
28436
- const {
28437
- index,
28438
- mode,
28439
- name,
28440
- blockTitle,
28441
- isPartOfSelection,
28442
- adjustScrolling,
28443
- enableAnimation,
28444
- lightBlockWrapper
28445
- } = (0,external_wp_data_namespaceObject.useSelect)(select => {
28446
- const {
28447
- getBlockRootClientId,
28448
- getBlockIndex,
28449
- getBlockMode,
28450
- getBlockName,
28451
- isTyping,
28452
- getGlobalBlockCount,
28453
- isBlockSelected,
28454
- isBlockMultiSelected,
28455
- isAncestorMultiSelected,
28456
- isFirstMultiSelectedBlock
28457
- } = select(store);
28458
- const isSelected = isBlockSelected(clientId);
28459
- const isPartOfMultiSelection = isBlockMultiSelected(clientId) || isAncestorMultiSelected(clientId);
28460
- const blockName = getBlockName(clientId);
28461
- const rootClientId = getBlockRootClientId(clientId);
28462
- const blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(blockName);
28463
- return {
28464
- index: getBlockIndex(clientId, rootClientId),
28465
- mode: getBlockMode(clientId),
28466
- name: blockName,
28467
- blockTitle: blockType.title,
28468
- isPartOfSelection: isSelected || isPartOfMultiSelection,
28469
- adjustScrolling: isSelected || isFirstMultiSelectedBlock(clientId),
28470
- enableAnimation: !isTyping() && getGlobalBlockCount() <= BLOCK_ANIMATION_THRESHOLD,
28471
- lightBlockWrapper: blockType.apiVersion > 1 || (0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockType, 'lightBlockWrapper', false)
28472
- };
28473
- }, [clientId]); // translators: %s: Type of block (i.e. Text, Image etc)
28474
 
28475
- const blockLabel = (0,external_wp_i18n_namespaceObject.sprintf)((0,external_wp_i18n_namespaceObject.__)('Block: %s'), blockTitle);
28476
- const htmlSuffix = mode === 'html' && !__unstableIsHtml ? '-visual' : '';
28477
- const mergedRefs = (0,external_wp_compose_namespaceObject.useMergeRefs)([props.ref, useFocusFirstElement(clientId), // Must happen after focus because we check for focus in the block.
28478
- useScrollIntoView(clientId), useBlockRefProvider(clientId), useFocusHandler(clientId), useMultiSelection(clientId), useEventHandlers(clientId), useNavModeExit(clientId), useIsHovered(), useIntersectionObserver(), use_moving_animation({
28479
- isSelected: isPartOfSelection,
28480
- adjustScrolling,
28481
- enableAnimation,
28482
- triggerAnimationOnChange: index
28483
- })]);
28484
- const blockEditContext = useBlockEditContext(); // Ensures it warns only inside the `edit` implementation for the block.
28485
 
28486
- if (!lightBlockWrapper && clientId === blockEditContext.clientId) {
28487
- typeof process !== "undefined" && process.env && "production" !== "production" ? external_wp_warning_default()(`Block type "${name}" must support API version 2 or higher to work correctly with "useBlockProps" method.`) : void 0;
28488
- }
 
 
 
28489
 
28490
- return { ...wrapperProps,
28491
- ...props,
28492
- ref: mergedRefs,
28493
- id: `block-${clientId}${htmlSuffix}`,
28494
- tabIndex: 0,
28495
- role: 'document',
28496
- 'aria-label': blockLabel,
28497
- 'data-block': clientId,
28498
- 'data-type': name,
28499
- 'data-title': blockTitle,
28500
- className: classnames_default()( // The wp-block className is important for editor styles.
28501
- classnames_default()('block-editor-block-list__block', {
28502
- 'wp-block': !isAligned
28503
- }), className, props.className, wrapperProps.className, useBlockClassNames(clientId), useBlockDefaultClassName(clientId), useBlockCustomClassName(clientId), useBlockMovingModeClassNames(clientId)),
28504
- style: { ...wrapperProps.style,
28505
- ...props.style
 
 
28506
  }
28507
- };
28508
- }
28509
- /**
28510
- * Call within a save function to get the props for the block wrapper.
28511
- *
28512
- * @param {Object} props Optional. Props to pass to the element.
28513
- */
28514
 
28515
- useBlockProps.save = external_wp_blocks_namespaceObject.__unstableGetBlockProps;
28516
- //# sourceMappingURL=index.js.map
28517
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-list/block.js
 
 
 
 
 
 
 
28518
 
 
 
 
 
 
 
 
28519
 
 
 
 
28520
  /**
28521
  * External dependencies
28522
  */
28523
 
28524
-
28525
  /**
28526
  * WordPress dependencies
28527
  */
28528
 
28529
 
28530
 
28531
-
28532
-
28533
-
28534
-
28535
  /**
28536
  * Internal dependencies
28537
  */
28538
 
28539
 
28540
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28541
 
 
 
 
28542
 
 
 
 
28543
 
 
 
 
28544
 
 
 
 
28545
 
28546
- const BlockListBlockContext = (0,external_wp_element_namespaceObject.createContext)();
28547
- /**
28548
- * Merges wrapper props with special handling for classNames and styles.
28549
- *
28550
- * @param {Object} propsA
28551
- * @param {Object} propsB
28552
- *
28553
- * @return {Object} Merged props.
28554
- */
28555
-
28556
- function mergeWrapperProps(propsA, propsB) {
28557
- const newProps = { ...propsA,
28558
- ...propsB
28559
- };
28560
-
28561
- if (propsA && propsB && propsA.className && propsB.className) {
28562
- newProps.className = classnames_default()(propsA.className, propsB.className);
28563
- }
28564
-
28565
- if (propsA && propsB && propsA.style && propsB.style) {
28566
- newProps.style = { ...propsA.style,
28567
- ...propsB.style
28568
- };
28569
- }
28570
-
28571
- return newProps;
28572
- }
28573
-
28574
- function Block({
28575
- children,
28576
- isHtml,
28577
- ...props
28578
- }) {
28579
- return (0,external_wp_element_namespaceObject.createElement)("div", useBlockProps(props, {
28580
- __unstableIsHtml: isHtml
28581
- }), children);
28582
- }
28583
-
28584
- function BlockListBlock({
28585
- mode,
28586
- isLocked,
28587
- clientId,
28588
- isSelected,
28589
- isSelectionEnabled,
28590
- className,
28591
- name,
28592
- isValid,
28593
- attributes,
28594
- wrapperProps,
28595
- setAttributes,
28596
- onReplace,
28597
- onInsertBlocksAfter,
28598
- onMerge,
28599
- toggleSelection
28600
- }) {
28601
- const {
28602
- removeBlock
28603
- } = (0,external_wp_data_namespaceObject.useDispatch)(store);
28604
- const onRemove = (0,external_wp_element_namespaceObject.useCallback)(() => removeBlock(clientId), [clientId]); // We wrap the BlockEdit component in a div that hides it when editing in
28605
- // HTML mode. This allows us to render all of the ancillary pieces
28606
- // (InspectorControls, etc.) which are inside `BlockEdit` but not
28607
- // `BlockHTML`, even in HTML mode.
28608
-
28609
- let blockEdit = (0,external_wp_element_namespaceObject.createElement)(BlockEdit, {
28610
- name: name,
28611
- isSelected: isSelected,
28612
- attributes: attributes,
28613
- setAttributes: setAttributes,
28614
- insertBlocksAfter: isLocked ? undefined : onInsertBlocksAfter,
28615
- onReplace: isLocked ? undefined : onReplace,
28616
- onRemove: isLocked ? undefined : onRemove,
28617
- mergeBlocks: isLocked ? undefined : onMerge,
28618
- clientId: clientId,
28619
- isSelectionEnabled: isSelectionEnabled,
28620
- toggleSelection: toggleSelection
28621
- });
28622
- const blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(name);
28623
- const lightBlockWrapper = blockType.apiVersion > 1 || (0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockType, 'lightBlockWrapper', false); // Determine whether the block has props to apply to the wrapper.
28624
-
28625
- if (blockType.getEditWrapperProps) {
28626
- wrapperProps = mergeWrapperProps(wrapperProps, blockType.getEditWrapperProps(attributes));
28627
- }
28628
-
28629
- const isAligned = wrapperProps && !!wrapperProps['data-align']; // For aligned blocks, provide a wrapper element so the block can be
28630
- // positioned relative to the block column.
28631
-
28632
- if (isAligned) {
28633
- blockEdit = (0,external_wp_element_namespaceObject.createElement)("div", {
28634
- className: "wp-block",
28635
- "data-align": wrapperProps['data-align']
28636
- }, blockEdit);
28637
- }
28638
-
28639
- let block;
28640
 
28641
- if (!isValid) {
28642
- const saveContent = (0,external_wp_blocks_namespaceObject.getSaveContent)(blockType, attributes);
28643
- block = (0,external_wp_element_namespaceObject.createElement)(Block, {
28644
- className: "has-warning"
28645
- }, (0,external_wp_element_namespaceObject.createElement)(block_invalid_warning, {
28646
- clientId: clientId
28647
- }), (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.RawHTML, null, (0,external_wp_dom_namespaceObject.safeHTML)(saveContent)));
28648
- } else if (mode === 'html') {
28649
- // Render blockEdit so the inspector controls don't disappear.
28650
- // See #8969.
28651
- block = (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("div", {
28652
- style: {
28653
- display: 'none'
28654
  }
28655
- }, blockEdit), (0,external_wp_element_namespaceObject.createElement)(Block, {
28656
- isHtml: true
28657
- }, (0,external_wp_element_namespaceObject.createElement)(block_html, {
28658
- clientId: clientId
28659
- })));
28660
- } else if (lightBlockWrapper) {
28661
- block = blockEdit;
28662
- } else {
28663
- block = (0,external_wp_element_namespaceObject.createElement)(Block, wrapperProps, blockEdit);
28664
- }
28665
-
28666
- const value = {
28667
- clientId,
28668
- className,
28669
- wrapperProps: (0,external_lodash_namespaceObject.omit)(wrapperProps, ['data-align']),
28670
- isAligned
28671
- };
28672
- const memoizedValue = (0,external_wp_element_namespaceObject.useMemo)(() => value, Object.values(value));
28673
- return (0,external_wp_element_namespaceObject.createElement)(BlockListBlockContext.Provider, {
28674
- value: memoizedValue
28675
- }, (0,external_wp_element_namespaceObject.createElement)(block_crash_boundary, {
28676
- fallback: (0,external_wp_element_namespaceObject.createElement)(Block, {
28677
- className: "has-warning"
28678
- }, (0,external_wp_element_namespaceObject.createElement)(block_crash_warning, null))
28679
- }, block));
28680
- }
28681
 
28682
- const applyWithSelect = (0,external_wp_data_namespaceObject.withSelect)((select, {
28683
- clientId,
28684
- rootClientId
28685
- }) => {
28686
- const {
28687
- isBlockSelected,
28688
- getBlockMode,
28689
- isSelectionEnabled,
28690
- getTemplateLock,
28691
- __unstableGetBlockWithoutInnerBlocks
28692
- } = select(store);
28693
 
28694
- const block = __unstableGetBlockWithoutInnerBlocks(clientId);
28695
 
28696
- const isSelected = isBlockSelected(clientId);
28697
- const templateLock = getTemplateLock(rootClientId); // The fallback to `{}` is a temporary fix.
28698
- // This function should never be called when a block is not present in
28699
- // the state. It happens now because the order in withSelect rendering
28700
- // is not correct.
28701
 
28702
- const {
28703
- name,
28704
- attributes,
28705
- isValid
28706
- } = block || {}; // Do not add new properties here, use `useSelect` instead to avoid
28707
- // leaking new props to the public API (editor.BlockListBlock filter).
28708
 
28709
- return {
28710
- mode: getBlockMode(clientId),
28711
- isSelectionEnabled: isSelectionEnabled(),
28712
- isLocked: !!templateLock,
28713
- // Users of the editor.BlockListBlock filter used to be able to
28714
- // access the block prop.
28715
- // Ideally these blocks would rely on the clientId prop only.
28716
- // This is kept for backward compatibility reasons.
28717
- block,
28718
- name,
28719
- attributes,
28720
- isValid,
28721
- isSelected
28722
- };
28723
- });
28724
- const applyWithDispatch = (0,external_wp_data_namespaceObject.withDispatch)((dispatch, ownProps, {
28725
- select
28726
- }) => {
28727
- const {
28728
- updateBlockAttributes,
28729
- insertBlocks,
28730
- mergeBlocks,
28731
- replaceBlocks,
28732
- toggleSelection,
28733
- __unstableMarkLastChangeAsPersistent
28734
- } = dispatch(store); // Do not add new properties here, use `useDispatch` instead to avoid
28735
- // leaking new props to the public API (editor.BlockListBlock filter).
28736
 
28737
- return {
28738
- setAttributes(newAttributes) {
28739
- const {
28740
- getMultiSelectedBlockClientIds
28741
- } = select(store);
28742
- const multiSelectedBlockClientIds = getMultiSelectedBlockClientIds();
28743
- const {
28744
- clientId
28745
- } = ownProps;
28746
- const clientIds = multiSelectedBlockClientIds.length ? multiSelectedBlockClientIds : [clientId];
28747
- updateBlockAttributes(clientIds, newAttributes);
28748
- },
28749
 
28750
- onInsertBlocks(blocks, index) {
28751
- const {
28752
- rootClientId
28753
- } = ownProps;
28754
- insertBlocks(blocks, index, rootClientId);
28755
- },
28756
 
28757
- onInsertBlocksAfter(blocks) {
28758
- const {
28759
- clientId,
28760
- rootClientId
28761
- } = ownProps;
28762
- const {
28763
- getBlockIndex
28764
- } = select(store);
28765
- const index = getBlockIndex(clientId, rootClientId);
28766
- insertBlocks(blocks, index + 1, rootClientId);
28767
  },
28768
 
28769
- onMerge(forward) {
28770
- const {
28771
  clientId
28772
- } = ownProps;
28773
- const {
28774
- getPreviousBlockClientId,
28775
- getNextBlockClientId
28776
- } = select(store);
28777
-
28778
- if (forward) {
28779
- const nextBlockClientId = getNextBlockClientId(clientId);
28780
-
28781
- if (nextBlockClientId) {
28782
- mergeBlocks(clientId, nextBlockClientId);
28783
- }
28784
- } else {
28785
- const previousBlockClientId = getPreviousBlockClientId(clientId);
28786
 
28787
- if (previousBlockClientId) {
28788
- mergeBlocks(previousBlockClientId, clientId);
28789
- }
28790
  }
28791
- },
28792
 
28793
- onReplace(blocks, indexToSelect, initialPosition) {
28794
- if (blocks.length && !(0,external_wp_blocks_namespaceObject.isUnmodifiedDefaultBlock)(blocks[blocks.length - 1])) {
28795
- __unstableMarkLastChangeAsPersistent();
28796
- }
28797
 
28798
- replaceBlocks([ownProps.clientId], blocks, indexToSelect, initialPosition);
28799
- },
 
 
28800
 
28801
- toggleSelection(selectionEnabled) {
28802
- toggleSelection(selectionEnabled);
28803
- }
28804
 
28805
- };
28806
- });
28807
- /* harmony default export */ var block_list_block = ((0,external_wp_compose_namespaceObject.compose)(external_wp_compose_namespaceObject.pure, applyWithSelect, applyWithDispatch, // block is sometimes not mounted at the right time, causing it be undefined
28808
- // see issue for more info
28809
- // https://github.com/WordPress/gutenberg/issues/17013
28810
- (0,external_wp_compose_namespaceObject.ifCondition)(({
28811
- block
28812
- }) => !!block), (0,external_wp_components_namespaceObject.withFilters)('editor.BlockListBlock'))(BlockListBlock));
28813
- //# sourceMappingURL=block.js.map
28814
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/list-view/utils.js
28815
  /**
28816
  * External dependencies
28817
  */
@@ -28821,139 +27907,128 @@ const applyWithDispatch = (0,external_wp_data_namespaceObject.withDispatch)((dis
28821
  */
28822
 
28823
 
28824
- const getBlockPositionDescription = (position, siblingCount, level) => (0,external_wp_i18n_namespaceObject.sprintf)(
28825
- /* translators: 1: The numerical position of the block. 2: The total number of blocks. 3. The level of nesting for the block. */
28826
- (0,external_wp_i18n_namespaceObject.__)('Block %1$d of %2$d, Level %3$d'), position, siblingCount, level);
28827
- /**
28828
- * Returns true if the client ID occurs within the block selection or multi-selection,
28829
- * or false otherwise.
28830
- *
28831
- * @param {string} clientId Block client ID.
28832
- * @param {string|string[]} selectedBlockClientIds Selected block client ID, or an array of multi-selected blocks client IDs.
28833
- *
28834
- * @return {boolean} Whether the block is in multi-selection set.
28835
- */
28836
 
28837
- const isClientIdSelected = (clientId, selectedBlockClientIds) => (0,external_lodash_namespaceObject.isArray)(selectedBlockClientIds) && selectedBlockClientIds.length ? selectedBlockClientIds.indexOf(clientId) !== -1 : selectedBlockClientIds === clientId;
28838
- //# sourceMappingURL=utils.js.map
28839
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/list-view/expander.js
28840
 
28841
 
28842
  /**
28843
- * WordPress dependencies
28844
  */
28845
 
28846
- function ListViewExpander({
28847
- onClick
 
 
 
 
 
28848
  }) {
28849
- return (// Keyboard events are handled by TreeGrid see: components/src/tree-grid/index.js
28850
- //
28851
- // The expander component is implemented as a pseudo element in the w3 example
28852
- // https://www.w3.org/TR/wai-aria-practices/examples/treegrid/treegrid-1.html
28853
- //
28854
- // We've mimicked this by adding an icon with aria-hidden set to true to hide this from the accessibility tree.
28855
- // For the current tree grid implementation, please do not try to make this a button.
28856
- //
28857
- // eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions
28858
- (0,external_wp_element_namespaceObject.createElement)("span", {
28859
- className: "block-editor-list-view__expander",
28860
- onClick: event => onClick(event, {
28861
- forceToggle: true
28862
- }),
28863
- "aria-hidden": "true"
28864
- }, (0,external_wp_element_namespaceObject.createElement)(icon, {
28865
- icon: chevron_right_small
28866
- }))
28867
- );
28868
  }
28869
- //# sourceMappingURL=expander.js.map
28870
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/list-view/block-select-button.js
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28871
 
 
 
 
28872
 
28873
- /**
28874
- * External dependencies
28875
- */
28876
 
28877
  /**
28878
  * WordPress dependencies
28879
  */
28880
 
28881
 
 
 
 
 
 
 
 
 
28882
 
 
28883
 
28884
-
 
 
 
 
 
28885
  /**
28886
- * Internal dependencies
28887
  */
28888
 
28889
 
28890
 
28891
-
28892
-
28893
-
28894
-
28895
- function ListViewBlockSelectButton({
28896
- className,
28897
- block: {
28898
- clientId
28899
- },
28900
- isSelected,
28901
- onClick,
28902
- onToggleExpanded,
28903
- position,
28904
- siblingBlockCount,
28905
- level,
28906
- tabIndex,
28907
- onFocus,
28908
- onDragStart,
28909
- onDragEnd,
28910
- draggable
28911
- }, ref) {
28912
- const blockInformation = useBlockDisplayInformation(clientId);
28913
- const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(ListViewBlockSelectButton);
28914
- const descriptionId = `list-view-block-select-button__${instanceId}`;
28915
- const blockPositionDescription = getBlockPositionDescription(position, siblingBlockCount, level);
28916
- return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
28917
- className: classnames_default()('block-editor-list-view-block-select-button', className),
28918
- onClick: onClick,
28919
- "aria-describedby": descriptionId,
28920
- ref: ref,
28921
- tabIndex: tabIndex,
28922
- onFocus: onFocus,
28923
- onDragStart: onDragStart,
28924
- onDragEnd: onDragEnd,
28925
- draggable: draggable
28926
- }, (0,external_wp_element_namespaceObject.createElement)(ListViewExpander, {
28927
- onClick: onToggleExpanded
28928
- }), (0,external_wp_element_namespaceObject.createElement)(BlockIcon, {
28929
- icon: blockInformation === null || blockInformation === void 0 ? void 0 : blockInformation.icon,
28930
- showColors: true
28931
- }), (0,external_wp_element_namespaceObject.createElement)(BlockTitle, {
28932
- clientId: clientId
28933
- }), (blockInformation === null || blockInformation === void 0 ? void 0 : blockInformation.anchor) && (0,external_wp_element_namespaceObject.createElement)("span", {
28934
- className: "block-editor-list-view-block-select-button__anchor"
28935
- }, blockInformation.anchor), isSelected && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, null, (0,external_wp_i18n_namespaceObject.__)('(selected block)'))), (0,external_wp_element_namespaceObject.createElement)("div", {
28936
- className: "block-editor-list-view-block-select-button__description",
28937
- id: descriptionId
28938
- }, blockPositionDescription));
28939
- }
28940
-
28941
- /* harmony default export */ var block_select_button = ((0,external_wp_element_namespaceObject.forwardRef)(ListViewBlockSelectButton));
28942
- //# sourceMappingURL=block-select-button.js.map
28943
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/list-view/block-slot.js
28944
-
28945
-
28946
-
28947
  /**
28948
- * External dependencies
28949
  */
28950
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28951
  /**
28952
  * WordPress dependencies
28953
  */
28954
 
 
 
 
 
 
 
 
 
28955
 
28956
 
 
 
 
28957
 
28958
 
28959
 
@@ -28965,172 +28040,145 @@ function ListViewBlockSelectButton({
28965
 
28966
 
28967
 
 
 
 
 
 
 
 
 
 
 
 
28968
 
 
 
 
28969
 
 
 
 
 
28970
 
 
 
28971
 
28972
- const getSlotName = clientId => `ListViewBlock-${clientId}`;
 
 
28973
 
28974
- function ListViewBlockSlot(props, ref) {
28975
- const {
28976
- clientId
28977
- } = props.block;
28978
- const {
28979
- name
28980
- } = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).getBlockName(clientId), [clientId]);
28981
- const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(ListViewBlockSlot);
28982
- return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Slot, {
28983
- name: getSlotName(clientId)
28984
- }, fills => {
28985
- if (!fills.length) {
28986
- return (0,external_wp_element_namespaceObject.createElement)(block_select_button, _extends({
28987
- ref: ref
28988
- }, props));
28989
- }
28990
-
28991
- const {
28992
- className,
28993
- isSelected,
28994
- position,
28995
- siblingBlockCount,
28996
- level,
28997
- tabIndex,
28998
- onFocus,
28999
- onToggleExpanded
29000
- } = props;
29001
- const blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(name);
29002
- const descriptionId = `list-view-block-slot__${instanceId}`;
29003
- const blockPositionDescription = getBlockPositionDescription(position, siblingBlockCount, level);
29004
- const forwardedFillProps = {
29005
- // Ensure that the component in the slot can receive
29006
- // keyboard navigation.
29007
- tabIndex,
29008
- onFocus,
29009
- ref,
29010
- // Give the element rendered in the slot a description
29011
- // that describes its position.
29012
- 'aria-describedby': descriptionId
29013
- };
29014
- return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("div", {
29015
- className: classnames_default()('block-editor-list-view-block-slot', className)
29016
- }, (0,external_wp_element_namespaceObject.createElement)(ListViewExpander, {
29017
- onClick: onToggleExpanded
29018
- }), (0,external_wp_element_namespaceObject.createElement)(BlockIcon, {
29019
- icon: blockType.icon,
29020
- showColors: true
29021
- }), external_wp_element_namespaceObject.Children.map(fills, fill => (0,external_wp_element_namespaceObject.cloneElement)(fill, { ...fill.props,
29022
- ...forwardedFillProps
29023
- })), isSelected && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, null, (0,external_wp_i18n_namespaceObject.__)('(selected block)')), (0,external_wp_element_namespaceObject.createElement)("div", {
29024
- className: "block-editor-list-view-block-slot__description",
29025
- id: descriptionId
29026
- }, blockPositionDescription)));
29027
- });
29028
- }
29029
-
29030
- /* harmony default export */ var block_slot = ((0,external_wp_element_namespaceObject.forwardRef)(ListViewBlockSlot));
29031
- const ListViewBlockFill = props => {
29032
- const {
29033
- clientId
29034
- } = (0,external_wp_element_namespaceObject.useContext)(BlockListBlockContext);
29035
- return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Fill, _extends({}, props, {
29036
- name: getSlotName(clientId)
29037
- }));
29038
- };
29039
- //# sourceMappingURL=block-slot.js.map
29040
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/list-view/block-contents.js
29041
 
 
 
 
29042
 
 
 
 
 
 
 
 
 
 
 
 
 
29043
 
29044
- /**
29045
- * External dependencies
29046
- */
29047
 
 
 
29048
  /**
29049
  * WordPress dependencies
29050
  */
29051
 
29052
 
29053
-
29054
  /**
29055
  * Internal dependencies
29056
  */
29057
 
29058
 
 
 
 
 
 
 
 
 
 
 
29059
 
 
 
 
 
 
 
 
29060
 
29061
-
29062
-
29063
- const ListViewBlockContents = (0,external_wp_element_namespaceObject.forwardRef)(({
29064
- onClick,
29065
- onToggleExpanded,
29066
- block,
29067
- isSelected,
29068
- position,
29069
- siblingBlockCount,
29070
- level,
29071
- ...props
29072
- }, ref) => {
29073
- const {
29074
- __experimentalFeatures
29075
- } = useListViewContext();
29076
- const {
29077
- clientId
29078
- } = block;
29079
  const {
29080
- blockMovingClientId,
29081
- selectedBlockInBlockEditor
 
 
 
29082
  } = (0,external_wp_data_namespaceObject.useSelect)(select => {
 
 
29083
  const {
29084
  getBlockRootClientId,
29085
- hasBlockMovingClientId,
29086
- getSelectedBlockClientId
 
29087
  } = select(store);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29088
  return {
29089
- rootClientId: getBlockRootClientId(clientId) || '',
29090
- blockMovingClientId: hasBlockMovingClientId(),
29091
- selectedBlockInBlockEditor: getSelectedBlockClientId()
 
 
29092
  };
29093
- }, [clientId]);
29094
- const isBlockMoveTarget = blockMovingClientId && selectedBlockInBlockEditor === clientId;
29095
- const className = classnames_default()('block-editor-list-view-block-contents', {
29096
- 'is-dropping-before': isBlockMoveTarget
29097
- });
29098
- return (0,external_wp_element_namespaceObject.createElement)(block_draggable, {
29099
- clientIds: [block.clientId]
29100
- }, ({
29101
- draggable,
29102
- onDragStart,
29103
- onDragEnd
29104
- }) => __experimentalFeatures ? (0,external_wp_element_namespaceObject.createElement)(block_slot, _extends({
29105
- ref: ref,
29106
- className: className,
29107
- block: block,
29108
- onToggleExpanded: onToggleExpanded,
29109
- isSelected: isSelected,
29110
- position: position,
29111
- siblingBlockCount: siblingBlockCount,
29112
- level: level,
29113
- draggable: draggable && __experimentalFeatures,
29114
- onDragStart: onDragStart,
29115
- onDragEnd: onDragEnd
29116
- }, props)) : (0,external_wp_element_namespaceObject.createElement)(block_select_button, _extends({
29117
- ref: ref,
29118
- className: className,
29119
- block: block,
29120
- onClick: onClick,
29121
- onToggleExpanded: onToggleExpanded,
29122
- isSelected: isSelected,
29123
- position: position,
29124
- siblingBlockCount: siblingBlockCount,
29125
- level: level,
29126
- draggable: draggable,
29127
- onDragStart: onDragStart,
29128
- onDragEnd: onDragEnd
29129
- }, props)));
29130
- });
29131
- /* harmony default export */ var block_contents = (ListViewBlockContents);
29132
- //# sourceMappingURL=block-contents.js.map
29133
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/list-view/block.js
29134
 
29135
 
29136
  /**
@@ -29143,199 +28191,69 @@ const ListViewBlockContents = (0,external_wp_element_namespaceObject.forwardRef)
29143
 
29144
 
29145
 
29146
-
29147
-
29148
-
29149
  /**
29150
  * Internal dependencies
29151
  */
29152
 
29153
 
29154
 
 
 
 
 
29155
 
29156
-
29157
-
29158
-
29159
- function ListViewBlock({
29160
- block,
29161
- isSelected,
29162
- isBranchSelected,
29163
- isLastOfSelectedBranch,
29164
- onClick,
29165
- onToggleExpanded,
29166
- position,
29167
- level,
29168
- rowCount,
29169
- siblingBlockCount,
29170
- showBlockMovers,
29171
- path,
29172
- isExpanded
29173
- }) {
29174
- const cellRef = (0,external_wp_element_namespaceObject.useRef)(null);
29175
- const [isHovered, setIsHovered] = (0,external_wp_element_namespaceObject.useState)(false);
29176
- const {
29177
- clientId
29178
- } = block;
29179
- const {
29180
- isDragging,
29181
- blockParents
29182
- } = (0,external_wp_data_namespaceObject.useSelect)(select => {
29183
  const {
29184
- isBlockBeingDragged,
29185
- isAncestorBeingDragged,
29186
- getBlockParents
29187
  } = select(store);
29188
- return {
29189
- isDragging: isBlockBeingDragged(clientId) || isAncestorBeingDragged(clientId),
29190
- blockParents: getBlockParents(clientId)
29191
- };
29192
- }, [clientId]);
29193
- const {
29194
- selectBlock: selectEditorBlock,
29195
- toggleBlockHighlight
29196
- } = (0,external_wp_data_namespaceObject.useDispatch)(store);
29197
- const hasSiblings = siblingBlockCount > 0;
29198
- const hasRenderedMovers = showBlockMovers && hasSiblings;
29199
- const moverCellClassName = classnames_default()('block-editor-list-view-block__mover-cell', {
29200
- 'is-visible': isHovered
29201
- });
29202
- const {
29203
- __experimentalFeatures: withExperimentalFeatures,
29204
- __experimentalPersistentListViewFeatures: withExperimentalPersistentListViewFeatures,
29205
- isTreeGridMounted
29206
- } = useListViewContext();
29207
- const listViewBlockSettingsClassName = classnames_default()('block-editor-list-view-block__menu-cell', {
29208
- 'is-visible': isHovered
29209
- }); // If ListView has experimental features related to the Persistent List View,
29210
- // only focus the selected list item on mount; otherwise the list would always
29211
- // try to steal the focus from the editor canvas.
29212
 
29213
- (0,external_wp_element_namespaceObject.useEffect)(() => {
29214
- if (withExperimentalPersistentListViewFeatures && !isTreeGridMounted && isSelected) {
29215
- cellRef.current.focus();
 
 
 
 
 
 
29216
  }
29217
- }, []); // If ListView has experimental features (such as drag and drop) enabled,
29218
- // leave the focus handling as it was before, to avoid accidental regressions.
29219
-
29220
- (0,external_wp_element_namespaceObject.useEffect)(() => {
29221
- if (withExperimentalFeatures && isSelected) {
29222
- cellRef.current.focus();
29223
  }
29224
- }, [withExperimentalFeatures, isSelected]);
29225
- const highlightBlock = withExperimentalPersistentListViewFeatures ? toggleBlockHighlight : () => {};
 
 
 
 
 
 
29226
 
29227
- const onMouseEnter = () => {
29228
- setIsHovered(true);
29229
- highlightBlock(clientId, true);
29230
- };
29231
 
29232
- const onMouseLeave = () => {
29233
- setIsHovered(false);
29234
- highlightBlock(clientId, false);
29235
- };
 
 
29236
 
29237
- const classes = classnames_default()({
29238
- 'is-selected': isSelected,
29239
- 'is-branch-selected': withExperimentalPersistentListViewFeatures && isBranchSelected,
29240
- 'is-last-of-selected-branch': withExperimentalPersistentListViewFeatures && isLastOfSelectedBranch,
29241
- 'is-dragging': isDragging
29242
- });
29243
- return (0,external_wp_element_namespaceObject.createElement)(ListViewLeaf, {
29244
- className: classes,
29245
- onMouseEnter: onMouseEnter,
29246
- onMouseLeave: onMouseLeave,
29247
- onFocus: onMouseEnter,
29248
- onBlur: onMouseLeave,
29249
- level: level,
29250
- position: position,
29251
- rowCount: rowCount,
29252
- path: path,
29253
- id: `list-view-block-${clientId}`,
29254
- "data-block": clientId,
29255
- isExpanded: isExpanded
29256
- }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalTreeGridCell, {
29257
- className: "block-editor-list-view-block__contents-cell",
29258
- colSpan: hasRenderedMovers ? undefined : 2,
29259
- ref: cellRef
29260
- }, ({
29261
- ref,
29262
- tabIndex,
29263
- onFocus
29264
- }) => (0,external_wp_element_namespaceObject.createElement)("div", {
29265
- className: "block-editor-list-view-block__contents-container"
29266
- }, (0,external_wp_element_namespaceObject.createElement)(block_contents, {
29267
- block: block,
29268
- onClick: onClick,
29269
- onToggleExpanded: onToggleExpanded,
29270
- isSelected: isSelected,
29271
- position: position,
29272
- siblingBlockCount: siblingBlockCount,
29273
- level: level,
29274
- ref: ref,
29275
- tabIndex: tabIndex,
29276
- onFocus: onFocus
29277
- }))), hasRenderedMovers && (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalTreeGridCell, {
29278
- className: moverCellClassName,
29279
- withoutGridItem: true
29280
- }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalTreeGridItem, null, ({
29281
- ref,
29282
- tabIndex,
29283
- onFocus
29284
- }) => (0,external_wp_element_namespaceObject.createElement)(BlockMoverUpButton, {
29285
- orientation: "vertical",
29286
- clientIds: [clientId],
29287
- ref: ref,
29288
- tabIndex: tabIndex,
29289
- onFocus: onFocus
29290
- })), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalTreeGridItem, null, ({
29291
- ref,
29292
- tabIndex,
29293
- onFocus
29294
- }) => (0,external_wp_element_namespaceObject.createElement)(BlockMoverDownButton, {
29295
- orientation: "vertical",
29296
- clientIds: [clientId],
29297
- ref: ref,
29298
- tabIndex: tabIndex,
29299
- onFocus: onFocus
29300
- })))), withExperimentalFeatures && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalTreeGridCell, {
29301
- className: listViewBlockSettingsClassName
29302
- }, ({
29303
- ref,
29304
- tabIndex,
29305
- onFocus
29306
- }) => (0,external_wp_element_namespaceObject.createElement)(block_settings_dropdown, {
29307
- clientIds: [clientId],
29308
- icon: more_vertical,
29309
- toggleProps: {
29310
- ref,
29311
- tabIndex,
29312
- onFocus
29313
- },
29314
- disableOpenOnArrowDown: true,
29315
- __experimentalSelectBlock: onClick
29316
- }, ({
29317
- onClose
29318
- }) => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
29319
- onClick: async () => {
29320
- if (blockParents.length) {
29321
- // If the block to select is inside a dropdown, we need to open the dropdown.
29322
- // Otherwise focus won't transfer to the block.
29323
- for (const parent of blockParents) {
29324
- await selectEditorBlock(parent);
29325
- }
29326
- } else {
29327
- // If clientId is already selected, it won't be focused (see block-wrapper.js)
29328
- // This removes the selection first to ensure the focus will always switch.
29329
- await selectEditorBlock(null);
29330
- }
29331
 
29332
- await selectEditorBlock(clientId);
29333
- onClose();
29334
- }
29335
- }, (0,external_wp_i18n_namespaceObject.__)('Go to block'))))));
29336
- }
29337
- //# sourceMappingURL=block.js.map
29338
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/list-view/appender.js
29339
 
29340
 
29341
  /**
@@ -29350,378 +28268,382 @@ function ListViewBlock({
29350
 
29351
 
29352
 
29353
- /**
29354
- * Internal dependencies
29355
- */
29356
-
29357
-
29358
 
29359
 
29360
- function ListViewAppender({
29361
- parentBlockClientId,
29362
- position,
29363
- level,
29364
- rowCount,
29365
- path
29366
- }) {
29367
- const isDragging = (0,external_wp_data_namespaceObject.useSelect)(select => {
29368
- const {
29369
- isBlockBeingDragged,
29370
- isAncestorBeingDragged
29371
- } = select(store);
29372
- return isBlockBeingDragged(parentBlockClientId) || isAncestorBeingDragged(parentBlockClientId);
29373
- }, [parentBlockClientId]);
29374
- const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(ListViewAppender);
29375
- const descriptionId = `list-view-appender-row__description_${instanceId}`;
29376
- const appenderPositionDescription = (0,external_wp_i18n_namespaceObject.sprintf)(
29377
- /* translators: 1: The numerical position of the block that will be inserted. 2: The level of nesting for the block that will be inserted. */
29378
- (0,external_wp_i18n_namespaceObject.__)('Add block at position %1$d, Level %2$d'), position, level);
29379
- return (0,external_wp_element_namespaceObject.createElement)(ListViewLeaf, {
29380
- className: classnames_default()({
29381
- 'is-dragging': isDragging
29382
- }),
29383
- level: level,
29384
- position: position,
29385
- rowCount: rowCount,
29386
- path: path
29387
- }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalTreeGridCell, {
29388
- className: "block-editor-list-view-appender__cell",
29389
- colSpan: "3"
29390
- }, ({
29391
- ref,
29392
- tabIndex,
29393
- onFocus
29394
- }) => (0,external_wp_element_namespaceObject.createElement)("div", {
29395
- className: "block-editor-list-view-appender__container"
29396
- }, (0,external_wp_element_namespaceObject.createElement)(inserter, {
29397
- rootClientId: parentBlockClientId,
29398
- __experimentalIsQuick: true,
29399
- "aria-describedby": descriptionId,
29400
- toggleProps: {
29401
- ref,
29402
- tabIndex,
29403
- onFocus
29404
- }
29405
- }), (0,external_wp_element_namespaceObject.createElement)("div", {
29406
- className: "block-editor-list-view-appender__description",
29407
- id: descriptionId
29408
- }, appenderPositionDescription))));
29409
- }
29410
- //# sourceMappingURL=appender.js.map
29411
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/list-view/branch.js
29412
 
29413
 
29414
  /**
29415
- * External dependencies
29416
  */
29417
 
29418
- /**
29419
- * WordPress dependencies
29420
- */
29421
 
29422
 
29423
- /**
29424
- * Internal dependencies
29425
- */
29426
 
29427
 
29428
 
29429
 
 
 
 
 
 
29430
 
29431
- function ListViewBranch(props) {
29432
- const {
29433
- blocks,
29434
- selectBlock,
29435
- selectedBlockClientIds,
29436
- showAppender,
29437
- showBlockMovers,
29438
- showNestedBlocks,
29439
- parentBlockClientId,
29440
- level = 1,
29441
- terminatedLevels = [],
29442
- path = [],
29443
- isBranchSelected = false,
29444
- isLastOfBranch = false
29445
- } = props;
29446
- const isTreeRoot = !parentBlockClientId;
29447
- const filteredBlocks = (0,external_lodash_namespaceObject.compact)(blocks);
29448
-
29449
- const itemHasAppender = parentClientId => showAppender && !isTreeRoot && isClientIdSelected(parentClientId, selectedBlockClientIds);
29450
 
29451
- const hasAppender = itemHasAppender(parentBlockClientId); // Add +1 to the rowCount to take the block appender into account.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29452
 
29453
- const blockCount = filteredBlocks.length;
29454
- const rowCount = hasAppender ? blockCount + 1 : blockCount;
29455
- const appenderPosition = rowCount;
29456
- const {
29457
- expandedState,
29458
- expand,
29459
- collapse
29460
- } = useListViewContext();
29461
- return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_lodash_namespaceObject.map)(filteredBlocks, (block, index) => {
29462
- var _expandedState$client;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29463
 
29464
- const {
29465
- clientId,
29466
- innerBlocks
29467
- } = block;
29468
- const position = index + 1;
29469
- const isLastRowAtLevel = rowCount === position;
29470
- const updatedTerminatedLevels = isLastRowAtLevel ? [...terminatedLevels, level] : terminatedLevels;
29471
- const updatedPath = [...path, position];
29472
- const hasNestedBlocks = showNestedBlocks && !!innerBlocks && !!innerBlocks.length;
29473
- const hasNestedAppender = itemHasAppender(clientId);
29474
- const hasNestedBranch = hasNestedBlocks || hasNestedAppender;
29475
- const isSelected = isClientIdSelected(clientId, selectedBlockClientIds);
29476
- const isSelectedBranch = isBranchSelected || isSelected && hasNestedBranch; // Logic needed to target the last item of a selected branch which might be deeply nested.
29477
- // This is currently only needed for styling purposes. See: `.is-last-of-selected-branch`.
29478
 
29479
- const isLastBlock = index === blockCount - 1;
29480
- const isLast = isSelected || isLastOfBranch && isLastBlock;
29481
- const isLastOfSelectedBranch = isLastOfBranch && !hasNestedBranch && isLastBlock;
29482
- const isExpanded = hasNestedBranch ? (_expandedState$client = expandedState[clientId]) !== null && _expandedState$client !== void 0 ? _expandedState$client : true : undefined;
29483
 
29484
- const selectBlockWithClientId = event => {
29485
- event.stopPropagation();
29486
- selectBlock(clientId);
29487
- };
29488
 
29489
- const toggleExpanded = event => {
29490
- event.stopPropagation();
 
29491
 
29492
- if (isExpanded === true) {
29493
- collapse(clientId);
29494
- } else if (isExpanded === false) {
29495
- expand(clientId);
29496
- }
29497
- };
29498
 
29499
- return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, {
29500
- key: clientId
29501
- }, (0,external_wp_element_namespaceObject.createElement)(ListViewBlock, {
29502
- block: block,
29503
- onClick: selectBlockWithClientId,
29504
- onToggleExpanded: toggleExpanded,
29505
- isSelected: isSelected,
29506
- isBranchSelected: isSelectedBranch,
29507
- isLastOfSelectedBranch: isLastOfSelectedBranch,
29508
- level: level,
29509
- position: position,
29510
- rowCount: rowCount,
29511
- siblingBlockCount: blockCount,
29512
- showBlockMovers: showBlockMovers,
29513
- terminatedLevels: terminatedLevels,
29514
- path: updatedPath,
29515
- isExpanded: isExpanded
29516
- }), hasNestedBranch && isExpanded && (0,external_wp_element_namespaceObject.createElement)(ListViewBranch, {
29517
- blocks: innerBlocks,
29518
- selectedBlockClientIds: selectedBlockClientIds,
29519
- selectBlock: selectBlock,
29520
- isBranchSelected: isSelectedBranch,
29521
- isLastOfBranch: isLast,
29522
- showAppender: showAppender,
29523
- showBlockMovers: showBlockMovers,
29524
- showNestedBlocks: showNestedBlocks,
29525
- parentBlockClientId: clientId,
29526
- level: level + 1,
29527
- terminatedLevels: updatedTerminatedLevels,
29528
- path: updatedPath
29529
- }));
29530
- }), hasAppender && (0,external_wp_element_namespaceObject.createElement)(ListViewAppender, {
29531
- parentBlockClientId: parentBlockClientId,
29532
- position: rowCount,
29533
- rowCount: appenderPosition,
29534
- level: level,
29535
- terminatedLevels: terminatedLevels,
29536
- path: [...path, appenderPosition]
29537
- }));
29538
  }
29539
- ListViewBranch.defaultProps = {
29540
- selectBlock: () => {}
29541
- };
29542
- //# sourceMappingURL=branch.js.map
29543
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/list-view/drop-indicator.js
29544
 
29545
 
 
 
 
 
29546
  /**
29547
  * WordPress dependencies
29548
  */
29549
 
29550
 
29551
- function ListViewDropIndicator({
29552
- listViewRef,
29553
- blockDropTarget
29554
- }) {
29555
- const {
29556
- rootClientId,
29557
- clientId,
29558
- dropPosition
29559
- } = blockDropTarget || {};
29560
- const [rootBlockElement, blockElement] = (0,external_wp_element_namespaceObject.useMemo)(() => {
29561
- if (!listViewRef.current) {
29562
- return [];
29563
- } // The rootClientId will be defined whenever dropping into inner
29564
- // block lists, but is undefined when dropping at the root level.
29565
 
29566
 
29567
- const _rootBlockElement = rootClientId ? listViewRef.current.querySelector(`[data-block="${rootClientId}"]`) : undefined; // The clientId represents the sibling block, the dragged block will
29568
- // usually be inserted adjacent to it. It will be undefined when
29569
- // dropping a block into an empty block list.
29570
 
29571
 
29572
- const _blockElement = clientId ? listViewRef.current.querySelector(`[data-block="${clientId}"]`) : undefined;
 
 
29573
 
29574
- return [_rootBlockElement, _blockElement];
29575
- }, [rootClientId, clientId]); // The targetElement is the element that the drop indicator will appear
29576
- // before or after. When dropping into an empty block list, blockElement
29577
- // is undefined, so the indicator will appear after the rootBlockElement.
29578
 
29579
- const targetElement = blockElement || rootBlockElement;
29580
- const getDropIndicatorIndent = (0,external_wp_element_namespaceObject.useCallback)(() => {
29581
- if (!rootBlockElement) {
29582
- return 0;
29583
- } // Calculate the indent using the block icon of the root block.
29584
- // Using a classname selector here might be flaky and could be
29585
- // improved.
29586
 
29587
 
29588
- const targetElementRect = targetElement.getBoundingClientRect();
29589
- const rootBlockIconElement = rootBlockElement.querySelector('.block-editor-block-icon');
29590
- const rootBlockIconRect = rootBlockIconElement.getBoundingClientRect();
29591
- return rootBlockIconRect.right - targetElementRect.left;
29592
- }, [rootBlockElement, targetElement]);
29593
- const style = (0,external_wp_element_namespaceObject.useMemo)(() => {
29594
- if (!targetElement) {
29595
- return {};
29596
- }
29597
 
29598
- const indent = getDropIndicatorIndent();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29599
  return {
29600
- width: targetElement.offsetWidth - indent
 
 
 
 
 
 
 
29601
  };
29602
- }, [getDropIndicatorIndent, targetElement]);
29603
- const getAnchorRect = (0,external_wp_element_namespaceObject.useCallback)(() => {
29604
- if (!targetElement) {
29605
- return {};
29606
- }
29607
 
29608
- const ownerDocument = targetElement.ownerDocument;
29609
- const rect = targetElement.getBoundingClientRect();
29610
- const indent = getDropIndicatorIndent();
29611
- const anchorRect = {
29612
- left: rect.left + indent,
29613
- right: rect.right,
29614
- width: 0,
29615
- height: rect.height,
29616
- ownerDocument
29617
- };
29618
 
29619
- if (dropPosition === 'top') {
29620
- return { ...anchorRect,
29621
- top: rect.top,
29622
- bottom: rect.top
29623
- };
 
29624
  }
29625
 
29626
- if (dropPosition === 'bottom' || dropPosition === 'inside') {
29627
- return { ...anchorRect,
29628
- top: rect.bottom,
29629
- bottom: rect.bottom
29630
- };
 
 
 
29631
  }
 
29632
 
29633
- return {};
29634
- }, [targetElement, dropPosition, getDropIndicatorIndent]);
29635
 
29636
- if (!targetElement) {
29637
  return null;
29638
  }
29639
 
29640
- return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Popover, {
29641
- noArrow: true,
29642
- animate: false,
29643
- getAnchorRect: getAnchorRect,
29644
- focusOnMount: false,
29645
- className: "block-editor-list-view-drop-indicator"
29646
- }, (0,external_wp_element_namespaceObject.createElement)("div", {
29647
- style: style,
29648
- className: "block-editor-list-view-drop-indicator__line"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29649
  }));
29650
  }
29651
- //# sourceMappingURL=drop-indicator.js.map
29652
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/list-view/use-list-view-client-ids.js
 
 
 
29653
  /**
29654
- * WordPress dependencies
29655
  */
29656
 
29657
  /**
29658
- * Internal dependencies
29659
  */
29660
 
29661
 
29662
 
29663
 
29664
- const useListViewSelectedClientIds = __experimentalPersistentListViewFeatures => (0,external_wp_data_namespaceObject.useSelect)(select => {
29665
- const {
29666
- getSelectedBlockClientId,
29667
- getSelectedBlockClientIds
29668
- } = select(store);
29669
 
29670
- if (__experimentalPersistentListViewFeatures) {
29671
- return getSelectedBlockClientIds();
29672
- }
29673
 
29674
- return getSelectedBlockClientId();
29675
- }, [__experimentalPersistentListViewFeatures]);
29676
 
29677
- const useListViewClientIdsTree = (blocks, selectedClientIds, showOnlyCurrentHierarchy) => (0,external_wp_data_namespaceObject.useSelect)(select => {
29678
- const {
29679
- getBlockHierarchyRootClientId,
29680
- __unstableGetClientIdsTree,
29681
- __unstableGetClientIdWithClientIdsTree
29682
- } = select(store);
29683
 
29684
- if (blocks) {
29685
- return blocks;
29686
- }
29687
 
29688
- const isSingleBlockSelected = selectedClientIds && !Array.isArray(selectedClientIds);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29689
 
29690
- if (!showOnlyCurrentHierarchy || !isSingleBlockSelected) {
29691
- return __unstableGetClientIdsTree();
29692
- }
 
 
29693
 
29694
- const rootBlock = __unstableGetClientIdWithClientIdsTree(getBlockHierarchyRootClientId(selectedClientIds));
29695
 
29696
- if (!rootBlock) {
29697
- return __unstableGetClientIdsTree();
29698
- }
 
 
 
 
 
 
 
 
 
 
 
29699
 
29700
- const hasHierarchy = !isClientIdSelected(rootBlock.clientId, selectedClientIds) || rootBlock.innerBlocks && rootBlock.innerBlocks.length !== 0;
 
 
29701
 
29702
- if (hasHierarchy) {
29703
- return [rootBlock];
29704
- }
29705
 
29706
- return __unstableGetClientIdsTree();
29707
- }, [blocks, selectedClientIds, showOnlyCurrentHierarchy]);
 
 
29708
 
29709
- function useListViewClientIds(blocks, showOnlyCurrentHierarchy, __experimentalPersistentListViewFeatures) {
29710
- const selectedClientIds = useListViewSelectedClientIds(__experimentalPersistentListViewFeatures);
29711
- const clientIdsTree = useListViewClientIdsTree(blocks, selectedClientIds, showOnlyCurrentHierarchy);
29712
- return {
29713
- clientIdsTree,
29714
- selectedClientIds
29715
- };
29716
- }
29717
- //# sourceMappingURL=use-list-view-client-ids.js.map
29718
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/list-view/use-list-view-drop-zone.js
29719
  /**
29720
  * WordPress dependencies
29721
  */
29722
 
29723
 
29724
 
 
 
 
 
 
29725
  /**
29726
  * Internal dependencies
29727
  */
@@ -29729,227 +28651,320 @@ function useListViewClientIds(blocks, showOnlyCurrentHierarchy, __experimentalPe
29729
 
29730
 
29731
 
29732
- /** @typedef {import('../../utils/math').WPPoint} WPPoint */
29733
 
29734
- /**
29735
- * The type of a drag event.
29736
- *
29737
- * @typedef {'default'|'file'|'html'} WPDragEventType
29738
- */
29739
-
29740
- /**
29741
- * An array representing data for blocks in the DOM used by drag and drop.
29742
- *
29743
- * @typedef {Object} WPListViewDropZoneBlocks
29744
- * @property {string} clientId The client id for the block.
29745
- * @property {string} rootClientId The root client id for the block.
29746
- * @property {number} blockIndex The block's index.
29747
- * @property {Element} element The DOM element representing the block.
29748
- * @property {number} innerBlockCount The number of inner blocks the block has.
29749
- * @property {boolean} isDraggedBlock Whether the block is currently being dragged.
29750
- * @property {boolean} canInsertDraggedBlocksAsSibling Whether the dragged block can be a sibling of this block.
29751
- * @property {boolean} canInsertDraggedBlocksAsChild Whether the dragged block can be a child of this block.
29752
- */
29753
 
29754
- /**
29755
- * An object containing details of a drop target.
29756
- *
29757
- * @typedef {Object} WPListViewDropZoneTarget
29758
- * @property {string} blockIndex The insertion index.
29759
- * @property {string} rootClientId The root client id for the block.
29760
- * @property {string|undefined} clientId The client id for the block.
29761
- * @property {'top'|'bottom'|'inside'} dropPosition The position relative to the block that the user is dropping to.
29762
- * 'inside' refers to nesting as an inner block.
29763
- */
29764
 
29765
- /**
29766
- * Is the point contained by the rectangle.
29767
- *
29768
- * @param {WPPoint} point The point.
29769
- * @param {DOMRect} rect The rectangle.
29770
- *
29771
- * @return {boolean} True if the point is contained by the rectangle, false otherwise.
29772
- */
29773
 
29774
- function isPointContainedByRect(point, rect) {
29775
- return rect.left <= point.x && rect.right >= point.x && rect.top <= point.y && rect.bottom >= point.y;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29776
  }
29777
- /**
29778
- * Determines whether the user positioning the dragged block to nest as an
29779
- * inner block.
29780
- *
29781
- * Presently this is determined by whether the cursor is on the right hand side
29782
- * of the block.
29783
- *
29784
- * @param {WPPoint} point The point representing the cursor position when dragging.
29785
- * @param {DOMRect} rect The rectangle.
29786
- */
29787
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29788
 
29789
- function isNestingGesture(point, rect) {
29790
- const blockCenterX = rect.left + rect.width / 2;
29791
- return point.x > blockCenterX;
29792
- } // Block navigation is always a vertical list, so only allow dropping
29793
- // to the above or below a block.
29794
 
 
 
 
 
 
 
 
 
 
 
 
29795
 
29796
- const ALLOWED_DROP_EDGES = ['top', 'bottom'];
29797
- /**
29798
- * Given blocks data and the cursor position, compute the drop target.
29799
- *
29800
- * @param {WPListViewDropZoneBlocks} blocksData Data about the blocks in list view.
29801
- * @param {WPPoint} position The point representing the cursor position when dragging.
29802
- *
29803
- * @return {WPListViewDropZoneTarget} An object containing data about the drop target.
29804
- */
 
 
 
 
 
 
 
 
 
29805
 
29806
- function getListViewDropTarget(blocksData, position) {
29807
- let candidateEdge;
29808
- let candidateBlockData;
29809
- let candidateDistance;
29810
- let candidateRect;
29811
 
29812
- for (const blockData of blocksData) {
29813
- if (blockData.isDraggedBlock) {
29814
- continue;
29815
- }
29816
 
29817
- const rect = blockData.element.getBoundingClientRect();
29818
- const [distance, edge] = getDistanceToNearestEdge(position, rect, ALLOWED_DROP_EDGES);
29819
- const isCursorWithinBlock = isPointContainedByRect(position, rect);
29820
 
29821
- if (candidateDistance === undefined || distance < candidateDistance || isCursorWithinBlock) {
29822
- candidateDistance = distance;
29823
- const index = blocksData.indexOf(blockData);
29824
- const previousBlockData = blocksData[index - 1]; // If dragging near the top of a block and the preceding block
29825
- // is at the same level, use the preceding block as the candidate
29826
- // instead, as later it makes determining a nesting drop easier.
29827
 
29828
- if (edge === 'top' && previousBlockData && previousBlockData.rootClientId === blockData.rootClientId && !previousBlockData.isDraggedBlock) {
29829
- candidateBlockData = previousBlockData;
29830
- candidateEdge = 'bottom';
29831
- candidateRect = previousBlockData.element.getBoundingClientRect();
29832
- } else {
29833
- candidateBlockData = blockData;
29834
- candidateEdge = edge;
29835
- candidateRect = rect;
29836
- } // If the mouse position is within the block, break early
29837
- // as the user would intend to drop either before or after
29838
- // this block.
29839
- //
29840
- // This solves an issue where some rows in the list view
29841
- // tree overlap slightly due to sub-pixel rendering.
29842
 
 
29843
 
29844
- if (isCursorWithinBlock) {
29845
- break;
29846
- }
 
 
29847
  }
 
 
 
 
 
29848
  }
29849
 
29850
- if (!candidateBlockData) {
29851
- return;
29852
  }
29853
 
29854
- const isDraggingBelow = candidateEdge === 'bottom'; // If the user is dragging towards the bottom of the block check whether
29855
- // they might be trying to nest the block as a child.
29856
- // If the block already has inner blocks, this should always be treated
29857
- // as nesting since the next block in the tree will be the first child.
 
 
29858
 
29859
- if (isDraggingBelow && candidateBlockData.canInsertDraggedBlocksAsChild && (candidateBlockData.innerBlockCount > 0 || isNestingGesture(position, candidateRect))) {
29860
- return {
29861
- rootClientId: candidateBlockData.clientId,
29862
- blockIndex: 0,
29863
- dropPosition: 'inside'
29864
- };
29865
- } // If dropping as a sibling, but block cannot be inserted in
29866
- // this context, return early.
29867
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29868
 
29869
- if (!candidateBlockData.canInsertDraggedBlocksAsSibling) {
29870
  return;
29871
  }
29872
 
29873
- const offset = isDraggingBelow ? 1 : 0;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29874
  return {
29875
- rootClientId: candidateBlockData.rootClientId,
29876
- clientId: candidateBlockData.clientId,
29877
- blockIndex: candidateBlockData.blockIndex + offset,
29878
- dropPosition: candidateEdge
 
 
 
 
 
29879
  };
29880
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29881
  /**
29882
- * A react hook for implementing a drop zone in list view.
29883
- *
29884
- * @return {WPListViewDropZoneTarget} The drop target.
29885
  */
29886
 
29887
 
29888
- function useListViewDropZone() {
29889
- const {
29890
- getBlockRootClientId,
29891
- getBlockIndex,
29892
- getBlockCount,
29893
- getDraggedBlockClientIds,
29894
- canInsertBlocks
29895
- } = (0,external_wp_data_namespaceObject.useSelect)(store);
29896
- const [target, setTarget] = (0,external_wp_element_namespaceObject.useState)();
29897
- const {
29898
- rootClientId: targetRootClientId,
29899
- blockIndex: targetBlockIndex
29900
- } = target || {};
29901
- const onBlockDrop = useOnBlockDrop(targetRootClientId, targetBlockIndex);
29902
- const draggedBlockClientIds = getDraggedBlockClientIds();
29903
- const throttled = (0,external_wp_compose_namespaceObject.useThrottle)((0,external_wp_element_namespaceObject.useCallback)((event, currentTarget) => {
29904
- const position = {
29905
- x: event.clientX,
29906
- y: event.clientY
29907
- };
29908
- const isBlockDrag = !!(draggedBlockClientIds !== null && draggedBlockClientIds !== void 0 && draggedBlockClientIds.length);
29909
- const blockElements = Array.from(currentTarget.querySelectorAll('[data-block]'));
29910
- const blocksData = blockElements.map(blockElement => {
29911
- const clientId = blockElement.dataset.block;
29912
- const rootClientId = getBlockRootClientId(clientId);
29913
- return {
29914
- clientId,
29915
- rootClientId,
29916
- blockIndex: getBlockIndex(clientId, rootClientId),
29917
- element: blockElement,
29918
- isDraggedBlock: isBlockDrag ? draggedBlockClientIds.includes(clientId) : false,
29919
- innerBlockCount: getBlockCount(clientId),
29920
- canInsertDraggedBlocksAsSibling: isBlockDrag ? canInsertBlocks(draggedBlockClientIds, rootClientId) : true,
29921
- canInsertDraggedBlocksAsChild: isBlockDrag ? canInsertBlocks(draggedBlockClientIds, clientId) : true
29922
- };
29923
- });
29924
- const newTarget = getListViewDropTarget(blocksData, position);
29925
 
29926
- if (newTarget) {
29927
- setTarget(newTarget);
29928
- }
29929
- }, [draggedBlockClientIds]), 200);
29930
- const ref = (0,external_wp_compose_namespaceObject.__experimentalUseDropZone)({
29931
- onDrop: onBlockDrop,
29932
 
29933
- onDragOver(event) {
29934
- // `currentTarget` is only available while the event is being
29935
- // handled, so get it now and pass it to the thottled function.
29936
- // https://developer.mozilla.org/en-US/docs/Web/API/Event/currentTarget
29937
- throttled(event, event.currentTarget);
29938
- },
29939
 
29940
- onDragEnd() {
29941
- throttled.cancel();
29942
- setTarget(null);
29943
- }
29944
 
 
 
 
 
 
 
 
 
 
 
 
 
29945
  });
29946
- return {
29947
- ref,
29948
- target
29949
- };
 
29950
  }
29951
- //# sourceMappingURL=use-list-view-drop-zone.js.map
29952
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/list-view/index.js
29953
 
29954
 
29955
 
@@ -29957,8 +28972,22 @@ function useListViewDropZone() {
29957
  * WordPress dependencies
29958
  */
29959
 
 
 
 
29960
 
29961
 
 
 
 
 
 
 
 
 
 
 
 
29962
 
29963
 
29964
  /**
@@ -29966,231 +28995,143 @@ function useListViewDropZone() {
29966
  */
29967
 
29968
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29969
 
29970
 
 
 
 
29971
 
 
 
 
29972
 
29973
 
29974
 
29975
- const noop = () => {};
 
 
29976
 
29977
- const expanded = (state, action) => {
29978
- switch (action.type) {
29979
- case 'expand':
29980
- return { ...state,
29981
- ...{
29982
- [action.clientId]: true
29983
- }
29984
- };
29985
 
29986
- case 'collapse':
29987
- return { ...state,
29988
- ...{
29989
- [action.clientId]: false
29990
- }
29991
- };
29992
-
29993
- default:
29994
- return state;
29995
- }
29996
- };
29997
- /**
29998
- * Wrap `ListViewRows` with `TreeGrid`. ListViewRows is a
29999
- * recursive component (it renders itself), so this ensures TreeGrid is only
30000
- * present at the very top of the navigation grid.
30001
- *
30002
- * @param {Object} props Components props.
30003
- * @param {Array} props.blocks Custom subset of block client IDs to be used instead of the default hierarchy.
30004
- * @param {Function} props.onSelect Block selection callback.
30005
- * @param {boolean} props.showNestedBlocks Flag to enable displaying nested blocks.
30006
- * @param {boolean} props.showOnlyCurrentHierarchy Flag to limit the list to the current hierarchy of blocks.
30007
- * @param {boolean} props.__experimentalFeatures Flag to enable experimental features.
30008
- * @param {boolean} props.__experimentalPersistentListViewFeatures Flag to enable features for the Persistent List View experiment.
30009
- */
30010
 
30011
 
30012
- function ListView({
30013
- blocks,
30014
- showOnlyCurrentHierarchy,
30015
- onSelect = noop,
30016
- __experimentalFeatures,
30017
- __experimentalPersistentListViewFeatures,
30018
- ...props
30019
- }) {
30020
- const {
30021
- clientIdsTree,
30022
- selectedClientIds
30023
- } = useListViewClientIds(blocks, showOnlyCurrentHierarchy, __experimentalPersistentListViewFeatures);
30024
- const {
30025
- selectBlock
30026
- } = (0,external_wp_data_namespaceObject.useDispatch)(store);
30027
- const selectEditorBlock = (0,external_wp_element_namespaceObject.useCallback)(clientId => {
30028
- selectBlock(clientId);
30029
- onSelect(clientId);
30030
- }, [selectBlock, onSelect]);
30031
- const [expandedState, setExpandedState] = (0,external_wp_element_namespaceObject.useReducer)(expanded, {});
30032
  const {
30033
- ref: dropZoneRef,
30034
- target: blockDropTarget
30035
- } = useListViewDropZone();
30036
- const elementRef = (0,external_wp_element_namespaceObject.useRef)();
30037
- const treeGridRef = (0,external_wp_compose_namespaceObject.useMergeRefs)([elementRef, dropZoneRef]);
30038
- const isMounted = (0,external_wp_element_namespaceObject.useRef)(false);
30039
- (0,external_wp_element_namespaceObject.useEffect)(() => {
30040
- isMounted.current = true;
30041
- }, []);
30042
-
30043
- const expand = clientId => {
30044
- if (!clientId) {
30045
- return;
30046
- }
30047
-
30048
- setExpandedState({
30049
- type: 'expand',
30050
- clientId
30051
- });
30052
- };
30053
-
30054
- const collapse = clientId => {
30055
- if (!clientId) {
30056
- return;
30057
- }
30058
-
30059
- setExpandedState({
30060
- type: 'collapse',
30061
- clientId
30062
- });
30063
- };
30064
-
30065
- const expandRow = row => {
30066
- var _row$dataset;
30067
-
30068
- expand(row === null || row === void 0 ? void 0 : (_row$dataset = row.dataset) === null || _row$dataset === void 0 ? void 0 : _row$dataset.block);
30069
- };
30070
-
30071
- const collapseRow = row => {
30072
- var _row$dataset2;
30073
-
30074
- collapse(row === null || row === void 0 ? void 0 : (_row$dataset2 = row.dataset) === null || _row$dataset2 === void 0 ? void 0 : _row$dataset2.block);
30075
  };
30076
-
30077
- const contextValue = (0,external_wp_element_namespaceObject.useMemo)(() => ({
30078
- __experimentalFeatures,
30079
- __experimentalPersistentListViewFeatures,
30080
- isTreeGridMounted: isMounted.current,
30081
- expandedState,
30082
- expand,
30083
- collapse
30084
- }), [__experimentalFeatures, __experimentalPersistentListViewFeatures, isMounted.current, expandedState, expand, collapse]);
30085
- return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(ListViewDropIndicator, {
30086
- listViewRef: elementRef,
30087
- blockDropTarget: blockDropTarget
30088
- }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalTreeGrid, {
30089
- className: "block-editor-list-view-tree",
30090
- "aria-label": (0,external_wp_i18n_namespaceObject.__)('Block navigation structure'),
30091
- ref: treeGridRef,
30092
- onCollapseRow: collapseRow,
30093
- onExpandRow: expandRow
30094
- }, (0,external_wp_element_namespaceObject.createElement)(ListViewContext.Provider, {
30095
- value: contextValue
30096
- }, (0,external_wp_element_namespaceObject.createElement)(ListViewBranch, _extends({
30097
- blocks: clientIdsTree,
30098
- selectBlock: selectEditorBlock,
30099
- selectedBlockClientIds: selectedClientIds
30100
- }, props)))));
30101
- }
30102
- //# sourceMappingURL=index.js.map
30103
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-navigation/dropdown.js
30104
-
30105
-
30106
-
30107
  /**
30108
  * WordPress dependencies
30109
  */
30110
 
30111
 
30112
 
30113
-
30114
-
30115
  /**
30116
  * Internal dependencies
30117
  */
30118
 
30119
 
30120
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30121
 
30122
- function BlockNavigationDropdownToggle({
30123
- isEnabled,
30124
- onToggle,
30125
- isOpen,
30126
- innerRef,
30127
- ...props
30128
- }) {
30129
- return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, _extends({}, props, {
30130
- ref: innerRef,
30131
- icon: list_view,
30132
- "aria-expanded": isOpen,
30133
- "aria-haspopup": "true",
30134
- onClick: isEnabled ? onToggle : undefined
30135
- /* translators: button label text should, if possible, be under 16 characters. */
30136
- ,
30137
- label: (0,external_wp_i18n_namespaceObject.__)('List view'),
30138
- className: "block-editor-block-navigation",
30139
- "aria-disabled": !isEnabled
30140
- }));
30141
- }
30142
-
30143
- function BlockNavigationDropdown({
30144
- isDisabled,
30145
- __experimentalFeatures,
30146
- ...props
30147
- }, ref) {
30148
- const hasBlocks = (0,external_wp_data_namespaceObject.useSelect)(select => !!select(store).getBlockCount(), []);
30149
- const isEnabled = hasBlocks && !isDisabled;
30150
- return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Dropdown, {
30151
- contentClassName: "block-editor-block-navigation__popover",
30152
- position: "bottom right",
30153
- renderToggle: ({
30154
- isOpen,
30155
- onToggle
30156
- }) => (0,external_wp_element_namespaceObject.createElement)(BlockNavigationDropdownToggle, _extends({}, props, {
30157
- innerRef: ref,
30158
- isOpen: isOpen,
30159
- onToggle: onToggle,
30160
- isEnabled: isEnabled
30161
- })),
30162
- renderContent: () => (0,external_wp_element_namespaceObject.createElement)("div", {
30163
- className: "block-editor-block-navigation__container"
30164
- }, (0,external_wp_element_namespaceObject.createElement)("p", {
30165
- className: "block-editor-block-navigation__label"
30166
- }, (0,external_wp_i18n_namespaceObject.__)('List view')), (0,external_wp_element_namespaceObject.createElement)(ListView, {
30167
- showNestedBlocks: true,
30168
- showOnlyCurrentHierarchy: true,
30169
- __experimentalFeatures: __experimentalFeatures
30170
- }))
30171
- });
30172
- }
30173
 
30174
- /* harmony default export */ var dropdown = ((0,external_wp_element_namespaceObject.forwardRef)(BlockNavigationDropdown));
30175
- //# sourceMappingURL=dropdown.js.map
30176
- ;// CONCATENATED MODULE: ./packages/icons/build-module/library/layout.js
30177
 
 
 
 
 
 
 
30178
 
30179
- /**
30180
- * WordPress dependencies
30181
- */
 
30182
 
30183
- const layout = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
30184
- xmlns: "http://www.w3.org/2000/svg",
30185
- viewBox: "0 0 24 24"
30186
- }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
30187
- d: "M18 5.5H6a.5.5 0 00-.5.5v3h13V6a.5.5 0 00-.5-.5zm.5 5H10v8h8a.5.5 0 00.5-.5v-7.5zm-10 0h-3V18a.5.5 0 00.5.5h2.5v-8zM6 4h12a2 2 0 012 2v12a2 2 0 01-2 2H6a2 2 0 01-2-2V6a2 2 0 012-2z"
30188
- }));
30189
- /* harmony default export */ var library_layout = (layout);
30190
- //# sourceMappingURL=layout.js.map
30191
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-variation-picker/index.js
30192
 
 
 
 
 
 
 
30193
 
 
 
 
 
 
 
 
30194
  /**
30195
  * External dependencies
30196
  */
@@ -30202,838 +29143,680 @@ const layout = (0,external_wp_element_namespaceObject.createElement)(external_wp
30202
 
30203
 
30204
 
30205
-
30206
- function BlockVariationPicker({
30207
- icon = library_layout,
30208
- label = (0,external_wp_i18n_namespaceObject.__)('Choose variation'),
30209
- instructions = (0,external_wp_i18n_namespaceObject.__)('Select a variation to start with.'),
30210
- variations,
30211
- onSelect,
30212
- allowSkip
30213
- }) {
30214
- const classes = classnames_default()('block-editor-block-variation-picker', {
30215
- 'has-many-variations': variations.length > 4
30216
- });
30217
- return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Placeholder, {
30218
- icon: icon,
30219
- label: label,
30220
- instructions: instructions,
30221
- className: classes
30222
- }, (0,external_wp_element_namespaceObject.createElement)("ul", {
30223
- className: "block-editor-block-variation-picker__variations",
30224
- role: "list",
30225
- "aria-label": (0,external_wp_i18n_namespaceObject.__)('Block variations')
30226
- }, variations.map(variation => (0,external_wp_element_namespaceObject.createElement)("li", {
30227
- key: variation.name
30228
- }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
30229
- variant: "secondary",
30230
- icon: variation.icon,
30231
- iconSize: 48,
30232
- onClick: () => onSelect(variation),
30233
- className: "block-editor-block-variation-picker__variation",
30234
- label: variation.description || variation.title
30235
- }), (0,external_wp_element_namespaceObject.createElement)("span", {
30236
- className: "block-editor-block-variation-picker__variation-label",
30237
- role: "presentation"
30238
- }, variation.title)))), allowSkip && (0,external_wp_element_namespaceObject.createElement)("div", {
30239
- className: "block-editor-block-variation-picker__skip"
30240
- }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
30241
- variant: "link",
30242
- onClick: () => onSelect()
30243
- }, (0,external_wp_i18n_namespaceObject.__)('Skip'))));
30244
- }
30245
-
30246
- /* harmony default export */ var block_variation_picker = (BlockVariationPicker);
30247
- //# sourceMappingURL=index.js.map
30248
- ;// CONCATENATED MODULE: ./packages/icons/build-module/library/grid.js
30249
-
30250
-
30251
  /**
30252
- * WordPress dependencies
30253
  */
30254
 
30255
- const grid = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
30256
- xmlns: "http://www.w3.org/2000/svg",
30257
- viewBox: "0 0 24 24"
30258
- }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
30259
- d: "M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-7.8 16.5H5c-.3 0-.5-.2-.5-.5v-6.2h6.8v6.7zm0-8.3H4.5V5c0-.3.2-.5.5-.5h6.2v6.7zm8.3 7.8c0 .3-.2.5-.5.5h-6.2v-6.8h6.8V19zm0-7.8h-6.8V4.5H19c.3 0 .5.2.5.5v6.2z",
30260
- fillRule: "evenodd",
30261
- clipRule: "evenodd"
30262
- }));
30263
- /* harmony default export */ var library_grid = (grid);
30264
- //# sourceMappingURL=grid.js.map
30265
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-pattern-setup/constants.js
30266
- const VIEWMODES = {
30267
- carousel: 'carousel',
30268
- grid: 'grid'
30269
- };
30270
- //# sourceMappingURL=constants.js.map
30271
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-pattern-setup/setup-toolbar.js
30272
-
30273
 
30274
  /**
30275
- * WordPress dependencies
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30276
  */
30277
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30278
 
 
 
 
30279
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30280
  /**
30281
- * Internal dependencies
30282
  */
30283
 
30284
-
30285
-
30286
- const Actions = ({
30287
- onStartBlank,
30288
- onBlockPatternSelect
30289
- }) => (0,external_wp_element_namespaceObject.createElement)("div", {
30290
- className: "block-editor-block-pattern-setup__actions"
30291
- }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
30292
- onClick: onStartBlank
30293
- }, (0,external_wp_i18n_namespaceObject.__)('Start blank')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
30294
- variant: "primary",
30295
- onClick: onBlockPatternSelect
30296
- }, (0,external_wp_i18n_namespaceObject.__)('Choose')));
30297
-
30298
- const CarouselNavigation = ({
30299
- handlePrevious,
30300
- handleNext,
30301
- activeSlide,
30302
- totalSlides
30303
- }) => (0,external_wp_element_namespaceObject.createElement)("div", {
30304
- className: "block-editor-block-pattern-setup__navigation"
30305
- }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
30306
- icon: chevron_left,
30307
- label: (0,external_wp_i18n_namespaceObject.__)('Previous pattern'),
30308
- onClick: handlePrevious,
30309
- disabled: activeSlide === 0
30310
- }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
30311
- icon: chevron_right,
30312
- label: (0,external_wp_i18n_namespaceObject.__)('Next pattern'),
30313
- onClick: handleNext,
30314
- disabled: activeSlide === totalSlides - 1
30315
- }));
30316
-
30317
- const SetupToolbar = ({
30318
- viewMode,
30319
- setViewMode,
30320
- handlePrevious,
30321
- handleNext,
30322
- activeSlide,
30323
- totalSlides,
30324
- onBlockPatternSelect,
30325
- onStartBlank
30326
- }) => {
30327
- const isCarouselView = viewMode === VIEWMODES.carousel;
30328
- const displayControls = (0,external_wp_element_namespaceObject.createElement)("div", {
30329
- className: "block-editor-block-pattern-setup__display-controls"
30330
- }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
30331
- icon: stretch_full_width,
30332
- label: (0,external_wp_i18n_namespaceObject.__)('Carousel view'),
30333
- onClick: () => setViewMode(VIEWMODES.carousel),
30334
- isPressed: isCarouselView
30335
- }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
30336
- icon: library_grid,
30337
- label: (0,external_wp_i18n_namespaceObject.__)('Grid view'),
30338
- onClick: () => setViewMode(VIEWMODES.grid),
30339
- isPressed: viewMode === VIEWMODES.grid
30340
- }));
30341
- return (0,external_wp_element_namespaceObject.createElement)("div", {
30342
- className: "block-editor-block-pattern-setup__toolbar"
30343
- }, isCarouselView && (0,external_wp_element_namespaceObject.createElement)(CarouselNavigation, {
30344
- handlePrevious: handlePrevious,
30345
- handleNext: handleNext,
30346
- activeSlide: activeSlide,
30347
- totalSlides: totalSlides
30348
- }), displayControls, isCarouselView && (0,external_wp_element_namespaceObject.createElement)(Actions, {
30349
- onBlockPatternSelect: onBlockPatternSelect,
30350
- onStartBlank: onStartBlank
30351
- }));
30352
- };
30353
-
30354
- /* harmony default export */ var setup_toolbar = (SetupToolbar);
30355
- //# sourceMappingURL=setup-toolbar.js.map
30356
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-pattern-setup/use-patterns-setup.js
30357
  /**
30358
- * WordPress dependencies
 
 
 
30359
  */
30360
 
 
30361
  /**
30362
- * Internal dependencies
 
 
 
 
 
 
30363
  */
30364
 
 
 
 
 
30365
 
 
30366
 
30367
- function usePatternsSetup(clientId, blockName, filterPatternsFn) {
30368
- return (0,external_wp_data_namespaceObject.useSelect)(select => {
30369
- const {
30370
- getBlockRootClientId,
30371
- __experimentalGetPatternsByBlockTypes,
30372
- __experimentalGetAllowedPatterns
30373
- } = select(store);
30374
- const rootClientId = getBlockRootClientId(clientId);
30375
-
30376
- if (filterPatternsFn) {
30377
- return __experimentalGetAllowedPatterns(rootClientId).filter(filterPatternsFn);
30378
- }
30379
 
30380
- return __experimentalGetPatternsByBlockTypes(blockName, rootClientId);
30381
- }, [clientId, blockName, filterPatternsFn]);
30382
  }
30383
-
30384
- /* harmony default export */ var use_patterns_setup = (usePatternsSetup);
30385
- //# sourceMappingURL=use-patterns-setup.js.map
30386
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-pattern-setup/index.js
30387
-
30388
-
30389
-
30390
  /**
30391
  * WordPress dependencies
30392
  */
30393
 
30394
 
30395
 
30396
-
30397
-
30398
-
30399
  /**
30400
  * Internal dependencies
30401
  */
30402
 
30403
 
 
30404
 
 
 
 
 
 
 
 
30405
 
 
 
 
 
 
 
 
 
30406
 
30407
-
30408
-
30409
- const SetupContent = ({
30410
- viewMode,
30411
- activeSlide,
30412
- patterns,
30413
- onBlockPatternSelect
30414
- }) => {
30415
- const composite = (0,external_wp_components_namespaceObject.__unstableUseCompositeState)();
30416
- const containerClass = 'block-editor-block-pattern-setup__container';
30417
-
30418
- if (viewMode === VIEWMODES.carousel) {
30419
- const slideClass = new Map([[activeSlide, 'active-slide'], [activeSlide - 1, 'previous-slide'], [activeSlide + 1, 'next-slide']]);
30420
- return (0,external_wp_element_namespaceObject.createElement)("div", {
30421
- className: containerClass
30422
- }, (0,external_wp_element_namespaceObject.createElement)("ul", {
30423
- className: "carousel-container"
30424
- }, patterns.map((pattern, index) => (0,external_wp_element_namespaceObject.createElement)(BlockPatternSlide, {
30425
- className: slideClass.get(index) || '',
30426
- key: pattern.name,
30427
- pattern: pattern
30428
- }))));
30429
  }
30430
 
30431
- return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableComposite, _extends({}, composite, {
30432
- role: "listbox",
30433
- className: containerClass,
30434
- "aria-label": (0,external_wp_i18n_namespaceObject.__)('Patterns list')
30435
- }), patterns.map(pattern => (0,external_wp_element_namespaceObject.createElement)(block_pattern_setup_BlockPattern, {
30436
- key: pattern.name,
30437
- pattern: pattern,
30438
- onSelect: onBlockPatternSelect,
30439
- composite: composite
30440
- })));
30441
- };
30442
 
30443
- function block_pattern_setup_BlockPattern({
30444
- pattern,
30445
- onSelect,
30446
- composite
30447
- }) {
30448
- const baseClassName = 'block-editor-block-pattern-setup-list';
30449
- const {
30450
- blocks,
30451
- title,
30452
- description,
30453
- viewportWidth = 700
30454
- } = pattern;
30455
- const descriptionId = (0,external_wp_compose_namespaceObject.useInstanceId)(block_pattern_setup_BlockPattern, `${baseClassName}__item-description`);
30456
- return (0,external_wp_element_namespaceObject.createElement)("div", {
30457
- className: `${baseClassName}__list-item`,
30458
- "aria-label": pattern.title,
30459
- "aria-describedby": pattern.description ? descriptionId : undefined
30460
- }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableCompositeItem, _extends({
30461
- role: "option",
30462
- as: "div"
30463
- }, composite, {
30464
- className: `${baseClassName}__item`,
30465
- onClick: () => onSelect(blocks)
30466
- }), (0,external_wp_element_namespaceObject.createElement)(block_preview, {
30467
- blocks: blocks,
30468
- viewportWidth: viewportWidth
30469
- }), (0,external_wp_element_namespaceObject.createElement)("div", {
30470
- className: `${baseClassName}__item-title`
30471
- }, title)), !!description && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, {
30472
- id: descriptionId
30473
- }, description));
30474
  }
 
 
 
 
 
 
 
 
 
 
 
 
30475
 
30476
- function BlockPatternSlide({
30477
- className,
30478
- pattern
30479
- }) {
30480
- const {
30481
- blocks,
30482
- title,
30483
- description
30484
- } = pattern;
30485
- const descriptionId = (0,external_wp_compose_namespaceObject.useInstanceId)(BlockPatternSlide, 'block-editor-block-pattern-setup-list__item-description');
30486
- return (0,external_wp_element_namespaceObject.createElement)("li", {
30487
- className: `pattern-slide ${className}`,
30488
- "aria-label": title,
30489
- "aria-describedby": description ? descriptionId : undefined
30490
- }, (0,external_wp_element_namespaceObject.createElement)(block_preview, {
30491
- blocks: blocks,
30492
- __experimentalLive: true
30493
- }), !!description && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, {
30494
- id: descriptionId
30495
- }, description));
30496
- }
30497
 
30498
- const BlockPatternSetup = ({
30499
- clientId,
30500
- blockName,
30501
- filterPatternsFn,
30502
- startBlankComponent,
30503
- onBlockPatternSelect
30504
- }) => {
30505
- const [viewMode, setViewMode] = (0,external_wp_element_namespaceObject.useState)(VIEWMODES.carousel);
30506
- const [activeSlide, setActiveSlide] = (0,external_wp_element_namespaceObject.useState)(0);
30507
- const [showBlank, setShowBlank] = (0,external_wp_element_namespaceObject.useState)(false);
30508
- const {
30509
- replaceBlock
30510
- } = (0,external_wp_data_namespaceObject.useDispatch)(store);
30511
- const patterns = use_patterns_setup(clientId, blockName, filterPatternsFn);
30512
 
30513
- if (!(patterns !== null && patterns !== void 0 && patterns.length) || showBlank) {
30514
- return startBlankComponent;
30515
- }
30516
 
30517
- const onBlockPatternSelectDefault = blocks => {
30518
- const clonedBlocks = blocks.map(block => (0,external_wp_blocks_namespaceObject.cloneBlock)(block));
30519
- replaceBlock(clientId, clonedBlocks);
30520
- };
30521
 
30522
- const onPatternSelectCallback = onBlockPatternSelect || onBlockPatternSelectDefault;
30523
- return (0,external_wp_element_namespaceObject.createElement)("div", {
30524
- className: `block-editor-block-pattern-setup view-mode-${viewMode}`
30525
- }, (0,external_wp_element_namespaceObject.createElement)(setup_toolbar, {
30526
- viewMode: viewMode,
30527
- setViewMode: setViewMode,
30528
- activeSlide: activeSlide,
30529
- totalSlides: patterns.length,
30530
- handleNext: () => {
30531
- setActiveSlide(active => active + 1);
30532
- },
30533
- handlePrevious: () => {
30534
- setActiveSlide(active => active - 1);
30535
- },
30536
- onBlockPatternSelect: () => {
30537
- onPatternSelectCallback(patterns[activeSlide].blocks);
30538
- },
30539
- onStartBlank: () => {
30540
- setShowBlank(true);
30541
- }
30542
- }), (0,external_wp_element_namespaceObject.createElement)(SetupContent, {
30543
- viewMode: viewMode,
30544
- activeSlide: activeSlide,
30545
- patterns: patterns,
30546
- onBlockPatternSelect: onPatternSelectCallback
30547
- }));
30548
- };
30549
 
30550
- /* harmony default export */ var block_pattern_setup = (BlockPatternSetup);
30551
- //# sourceMappingURL=index.js.map
30552
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/utils/block-variation-transforms.js
30553
- /**
30554
- * External dependencies
30555
- */
30556
 
30557
- /** @typedef {import('@wordpress/blocks').WPBlockVariation} WPBlockVariation */
 
 
 
 
 
 
 
30558
 
 
 
 
 
 
30559
  /**
30560
- * Matches the provided block variations with a block's attributes. If no match
30561
- * or more than one matches are found it returns `undefined`. If a single match is
30562
- * found it returns it.
30563
  *
30564
- * This is a simple implementation for now as it takes into account only the attributes
30565
- * of a block variation and not `InnerBlocks`.
 
 
 
 
30566
  *
30567
- * @param {Object} blockAttributes - The block attributes to try to find a match.
30568
- * @param {WPBlockVariation[]} variations - A list of block variations to test for a match.
30569
- * @return {?WPBlockVariation} - If a match is found returns it. If not or more than one matches are found returns `undefined`.
30570
  */
30571
 
30572
- const __experimentalGetMatchingVariation = (blockAttributes, variations) => {
30573
- if (!variations || !blockAttributes) return;
30574
- const matches = variations.filter(({
30575
- attributes
30576
- }) => {
30577
- if (!attributes || !Object.keys(attributes).length) return false;
30578
- return (0,external_lodash_namespaceObject.isMatch)(blockAttributes, attributes);
30579
- });
30580
- if (matches.length !== 1) return;
30581
- return matches[0];
30582
- };
30583
- //# sourceMappingURL=block-variation-transforms.js.map
30584
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-variation-transforms/index.js
30585
 
 
30586
 
 
 
 
 
 
 
30587
  /**
30588
- * WordPress dependencies
 
 
 
 
 
 
30589
  */
30590
 
 
 
 
 
 
 
30591
 
30592
-
30593
-
30594
-
30595
-
 
30596
  /**
30597
- * Internal dependencies
 
 
 
 
 
30598
  */
30599
 
30600
-
30601
-
30602
-
30603
- function __experimentalBlockVariationTransforms({
30604
- blockClientId
30605
- }) {
30606
- const [selectedValue, setSelectedValue] = (0,external_wp_element_namespaceObject.useState)();
30607
  const {
30608
- updateBlockAttributes
30609
- } = (0,external_wp_data_namespaceObject.useDispatch)(store);
 
 
30610
  const {
30611
- variations,
30612
- blockAttributes
30613
- } = (0,external_wp_data_namespaceObject.useSelect)(select => {
30614
- const {
30615
- getBlockVariations
30616
- } = select(external_wp_blocks_namespaceObject.store);
30617
- const {
30618
- getBlockName,
30619
- getBlockAttributes
30620
- } = select(store);
30621
- const blockName = blockClientId && getBlockName(blockClientId);
30622
- return {
30623
- variations: blockName && getBlockVariations(blockName, 'transform'),
30624
- blockAttributes: getBlockAttributes(blockClientId)
30625
- };
30626
- }, [blockClientId]);
30627
- (0,external_wp_element_namespaceObject.useEffect)(() => {
30628
- var _getMatchingVariation;
30629
 
30630
- setSelectedValue((_getMatchingVariation = __experimentalGetMatchingVariation(blockAttributes, variations)) === null || _getMatchingVariation === void 0 ? void 0 : _getMatchingVariation.name);
30631
- }, [blockAttributes, variations]);
30632
- if (!(variations !== null && variations !== void 0 && variations.length)) return null;
30633
- const selectOptions = variations.map(({
30634
- name,
30635
- title,
30636
- description
30637
- }) => ({
30638
- value: name,
30639
- label: title,
30640
- info: description
30641
- }));
30642
 
30643
- const onSelectVariation = variationName => {
30644
- updateBlockAttributes(blockClientId, { ...variations.find(({
30645
- name
30646
- }) => name === variationName).attributes
30647
- });
30648
- };
30649
 
30650
- const baseClass = 'block-editor-block-variation-transforms';
30651
- return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.DropdownMenu, {
30652
- className: baseClass,
30653
- label: (0,external_wp_i18n_namespaceObject.__)('Transform to variation'),
30654
- text: (0,external_wp_i18n_namespaceObject.__)('Transform to variation'),
30655
- popoverProps: {
30656
- position: 'bottom center',
30657
- className: `${baseClass}__popover`
30658
- },
30659
- icon: chevron_down,
30660
- toggleProps: {
30661
- iconPosition: 'right'
30662
  }
30663
- }, () => (0,external_wp_element_namespaceObject.createElement)("div", {
30664
- className: `${baseClass}__container`
30665
- }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItemsChoice, {
30666
- choices: selectOptions,
30667
- value: selectedValue,
30668
- onSelect: onSelectVariation
30669
- }))));
30670
  }
30671
-
30672
- /* harmony default export */ var block_variation_transforms = (__experimentalBlockVariationTransforms);
30673
  //# sourceMappingURL=index.js.map
30674
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-vertical-alignment-control/icons.js
30675
-
 
 
 
 
30676
 
30677
  /**
30678
- * WordPress dependencies
 
 
30679
  */
30680
 
30681
- const alignBottom = (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SVG, {
30682
- xmlns: "http://www.w3.org/2000/svg",
30683
- viewBox: "0 0 24 24"
30684
- }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Path, {
30685
- d: "M15 4H9v11h6V4zM4 18.5V20h16v-1.5H4z"
30686
- }));
30687
- const icons_alignCenter = (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SVG, {
30688
- xmlns: "http://www.w3.org/2000/svg",
30689
- viewBox: "0 0 24 24"
30690
- }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Path, {
30691
- d: "M20 11h-5V4H9v7H4v1.5h5V20h6v-7.5h5z"
30692
- }));
30693
- const alignTop = (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SVG, {
30694
- xmlns: "http://www.w3.org/2000/svg",
30695
- viewBox: "0 0 24 24"
30696
- }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Path, {
30697
- d: "M9 20h6V9H9v11zM4 4v1.5h16V4H4z"
30698
- }));
30699
- //# sourceMappingURL=icons.js.map
30700
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-vertical-alignment-control/ui.js
 
 
 
 
 
 
 
 
 
 
 
30701
 
 
30702
 
 
 
 
 
 
 
 
30703
 
 
 
30704
  /**
30705
- * WordPress dependencies
 
 
 
 
 
 
 
 
 
30706
  */
30707
 
 
 
 
 
 
30708
 
 
 
 
 
 
 
 
 
 
30709
  /**
30710
- * Internal dependencies
30711
  */
30712
 
30713
 
30714
- const ui_BLOCK_ALIGNMENTS_CONTROLS = {
30715
- top: {
30716
- icon: alignTop,
30717
- title: (0,external_wp_i18n_namespaceObject._x)('Align top', 'Block vertical alignment setting')
30718
- },
30719
- center: {
30720
- icon: icons_alignCenter,
30721
- title: (0,external_wp_i18n_namespaceObject._x)('Align middle', 'Block vertical alignment setting')
30722
- },
30723
- bottom: {
30724
- icon: alignBottom,
30725
- title: (0,external_wp_i18n_namespaceObject._x)('Align bottom', 'Block vertical alignment setting')
30726
- }
30727
- };
30728
- const ui_DEFAULT_CONTROLS = ['top', 'center', 'bottom'];
30729
- const ui_DEFAULT_CONTROL = 'top';
30730
- const block_vertical_alignment_control_ui_POPOVER_PROPS = {
30731
- isAlternate: true
30732
- };
30733
 
30734
- function BlockVerticalAlignmentUI({
30735
- value,
30736
- onChange,
30737
- controls = ui_DEFAULT_CONTROLS,
30738
- isCollapsed = true,
30739
- isToolbar
30740
- }) {
30741
- function applyOrUnset(align) {
30742
- return () => onChange(value === align ? undefined : align);
30743
- }
30744
 
30745
- const activeAlignment = ui_BLOCK_ALIGNMENTS_CONTROLS[value];
30746
- const defaultAlignmentControl = ui_BLOCK_ALIGNMENTS_CONTROLS[ui_DEFAULT_CONTROL];
30747
- const UIComponent = isToolbar ? external_wp_components_namespaceObject.ToolbarGroup : external_wp_components_namespaceObject.ToolbarDropdownMenu;
30748
- const extraProps = isToolbar ? {
30749
- isCollapsed
30750
- } : {};
30751
- return (0,external_wp_element_namespaceObject.createElement)(UIComponent, _extends({
30752
- popoverProps: block_vertical_alignment_control_ui_POPOVER_PROPS,
30753
- icon: activeAlignment ? activeAlignment.icon : defaultAlignmentControl.icon,
30754
- label: (0,external_wp_i18n_namespaceObject._x)('Change vertical alignment', 'Block vertical alignment setting label'),
30755
- controls: controls.map(control => {
30756
- return { ...ui_BLOCK_ALIGNMENTS_CONTROLS[control],
30757
- isActive: value === control,
30758
- role: isCollapsed ? 'menuitemradio' : undefined,
30759
- onClick: applyOrUnset(control)
30760
- };
30761
- })
30762
- }, extraProps));
30763
- }
30764
  /**
30765
- * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-vertical-alignment-toolbar/README.md
30766
  */
30767
 
30768
 
30769
- /* harmony default export */ var block_vertical_alignment_control_ui = (BlockVerticalAlignmentUI);
30770
- //# sourceMappingURL=ui.js.map
30771
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-vertical-alignment-control/index.js
30772
 
30773
 
 
30774
 
30775
  /**
30776
- * Internal dependencies
 
 
30777
  */
30778
 
30779
- function BlockVerticalAlignmentControl(props) {
30780
- return (0,external_wp_element_namespaceObject.createElement)(block_vertical_alignment_control_ui, _extends({}, props, {
30781
- isToolbar: false
30782
- }));
30783
- }
30784
- function BlockVerticalAlignmentToolbar(props) {
30785
- return (0,external_wp_element_namespaceObject.createElement)(block_vertical_alignment_control_ui, _extends({}, props, {
30786
- isToolbar: true
30787
- }));
30788
- }
30789
- //# sourceMappingURL=index.js.map
30790
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/color-palette/with-color-context.js
30791
 
 
 
 
 
 
 
 
 
30792
 
 
 
 
 
 
 
 
30793
 
 
 
 
 
 
 
30794
  /**
30795
- * External dependencies
 
30796
  */
30797
 
30798
  /**
30799
- * WordPress dependencies
 
 
30800
  */
30801
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30802
 
30803
- /**
30804
- * Internal dependencies
30805
- */
 
 
 
 
30806
 
 
 
 
 
 
 
 
30807
 
30808
- /* harmony default export */ var with_color_context = ((0,external_wp_compose_namespaceObject.createHigherOrderComponent)(WrappedComponent => {
30809
- return props => {
30810
- const colorsFeature = useSetting('color.palette');
30811
- const disableCustomColorsFeature = !useSetting('color.custom');
30812
- const colors = props.colors === undefined ? colorsFeature : props.colors;
30813
- const disableCustomColors = props.disableCustomColors === undefined ? disableCustomColorsFeature : props.disableCustomColors;
30814
- const hasColorsToChoose = !(0,external_lodash_namespaceObject.isEmpty)(colors) || !disableCustomColors;
30815
- return (0,external_wp_element_namespaceObject.createElement)(WrappedComponent, _extends({}, props, {
30816
- colors,
30817
- disableCustomColors,
30818
- hasColorsToChoose
30819
- }));
30820
- };
30821
- }, 'withColorContext'));
30822
- //# sourceMappingURL=with-color-context.js.map
30823
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/color-palette/index.js
30824
- /**
30825
- * WordPress dependencies
30826
- */
30827
 
30828
- /**
30829
- * Internal dependencies
30830
- */
 
 
30831
 
 
 
 
 
 
30832
 
30833
- /* harmony default export */ var color_palette = (with_color_context(external_wp_components_namespaceObject.ColorPalette));
 
30834
  //# sourceMappingURL=index.js.map
30835
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/color-palette/control.js
30836
 
30837
 
30838
 
30839
  /**
30840
- * Internal dependencies
30841
  */
30842
 
30843
- function ColorPaletteControl({
30844
- onChange,
30845
- value,
30846
- ...otherProps
30847
- }) {
30848
- return (0,external_wp_element_namespaceObject.createElement)(control, _extends({}, otherProps, {
30849
- onColorChange: onChange,
30850
- colorValue: value,
30851
- gradients: [],
30852
- disableCustomGradients: true
30853
- }));
30854
- }
30855
- //# sourceMappingURL=control.js.map
30856
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/image-size-control/use-dimension-handler.js
30857
  /**
30858
  * WordPress dependencies
30859
  */
30860
 
30861
- function useDimensionHander(customHeight, customWidth, defaultHeight, defaultWidth, onChange) {
30862
- var _ref, _ref2;
30863
 
30864
- const [currentWidth, setCurrentWidth] = (0,external_wp_element_namespaceObject.useState)((_ref = customWidth !== null && customWidth !== void 0 ? customWidth : defaultWidth) !== null && _ref !== void 0 ? _ref : '');
30865
- const [currentHeight, setCurrentHeight] = (0,external_wp_element_namespaceObject.useState)((_ref2 = customHeight !== null && customHeight !== void 0 ? customHeight : defaultHeight) !== null && _ref2 !== void 0 ? _ref2 : ''); // When an image is first inserted, the default dimensions are initially
30866
- // undefined. This effect updates the dimensions when the default values
30867
- // come through.
30868
 
30869
- (0,external_wp_element_namespaceObject.useEffect)(() => {
30870
- if (customWidth === undefined && defaultWidth !== undefined) {
30871
- setCurrentWidth(defaultWidth);
30872
- }
30873
 
30874
- if (customHeight === undefined && defaultHeight !== undefined) {
30875
- setCurrentHeight(defaultHeight);
30876
- }
30877
- }, [defaultWidth, defaultHeight]);
30878
 
30879
- const updateDimension = (dimension, value) => {
30880
- if (dimension === 'width') {
30881
- setCurrentWidth(value);
30882
- } else {
30883
- setCurrentHeight(value);
30884
- }
30885
 
30886
- onChange({
30887
- [dimension]: value === '' ? undefined : parseInt(value, 10)
30888
- });
30889
- };
30890
 
30891
- const updateDimensions = (nextHeight, nextWidth) => {
30892
- setCurrentHeight(nextHeight !== null && nextHeight !== void 0 ? nextHeight : defaultHeight);
30893
- setCurrentWidth(nextWidth !== null && nextWidth !== void 0 ? nextWidth : defaultWidth);
30894
- onChange({
30895
- height: nextHeight,
30896
- width: nextWidth
30897
- });
30898
- };
30899
 
30900
- return {
30901
- currentHeight,
30902
- currentWidth,
30903
- updateDimension,
30904
- updateDimensions
30905
- };
30906
- }
30907
- //# sourceMappingURL=use-dimension-handler.js.map
30908
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/image-size-control/index.js
30909
 
30910
 
30911
- /**
30912
- * External dependencies
30913
- */
30914
 
30915
- /**
30916
- * WordPress dependencies
30917
- */
30918
 
30919
 
30920
 
30921
  /**
30922
- * Internal dependencies
 
 
 
 
 
30923
  */
30924
 
30925
-
30926
- const IMAGE_SIZE_PRESETS = [25, 50, 75, 100];
30927
- function ImageSizeControl({
30928
- imageWidth,
30929
- imageHeight,
30930
- imageSizeOptions = [],
30931
- isResizable = true,
30932
- slug,
30933
- width,
30934
- height,
30935
- onChange,
30936
- onChangeImage = external_lodash_namespaceObject.noop
30937
- }) {
30938
  const {
30939
- currentHeight,
30940
- currentWidth,
30941
- updateDimension,
30942
- updateDimensions
30943
- } = useDimensionHander(height, width, imageHeight, imageWidth, onChange);
30944
- return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, !(0,external_lodash_namespaceObject.isEmpty)(imageSizeOptions) && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SelectControl, {
30945
- label: (0,external_wp_i18n_namespaceObject.__)('Image size'),
30946
- value: slug,
30947
- options: imageSizeOptions,
30948
- onChange: onChangeImage
30949
- }), isResizable && (0,external_wp_element_namespaceObject.createElement)("div", {
30950
- className: "block-editor-image-size-control"
30951
- }, (0,external_wp_element_namespaceObject.createElement)("p", {
30952
- className: "block-editor-image-size-control__row"
30953
- }, (0,external_wp_i18n_namespaceObject.__)('Image dimensions')), (0,external_wp_element_namespaceObject.createElement)("div", {
30954
- className: "block-editor-image-size-control__row"
30955
- }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextControl, {
30956
- type: "number",
30957
- className: "block-editor-image-size-control__width",
30958
- label: (0,external_wp_i18n_namespaceObject.__)('Width'),
30959
- value: currentWidth,
30960
- min: 1,
30961
- onChange: value => updateDimension('width', value)
30962
- }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextControl, {
30963
- type: "number",
30964
- className: "block-editor-image-size-control__height",
30965
- label: (0,external_wp_i18n_namespaceObject.__)('Height'),
30966
- value: currentHeight,
30967
- min: 1,
30968
- onChange: value => updateDimension('height', value)
30969
- })), (0,external_wp_element_namespaceObject.createElement)("div", {
30970
- className: "block-editor-image-size-control__row"
30971
- }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ButtonGroup, {
30972
- "aria-label": (0,external_wp_i18n_namespaceObject.__)('Image size presets')
30973
- }, IMAGE_SIZE_PRESETS.map(scale => {
30974
- const scaledWidth = Math.round(imageWidth * (scale / 100));
30975
- const scaledHeight = Math.round(imageHeight * (scale / 100));
30976
- const isCurrent = currentWidth === scaledWidth && currentHeight === scaledHeight;
30977
- return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
30978
- key: scale,
30979
- isSmall: true,
30980
- variant: isCurrent ? 'primary' : undefined,
30981
- isPressed: isCurrent,
30982
- onClick: () => updateDimensions(scaledHeight, scaledWidth)
30983
- }, scale, "%");
30984
- })), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
30985
- isSmall: true,
30986
- onClick: () => updateDimensions()
30987
- }, (0,external_wp_i18n_namespaceObject.__)('Reset')))));
30988
- }
30989
- //# sourceMappingURL=index.js.map
30990
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/inner-blocks/with-client-id.js
30991
 
 
 
 
30992
 
 
 
 
30993
 
 
 
 
 
 
 
 
 
 
 
 
30994
  /**
30995
- * WordPress dependencies
 
 
 
 
 
 
30996
  */
30997
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30998
  /**
30999
- * Internal dependencies
 
 
 
 
 
 
 
 
 
 
 
 
31000
  */
31001
 
31002
-
31003
- const withClientId = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(WrappedComponent => props => {
31004
  const {
31005
  clientId
31006
  } = useBlockEditContext();
31007
- return (0,external_wp_element_namespaceObject.createElement)(WrappedComponent, _extends({}, props, {
31008
- clientId: clientId
31009
- }));
31010
- }, 'withClientId');
31011
- /* harmony default export */ var with_client_id = (withClientId);
31012
- //# sourceMappingURL=with-client-id.js.map
31013
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/inner-blocks/button-block-appender.js
 
31014
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31015
 
 
 
 
 
 
31016
  /**
31017
- * Internal dependencies
31018
  */
31019
 
31020
-
31021
- const button_block_appender_ButtonBlockAppender = ({
31022
- clientId,
31023
- showSeparator,
31024
- isFloating,
31025
- onAddBlock
31026
- }) => {
31027
- return (0,external_wp_element_namespaceObject.createElement)(button_block_appender, {
31028
- rootClientId: clientId,
31029
- showSeparator: showSeparator,
31030
- isFloating: isFloating,
31031
- onAddBlock: onAddBlock
31032
- });
31033
- };
31034
- /* harmony default export */ var inner_blocks_button_block_appender = (with_client_id(button_block_appender_ButtonBlockAppender));
31035
- //# sourceMappingURL=button-block-appender.js.map
31036
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/inner-blocks/default-block-appender.js
31037
 
31038
 
31039
  /**
@@ -31046,6 +29829,7 @@ const button_block_appender_ButtonBlockAppender = ({
31046
 
31047
 
31048
 
 
31049
  /**
31050
  * Internal dependencies
31051
  */
@@ -31053,112 +29837,142 @@ const button_block_appender_ButtonBlockAppender = ({
31053
 
31054
 
31055
 
31056
- const default_block_appender_DefaultBlockAppender = ({
31057
- clientId,
31058
- lastBlockClientId
31059
- }) => {
31060
- return (0,external_wp_element_namespaceObject.createElement)(default_block_appender, {
31061
- rootClientId: clientId,
31062
- lastBlockClientId: lastBlockClientId
31063
- });
31064
- };
31065
- /* harmony default export */ var inner_blocks_default_block_appender = ((0,external_wp_compose_namespaceObject.compose)([with_client_id, (0,external_wp_data_namespaceObject.withSelect)((select, {
31066
- clientId
31067
- }) => {
31068
- const {
31069
- getBlockOrder
31070
- } = select(store);
31071
- const blockClientIds = getBlockOrder(clientId);
31072
- return {
31073
- lastBlockClientId: (0,external_lodash_namespaceObject.last)(blockClientIds)
31074
- };
31075
- })])(default_block_appender_DefaultBlockAppender));
31076
- //# sourceMappingURL=default-block-appender.js.map
31077
- ;// CONCATENATED MODULE: external ["wp","isShallowEqual"]
31078
- var external_wp_isShallowEqual_namespaceObject = window["wp"]["isShallowEqual"];
31079
- var external_wp_isShallowEqual_default = /*#__PURE__*/__webpack_require__.n(external_wp_isShallowEqual_namespaceObject);
31080
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/inner-blocks/use-nested-settings-update.js
31081
- /**
31082
- * WordPress dependencies
31083
- */
31084
 
31085
 
31086
 
31087
- /**
31088
- * Internal dependencies
31089
- */
31090
 
31091
 
31092
 
31093
- /**
31094
- * This hook is a side effect which updates the block-editor store when changes
31095
- * happen to inner block settings. The given props are transformed into a
31096
- * settings object, and if that is different from the current settings object in
31097
- * the block-editor store, then the store is updated with the new settings which
31098
- * came from props.
31099
- *
31100
- * @param {string} clientId The client ID of the block to update.
31101
- * @param {string[]} allowedBlocks An array of block names which are permitted
31102
- * in inner blocks.
31103
- * @param {string} [templateLock] The template lock specified for the inner
31104
- * blocks component. (e.g. "all")
31105
- * @param {boolean} captureToolbars Whether or children toolbars should be shown
31106
- * in the inner blocks component rather than on
31107
- * the child block.
31108
- * @param {string} orientation The direction in which the block
31109
- * should face.
31110
- * @param {Object} layout The layout object for the block container.
31111
- */
31112
 
31113
- function useNestedSettingsUpdate(clientId, allowedBlocks, templateLock, captureToolbars, orientation, layout) {
31114
- const {
31115
- updateBlockListSettings
31116
- } = (0,external_wp_data_namespaceObject.useDispatch)(store);
 
 
 
 
 
31117
  const {
31118
- blockListSettings,
31119
- parentLock
 
31120
  } = (0,external_wp_data_namespaceObject.useSelect)(select => {
31121
- const rootClientId = select(store).getBlockRootClientId(clientId);
 
 
 
 
 
 
 
31122
  return {
31123
- blockListSettings: select(store).getBlockListSettings(clientId),
31124
- parentLock: select(store).getTemplateLock(rootClientId)
 
31125
  };
31126
- }, [clientId]); // Memoize as inner blocks implementors often pass a new array on every
31127
- // render.
 
 
 
 
 
 
 
 
 
 
 
31128
 
31129
- const _allowedBlocks = (0,external_wp_element_namespaceObject.useMemo)(() => allowedBlocks, allowedBlocks);
 
 
 
 
 
 
31130
 
31131
- (0,external_wp_element_namespaceObject.useLayoutEffect)(() => {
31132
- const newSettings = {
31133
- allowedBlocks: _allowedBlocks,
31134
- templateLock: templateLock === undefined ? parentLock : templateLock
31135
- }; // These values are not defined for RN, so only include them if they
31136
- // are defined.
 
 
 
 
 
 
31137
 
31138
- if (captureToolbars !== undefined) {
31139
- newSettings.__experimentalCaptureToolbars = captureToolbars;
31140
- } // Orientation depends on layout,
31141
- // ideally the separate orientation prop should be deprecated.
31142
 
 
 
 
31143
 
31144
- if (orientation !== undefined) {
31145
- newSettings.orientation = orientation;
31146
- } else {
31147
- const layoutType = getLayoutType(layout === null || layout === void 0 ? void 0 : layout.type);
31148
- newSettings.orientation = layoutType.getOrientation(layout);
31149
- }
31150
 
31151
- if (!external_wp_isShallowEqual_default()(blockListSettings, newSettings)) {
31152
- updateBlockListSettings(clientId, newSettings);
31153
- }
31154
- }, [clientId, blockListSettings, _allowedBlocks, templateLock, parentLock, captureToolbars, orientation, updateBlockListSettings, layout]);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31155
  }
31156
- //# sourceMappingURL=use-nested-settings-update.js.map
31157
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/inner-blocks/use-inner-block-template-sync.js
 
 
 
 
 
 
 
 
 
 
 
31158
  /**
31159
  * External dependencies
31160
  */
31161
 
 
31162
  /**
31163
  * WordPress dependencies
31164
  */
@@ -31166,102 +29980,223 @@ function useNestedSettingsUpdate(clientId, allowedBlocks, templateLock, captureT
31166
 
31167
 
31168
 
 
 
31169
  /**
31170
  * Internal dependencies
31171
  */
31172
 
31173
 
 
 
31174
  /**
31175
- * This hook makes sure that a block's inner blocks stay in sync with the given
31176
- * block "template". The template is a block hierarchy to which inner blocks must
31177
- * conform. If the blocks get "out of sync" with the template and the template
31178
- * is meant to be locked (e.g. templateLock = "all"), then we replace the inner
31179
- * blocks with the correct value after synchronizing it with the template.
31180
  *
31181
- * @param {string} clientId The block client ID.
31182
- * @param {Object} template The template to match.
31183
- * @param {string} templateLock The template lock state for the inner blocks. For
31184
- * example, if the template lock is set to "all",
31185
- * then the inner blocks will stay in sync with the
31186
- * template. If not defined or set to false, then
31187
- * the inner blocks will not be synchronized with
31188
- * the given template.
31189
- * @param {boolean} templateInsertUpdatesSelection Whether or not to update the
31190
- * block-editor selection state when inner blocks
31191
- * are replaced after template synchronization.
31192
  */
31193
 
31194
- function useInnerBlockTemplateSync(clientId, template, templateLock, templateInsertUpdatesSelection) {
31195
- const {
31196
- getSelectedBlocksInitialCaretPosition
31197
- } = (0,external_wp_data_namespaceObject.useSelect)(store);
31198
- const {
31199
- replaceInnerBlocks
31200
- } = (0,external_wp_data_namespaceObject.useDispatch)(store);
31201
- const innerBlocks = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).getBlocks(clientId), [clientId]); // Maintain a reference to the previous value so we can do a deep equality check.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31202
 
31203
- const existingTemplate = (0,external_wp_element_namespaceObject.useRef)(null);
31204
- (0,external_wp_element_namespaceObject.useLayoutEffect)(() => {
31205
- // Only synchronize innerBlocks with template if innerBlocks are empty or
31206
- // a locking all exists directly on the block.
31207
- if (innerBlocks.length === 0 || templateLock === 'all') {
31208
- const hasTemplateChanged = !(0,external_lodash_namespaceObject.isEqual)(template, existingTemplate.current);
 
 
 
 
31209
 
31210
- if (hasTemplateChanged) {
31211
- existingTemplate.current = template;
31212
- const nextBlocks = (0,external_wp_blocks_namespaceObject.synchronizeBlocksWithTemplate)(innerBlocks, template);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31213
 
31214
- if (!(0,external_lodash_namespaceObject.isEqual)(nextBlocks, innerBlocks)) {
31215
- replaceInnerBlocks(clientId, nextBlocks, innerBlocks.length === 0 && templateInsertUpdatesSelection && nextBlocks.length !== 0, // This ensures the "initialPosition" doesn't change when applying the template
31216
- // If we're supposed to focus the block, we'll focus the first inner block
31217
- // otherwise, we won't apply any auto-focus.
31218
- // This ensures for instance that the focus stays in the inserter when inserting the "buttons" block.
31219
- getSelectedBlocksInitialCaretPosition());
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31220
  }
31221
- }
 
 
 
31222
  }
31223
- }, [innerBlocks, template, templateLock, clientId]);
31224
  }
31225
- //# sourceMappingURL=use-inner-block-template-sync.js.map
31226
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/inner-blocks/get-block-context.js
31227
  /**
31228
- * External dependencies
 
 
 
 
 
31229
  */
31230
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31231
  /**
31232
- * Block context cache, implemented as a WeakMap mapping block types to a
31233
- * WeakMap mapping attributes object to context value.
31234
  *
31235
- * @type {WeakMap<string,WeakMap<string,*>>}
 
 
31236
  */
31237
 
31238
- const BLOCK_CONTEXT_CACHE = new WeakMap();
 
 
 
 
31239
  /**
31240
- * Returns a cached context object value for a given set of attributes for the
31241
- * block type.
31242
  *
31243
- * @param {Record<string,*>} attributes Block attributes object.
31244
- * @param {WPBlockType} blockType Block type settings.
31245
  *
31246
- * @return {Record<string,*>} Context value.
31247
  */
31248
 
31249
- function getBlockContext(attributes, blockType) {
31250
- if (!BLOCK_CONTEXT_CACHE.has(blockType)) {
31251
- BLOCK_CONTEXT_CACHE.set(blockType, new WeakMap());
31252
- }
31253
 
31254
- const blockTypeCache = BLOCK_CONTEXT_CACHE.get(blockType);
 
31255
 
31256
- if (!blockTypeCache.has(attributes)) {
31257
- const context = (0,external_lodash_namespaceObject.mapValues)(blockType.providesContext, attributeName => attributes[attributeName]);
31258
- blockTypeCache.set(attributes, context);
31259
  }
31260
 
31261
- return blockTypeCache.get(attributes);
31262
- }
31263
- //# sourceMappingURL=get-block-context.js.map
31264
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/inner-blocks/index.js
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31265
 
31266
 
31267
 
@@ -31269,6 +30204,7 @@ function getBlockContext(attributes, blockType) {
31269
  * External dependencies
31270
  */
31271
 
 
31272
  /**
31273
  * WordPress dependencies
31274
  */
@@ -31277,6 +30213,9 @@ function getBlockContext(attributes, blockType) {
31277
 
31278
 
31279
 
 
 
 
31280
  /**
31281
  * Internal dependencies
31282
  */
@@ -31287,357 +30226,396 @@ function getBlockContext(attributes, blockType) {
31287
 
31288
 
31289
 
 
31290
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31291
 
 
 
 
31292
 
 
 
 
 
 
 
31293
 
 
 
 
31294
 
31295
- /**
31296
- * InnerBlocks is a component which allows a single block to have multiple blocks
31297
- * as children. The UncontrolledInnerBlocks component is used whenever the inner
31298
- * blocks are not controlled by another entity. In other words, it is normally
31299
- * used for inner blocks in the post editor
31300
- *
31301
- * @param {Object} props The component props.
31302
- */
31303
-
31304
- function UncontrolledInnerBlocks(props) {
31305
  const {
31306
- clientId,
31307
- allowedBlocks,
31308
- template,
31309
- templateLock,
31310
- wrapperRef,
31311
- templateInsertUpdatesSelection,
31312
- __experimentalCaptureToolbars: captureToolbars,
31313
- __experimentalAppenderTagName,
31314
- renderAppender,
31315
- orientation,
31316
- placeholder,
31317
- __experimentalLayout
31318
- } = props;
31319
- useNestedSettingsUpdate(clientId, allowedBlocks, templateLock, captureToolbars, orientation, __experimentalLayout);
31320
- useInnerBlockTemplateSync(clientId, template, templateLock, templateInsertUpdatesSelection);
31321
- const context = (0,external_wp_data_namespaceObject.useSelect)(select => {
31322
- const block = select(store).getBlock(clientId);
31323
- const blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(block.name);
31324
 
31325
- if (!blockType || !blockType.providesContext) {
31326
- return;
 
31327
  }
 
31328
 
31329
- return getBlockContext(block.attributes, blockType);
31330
- }, [clientId]); // This component needs to always be synchronous as it's the one changing
31331
- // the async mode depending on the block selection.
31332
 
31333
- return (0,external_wp_element_namespaceObject.createElement)(BlockContextProvider, {
31334
- value: context
31335
- }, (0,external_wp_element_namespaceObject.createElement)(BlockListItems, {
31336
- rootClientId: clientId,
31337
- renderAppender: renderAppender,
31338
- __experimentalAppenderTagName: __experimentalAppenderTagName,
31339
- __experimentalLayout: __experimentalLayout,
31340
- wrapperRef: wrapperRef,
31341
- placeholder: placeholder
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31342
  }));
31343
  }
31344
  /**
31345
- * The controlled inner blocks component wraps the uncontrolled inner blocks
31346
- * component with the blockSync hook. This keeps the innerBlocks of the block in
31347
- * the block-editor store in sync with the blocks of the controlling entity. An
31348
- * example of an inner block controller is a template part block, which provides
31349
- * its own blocks from the template part entity data source.
31350
  *
31351
- * @param {Object} props The component props.
 
 
31352
  */
31353
 
31354
 
31355
- function ControlledInnerBlocks(props) {
31356
- useBlockSync(props);
31357
- return (0,external_wp_element_namespaceObject.createElement)(UncontrolledInnerBlocks, props);
 
 
 
 
 
 
 
 
 
 
 
31358
  }
 
 
 
 
 
 
 
31359
 
31360
- const ForwardedInnerBlocks = (0,external_wp_element_namespaceObject.forwardRef)((props, ref) => {
31361
- const innerBlocksProps = useInnerBlocksProps({
31362
- ref
31363
- }, props);
31364
- return (0,external_wp_element_namespaceObject.createElement)("div", {
31365
- className: "block-editor-inner-blocks"
31366
- }, (0,external_wp_element_namespaceObject.createElement)("div", innerBlocksProps));
31367
- });
 
 
 
31368
  /**
31369
- * This hook is used to lightly mark an element as an inner blocks wrapper
31370
- * element. Call this hook and pass the returned props to the element to mark as
31371
- * an inner blocks wrapper, automatically rendering inner blocks as children. If
31372
- * you define a ref for the element, it is important to pass the ref to this
31373
- * hook, which the hook in turn will pass to the component through the props it
31374
- * returns. Optionally, you can also pass any other props through this hook, and
31375
- * they will be merged and returned.
31376
  *
31377
- * @param {Object} props Optional. Props to pass to the element. Must contain
31378
- * the ref if one is defined.
31379
- * @param {Object} options Optional. Inner blocks options.
31380
  *
31381
- * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/inner-blocks/README.md
31382
  */
31383
 
31384
- function useInnerBlocksProps(props = {}, options = {}) {
31385
  const {
31386
- clientId
31387
- } = useBlockEditContext();
31388
- const isSmallScreen = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<');
31389
- const hasOverlay = (0,external_wp_data_namespaceObject.useSelect)(select => {
31390
- const {
31391
- getBlockName,
31392
- isBlockSelected,
31393
- hasSelectedInnerBlock,
31394
- isNavigationMode
31395
- } = select(store);
31396
- const enableClickThrough = isNavigationMode() || isSmallScreen;
31397
- return getBlockName(clientId) !== 'core/template' && !isBlockSelected(clientId) && !hasSelectedInnerBlock(clientId, true) && enableClickThrough;
31398
- }, [clientId, isSmallScreen]);
31399
- const ref = (0,external_wp_compose_namespaceObject.useMergeRefs)([props.ref, useBlockDropZone({
31400
- rootClientId: clientId
31401
- })]);
31402
- const InnerBlocks = options.value && options.onChange ? ControlledInnerBlocks : UncontrolledInnerBlocks;
31403
- return { ...props,
31404
- ref,
31405
- className: classnames_default()(props.className, 'block-editor-block-list__layout', {
31406
- 'has-overlay': hasOverlay
31407
- }),
31408
- children: (0,external_wp_element_namespaceObject.createElement)(InnerBlocks, _extends({}, options, {
31409
- clientId: clientId
31410
- }))
31411
- };
31412
- } // Expose default appender placeholders as components.
 
 
 
 
 
31413
 
31414
- ForwardedInnerBlocks.DefaultBlockAppender = inner_blocks_default_block_appender;
31415
- ForwardedInnerBlocks.ButtonBlockAppender = inner_blocks_button_block_appender;
31416
- ForwardedInnerBlocks.Content = (0,external_wp_blocks_namespaceObject.withBlockContentContext)(({
31417
- BlockContent
31418
- }) => (0,external_wp_element_namespaceObject.createElement)(BlockContent, null));
31419
  /**
31420
- * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/inner-blocks/README.md
31421
  */
31422
 
31423
- /* harmony default export */ var inner_blocks = (ForwardedInnerBlocks);
31424
- //# sourceMappingURL=index.js.map
31425
- ;// CONCATENATED MODULE: ./packages/icons/build-module/library/justify-left.js
31426
 
31427
 
 
 
 
 
 
31428
  /**
31429
- * WordPress dependencies
 
 
 
 
 
 
 
31430
  */
31431
 
31432
- const justifyLeft = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
31433
- xmlns: "http://www.w3.org/2000/svg",
31434
- viewBox: "0 0 24 24"
31435
- }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
31436
- d: "M9 9v6h11V9H9zM4 20h1.5V4H4v16z"
31437
- }));
31438
- /* harmony default export */ var justify_left = (justifyLeft);
31439
- //# sourceMappingURL=justify-left.js.map
31440
- ;// CONCATENATED MODULE: ./packages/icons/build-module/library/justify-center.js
31441
-
31442
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31443
  /**
31444
- * WordPress dependencies
 
 
 
 
 
 
 
 
31445
  */
31446
 
31447
- const justifyCenter = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
31448
- xmlns: "http://www.w3.org/2000/svg",
31449
- viewBox: "0 0 24 24"
31450
- }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
31451
- d: "M20 9h-7.2V4h-1.6v5H4v6h7.2v5h1.6v-5H20z"
31452
- }));
31453
- /* harmony default export */ var justify_center = (justifyCenter);
31454
- //# sourceMappingURL=justify-center.js.map
31455
- ;// CONCATENATED MODULE: ./packages/icons/build-module/library/justify-right.js
31456
 
 
 
 
 
31457
 
 
 
 
 
31458
  /**
31459
- * WordPress dependencies
31460
  */
31461
 
31462
- const justifyRight = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
31463
- xmlns: "http://www.w3.org/2000/svg",
31464
- viewBox: "0 0 24 24"
31465
- }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
31466
- d: "M4 15h11V9H4v6zM18.5 4v16H20V4h-1.5z"
31467
- }));
31468
- /* harmony default export */ var justify_right = (justifyRight);
31469
- //# sourceMappingURL=justify-right.js.map
31470
- ;// CONCATENATED MODULE: ./packages/icons/build-module/library/justify-space-between.js
31471
-
31472
-
31473
  /**
31474
- * WordPress dependencies
31475
  */
31476
 
31477
- const justifySpaceBetween = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
31478
- xmlns: "http://www.w3.org/2000/svg",
31479
- viewBox: "0 0 24 24"
31480
- }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
31481
- d: "M9 15h6V9H9v6zm-5 5h1.5V4H4v16zM18.5 4v16H20V4h-1.5z"
31482
- }));
31483
- /* harmony default export */ var justify_space_between = (justifySpaceBetween);
31484
- //# sourceMappingURL=justify-space-between.js.map
31485
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/justify-content-control/ui.js
31486
 
31487
 
31488
 
 
 
 
 
 
 
 
 
31489
  /**
31490
- * WordPress dependencies
 
 
 
 
 
31491
  */
31492
 
 
 
31493
 
 
 
 
 
 
 
31494
 
31495
- const icons = {
31496
- left: justify_left,
31497
- center: justify_center,
31498
- right: justify_right,
31499
- 'space-between': justify_space_between
31500
- };
31501
 
31502
- function JustifyContentUI({
31503
- allowedControls = ['left', 'center', 'right', 'space-between'],
31504
- isCollapsed = true,
31505
- onChange,
31506
- value,
31507
- popoverProps,
31508
- isToolbar
31509
- }) {
31510
- // If the control is already selected we want a click
31511
- // again on the control to deselect the item, so we
31512
- // call onChange( undefined )
31513
- const handleClick = next => {
31514
- if (next === value) {
31515
- onChange(undefined);
31516
- } else {
31517
- onChange(next);
31518
- }
31519
- };
31520
 
31521
- const icon = value ? icons[value] : icons.left;
31522
- const allControls = [{
31523
- name: 'left',
31524
- icon: justify_left,
31525
- title: (0,external_wp_i18n_namespaceObject.__)('Justify items left'),
31526
- isActive: 'left' === value,
31527
- onClick: () => handleClick('left')
31528
- }, {
31529
- name: 'center',
31530
- icon: justify_center,
31531
- title: (0,external_wp_i18n_namespaceObject.__)('Justify items center'),
31532
- isActive: 'center' === value,
31533
- onClick: () => handleClick('center')
31534
- }, {
31535
- name: 'right',
31536
- icon: justify_right,
31537
- title: (0,external_wp_i18n_namespaceObject.__)('Justify items right'),
31538
- isActive: 'right' === value,
31539
- onClick: () => handleClick('right')
31540
- }, {
31541
- name: 'space-between',
31542
- icon: justify_space_between,
31543
- title: (0,external_wp_i18n_namespaceObject.__)('Space between items'),
31544
- isActive: 'space-between' === value,
31545
- onClick: () => handleClick('space-between')
31546
- }];
31547
- const UIComponent = isToolbar ? external_wp_components_namespaceObject.ToolbarGroup : external_wp_components_namespaceObject.ToolbarDropdownMenu;
31548
- const extraProps = isToolbar ? {
31549
- isCollapsed
31550
- } : {};
31551
- return (0,external_wp_element_namespaceObject.createElement)(UIComponent, _extends({
31552
- icon: icon,
31553
- popoverProps: popoverProps,
31554
- label: (0,external_wp_i18n_namespaceObject.__)('Change items justification'),
31555
- controls: allControls.filter(elem => allowedControls.includes(elem.name))
31556
- }, extraProps));
31557
  }
 
 
 
 
 
 
 
 
 
 
 
31558
 
31559
- /* harmony default export */ var justify_content_control_ui = (JustifyContentUI);
31560
- //# sourceMappingURL=ui.js.map
31561
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/justify-content-control/index.js
 
 
 
 
 
 
 
 
 
 
 
 
31562
 
 
 
 
31563
 
 
 
 
 
31564
 
 
 
 
 
31565
  /**
31566
  * Internal dependencies
31567
  */
 
 
 
31568
 
31569
- function JustifyContentControl(props) {
31570
- return (0,external_wp_element_namespaceObject.createElement)(justify_content_control_ui, _extends({}, props, {
31571
- isToolbar: false
31572
- }));
31573
- }
31574
- function JustifyToolbar(props) {
31575
- return (0,external_wp_element_namespaceObject.createElement)(justify_content_control_ui, _extends({}, props, {
31576
- isToolbar: true
31577
- }));
31578
- }
31579
- //# sourceMappingURL=index.js.map
31580
- ;// CONCATENATED MODULE: ./packages/icons/build-module/library/keyboard-return.js
31581
 
 
 
 
 
31582
 
 
 
 
 
 
 
 
 
 
 
31583
  /**
31584
- * WordPress dependencies
31585
  */
31586
 
31587
- const keyboardReturn = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
31588
- xmlns: "http://www.w3.org/2000/svg",
31589
- viewBox: "-2 -2 24 24"
31590
- }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
31591
- d: "M6.734 16.106l2.176-2.38-1.093-1.028-3.846 4.158 3.846 4.157 1.093-1.027-2.176-2.38h2.811c1.125 0 2.25.03 3.374 0 1.428-.001 3.362-.25 4.963-1.277 1.66-1.065 2.868-2.906 2.868-5.859 0-2.479-1.327-4.896-3.65-5.93-1.82-.813-3.044-.8-4.806-.788l-.567.002v1.5c.184 0 .368 0 .553-.002 1.82-.007 2.704-.014 4.21.657 1.854.827 2.76 2.657 2.76 4.561 0 2.472-.973 3.824-2.178 4.596-1.258.807-2.864 1.04-4.163 1.04h-.02c-1.115.03-2.229 0-3.344 0H6.734z"
31592
- }));
31593
- /* harmony default export */ var keyboard_return = (keyboardReturn);
31594
- //# sourceMappingURL=keyboard-return.js.map
31595
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/link-control/settings-drawer.js
31596
 
31597
 
31598
- /**
31599
- * External dependencies
31600
- */
31601
 
31602
- /**
31603
- * WordPress dependencies
31604
- */
31605
 
31606
 
31607
 
31608
 
31609
- const LinkControlSettingsDrawer = ({
31610
- value,
31611
- onChange = external_lodash_namespaceObject.noop,
31612
- settings
31613
- }) => {
31614
- if (!settings || !settings.length) {
31615
- return null;
31616
- }
31617
 
31618
- const handleSettingChange = setting => newValue => {
31619
- onChange({ ...value,
31620
- [setting.id]: newValue
31621
- });
31622
- };
31623
 
31624
- const theSettings = settings.map(setting => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToggleControl, {
31625
- className: "block-editor-link-control__setting",
31626
- key: setting.id,
31627
- label: setting.title,
31628
- onChange: handleSettingChange(setting),
31629
- checked: value ? !!value[setting.id] : false
31630
- }));
31631
- return (0,external_wp_element_namespaceObject.createElement)("fieldset", {
31632
- className: "block-editor-link-control__settings"
31633
- }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, {
31634
- as: "legend"
31635
- }, (0,external_wp_i18n_namespaceObject.__)('Currently selected link settings')), theSettings);
31636
- };
31637
 
31638
- /* harmony default export */ var settings_drawer = (LinkControlSettingsDrawer);
31639
- //# sourceMappingURL=settings-drawer.js.map
31640
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/url-input/index.js
 
 
31641
 
31642
 
31643
 
@@ -31645,553 +30623,704 @@ const LinkControlSettingsDrawer = ({
31645
  * External dependencies
31646
  */
31647
 
31648
-
31649
-
31650
  /**
31651
  * WordPress dependencies
31652
  */
31653
 
31654
 
31655
 
31656
-
31657
-
31658
-
31659
-
31660
-
31661
  /**
31662
  * Internal dependencies
31663
  */
31664
 
31665
 
31666
 
31667
- class URLInput extends external_wp_element_namespaceObject.Component {
31668
- constructor(props) {
31669
- super(props);
31670
- this.onChange = this.onChange.bind(this);
31671
- this.onFocus = this.onFocus.bind(this);
31672
- this.onKeyDown = this.onKeyDown.bind(this);
31673
- this.selectLink = this.selectLink.bind(this);
31674
- this.handleOnClick = this.handleOnClick.bind(this);
31675
- this.bindSuggestionNode = this.bindSuggestionNode.bind(this);
31676
- this.autocompleteRef = props.autocompleteRef || (0,external_wp_element_namespaceObject.createRef)();
31677
- this.inputRef = (0,external_wp_element_namespaceObject.createRef)();
31678
- this.updateSuggestions = (0,external_lodash_namespaceObject.debounce)(this.updateSuggestions.bind(this), 200);
31679
- this.suggestionNodes = [];
31680
- this.isUpdatingSuggestions = false;
31681
- this.state = {
31682
- suggestions: [],
31683
- showSuggestions: false,
31684
- selectedSuggestion: null,
31685
- suggestionsListboxId: '',
31686
- suggestionOptionIdPrefix: ''
31687
- };
31688
- }
31689
 
31690
- componentDidUpdate(prevProps) {
31691
- const {
31692
- showSuggestions,
31693
- selectedSuggestion
31694
- } = this.state;
31695
- const {
31696
- value
31697
- } = this.props; // only have to worry about scrolling selected suggestion into view
31698
- // when already expanded
31699
 
31700
- if (showSuggestions && selectedSuggestion !== null && this.suggestionNodes[selectedSuggestion] && !this.scrollingIntoView) {
31701
- this.scrollingIntoView = true;
31702
- lib_default()(this.suggestionNodes[selectedSuggestion], this.autocompleteRef.current, {
31703
- onlyScrollIfNeeded: true
31704
- });
31705
- this.props.setTimeout(() => {
31706
- this.scrollingIntoView = false;
31707
- }, 100);
31708
- } // Only attempt an update on suggestions if the input value has actually changed.
31709
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31710
 
31711
- if (prevProps.value !== value && this.shouldShowInitialSuggestions()) {
31712
- this.updateSuggestions();
31713
- }
31714
- }
31715
 
31716
- componentDidMount() {
31717
- if (this.shouldShowInitialSuggestions()) {
31718
- this.updateSuggestions();
31719
- }
31720
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
31721
 
31722
- componentWillUnmount() {
31723
- var _this$suggestionsRequ, _this$suggestionsRequ2;
 
 
 
 
31724
 
31725
- (_this$suggestionsRequ = this.suggestionsRequest) === null || _this$suggestionsRequ === void 0 ? void 0 : (_this$suggestionsRequ2 = _this$suggestionsRequ.cancel) === null || _this$suggestionsRequ2 === void 0 ? void 0 : _this$suggestionsRequ2.call(_this$suggestionsRequ);
31726
- delete this.suggestionsRequest;
31727
- }
 
 
 
 
 
31728
 
31729
- bindSuggestionNode(index) {
31730
- return ref => {
31731
- this.suggestionNodes[index] = ref;
31732
- };
31733
- }
 
 
 
 
31734
 
31735
- shouldShowInitialSuggestions() {
31736
- const {
31737
- suggestions
31738
- } = this.state;
31739
- const {
31740
- __experimentalShowInitialSuggestions = false,
31741
- value
31742
- } = this.props;
31743
- return !this.isUpdatingSuggestions && __experimentalShowInitialSuggestions && !(value && value.length) && !(suggestions && suggestions.length);
31744
- }
 
 
 
31745
 
31746
- updateSuggestions(value = '') {
31747
- const {
31748
- __experimentalFetchLinkSuggestions: fetchLinkSuggestions,
31749
- __experimentalHandleURLSuggestions: handleURLSuggestions
31750
- } = this.props;
 
 
31751
 
31752
- if (!fetchLinkSuggestions) {
31753
- return;
31754
- }
31755
 
31756
- const isInitialSuggestions = !(value && value.length); // Allow a suggestions request if:
31757
- // - there are at least 2 characters in the search input (except manual searches where
31758
- // search input length is not required to trigger a fetch)
31759
- // - this is a direct entry (eg: a URL)
 
 
 
31760
 
31761
- if (!isInitialSuggestions && (value.length < 2 || !handleURLSuggestions && (0,external_wp_url_namespaceObject.isURL)(value))) {
31762
- this.setState({
31763
- showSuggestions: false,
31764
- selectedSuggestion: null,
31765
- loading: false
31766
- });
31767
- return;
31768
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31769
 
31770
- this.isUpdatingSuggestions = true;
31771
- this.setState({
31772
- selectedSuggestion: null,
31773
- loading: true
31774
- });
31775
- const request = fetchLinkSuggestions(value, {
31776
- isInitialSuggestions
31777
- });
31778
- request.then(suggestions => {
31779
- // A fetch Promise doesn't have an abort option. It's mimicked by
31780
- // comparing the request reference in on the instance, which is
31781
- // reset or deleted on subsequent requests or unmounting.
31782
- if (this.suggestionsRequest !== request) {
31783
- return;
31784
- }
31785
 
31786
- this.setState({
31787
- suggestions,
31788
- loading: false,
31789
- showSuggestions: !!suggestions.length
31790
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31791
 
31792
- if (!!suggestions.length) {
31793
- this.props.debouncedSpeak((0,external_wp_i18n_namespaceObject.sprintf)(
31794
- /* translators: %s: number of results. */
31795
- (0,external_wp_i18n_namespaceObject._n)('%d result found, use up and down arrow keys to navigate.', '%d results found, use up and down arrow keys to navigate.', suggestions.length), suggestions.length), 'assertive');
31796
- } else {
31797
- this.props.debouncedSpeak((0,external_wp_i18n_namespaceObject.__)('No results.'), 'assertive');
31798
- }
31799
 
31800
- this.isUpdatingSuggestions = false;
31801
- }).catch(() => {
31802
- if (this.suggestionsRequest === request) {
31803
- this.setState({
31804
- loading: false
31805
- });
31806
- this.isUpdatingSuggestions = false;
31807
- }
31808
- }); // Note that this assignment is handled *before* the async search request
31809
- // as a Promise always resolves on the next tick of the event loop.
31810
 
31811
- this.suggestionsRequest = request;
31812
- }
31813
 
31814
- onChange(event) {
31815
- const inputValue = event.target.value;
31816
- this.props.onChange(inputValue);
31817
 
31818
- if (!this.props.disableSuggestions) {
31819
- this.updateSuggestions(inputValue.trim());
31820
- }
31821
- }
31822
 
31823
- onFocus() {
31824
- const {
31825
- suggestions
31826
- } = this.state;
31827
- const {
31828
- disableSuggestions,
31829
- value
31830
- } = this.props; // When opening the link editor, if there's a value present, we want to load the suggestions pane with the results for this input search value
31831
- // Don't re-run the suggestions on focus if there are already suggestions present (prevents searching again when tabbing between the input and buttons)
31832
 
31833
- if (value && !disableSuggestions && !this.isUpdatingSuggestions && !(suggestions && suggestions.length)) {
31834
- // Ensure the suggestions are updated with the current input value
31835
- this.updateSuggestions(value.trim());
31836
- }
31837
- }
31838
 
31839
- onKeyDown(event) {
31840
- const {
31841
- showSuggestions,
31842
- selectedSuggestion,
31843
- suggestions,
31844
- loading
31845
- } = this.state; // If the suggestions are not shown or loading, we shouldn't handle the arrow keys
31846
- // We shouldn't preventDefault to allow block arrow keys navigation
31847
 
31848
- if (!showSuggestions || !suggestions.length || loading) {
31849
- // In the Windows version of Firefox the up and down arrows don't move the caret
31850
- // within an input field like they do for Mac Firefox/Chrome/Safari. This causes
31851
- // a form of focus trapping that is disruptive to the user experience. This disruption
31852
- // only happens if the caret is not in the first or last position in the text input.
31853
- // See: https://github.com/WordPress/gutenberg/issues/5693#issuecomment-436684747
31854
- switch (event.keyCode) {
31855
- // When UP is pressed, if the caret is at the start of the text, move it to the 0
31856
- // position.
31857
- case external_wp_keycodes_namespaceObject.UP:
31858
- {
31859
- if (0 !== event.target.selectionStart) {
31860
- event.preventDefault(); // Set the input caret to position 0
31861
 
31862
- event.target.setSelectionRange(0, 0);
31863
- }
31864
 
31865
- break;
31866
- }
31867
- // When DOWN is pressed, if the caret is not at the end of the text, move it to the
31868
- // last position.
31869
 
31870
- case external_wp_keycodes_namespaceObject.DOWN:
31871
- {
31872
- if (this.props.value.length !== event.target.selectionStart) {
31873
- event.preventDefault(); // Set the input caret to the last position
31874
 
31875
- event.target.setSelectionRange(this.props.value.length, this.props.value.length);
31876
- }
31877
 
31878
- break;
31879
- }
31880
- // Submitting while loading should trigger onSubmit
 
 
 
 
 
 
 
 
31881
 
31882
- case external_wp_keycodes_namespaceObject.ENTER:
31883
- {
31884
- if (this.props.onSubmit) {
31885
- this.props.onSubmit();
31886
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31887
 
31888
- break;
31889
- }
 
 
 
 
31890
  }
31891
 
31892
- return;
31893
- }
 
 
 
 
 
 
 
 
 
31894
 
31895
- const suggestion = this.state.suggestions[this.state.selectedSuggestion];
 
 
 
 
 
 
 
 
 
31896
 
31897
- switch (event.keyCode) {
31898
- case external_wp_keycodes_namespaceObject.UP:
31899
- {
31900
- event.preventDefault();
31901
- const previousIndex = !selectedSuggestion ? suggestions.length - 1 : selectedSuggestion - 1;
31902
- this.setState({
31903
- selectedSuggestion: previousIndex
31904
- });
31905
- break;
31906
- }
31907
 
31908
- case external_wp_keycodes_namespaceObject.DOWN:
31909
- {
31910
- event.preventDefault();
31911
- const nextIndex = selectedSuggestion === null || selectedSuggestion === suggestions.length - 1 ? 0 : selectedSuggestion + 1;
31912
- this.setState({
31913
- selectedSuggestion: nextIndex
31914
- });
31915
- break;
31916
- }
31917
 
31918
- case external_wp_keycodes_namespaceObject.TAB:
31919
- {
31920
- if (this.state.selectedSuggestion !== null) {
31921
- this.selectLink(suggestion); // Announce a link has been selected when tabbing away from the input field.
31922
 
31923
- this.props.speak((0,external_wp_i18n_namespaceObject.__)('Link selected.'));
31924
- }
31925
 
31926
- break;
 
31927
  }
31928
 
31929
- case external_wp_keycodes_namespaceObject.ENTER:
31930
- {
31931
- if (this.state.selectedSuggestion !== null) {
31932
- this.selectLink(suggestion);
 
 
 
 
 
 
 
 
31933
 
31934
- if (this.props.onSubmit) {
31935
- this.props.onSubmit(suggestion);
31936
- }
31937
- } else if (this.props.onSubmit) {
31938
- this.props.onSubmit();
31939
- }
31940
 
31941
- break;
31942
- }
31943
- }
31944
- }
 
31945
 
31946
- selectLink(suggestion) {
31947
- this.props.onChange(suggestion.url, suggestion);
31948
- this.setState({
31949
- selectedSuggestion: null,
31950
- showSuggestions: false
31951
- });
31952
- }
31953
 
31954
- handleOnClick(suggestion) {
31955
- this.selectLink(suggestion); // Move focus to the input field when a link suggestion is clicked.
31956
 
31957
- this.inputRef.current.focus();
31958
- }
31959
 
31960
- static getDerivedStateFromProps({
31961
- value,
31962
- instanceId,
31963
- disableSuggestions,
31964
- __experimentalShowInitialSuggestions = false
31965
- }, {
31966
- showSuggestions
31967
- }) {
31968
- let shouldShowSuggestions = showSuggestions;
31969
- const hasValue = value && value.length;
31970
 
31971
- if (!__experimentalShowInitialSuggestions && !hasValue) {
31972
- shouldShowSuggestions = false;
31973
- }
31974
 
31975
- if (disableSuggestions === true) {
31976
- shouldShowSuggestions = false;
31977
- }
 
 
 
 
 
 
31978
 
31979
- return {
31980
- showSuggestions: shouldShowSuggestions,
31981
- suggestionsListboxId: `block-editor-url-input-suggestions-${instanceId}`,
31982
- suggestionOptionIdPrefix: `block-editor-url-input-suggestion-${instanceId}`
31983
- };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31984
  }
31985
 
31986
- render() {
31987
- return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, this.renderControl(), this.renderSuggestions());
 
 
 
31988
  }
31989
 
31990
- renderControl() {
31991
- const {
31992
- label,
31993
- className,
31994
- isFullWidth,
31995
- instanceId,
31996
- placeholder = (0,external_wp_i18n_namespaceObject.__)('Paste URL or type to search'),
31997
- __experimentalRenderControl: renderControl,
31998
- value = ''
31999
- } = this.props;
32000
- const {
32001
- loading,
32002
- showSuggestions,
32003
- selectedSuggestion,
32004
- suggestionsListboxId,
32005
- suggestionOptionIdPrefix
32006
- } = this.state;
32007
- const controlProps = {
32008
- id: `url-input-control-${instanceId}`,
32009
- label,
32010
- className: classnames_default()('block-editor-url-input', className, {
32011
- 'is-full-width': isFullWidth
32012
- })
32013
- };
32014
- const inputProps = {
32015
- value,
32016
- required: true,
32017
- className: 'block-editor-url-input__input',
32018
- type: 'text',
32019
- onChange: this.onChange,
32020
- onFocus: this.onFocus,
32021
- placeholder,
32022
- onKeyDown: this.onKeyDown,
32023
- role: 'combobox',
32024
- 'aria-label': (0,external_wp_i18n_namespaceObject.__)('URL'),
32025
- 'aria-expanded': showSuggestions,
32026
- 'aria-autocomplete': 'list',
32027
- 'aria-owns': suggestionsListboxId,
32028
- 'aria-activedescendant': selectedSuggestion !== null ? `${suggestionOptionIdPrefix}-${selectedSuggestion}` : undefined,
32029
- ref: this.inputRef
32030
- };
32031
 
32032
- if (renderControl) {
32033
- return renderControl(controlProps, inputProps, loading);
32034
- }
32035
 
32036
- return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.BaseControl, controlProps, (0,external_wp_element_namespaceObject.createElement)("input", inputProps), loading && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Spinner, null));
32037
- }
32038
 
32039
- renderSuggestions() {
32040
- const {
32041
- className,
32042
- __experimentalRenderSuggestions: renderSuggestions,
32043
- value = '',
32044
- __experimentalShowInitialSuggestions = false
32045
- } = this.props;
32046
- const {
32047
- showSuggestions,
32048
- suggestions,
32049
- selectedSuggestion,
32050
- suggestionsListboxId,
32051
- suggestionOptionIdPrefix,
32052
- loading
32053
- } = this.state;
32054
- const suggestionsListProps = {
32055
- id: suggestionsListboxId,
32056
- ref: this.autocompleteRef,
32057
- role: 'listbox'
32058
- };
32059
 
32060
- const buildSuggestionItemProps = (suggestion, index) => {
32061
- return {
32062
- role: 'option',
32063
- tabIndex: '-1',
32064
- id: `${suggestionOptionIdPrefix}-${index}`,
32065
- ref: this.bindSuggestionNode(index),
32066
- 'aria-selected': index === selectedSuggestion
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32067
  };
32068
- };
32069
-
32070
- if ((0,external_lodash_namespaceObject.isFunction)(renderSuggestions) && showSuggestions && !!suggestions.length) {
32071
- return renderSuggestions({
32072
- suggestions,
32073
- selectedSuggestion,
32074
- suggestionsListProps,
32075
- buildSuggestionItemProps,
32076
- isLoading: loading,
32077
- handleSuggestionClick: this.handleOnClick,
32078
- isInitialSuggestions: __experimentalShowInitialSuggestions && !(value && value.length)
32079
- });
32080
  }
32081
 
32082
- if (!(0,external_lodash_namespaceObject.isFunction)(renderSuggestions) && showSuggestions && !!suggestions.length) {
32083
- return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Popover, {
32084
- position: "bottom",
32085
- noArrow: true,
32086
- focusOnMount: false
32087
- }, (0,external_wp_element_namespaceObject.createElement)("div", _extends({}, suggestionsListProps, {
32088
- className: classnames_default()('block-editor-url-input__suggestions', `${className}__suggestions`)
32089
- }), suggestions.map((suggestion, index) => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, _extends({}, buildSuggestionItemProps(suggestion, index), {
32090
- key: suggestion.id,
32091
- className: classnames_default()('block-editor-url-input__suggestion', {
32092
- 'is-selected': index === selectedSuggestion
32093
- }),
32094
- onClick: () => this.handleOnClick(suggestion)
32095
- }), suggestion.title))));
32096
- }
32097
 
32098
- return null;
32099
- }
32100
 
32101
- }
32102
  /**
32103
- * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/url-input/README.md
32104
  */
32105
 
 
 
 
32106
 
32107
- /* harmony default export */ var url_input = ((0,external_wp_compose_namespaceObject.compose)(external_wp_compose_namespaceObject.withSafeTimeout, external_wp_components_namespaceObject.withSpokenMessages, external_wp_compose_namespaceObject.withInstanceId, (0,external_wp_data_namespaceObject.withSelect)((select, props) => {
32108
- // If a link suggestions handler is already provided then
32109
- // bail
32110
- if ((0,external_lodash_namespaceObject.isFunction)(props.__experimentalFetchLinkSuggestions)) {
32111
- return;
32112
- }
32113
 
32114
- const {
32115
- getSettings
32116
- } = select(store);
32117
- return {
32118
- __experimentalFetchLinkSuggestions: getSettings().__experimentalFetchLinkSuggestions
32119
- };
32120
- }))(URLInput));
32121
- //# sourceMappingURL=index.js.map
32122
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/link-control/search-create-button.js
32123
 
32124
 
32125
 
32126
  /**
32127
- * External dependencies
32128
  */
32129
 
32130
 
 
32131
  /**
32132
- * WordPress dependencies
 
 
 
32133
  */
32134
 
 
32135
 
 
 
 
 
 
 
 
 
32136
 
 
 
 
32137
 
 
 
 
 
 
32138
 
32139
- const LinkControlSearchCreate = ({
32140
- searchTerm,
32141
- onClick,
32142
- itemProps,
32143
- isSelected,
32144
- buttonText
32145
- }) => {
32146
- if (!searchTerm) {
32147
- return null;
32148
- }
32149
 
32150
- let text;
 
 
32151
 
32152
- if (buttonText) {
32153
- text = (0,external_lodash_namespaceObject.isFunction)(buttonText) ? buttonText(searchTerm) : buttonText;
32154
- } else {
32155
- text = (0,external_wp_element_namespaceObject.createInterpolateElement)((0,external_wp_i18n_namespaceObject.sprintf)(
32156
- /* translators: %s: search term. */
32157
- (0,external_wp_i18n_namespaceObject.__)('Create: <mark>%s</mark>'), searchTerm), {
32158
- mark: (0,external_wp_element_namespaceObject.createElement)("mark", null)
32159
- });
32160
- }
 
 
32161
 
32162
- return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, _extends({}, itemProps, {
32163
- className: classnames_default()('block-editor-link-control__search-create block-editor-link-control__search-item', {
32164
- 'is-selected': isSelected
32165
- }),
32166
- onClick: onClick
32167
- }), (0,external_wp_element_namespaceObject.createElement)(icon, {
32168
- className: "block-editor-link-control__search-item-icon",
32169
- icon: library_plus
32170
- }), (0,external_wp_element_namespaceObject.createElement)("span", {
32171
- className: "block-editor-link-control__search-item-header"
32172
- }, (0,external_wp_element_namespaceObject.createElement)("span", {
32173
- className: "block-editor-link-control__search-item-title"
32174
- }, text)));
32175
- };
32176
- /* harmony default export */ var search_create_button = (LinkControlSearchCreate);
32177
- //# sourceMappingURL=search-create-button.js.map
32178
- ;// CONCATENATED MODULE: ./packages/icons/build-module/library/globe.js
32179
 
32180
 
32181
  /**
32182
  * WordPress dependencies
32183
  */
32184
 
32185
- const globe = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
32186
  xmlns: "http://www.w3.org/2000/svg",
32187
- viewBox: "-2 -2 24 24"
32188
  }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
32189
- d: "M9 0C4.03 0 0 4.03 0 9s4.03 9 9 9 9-4.03 9-9-4.03-9-9-9zM1.11 9.68h2.51c.04.91.167 1.814.38 2.7H1.84c-.403-.85-.65-1.764-.73-2.7zm8.57-5.4V1.19c.964.366 1.756 1.08 2.22 2 .205.347.386.708.54 1.08l-2.76.01zm3.22 1.35c.232.883.37 1.788.41 2.7H9.68v-2.7h3.22zM8.32 1.19v3.09H5.56c.154-.372.335-.733.54-1.08.462-.924 1.255-1.64 2.22-2.01zm0 4.44v2.7H4.7c.04-.912.178-1.817.41-2.7h3.21zm-4.7 2.69H1.11c.08-.936.327-1.85.73-2.7H4c-.213.886-.34 1.79-.38 2.7zM4.7 9.68h3.62v2.7H5.11c-.232-.883-.37-1.788-.41-2.7zm3.63 4v3.09c-.964-.366-1.756-1.08-2.22-2-.205-.347-.386-.708-.54-1.08l2.76-.01zm1.35 3.09v-3.04h2.76c-.154.372-.335.733-.54 1.08-.464.92-1.256 1.634-2.22 2v-.04zm0-4.44v-2.7h3.62c-.04.912-.178 1.817-.41 2.7H9.68zm4.71-2.7h2.51c-.08.936-.327 1.85-.73 2.7H14c.21-.87.337-1.757.38-2.65l.01-.05zm0-1.35c-.046-.894-.176-1.78-.39-2.65h2.16c.403.85.65 1.764.73 2.7l-2.5-.05zm1-4H13.6c-.324-.91-.793-1.76-1.39-2.52 1.244.56 2.325 1.426 3.14 2.52h.04zm-9.6-2.52c-.597.76-1.066 1.61-1.39 2.52H2.65c.815-1.094 1.896-1.96 3.14-2.52zm-3.15 12H4.4c.324.91.793 1.76 1.39 2.52-1.248-.567-2.33-1.445-3.14-2.55l-.01.03zm9.56 2.52c.597-.76 1.066-1.61 1.39-2.52h1.76c-.82 1.08-1.9 1.933-3.14 2.48l-.01.04z"
32190
  }));
32191
- /* harmony default export */ var library_globe = (globe);
32192
- //# sourceMappingURL=globe.js.map
32193
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/link-control/search-item.js
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32194
 
 
 
 
32195
 
32196
 
32197
  /**
@@ -32206,56 +31335,74 @@ const globe = (0,external_wp_element_namespaceObject.createElement)(external_wp_
32206
 
32207
 
32208
 
32209
- const LinkControlSearchItem = ({
32210
- itemProps,
32211
- suggestion,
32212
- isSelected = false,
32213
- onClick,
32214
- isURL = false,
32215
- searchTerm = '',
32216
- shouldShowType = false
32217
- }) => {
32218
- return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, _extends({}, itemProps, {
32219
- onClick: onClick,
32220
- className: classnames_default()('block-editor-link-control__search-item', {
32221
- 'is-selected': isSelected,
32222
- 'is-url': isURL,
32223
- 'is-entity': !isURL
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32224
  })
32225
- }), isURL && (0,external_wp_element_namespaceObject.createElement)(icon, {
32226
- className: "block-editor-link-control__search-item-icon",
32227
- icon: library_globe
32228
- }), (0,external_wp_element_namespaceObject.createElement)("span", {
32229
- className: "block-editor-link-control__search-item-header"
32230
- }, (0,external_wp_element_namespaceObject.createElement)("span", {
32231
- className: "block-editor-link-control__search-item-title"
32232
- }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextHighlight, {
32233
- text: suggestion.title,
32234
- highlight: searchTerm
32235
- })), (0,external_wp_element_namespaceObject.createElement)("span", {
32236
- "aria-hidden": !isURL,
32237
- className: "block-editor-link-control__search-item-info"
32238
- }, !isURL && ((0,external_wp_url_namespaceObject.filterURLForDisplay)((0,external_wp_url_namespaceObject.safeDecodeURI)(suggestion.url)) || ''), isURL && (0,external_wp_i18n_namespaceObject.__)('Press ENTER to add this link'))), shouldShowType && suggestion.type && (0,external_wp_element_namespaceObject.createElement)("span", {
32239
- className: "block-editor-link-control__search-item-type"
32240
- }, suggestion.type === 'post_tag' ? 'tag' : suggestion.type));
32241
- };
32242
- /* harmony default export */ var search_item = (LinkControlSearchItem);
32243
- //# sourceMappingURL=search-item.js.map
32244
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/link-control/constants.js
32245
  /**
32246
  * WordPress dependencies
32247
  */
32248
- // Used as a unique identifier for the "Create" option within search results.
32249
- // Used to help distinguish the "Create" suggestion within the search results in
32250
- // order to handle it as a unique case.
32251
 
32252
- const CREATE_TYPE = '__CREATE__';
32253
- const DEFAULT_LINK_SETTINGS = [{
32254
- id: 'opensInNewTab',
32255
- title: (0,external_wp_i18n_namespaceObject.__)('Open in new tab')
32256
- }];
32257
- //# sourceMappingURL=constants.js.map
32258
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/link-control/search-results.js
 
 
32259
 
32260
 
32261
  /**
@@ -32263,376 +31410,396 @@ const DEFAULT_LINK_SETTINGS = [{
32263
  */
32264
 
32265
 
 
 
32266
  /**
32267
- * External dependencies
32268
  */
32269
 
32270
 
32271
 
32272
  /**
32273
- * Internal dependencies
 
 
 
 
32274
  */
32275
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32276
 
 
 
 
 
 
32277
 
 
32278
 
32279
- function LinkControlSearchResults({
32280
- instanceId,
32281
- withCreateSuggestion,
32282
- currentInputValue,
32283
- handleSuggestionClick,
32284
- suggestionsListProps,
32285
- buildSuggestionItemProps,
32286
- suggestions,
32287
- selectedSuggestion,
32288
- isLoading,
32289
- isInitialSuggestions,
32290
- createSuggestionButtonText,
32291
- suggestionsQuery
32292
- }) {
32293
- const resultsListClasses = classnames_default()('block-editor-link-control__search-results', {
32294
- 'is-loading': isLoading
32295
- });
32296
- const directLinkEntryTypes = ['url', 'mailto', 'tel', 'internal'];
32297
- const isSingleDirectEntryResult = suggestions.length === 1 && directLinkEntryTypes.includes(suggestions[0].type.toLowerCase());
32298
- const shouldShowCreateSuggestion = withCreateSuggestion && !isSingleDirectEntryResult && !isInitialSuggestions; // If the query has a specified type, then we can skip showing them in the result. See #24839.
32299
 
32300
- const shouldShowSuggestionsTypes = !(suggestionsQuery !== null && suggestionsQuery !== void 0 && suggestionsQuery.type); // According to guidelines aria-label should be added if the label
32301
- // itself is not visible.
32302
- // See: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/listbox_role
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32303
 
32304
- const searchResultsLabelId = `block-editor-link-control-search-results-label-${instanceId}`;
32305
- const labelText = isInitialSuggestions ? (0,external_wp_i18n_namespaceObject.__)('Recently updated') : (0,external_wp_i18n_namespaceObject.sprintf)(
32306
- /* translators: %s: search term. */
32307
- (0,external_wp_i18n_namespaceObject.__)('Search results for "%s"'), currentInputValue); // VisuallyHidden rightly doesn't accept custom classNames
32308
- // so we conditionally render it as a wrapper to visually hide the label
32309
- // when that is required.
32310
 
32311
- const searchResultsLabel = (0,external_wp_element_namespaceObject.createElement)(isInitialSuggestions ? external_wp_element_namespaceObject.Fragment : external_wp_components_namespaceObject.VisuallyHidden, {}, // empty props
32312
- (0,external_wp_element_namespaceObject.createElement)("span", {
32313
- className: "block-editor-link-control__search-results-label",
32314
- id: searchResultsLabelId
32315
- }, labelText));
32316
- return (0,external_wp_element_namespaceObject.createElement)("div", {
32317
- className: "block-editor-link-control__search-results-wrapper"
32318
- }, searchResultsLabel, (0,external_wp_element_namespaceObject.createElement)("div", _extends({}, suggestionsListProps, {
32319
- className: resultsListClasses,
32320
- "aria-labelledby": searchResultsLabelId
32321
- }), suggestions.map((suggestion, index) => {
32322
- if (shouldShowCreateSuggestion && CREATE_TYPE === suggestion.type) {
32323
- return (0,external_wp_element_namespaceObject.createElement)(search_create_button, {
32324
- searchTerm: currentInputValue,
32325
- buttonText: createSuggestionButtonText,
32326
- onClick: () => handleSuggestionClick(suggestion) // Intentionally only using `type` here as
32327
- // the constant is enough to uniquely
32328
- // identify the single "CREATE" suggestion.
32329
- ,
32330
- key: suggestion.type,
32331
- itemProps: buildSuggestionItemProps(suggestion, index),
32332
- isSelected: index === selectedSuggestion
32333
- });
32334
- } // If we're not handling "Create" suggestions above then
32335
- // we don't want them in the main results so exit early
32336
 
32337
 
32338
- if (CREATE_TYPE === suggestion.type) {
32339
- return null;
32340
- }
 
 
 
 
 
 
32341
 
32342
- return (0,external_wp_element_namespaceObject.createElement)(search_item, {
32343
- key: `${suggestion.id}-${suggestion.type}`,
32344
- itemProps: buildSuggestionItemProps(suggestion, index),
32345
- suggestion: suggestion,
32346
- index: index,
32347
- onClick: () => {
32348
- handleSuggestionClick(suggestion);
32349
- },
32350
- isSelected: index === selectedSuggestion,
32351
- isURL: directLinkEntryTypes.includes(suggestion.type.toLowerCase()),
32352
- searchTerm: currentInputValue,
32353
- shouldShowType: shouldShowSuggestionsTypes
32354
- });
32355
- })));
32356
- }
32357
- //# sourceMappingURL=search-results.js.map
32358
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/link-control/is-url-like.js
32359
  /**
32360
  * External dependencies
32361
  */
32362
 
32363
- /**
32364
- * WordPress dependencies
32365
- */
32366
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32367
 
32368
- /**
32369
- * Determines whether a given value could be a URL. Note this does not
32370
- * guarantee the value is a URL only that it looks like it might be one. For
32371
- * example, just because a string has `www.` in it doesn't make it a URL,
32372
- * but it does make it highly likely that it will be so in the context of
32373
- * creating a link it makes sense to treat it like one.
32374
- *
32375
- * @param {string} val the candidate for being URL-like (or not).
32376
- *
32377
- * @return {boolean} whether or not the value is potentially a URL.
32378
- */
32379
 
32380
- function isURLLike(val) {
32381
- const isInternal = (0,external_lodash_namespaceObject.startsWith)(val, '#');
32382
- return (0,external_wp_url_namespaceObject.isURL)(val) || val && val.includes('www.') || isInternal;
 
 
 
32383
  }
32384
- //# sourceMappingURL=is-url-like.js.map
32385
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/link-control/use-search-handler.js
 
 
 
32386
  /**
32387
  * WordPress dependencies
32388
  */
32389
 
32390
 
32391
 
 
 
 
 
 
 
 
32392
  /**
32393
- * External dependencies
 
 
 
 
 
 
32394
  */
32395
 
32396
 
 
 
 
 
 
 
 
 
 
 
 
32397
  /**
32398
- * Internal dependencies
 
 
 
 
 
 
32399
  */
32400
 
32401
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32402
 
32403
-
32404
- const handleNoop = () => Promise.resolve([]);
32405
- const handleDirectEntry = val => {
32406
- let type = 'URL';
32407
- const protocol = (0,external_wp_url_namespaceObject.getProtocol)(val) || '';
32408
-
32409
- if (protocol.includes('mailto')) {
32410
- type = 'mailto';
32411
- }
32412
-
32413
- if (protocol.includes('tel')) {
32414
- type = 'tel';
32415
- }
32416
-
32417
- if ((0,external_lodash_namespaceObject.startsWith)(val, '#')) {
32418
- type = 'internal';
32419
- }
32420
-
32421
- return Promise.resolve([{
32422
- id: val,
32423
- title: val,
32424
- url: type === 'URL' ? (0,external_wp_url_namespaceObject.prependHTTP)(val) : val,
32425
- type
32426
- }]);
32427
  };
32428
 
32429
- const handleEntitySearch = async (val, suggestionsQuery, fetchSearchSuggestions, directEntryHandler, withCreateSuggestion, withURLSuggestion) => {
32430
- const {
32431
- isInitialSuggestions
32432
- } = suggestionsQuery;
32433
- let results = await Promise.all([fetchSearchSuggestions(val, suggestionsQuery), directEntryHandler(val)]);
32434
- const couldBeURL = !val.includes(' '); // If it's potentially a URL search then concat on a URL search suggestion
32435
- // just for good measure. That way once the actual results run out we always
32436
- // have a URL option to fallback on.
32437
-
32438
- if (couldBeURL && withURLSuggestion && !isInitialSuggestions) {
32439
- results = results[0].concat(results[1]);
32440
- } else {
32441
- results = results[0];
32442
- } // If displaying initial suggestions just return plain results.
32443
 
 
 
 
32444
 
32445
- if (isInitialSuggestions) {
32446
- return results;
32447
- } // Here we append a faux suggestion to represent a "CREATE" option. This
32448
- // is detected in the rendering of the search results and handled as a
32449
- // special case. This is currently necessary because the suggestions
32450
- // dropdown will only appear if there are valid suggestions and
32451
- // therefore unless the create option is a suggestion it will not
32452
- // display in scenarios where there are no results returned from the
32453
- // API. In addition promoting CREATE to a first class suggestion affords
32454
- // the a11y benefits afforded by `URLInput` to all suggestions (eg:
32455
- // keyboard handling, ARIA roles...etc).
32456
- //
32457
- // Note also that the value of the `title` and `url` properties must correspond
32458
- // to the text value of the `<input>`. This is because `title` is used
32459
- // when creating the suggestion. Similarly `url` is used when using keyboard to select
32460
- // the suggestion (the <form> `onSubmit` handler falls-back to `url`).
32461
 
 
 
 
32462
 
32463
- return isURLLike(val) || !withCreateSuggestion ? results : results.concat({
32464
- // the `id` prop is intentionally ommitted here because it
32465
- // is never exposed as part of the component's public API.
32466
- // see: https://github.com/WordPress/gutenberg/pull/19775#discussion_r378931316.
32467
- title: val,
32468
- // must match the existing `<input>`s text value
32469
- url: val,
32470
- // must match the existing `<input>`s text value
32471
- type: CREATE_TYPE
32472
- });
32473
- };
32474
 
32475
- function useSearchHandler(suggestionsQuery, allowDirectEntry, withCreateSuggestion, withURLSuggestion) {
32476
- const {
32477
- fetchSearchSuggestions
32478
- } = (0,external_wp_data_namespaceObject.useSelect)(select => {
32479
- const {
32480
- getSettings
32481
- } = select(store);
32482
- return {
32483
- fetchSearchSuggestions: getSettings().__experimentalFetchLinkSuggestions
32484
- };
32485
- }, []);
32486
- const directEntryHandler = allowDirectEntry ? handleDirectEntry : handleNoop;
32487
- return (0,external_wp_element_namespaceObject.useCallback)((val, {
32488
- isInitialSuggestions
32489
- }) => {
32490
- return isURLLike(val) ? directEntryHandler(val, {
32491
- isInitialSuggestions
32492
- }) : handleEntitySearch(val, { ...suggestionsQuery,
32493
- isInitialSuggestions
32494
- }, fetchSearchSuggestions, directEntryHandler, withCreateSuggestion, withURLSuggestion);
32495
- }, [directEntryHandler, fetchSearchSuggestions, withCreateSuggestion]);
32496
- }
32497
- //# sourceMappingURL=use-search-handler.js.map
32498
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/link-control/search-input.js
32499
 
32500
 
32501
  /**
32502
  * External dependencies
32503
  */
32504
 
 
32505
  /**
32506
  * WordPress dependencies
32507
  */
32508
 
32509
 
32510
-
32511
-
32512
  /**
32513
  * Internal dependencies
32514
  */
32515
 
32516
 
32517
-
32518
-
32519
- // Must be a function as otherwise URLInput will default
32520
- // to the fetchLinkSuggestions passed in block editor settings
32521
- // which will cause an unintended http request.
32522
-
32523
- const noopSearchHandler = () => Promise.resolve([]);
32524
-
32525
- const LinkControlSearchInput = (0,external_wp_element_namespaceObject.forwardRef)(({
32526
- value,
32527
  children,
32528
- currentLink = {},
32529
- className = null,
32530
- placeholder = null,
32531
- withCreateSuggestion = false,
32532
- onCreateSuggestion = external_lodash_namespaceObject.noop,
32533
- onChange = external_lodash_namespaceObject.noop,
32534
- onSelect = external_lodash_namespaceObject.noop,
32535
- showSuggestions = true,
32536
- renderSuggestions = props => (0,external_wp_element_namespaceObject.createElement)(LinkControlSearchResults, props),
32537
- fetchSuggestions = null,
32538
- allowDirectEntry = true,
32539
- showInitialSuggestions = false,
32540
- suggestionsQuery = {},
32541
- withURLSuggestion = true,
32542
- createSuggestionButtonText
32543
- }, ref) => {
32544
- const genericSearchHandler = useSearchHandler(suggestionsQuery, allowDirectEntry, withCreateSuggestion, withURLSuggestion);
32545
- const searchHandler = showSuggestions ? fetchSuggestions || genericSearchHandler : noopSearchHandler;
32546
- const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(LinkControlSearchInput);
32547
- const [focusedSuggestion, setFocusedSuggestion] = (0,external_wp_element_namespaceObject.useState)();
32548
- /**
32549
- * Handles the user moving between different suggestions. Does not handle
32550
- * choosing an individual item.
32551
- *
32552
- * @param {string} selection the url of the selected suggestion.
32553
- * @param {Object} suggestion the suggestion object.
32554
- */
32555
-
32556
- const onInputChange = (selection, suggestion) => {
32557
- onChange(selection);
32558
- setFocusedSuggestion(suggestion);
32559
- };
32560
-
32561
- const handleRenderSuggestions = props => renderSuggestions({ ...props,
32562
- instanceId,
32563
- withCreateSuggestion,
32564
- currentInputValue: value,
32565
- createSuggestionButtonText,
32566
- suggestionsQuery,
32567
- handleSuggestionClick: suggestion => {
32568
- if (props.handleSuggestionClick) {
32569
- props.handleSuggestionClick(suggestion);
32570
- }
32571
-
32572
- onSuggestionSelected(suggestion);
32573
- }
32574
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
32575
 
32576
- const onSuggestionSelected = async selectedSuggestion => {
32577
- let suggestion = selectedSuggestion;
 
 
 
 
 
 
 
 
32578
 
32579
- if (CREATE_TYPE === selectedSuggestion.type) {
32580
- // Create a new page and call onSelect with the output from the onCreateSuggestion callback
32581
- try {
32582
- var _suggestion;
32583
 
32584
- suggestion = await onCreateSuggestion(selectedSuggestion.title);
32585
 
32586
- if ((_suggestion = suggestion) !== null && _suggestion !== void 0 && _suggestion.url) {
32587
- onSelect(suggestion);
32588
- }
32589
- } catch (e) {}
 
 
 
 
 
 
 
 
32590
 
32591
- return;
32592
- }
 
32593
 
32594
- if (allowDirectEntry || suggestion && Object.keys(suggestion).length >= 1) {
32595
- onSelect( // Some direct entries don't have types or IDs, and we still need to clear the previous ones.
32596
- { ...(0,external_lodash_namespaceObject.omit)(currentLink, 'id', 'url'),
32597
- ...suggestion
32598
- }, suggestion);
32599
- }
32600
- };
32601
 
32602
- return (0,external_wp_element_namespaceObject.createElement)("div", null, (0,external_wp_element_namespaceObject.createElement)(url_input, {
32603
- className: className,
32604
- value: value,
32605
- onChange: onInputChange,
32606
- placeholder: placeholder !== null && placeholder !== void 0 ? placeholder : (0,external_wp_i18n_namespaceObject.__)('Search or type url'),
32607
- __experimentalRenderSuggestions: showSuggestions ? handleRenderSuggestions : null,
32608
- __experimentalFetchLinkSuggestions: searchHandler,
32609
- __experimentalHandleURLSuggestions: true,
32610
- __experimentalShowInitialSuggestions: showInitialSuggestions,
32611
- onSubmit: suggestion => {
32612
- onSuggestionSelected(suggestion || focusedSuggestion || {
32613
- url: value
32614
- });
32615
- },
32616
- ref: ref
32617
- }), children);
32618
- });
32619
- /* harmony default export */ var search_input = (LinkControlSearchInput);
32620
- //# sourceMappingURL=search-input.js.map
32621
- ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/link-control/viewer-slot.js
32622
  /**
32623
  * WordPress dependencies
32624
  */
32625
 
32626
- const {
32627
- Slot: ViewerSlot,
32628
- Fill: ViewerFill
32629
- } = (0,external_wp_components_namespaceObject.createSlotFill)('BlockEditorLinkControlViewer');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
486
  module.exports = computedStyle;
487
 
488
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
489
  /***/ }),
490
 
491
  /***/ 5913:
5797
  "FontSizePicker": function() { return /* reexport */ font_size_picker; },
5798
  "InnerBlocks": function() { return /* reexport */ inner_blocks; },
5799
  "Inserter": function() { return /* reexport */ inserter; },
5800
+ "InspectorAdvancedControls": function() { return /* reexport */ InspectorAdvancedControls; },
5801
  "InspectorControls": function() { return /* reexport */ inspector_controls; },
5802
  "JustifyContentControl": function() { return /* reexport */ JustifyContentControl; },
5803
  "JustifyToolbar": function() { return /* reexport */ JustifyToolbar; },
5865
  "__experimentalUseInnerBlocksProps": function() { return /* reexport */ useInnerBlocksProps; },
5866
  "__experimentalUseNoRecursiveRenders": function() { return /* reexport */ useNoRecursiveRenders; },
5867
  "__experimentalUseResizeCanvas": function() { return /* reexport */ useResizeCanvas; },
 
5868
  "__unstableBlockSettingsMenuFirstItem": function() { return /* reexport */ block_settings_menu_first_item; },
5869
  "__unstableEditorStyles": function() { return /* reexport */ EditorStyles; },
5870
  "__unstableIframe": function() { return /* reexport */ iframe; },
6087
  var external_wp_components_namespaceObject = window["wp"]["components"];
6088
  ;// CONCATENATED MODULE: external ["wp","data"]
6089
  var external_wp_data_namespaceObject = window["wp"]["data"];
6090
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-controls/groups.js
6091
  /**
6092
  * WordPress dependencies
6093
  */
6094
 
6095
+ const BlockControlsDefault = (0,external_wp_components_namespaceObject.createSlotFill)('BlockControls');
6096
+ const BlockControlsBlock = (0,external_wp_components_namespaceObject.createSlotFill)('BlockControlsBlock');
6097
+ const BlockControlsInline = (0,external_wp_components_namespaceObject.createSlotFill)('BlockFormatControls');
6098
+ const BlockControlsOther = (0,external_wp_components_namespaceObject.createSlotFill)('BlockControlsOther');
6099
+ const BlockControlsParent = (0,external_wp_components_namespaceObject.createSlotFill)('BlockControlsParent');
6100
+ const groups = {
6101
+ default: BlockControlsDefault,
6102
+ block: BlockControlsBlock,
6103
+ inline: BlockControlsInline,
6104
+ other: BlockControlsOther,
6105
+ parent: BlockControlsParent
6106
+ };
6107
+ /* harmony default export */ var block_controls_groups = (groups);
6108
+ //# sourceMappingURL=groups.js.map
 
 
 
 
 
6109
  ;// CONCATENATED MODULE: external ["wp","i18n"]
6110
  var external_wp_i18n_namespaceObject = window["wp"]["i18n"];
6111
  ;// CONCATENATED MODULE: ./packages/block-editor/build-module/store/defaults.js
6137
  * @property {boolean} __experimentalBlockDirectory Whether the user has enabled the Block Directory
6138
  * @property {Array} __experimentalBlockPatterns Array of objects representing the block patterns
6139
  * @property {Array} __experimentalBlockPatternCategories Array of objects representing the block pattern categories
6140
+ * @property {boolean} __unstableGalleryWithImageBlocks Whether the user has enabled the refactored gallery block which uses InnerBlocks
6141
  */
6142
 
6143
  const SETTINGS_DEFAULTS = {
6249
  __experimentalBlockPatterns: [],
6250
  __experimentalBlockPatternCategories: [],
6251
  __experimentalSpotlightEntityBlocks: [],
6252
+ __unstableGalleryWithImageBlocks: false,
6253
  // gradients setting is not used anymore now defaults are passed from theme.json on the server and core has its own defaults.
6254
  // The setting is only kept for backward compatibility purposes.
6255
  gradients: [{
9740
  const variationMapper = getItemFromVariation(state, item);
9741
  blockVariations.push(...variations.map(variationMapper));
9742
  }
9743
+ } // Ensure core blocks are prioritized in the returned results,
 
 
 
 
 
 
 
 
 
 
 
 
 
9744
  // because third party blocks can be registered earlier than
9745
  // the core blocks (usually by using the `init` action),
9746
  // thus affecting the display order.
9747
  // We don't sort reusable blocks as they are handled differently.
9748
 
9749
 
9750
+ const groupByType = (blocks, block) => {
9751
+ const {
9752
+ core,
9753
+ noncore
9754
+ } = blocks;
9755
+ const type = block.name.startsWith('core/') ? core : noncore;
9756
+ type.push(block);
9757
+ return blocks;
9758
+ };
9759
+
9760
+ const items = visibleBlockTypeInserterItems.reduce(groupByType, {
9761
+ core: [],
9762
+ noncore: []
9763
+ });
9764
+ const variations = blockVariations.reduce(groupByType, {
9765
+ core: [],
9766
+ noncore: []
9767
+ });
9768
+ const sortedBlockTypes = [...items.core, ...variations.core, ...items.noncore, ...variations.noncore];
9769
  return [...sortedBlockTypes, ...reusableBlockInserterItems];
9770
  }, (state, rootClientId) => [state.blockListSettings[rootClientId], state.blocks.byClientId, state.blocks.order, state.preferences.insertUsage, state.settings.allowedBlockTypes, state.settings.templateLock, getReusableBlocks(state), (0,external_wp_blocks_namespaceObject.getBlockTypes)()]);
9771
  /**
11476
  persist: ['preferences']
11477
  });
11478
  //# sourceMappingURL=index.js.map
11479
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-edit/context.js
11480
+ /**
11481
+ * WordPress dependencies
11482
+ */
11483
+
11484
+ const DEFAULT_BLOCK_EDIT_CONTEXT = {
11485
+ name: '',
11486
+ isSelected: false
11487
+ };
11488
+ const Context = (0,external_wp_element_namespaceObject.createContext)(DEFAULT_BLOCK_EDIT_CONTEXT);
11489
+ const {
11490
+ Provider
11491
+ } = Context;
11492
+
11493
+ /**
11494
+ * A hook that returns the block edit context.
11495
+ *
11496
+ * @return {Object} Block edit context
11497
+ */
11498
+
11499
+ function useBlockEditContext() {
11500
+ return (0,external_wp_element_namespaceObject.useContext)(Context);
11501
+ }
11502
+ //# sourceMappingURL=context.js.map
11503
  ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/use-display-block-controls/index.js
11504
  /**
11505
  * WordPress dependencies
11517
  clientId,
11518
  name
11519
  } = useBlockEditContext();
11520
+ return (0,external_wp_data_namespaceObject.useSelect)(select => {
 
11521
  if (isSelected) {
11522
+ return true;
11523
  }
11524
 
11525
  const {
11528
  getMultiSelectedBlockClientIds
11529
  } = select(store);
11530
 
11531
+ if (isFirstMultiSelectedBlock(clientId)) {
11532
+ return getMultiSelectedBlockClientIds().every(id => getBlockName(id) === name);
11533
  }
11534
 
11535
+ return false;
11536
  }, [clientId, isSelected, name]);
 
11537
  }
11538
  //# sourceMappingURL=index.js.map
11539
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-controls/hook.js
11540
  /**
11541
  * WordPress dependencies
11542
  */
11543
 
11544
+
11545
+ /**
11546
+ * Internal dependencies
11547
+ */
11548
+
11549
+
11550
+
11551
+
11552
+
11553
+ function useBlockControlsFill(group, exposeToChildren) {
11554
+ const isDisplayed = useDisplayBlockControls();
11555
+ const {
11556
+ clientId
11557
+ } = useBlockEditContext();
11558
+ const isParentDisplayed = (0,external_wp_data_namespaceObject.useSelect)(select => {
11559
+ const {
11560
+ getBlockName,
11561
+ hasSelectedInnerBlock
11562
+ } = select(store);
11563
+ const {
11564
+ hasBlockSupport
11565
+ } = select(external_wp_blocks_namespaceObject.store);
11566
+ return exposeToChildren && hasBlockSupport(getBlockName(clientId), '__experimentalExposeControlsToChildren', false) && hasSelectedInnerBlock(clientId);
11567
+ }, [exposeToChildren, clientId]);
11568
+
11569
+ if (isDisplayed) {
11570
+ var _groups$group;
11571
+
11572
+ return (_groups$group = block_controls_groups[group]) === null || _groups$group === void 0 ? void 0 : _groups$group.Fill;
11573
+ }
11574
+
11575
+ if (isParentDisplayed) {
11576
+ return block_controls_groups.parent.Fill;
11577
+ }
11578
+
11579
+ return null;
11580
+ }
11581
+ //# sourceMappingURL=hook.js.map
11582
  ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-controls/fill.js
11583
 
11584
 
11596
  */
11597
 
11598
 
 
11599
  function BlockControlsFill({
11600
  group = 'default',
11601
  controls,
11602
+ children,
11603
+ __experimentalExposeToChildren = false
11604
  }) {
11605
+ const Fill = useBlockControlsFill(group, __experimentalExposeToChildren);
11606
+
11607
+ if (!Fill) {
11608
  return null;
11609
  }
11610
 
 
11611
  return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalStyleProvider, {
11612
  document: document
11613
  }, (0,external_wp_element_namespaceObject.createElement)(Fill, null, fillProps => {
11805
  save: function FlexLayoutStyle({
11806
  selector
11807
  }) {
11808
+ return (0,external_wp_element_namespaceObject.createElement)("style", null, `
11809
+ ${appendSelectors(selector)} {
11810
+ display: flex;
11811
+ gap: var( --wp--style--block-gap, 0.5em );
11812
+ flex-wrap: wrap;
11813
+ align-items: center;
11814
+ }
11815
+
11816
+ ${appendSelectors(selector, '> *')} {
11817
+ margin: 0;
11818
+ }
11819
+ `);
11820
  },
11821
 
11822
  getOrientation() {
12068
  float: right;
12069
  margin-left: 2em;
12070
  }
12071
+
12072
+ ${appendSelectors(selector, '> * + *')} {
12073
+ margin-top: var( --wp--style--block-gap );
12074
+ margin-bottom: 0;
12075
+ }
12076
  `;
12077
  return (0,external_wp_element_namespaceObject.createElement)("style", null, style);
12078
  },
12450
  });
12451
  };
12452
 
12453
+ return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, validAlignments.length > 0 && (0,external_wp_element_namespaceObject.createElement)(block_controls, {
12454
+ group: "block",
12455
+ __experimentalExposeToChildren: true
12456
  }, (0,external_wp_element_namespaceObject.createElement)(BlockAlignmentControl, {
12457
  value: props.attributes.align,
12458
  onChange: updateAlignment,
12459
  controls: validAlignments
12460
+ })), (0,external_wp_element_namespaceObject.createElement)(BlockEdit, props));
 
 
12461
  }, 'withToolbarControls');
12462
  /**
12463
  * Override the default block element to add alignment wrapper props.
12528
  (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockEdit', 'core/editor/align/with-toolbar-controls', withToolbarControls);
12529
  (0,external_wp_hooks_namespaceObject.addFilter)('blocks.getSaveContent.extraProps', 'core/align/addAssignedAlign', addAssignedAlign);
12530
  //# sourceMappingURL=align.js.map
12531
+ ;// CONCATENATED MODULE: external ["wp","warning"]
12532
+ var external_wp_warning_namespaceObject = window["wp"]["warning"];
12533
+ var external_wp_warning_default = /*#__PURE__*/__webpack_require__.n(external_wp_warning_namespaceObject);
12534
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/inspector-controls/groups.js
12535
+ /**
12536
+ * WordPress dependencies
12537
+ */
12538
+
12539
+ const InspectorControlsDefault = (0,external_wp_components_namespaceObject.createSlotFill)('InspectorControls');
12540
+ const InspectorControlsAdvanced = (0,external_wp_components_namespaceObject.createSlotFill)('InspectorAdvancedControls');
12541
+ const groups_groups = {
12542
+ default: InspectorControlsDefault,
12543
+ advanced: InspectorControlsAdvanced
12544
+ };
12545
+ /* harmony default export */ var inspector_controls_groups = (groups_groups);
12546
+ //# sourceMappingURL=groups.js.map
12547
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/inspector-controls/fill.js
12548
 
12549
 
12550
  /**
12551
  * WordPress dependencies
12552
  */
12553
 
12554
+
12555
  /**
12556
  * Internal dependencies
12557
  */
12558
 
12559
 
 
 
 
 
 
12560
 
12561
+ function InspectorControlsFill({
12562
+ __experimentalGroup: group = 'default',
12563
  children
12564
  }) {
12565
+ var _groups$group;
12566
+
12567
+ const isDisplayed = useDisplayBlockControls();
12568
+ const Fill = (_groups$group = inspector_controls_groups[group]) === null || _groups$group === void 0 ? void 0 : _groups$group.Fill;
12569
+
12570
+ if (!Fill) {
12571
+ typeof process !== "undefined" && process.env && "production" !== "production" ? external_wp_warning_default()(`Unknown InspectorControl group "${group}" provided.`) : void 0;
12572
+ return null;
12573
+ }
12574
+
12575
+ if (!isDisplayed) {
12576
+ return null;
12577
+ }
12578
+
12579
+ return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalStyleProvider, {
12580
  document: document
12581
+ }, (0,external_wp_element_namespaceObject.createElement)(Fill, null, children));
12582
  }
12583
+ //# sourceMappingURL=fill.js.map
12584
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/inspector-controls/slot.js
12585
 
 
 
 
 
 
 
 
 
 
12586
 
12587
 
12588
  /**
12589
  * WordPress dependencies
12590
  */
12591
 
12592
+
12593
  /**
12594
  * Internal dependencies
12595
  */
12596
 
12597
 
12598
+ function InspectorControlsSlot({
12599
+ __experimentalGroup: group = 'default',
12600
+ bubblesVirtually = true,
12601
+ ...props
 
 
 
12602
  }) {
12603
+ var _groups$group;
12604
+
12605
+ const Slot = (_groups$group = inspector_controls_groups[group]) === null || _groups$group === void 0 ? void 0 : _groups$group.Slot;
12606
+ const slot = (0,external_wp_components_namespaceObject.__experimentalUseSlot)(Slot === null || Slot === void 0 ? void 0 : Slot.__unstableName);
12607
+
12608
+ if (!Slot || !slot) {
12609
+ typeof process !== "undefined" && process.env && "production" !== "production" ? external_wp_warning_default()(`Unknown InspectorControl group "${group}" provided.`) : void 0;
12610
+ return null;
12611
+ }
12612
+
12613
+ const hasFills = Boolean(slot.fills && slot.fills.length);
12614
+
12615
+ if (!hasFills) {
12616
+ return null;
12617
+ }
12618
+
12619
+ return (0,external_wp_element_namespaceObject.createElement)(Slot, _extends({}, props, {
12620
+ bubblesVirtually: bubblesVirtually
12621
+ }));
12622
  }
12623
+ //# sourceMappingURL=slot.js.map
12624
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/inspector-controls/index.js
12625
+
12626
 
12627
+
12628
+ /**
12629
+ * Internal dependencies
12630
+ */
12631
+
12632
+
12633
+ const InspectorControls = InspectorControlsFill;
12634
+ InspectorControls.Slot = InspectorControlsSlot; // This is just here for backward compatibility.
12635
+
12636
+ const InspectorAdvancedControls = props => {
12637
+ return (0,external_wp_element_namespaceObject.createElement)(InspectorControlsFill, _extends({}, props, {
12638
+ __experimentalGroup: "advanced"
12639
+ }));
12640
+ };
12641
+
12642
+ InspectorAdvancedControls.Slot = props => {
12643
+ return (0,external_wp_element_namespaceObject.createElement)(InspectorControlsSlot, _extends({}, props, {
12644
+ __experimentalGroup: "advanced"
12645
+ }));
12646
+ };
12647
+
12648
+ InspectorAdvancedControls.slotName = 'InspectorAdvancedControls';
12649
  /**
12650
  * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/inspector-controls/README.md
12651
  */
12742
  autoCapitalize: "none",
12743
  autoComplete: "off"
12744
  });
12745
+ return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(BlockEdit, props), isWeb && (0,external_wp_element_namespaceObject.createElement)(inspector_controls, {
12746
+ __experimentalGroup: "advanced"
12747
+ }, textControl), !isWeb && props.name === 'core/heading' && (0,external_wp_element_namespaceObject.createElement)(inspector_controls, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelBody, {
12748
  title: (0,external_wp_i18n_namespaceObject.__)('Heading settings')
12749
  }, textControl)));
12750
  }
12831
  const hasCustomClassName = (0,external_wp_blocks_namespaceObject.hasBlockSupport)(props.name, 'customClassName', true);
12832
 
12833
  if (hasCustomClassName && props.isSelected) {
12834
+ return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(BlockEdit, props), (0,external_wp_element_namespaceObject.createElement)(inspector_controls, {
12835
+ __experimentalGroup: "advanced"
12836
+ }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextControl, {
12837
  autoComplete: "off",
12838
  label: (0,external_wp_i18n_namespaceObject.__)('Additional CSS class(es)'),
12839
  value: props.attributes.className || '',
16374
 
16375
 
16376
 
 
16377
  /**
16378
  * Internal dependencies
16379
  */
16399
  }
16400
 
16401
  const hasTypographySupport = blockName => {
16402
+ return TYPOGRAPHY_SUPPORT_KEYS.some(key => (0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockName, key));
16403
  };
16404
 
16405
  function useIsTypographyDisabled(props = {}) {
16484
  name: blockName
16485
  } = {}) {
16486
  const isDisabled = !useSetting('spacing.customMargin');
16487
+ const isInvalid = !useIsDimensionsSupportValid(blockName, 'margin');
16488
+ return !hasMarginSupport(blockName) || isDisabled || isInvalid;
16489
  }
16490
  /**
16491
  * Inspector control panel containing the margin related configuration
16509
  availableUnits: useSetting('spacing.units') || ['%', 'px', 'em', 'rem', 'vw']
16510
  });
16511
  const sides = useCustomSides(blockName, 'margin');
16512
+ const splitOnAxis = sides && sides.some(side => AXIAL_SIDES.includes(side));
16513
 
16514
  if (useIsMarginDisabled(props)) {
16515
  return null;
16545
  label: (0,external_wp_i18n_namespaceObject.__)('Margin'),
16546
  sides: sides,
16547
  units: units,
16548
+ allowReset: false,
16549
+ splitOnAxis: splitOnAxis
16550
  })),
16551
  native: null
16552
  });
16629
  name: blockName
16630
  } = {}) {
16631
  const isDisabled = !useSetting('spacing.customPadding');
16632
+ const isInvalid = !useIsDimensionsSupportValid(blockName, 'padding');
16633
+ return !hasPaddingSupport(blockName) || isDisabled || isInvalid;
16634
  }
16635
  /**
16636
  * Inspector control panel containing the padding related configuration
16654
  availableUnits: useSetting('spacing.units') || ['%', 'px', 'em', 'rem', 'vw']
16655
  });
16656
  const sides = useCustomSides(blockName, 'padding');
16657
+ const splitOnAxis = sides && sides.some(side => AXIAL_SIDES.includes(side));
16658
 
16659
  if (useIsPaddingDisabled(props)) {
16660
  return null;
16690
  label: (0,external_wp_i18n_namespaceObject.__)('Padding'),
16691
  sides: sides,
16692
  units: units,
16693
+ allowReset: false,
16694
+ splitOnAxis: splitOnAxis
16695
  })),
16696
  native: null
16697
  });
16716
 
16717
 
16718
  const SPACING_SUPPORT_KEY = 'spacing';
16719
+ const ALL_SIDES = ['top', 'right', 'bottom', 'left'];
16720
+ const AXIAL_SIDES = ['vertical', 'horizontal'];
16721
  /**
16722
  * Inspector controls for dimensions support.
16723
  *
16815
  function useCustomSides(blockName, feature) {
16816
  const support = (0,external_wp_blocks_namespaceObject.getBlockSupport)(blockName, SPACING_SUPPORT_KEY); // Skip when setting is boolean as theme isn't setting arbitrary sides.
16817
 
16818
+ if (!support || typeof support[feature] === 'boolean') {
16819
  return;
16820
  }
16821
 
16822
  return support[feature];
16823
  }
16824
+ /**
16825
+ * Custom hook to determine whether the sides configured in the
16826
+ * block support are valid. A dimension property cannot declare
16827
+ * support for a mix of axial and individual sides.
16828
+ *
16829
+ * @param {string} blockName Block name.
16830
+ * @param {string} feature The feature custom sides relate to e.g. padding or margins.
16831
+ *
16832
+ * @return {boolean} If the feature has a valid configuration of sides.
16833
+ */
16834
+
16835
+ function useIsDimensionsSupportValid(blockName, feature) {
16836
+ const sides = useCustomSides(blockName, feature);
16837
+
16838
+ if (sides && sides.some(side => ALL_SIDES.includes(side)) && sides.some(side => AXIAL_SIDES.includes(side))) {
16839
+ // eslint-disable-next-line no-console
16840
+ console.warn(`The ${feature} support for the "${blockName}" block can not be configured to support both axial and arbitrary sides.`);
16841
+ return false;
16842
+ }
16843
+
16844
+ return true;
16845
+ }
16846
  //# sourceMappingURL=dimensions.js.map
16847
  ;// CONCATENATED MODULE: ./packages/block-editor/build-module/hooks/style.js
16848
 
17157
 
17158
  /* harmony default export */ var duotone_control = (DuotoneControl);
17159
  //# sourceMappingURL=index.js.map
17160
+ ;// CONCATENATED MODULE: external ["wp","dom"]
17161
+ var external_wp_dom_namespaceObject = window["wp"]["dom"];
17162
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-context/index.js
17163
 
17164
 
17165
  /**
17166
  * WordPress dependencies
17167
  */
17168
 
17169
+ /** @typedef {import('react').ReactNode} ReactNode */
17170
+
17171
+ /**
17172
+ * @typedef BlockContextProviderProps
17173
+ *
17174
+ * @property {Record<string,*>} value Context value to merge with current
17175
+ * value.
17176
+ * @property {ReactNode} children Component children.
17177
+ */
17178
+
17179
+ /** @type {import('react').Context<Record<string,*>>} */
17180
+
17181
+ const block_context_Context = (0,external_wp_element_namespaceObject.createContext)({});
17182
+ /**
17183
+ * Component which merges passed value with current consumed block context.
17184
+ *
17185
+ * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-context/README.md
17186
+ *
17187
+ * @param {BlockContextProviderProps} props
17188
+ */
17189
+
17190
+ function BlockContextProvider({
17191
+ value,
17192
  children
17193
  }) {
17194
+ const context = (0,external_wp_element_namespaceObject.useContext)(block_context_Context);
17195
+ const nextValue = (0,external_wp_element_namespaceObject.useMemo)(() => ({ ...context,
17196
+ ...value
17197
+ }), [context, value]);
17198
+ return (0,external_wp_element_namespaceObject.createElement)(block_context_Context.Provider, {
17199
+ value: nextValue,
17200
+ children: children
17201
+ });
17202
  }
17203
+ /* harmony default export */ var block_context = (block_context_Context);
17204
+ //# sourceMappingURL=index.js.map
17205
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-edit/edit.js
17206
 
17207
 
17208
 
17218
 
17219
 
17220
 
 
 
17221
  /**
17222
  * Internal dependencies
17223
  */
17224
 
17225
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17226
  /**
17227
+ * Default value used for blocks which do not define their own context needs,
17228
+ * used to guarantee that a block's `context` prop will always be an object. It
17229
+ * is assigned as a constant since it is always expected to be an empty object,
17230
+ * and in order to avoid unnecessary React reconciliations of a changing object.
 
 
17231
  *
17232
+ * @type {{}}
17233
  */
17234
 
17235
+ const DEFAULT_BLOCK_CONTEXT = {};
17236
+ const Edit = props => {
17237
+ const {
17238
+ attributes = {},
17239
+ name
17240
+ } = props;
17241
+ const blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(name);
17242
+ const blockContext = (0,external_wp_element_namespaceObject.useContext)(block_context); // Assign context values using the block type's declared context needs.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17243
 
17244
+ const context = (0,external_wp_element_namespaceObject.useMemo)(() => {
17245
+ return blockType && blockType.usesContext ? (0,external_lodash_namespaceObject.pick)(blockContext, blockType.usesContext) : DEFAULT_BLOCK_CONTEXT;
17246
+ }, [blockType, blockContext]);
 
 
 
17247
 
17248
+ if (!blockType) {
17249
  return null;
17250
+ } // `edit` and `save` are functions or components describing the markup
17251
+ // with which a block is displayed. If `blockType` is valid, assign
17252
+ // them preferentially as the render value for the block.
17253
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17254
 
17255
+ const Component = blockType.edit || blockType.save;
17256
+
17257
+ if (blockType.apiVersion > 1 || (0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockType, 'lightBlockWrapper', false)) {
17258
+ return (0,external_wp_element_namespaceObject.createElement)(Component, _extends({}, props, {
17259
+ context: context
17260
+ }));
17261
+ } // Generate a class name for the block's editable form
17262
 
 
 
 
 
 
17263
 
17264
+ const generatedClassName = (0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockType, 'className', true) ? (0,external_wp_blocks_namespaceObject.getBlockDefaultClassName)(name) : null;
17265
+ const className = classnames_default()(generatedClassName, attributes.className);
17266
+ return (0,external_wp_element_namespaceObject.createElement)(Component, _extends({}, props, {
17267
+ context: context,
17268
+ className: className
17269
+ }));
17270
+ };
17271
+ /* harmony default export */ var edit = ((0,external_wp_components_namespaceObject.withFilters)('editor.BlockEdit')(Edit));
17272
+ //# sourceMappingURL=edit.js.map
17273
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-edit/index.js
17274
 
 
 
 
 
 
 
 
17275
 
 
 
17276
  /**
17277
+ * WordPress dependencies
 
 
 
 
 
17278
  */
17279
 
 
 
 
 
 
17280
  /**
17281
+ * Internal dependencies
 
 
 
 
17282
  */
17283
 
 
 
17284
 
 
 
17285
 
 
 
 
17286
 
17287
+ function BlockEdit(props) {
17288
+ const {
17289
+ name,
17290
+ isSelected,
17291
+ clientId
17292
+ } = props;
17293
+ const context = {
17294
+ name,
17295
+ isSelected,
17296
+ clientId
17297
+ };
17298
+ return (0,external_wp_element_namespaceObject.createElement)(Provider // It is important to return the same object if props haven't
17299
+ // changed to avoid unnecessary rerenders.
17300
+ // See https://reactjs.org/docs/context.html#caveats.
17301
+ , {
17302
+ value: (0,external_wp_element_namespaceObject.useMemo)(() => context, Object.values(context))
17303
+ }, (0,external_wp_element_namespaceObject.createElement)(edit, props));
17304
+ }
17305
+ //# sourceMappingURL=index.js.map
17306
+ ;// CONCATENATED MODULE: ./packages/icons/build-module/library/more-horizontal.js
17307
+
17308
+
17309
+ /**
17310
+ * WordPress dependencies
17311
+ */
17312
 
17313
+ const moreHorizontal = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
17314
+ xmlns: "http://www.w3.org/2000/svg",
17315
+ viewBox: "0 0 24 24"
17316
+ }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
17317
+ d: "M11 13h2v-2h-2v2zm-6 0h2v-2H5v2zm12-2v2h2v-2h-2z"
17318
+ }));
17319
+ /* harmony default export */ var more_horizontal = (moreHorizontal);
17320
+ //# sourceMappingURL=more-horizontal.js.map
17321
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/warning/index.js
17322
 
17323
 
17324
  /**
17325
  * External dependencies
17326
  */
17327
 
 
17328
  /**
17329
  * WordPress dependencies
17330
  */
17334
 
17335
 
17336
 
17337
+ function Warning({
17338
+ className,
17339
+ actions,
17340
+ children,
17341
+ secondaryActions
17342
+ }) {
17343
+ return (0,external_wp_element_namespaceObject.createElement)("div", {
17344
+ className: classnames_default()(className, 'block-editor-warning')
17345
+ }, (0,external_wp_element_namespaceObject.createElement)("div", {
17346
+ className: "block-editor-warning__contents"
17347
+ }, (0,external_wp_element_namespaceObject.createElement)("p", {
17348
+ className: "block-editor-warning__message"
17349
+ }, children), (external_wp_element_namespaceObject.Children.count(actions) > 0 || secondaryActions) && (0,external_wp_element_namespaceObject.createElement)("div", {
17350
+ className: "block-editor-warning__actions"
17351
+ }, external_wp_element_namespaceObject.Children.count(actions) > 0 && external_wp_element_namespaceObject.Children.map(actions, (action, i) => (0,external_wp_element_namespaceObject.createElement)("span", {
17352
+ key: i,
17353
+ className: "block-editor-warning__action"
17354
+ }, action)), secondaryActions && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.DropdownMenu, {
17355
+ className: "block-editor-warning__secondary",
17356
+ icon: more_horizontal,
17357
+ label: (0,external_wp_i18n_namespaceObject.__)('More options'),
17358
+ popoverProps: {
17359
+ position: 'bottom left',
17360
+ className: 'block-editor-warning__dropdown'
17361
+ },
17362
+ noIcons: true
17363
+ }, () => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, null, secondaryActions.map((item, pos) => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
17364
+ onClick: item.onClick,
17365
+ key: pos
17366
+ }, item.title)))))));
17367
+ }
17368
  /**
17369
+ * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/warning/README.md
17370
  */
17371
 
17372
 
17373
+ /* harmony default export */ var warning = (Warning);
17374
+ //# sourceMappingURL=index.js.map
17375
+ // EXTERNAL MODULE: ./node_modules/diff/lib/diff/character.js
17376
+ var character = __webpack_require__(7630);
17377
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-compare/block-view.js
17378
 
17379
 
17380
+ /**
17381
+ * WordPress dependencies
17382
+ */
17383
 
17384
 
17385
 
17386
+ function BlockView({
17387
+ title,
17388
+ rawContent,
17389
+ renderedContent,
17390
+ action,
17391
+ actionText,
17392
+ className
17393
+ }) {
17394
+ return (0,external_wp_element_namespaceObject.createElement)("div", {
17395
+ className: className
17396
+ }, (0,external_wp_element_namespaceObject.createElement)("div", {
17397
+ className: "block-editor-block-compare__content"
17398
+ }, (0,external_wp_element_namespaceObject.createElement)("h2", {
17399
+ className: "block-editor-block-compare__heading"
17400
+ }, title), (0,external_wp_element_namespaceObject.createElement)("div", {
17401
+ className: "block-editor-block-compare__html"
17402
+ }, rawContent), (0,external_wp_element_namespaceObject.createElement)("div", {
17403
+ className: "block-editor-block-compare__preview edit-post-visual-editor"
17404
+ }, (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.RawHTML, null, (0,external_wp_dom_namespaceObject.safeHTML)(renderedContent)))), (0,external_wp_element_namespaceObject.createElement)("div", {
17405
+ className: "block-editor-block-compare__action"
17406
+ }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
17407
+ variant: "secondary",
17408
+ tabIndex: "0",
17409
+ onClick: action
17410
+ }, actionText)));
17411
+ }
17412
+ //# sourceMappingURL=block-view.js.map
17413
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-compare/index.js
17414
 
 
 
 
 
17415
 
17416
+ /**
17417
+ * External dependencies
17418
+ */
 
 
 
 
 
 
 
 
 
 
 
 
17419
 
17420
+ // diff doesn't tree-shake correctly, so we import from the individual
17421
+ // module here, to avoid including too much of the library
 
17422
 
 
 
 
 
 
 
17423
 
17424
+ /**
17425
+ * WordPress dependencies
17426
+ */
 
 
17427
 
 
 
 
17428
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17429
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17430
  /**
17431
+ * Internal dependencies
 
 
 
 
17432
  */
17433
 
17434
 
17435
+
17436
+ function BlockCompare({
17437
+ block,
17438
+ onKeep,
17439
+ onConvert,
17440
+ convertor,
17441
+ convertButtonText
17442
+ }) {
17443
+ function getDifference(originalContent, newContent) {
17444
+ const difference = (0,character/* diffChars */.Kx)(originalContent, newContent);
17445
+ return difference.map((item, pos) => {
17446
+ const classes = classnames_default()({
17447
+ 'block-editor-block-compare__added': item.added,
17448
+ 'block-editor-block-compare__removed': item.removed
17449
+ });
17450
+ return (0,external_wp_element_namespaceObject.createElement)("span", {
17451
+ key: pos,
17452
+ className: classes
17453
+ }, item.value);
17454
+ });
17455
  }
17456
 
17457
+ function getConvertedContent(convertedBlock) {
17458
+ // The convertor may return an array of items or a single item
17459
+ const newBlocks = (0,external_lodash_namespaceObject.castArray)(convertedBlock); // Get converted block details
17460
+
17461
+ const newContent = newBlocks.map(item => (0,external_wp_blocks_namespaceObject.getSaveContent)(item.name, item.attributes, item.innerBlocks));
17462
+ return newContent.join('');
17463
  }
17464
 
17465
+ const converted = getConvertedContent(convertor(block));
17466
+ const difference = getDifference(block.originalContent, converted);
17467
+ return (0,external_wp_element_namespaceObject.createElement)("div", {
17468
+ className: "block-editor-block-compare__wrapper"
17469
+ }, (0,external_wp_element_namespaceObject.createElement)(BlockView, {
17470
+ title: (0,external_wp_i18n_namespaceObject.__)('Current'),
17471
+ className: "block-editor-block-compare__current",
17472
+ action: onKeep,
17473
+ actionText: (0,external_wp_i18n_namespaceObject.__)('Convert to HTML'),
17474
+ rawContent: block.originalContent,
17475
+ renderedContent: block.originalContent
17476
+ }), (0,external_wp_element_namespaceObject.createElement)(BlockView, {
17477
+ title: (0,external_wp_i18n_namespaceObject.__)('After Conversion'),
17478
+ className: "block-editor-block-compare__converted",
17479
+ action: onConvert,
17480
+ actionText: convertButtonText,
17481
+ rawContent: difference,
17482
+ renderedContent: converted
17483
+ }));
17484
  }
17485
+
17486
+ /* harmony default export */ var block_compare = (BlockCompare);
17487
+ //# sourceMappingURL=index.js.map
17488
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-list/block-invalid-warning.js
17489
+
17490
+
17491
  /**
17492
+ * WordPress dependencies
 
 
 
 
17493
  */
17494
 
17495
+
17496
+
17497
+
17498
+
17499
+
 
 
 
 
 
 
17500
  /**
17501
+ * Internal dependencies
 
 
 
 
17502
  */
17503
 
 
 
 
 
 
 
 
 
17504
 
 
 
 
17505
 
17506
+
17507
+ function BlockInvalidWarning({
17508
+ convertToHTML,
17509
+ convertToBlocks,
17510
+ convertToClassic,
17511
+ attemptBlockRecovery,
17512
+ block
17513
+ }) {
17514
+ const hasHTMLBlock = !!(0,external_wp_blocks_namespaceObject.getBlockType)('core/html');
17515
+ const [compare, setCompare] = (0,external_wp_element_namespaceObject.useState)(false);
17516
+ const onCompare = (0,external_wp_element_namespaceObject.useCallback)(() => setCompare(true), []);
17517
+ const onCompareClose = (0,external_wp_element_namespaceObject.useCallback)(() => setCompare(false), []); // We memo the array here to prevent the children components from being updated unexpectedly
17518
+
17519
+ const hiddenActions = (0,external_wp_element_namespaceObject.useMemo)(() => [{
17520
+ // translators: Button to fix block content
17521
+ title: (0,external_wp_i18n_namespaceObject._x)('Resolve', 'imperative verb'),
17522
+ onClick: onCompare
17523
+ }, hasHTMLBlock && {
17524
+ title: (0,external_wp_i18n_namespaceObject.__)('Convert to HTML'),
17525
+ onClick: convertToHTML
17526
+ }, {
17527
+ title: (0,external_wp_i18n_namespaceObject.__)('Convert to Classic Block'),
17528
+ onClick: convertToClassic
17529
+ }].filter(Boolean), [onCompare, convertToHTML, convertToClassic]);
17530
+ return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(warning, {
17531
+ actions: [(0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
17532
+ key: "recover",
17533
+ onClick: attemptBlockRecovery,
17534
+ variant: "primary"
17535
+ }, (0,external_wp_i18n_namespaceObject.__)('Attempt Block Recovery'))],
17536
+ secondaryActions: hiddenActions
17537
+ }, (0,external_wp_i18n_namespaceObject.__)('This block contains unexpected or invalid content.')), compare && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Modal, {
17538
+ title: // translators: Dialog title to fix block content
17539
+ (0,external_wp_i18n_namespaceObject.__)('Resolve Block'),
17540
+ onRequestClose: onCompareClose,
17541
+ className: "block-editor-block-compare"
17542
+ }, (0,external_wp_element_namespaceObject.createElement)(block_compare, {
17543
+ block: block,
17544
+ onKeep: convertToHTML,
17545
+ onConvert: convertToBlocks,
17546
+ convertor: blockToBlocks,
17547
+ convertButtonText: (0,external_wp_i18n_namespaceObject.__)('Convert to Blocks')
17548
  })));
17549
+ }
17550
+
17551
+ const blockToClassic = block => (0,external_wp_blocks_namespaceObject.createBlock)('core/freeform', {
17552
+ content: block.originalContent
17553
  });
17554
+
17555
+ const blockToHTML = block => (0,external_wp_blocks_namespaceObject.createBlock)('core/html', {
17556
+ content: block.originalContent
17557
+ });
17558
+
17559
+ const blockToBlocks = block => (0,external_wp_blocks_namespaceObject.rawHandler)({
17560
+ HTML: block.originalContent
17561
+ });
17562
+
17563
+ const recoverBlock = ({
17564
+ name,
17565
+ attributes,
17566
+ innerBlocks
17567
+ }) => (0,external_wp_blocks_namespaceObject.createBlock)(name, attributes, innerBlocks);
17568
+
17569
+ /* harmony default export */ var block_invalid_warning = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)((select, {
17570
+ clientId
17571
+ }) => ({
17572
+ block: select(store).getBlock(clientId)
17573
+ })), (0,external_wp_data_namespaceObject.withDispatch)((dispatch, {
17574
+ block
17575
+ }) => {
17576
+ const {
17577
+ replaceBlock
17578
+ } = dispatch(store);
17579
+ return {
17580
+ convertToClassic() {
17581
+ replaceBlock(block.clientId, blockToClassic(block));
17582
+ },
17583
+
17584
+ convertToHTML() {
17585
+ replaceBlock(block.clientId, blockToHTML(block));
17586
+ },
17587
+
17588
+ convertToBlocks() {
17589
+ replaceBlock(block.clientId, blockToBlocks(block));
17590
+ },
17591
+
17592
+ attemptBlockRecovery() {
17593
+ replaceBlock(block.clientId, recoverBlock(block));
17594
+ }
17595
+
17596
+ };
17597
+ })])(BlockInvalidWarning));
17598
+ //# sourceMappingURL=block-invalid-warning.js.map
17599
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-list/block-crash-warning.js
17600
+
17601
+
17602
  /**
17603
+ * WordPress dependencies
17604
  */
17605
 
17606
  /**
17608
  */
17609
 
17610
 
17611
+ const block_crash_warning_warning = (0,external_wp_element_namespaceObject.createElement)(warning, {
17612
+ className: "block-editor-block-list__block-crash-warning"
17613
+ }, (0,external_wp_i18n_namespaceObject.__)('This block has encountered an error and cannot be previewed.'));
17614
+ /* harmony default export */ var block_crash_warning = (() => block_crash_warning_warning);
17615
+ //# sourceMappingURL=block-crash-warning.js.map
17616
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-list/block-crash-boundary.js
17617
  /**
17618
+ * WordPress dependencies
 
 
 
 
 
 
 
17619
  */
17620
 
 
 
 
 
 
17621
 
17622
+ class BlockCrashBoundary extends external_wp_element_namespaceObject.Component {
17623
+ constructor() {
17624
+ super(...arguments);
17625
+ this.state = {
17626
+ hasError: false
17627
+ };
17628
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17629
 
17630
+ componentDidCatch() {
17631
+ this.setState({
17632
+ hasError: true
17633
+ });
17634
+ }
17635
 
17636
+ render() {
17637
+ if (this.state.hasError) {
17638
+ return this.props.fallback;
17639
+ }
17640
+
17641
+ return this.props.children;
17642
  }
17643
 
 
17644
  }
17645
+
17646
+ /* harmony default export */ var block_crash_boundary = (BlockCrashBoundary);
17647
+ //# sourceMappingURL=block-crash-boundary.js.map
17648
+ // EXTERNAL MODULE: ./node_modules/react-autosize-textarea/lib/index.js
17649
+ var lib = __webpack_require__(4042);
17650
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-list/block-html.js
17651
+
17652
+
17653
  /**
17654
  * External dependencies
17655
  */
17656
 
17657
  /**
17658
+ * WordPress dependencies
17659
  */
17660
 
17661
 
17662
 
17663
 
 
 
 
 
 
 
 
 
17664
  /**
17665
+ * Internal dependencies
 
 
 
 
 
17666
  */
17667
 
 
 
 
 
 
 
 
 
 
 
 
 
17668
 
 
17669
 
17670
+ function BlockHTML({
17671
+ clientId
17672
+ }) {
17673
+ const [html, setHtml] = (0,external_wp_element_namespaceObject.useState)('');
17674
+ const block = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).getBlock(clientId), [clientId]);
17675
+ const {
17676
+ updateBlock
17677
+ } = (0,external_wp_data_namespaceObject.useDispatch)(store);
17678
 
17679
+ const onChange = () => {
17680
+ const blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(block.name);
17681
+ const attributes = (0,external_wp_blocks_namespaceObject.getBlockAttributes)(blockType, html, block.attributes); // If html is empty we reset the block to the default HTML and mark it as valid to avoid triggering an error
 
 
 
 
17682
 
17683
+ const content = html ? html : (0,external_wp_blocks_namespaceObject.getSaveContent)(blockType, attributes);
17684
+ const isValid = html ? (0,external_wp_blocks_namespaceObject.isValidBlockContent)(blockType, attributes, content) : true;
17685
+ updateBlock(clientId, {
17686
+ attributes,
17687
+ originalContent: content,
17688
+ isValid
17689
+ }); // Ensure the state is updated if we reset so it displays the default content
17690
+
17691
+ if (!html) {
17692
+ setHtml({
17693
+ content
17694
+ });
17695
+ }
17696
  };
17697
+
17698
+ (0,external_wp_element_namespaceObject.useEffect)(() => {
17699
+ setHtml((0,external_wp_blocks_namespaceObject.getBlockContent)(block));
17700
+ }, [block]);
17701
+ return (0,external_wp_element_namespaceObject.createElement)(lib/* default */.Z, {
17702
+ className: "block-editor-block-list__block-html-textarea",
17703
+ value: html,
17704
+ onBlur: onChange,
17705
+ onChange: event => setHtml(event.target.value)
17706
+ });
17707
  }
17708
+
17709
+ /* harmony default export */ var block_html = (BlockHTML);
17710
+ //# sourceMappingURL=block-html.js.map
17711
+ // EXTERNAL MODULE: ./node_modules/react-spring/web.cjs.js
17712
+ var web_cjs = __webpack_require__(8088);
17713
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/use-moving-animation/index.js
17714
  /**
17715
+ * External dependencies
 
 
 
 
 
 
 
 
17716
  */
17717
 
17718
+ /**
17719
+ * WordPress dependencies
17720
+ */
 
 
 
 
 
 
 
17721
 
 
 
 
 
17722
 
 
 
 
17723
 
 
 
 
 
17724
 
 
 
 
 
17725
  /**
17726
+ * Simple reducer used to increment a counter.
17727
+ *
17728
+ * @param {number} state Previous counter value.
17729
+ * @return {number} New state value.
17730
  */
 
 
 
17731
 
17732
+ const counterReducer = state => state + 1;
17733
+
17734
+ const getAbsolutePosition = element => {
17735
+ return {
17736
+ top: element.offsetTop,
17737
+ left: element.offsetLeft
17738
+ };
17739
+ };
17740
  /**
17741
+ * Hook used to compute the styles required to move a div into a new position.
 
17742
  *
17743
+ * The way this animation works is the following:
17744
+ * - It first renders the element as if there was no animation.
17745
+ * - It takes a snapshot of the position of the block to use it
17746
+ * as a destination point for the animation.
17747
+ * - It restores the element to the previous position using a CSS transform
17748
+ * - It uses the "resetAnimation" flag to reset the animation
17749
+ * from the beginning in order to animate to the new destination point.
17750
  *
17751
+ * @param {Object} $1 Options
17752
+ * @param {boolean} $1.isSelected Whether it's the current block or not.
17753
+ * @param {boolean} $1.adjustScrolling Adjust the scroll position to the current block.
17754
+ * @param {boolean} $1.enableAnimation Enable/Disable animation.
17755
+ * @param {*} $1.triggerAnimationOnChange Variable used to trigger the animation if it changes.
17756
  */
17757
 
 
 
 
 
17758
 
17759
+ function useMovingAnimation({
17760
+ isSelected,
17761
+ adjustScrolling,
17762
+ enableAnimation,
17763
+ triggerAnimationOnChange
17764
+ }) {
17765
+ const ref = (0,external_wp_element_namespaceObject.useRef)();
17766
+ const prefersReducedMotion = (0,external_wp_compose_namespaceObject.useReducedMotion)() || !enableAnimation;
17767
+ const [triggeredAnimation, triggerAnimation] = (0,external_wp_element_namespaceObject.useReducer)(counterReducer, 0);
17768
+ const [finishedAnimation, endAnimation] = (0,external_wp_element_namespaceObject.useReducer)(counterReducer, 0);
17769
+ const [transform, setTransform] = (0,external_wp_element_namespaceObject.useState)({
17770
+ x: 0,
17771
+ y: 0
17772
  });
17773
+ const previous = (0,external_wp_element_namespaceObject.useMemo)(() => ref.current ? getAbsolutePosition(ref.current) : null, [triggerAnimationOnChange]); // Calculate the previous position of the block relative to the viewport and
17774
+ // return a function to maintain that position by scrolling.
 
 
 
 
 
 
 
17775
 
17776
+ const preserveScrollPosition = (0,external_wp_element_namespaceObject.useMemo)(() => {
17777
+ if (!adjustScrolling || !ref.current) {
17778
+ return () => {};
17779
+ }
17780
 
17781
+ const scrollContainer = (0,external_wp_dom_namespaceObject.getScrollContainer)(ref.current);
17782
 
17783
+ if (!scrollContainer) {
17784
+ return () => {};
17785
+ }
17786
 
17787
+ const prevRect = ref.current.getBoundingClientRect();
17788
+ return () => {
17789
+ const blockRect = ref.current.getBoundingClientRect();
17790
+ const diff = blockRect.top - prevRect.top;
17791
 
17792
+ if (diff) {
17793
+ scrollContainer.scrollTop += diff;
17794
+ }
17795
+ };
17796
+ }, [triggerAnimationOnChange, adjustScrolling]);
17797
+ (0,external_wp_element_namespaceObject.useLayoutEffect)(() => {
17798
+ if (triggeredAnimation) {
17799
+ endAnimation();
17800
+ }
17801
+ }, [triggeredAnimation]);
17802
+ (0,external_wp_element_namespaceObject.useLayoutEffect)(() => {
17803
+ if (!previous) {
17804
+ return;
17805
+ }
17806
 
17807
+ if (prefersReducedMotion) {
17808
+ // if the animation is disabled and the scroll needs to be adjusted,
17809
+ // just move directly to the final scroll position.
17810
+ preserveScrollPosition();
17811
+ return;
17812
+ }
17813
 
17814
+ ref.current.style.transform = '';
17815
+ const destination = getAbsolutePosition(ref.current);
17816
+ triggerAnimation();
17817
+ setTransform({
17818
+ x: Math.round(previous.left - destination.left),
17819
+ y: Math.round(previous.top - destination.top)
17820
+ });
17821
+ }, [triggerAnimationOnChange]); // Only called when either the x or y value changes.
17822
 
17823
+ function onFrameChange({
17824
+ x,
17825
+ y
17826
+ }) {
17827
+ if (!ref.current) {
17828
+ return;
17829
+ }
17830
 
17831
+ const isMoving = x === 0 && y === 0;
17832
+ ref.current.style.transformOrigin = isMoving ? '' : 'center';
17833
+ ref.current.style.transform = isMoving ? '' : `translate3d(${x}px,${y}px,0)`;
17834
+ ref.current.style.zIndex = !isSelected || isMoving ? '' : '1';
17835
+ preserveScrollPosition();
17836
+ } // Called for every frame computed by useSpring.
17837
 
17838
 
17839
+ function onFrame({
17840
+ x,
17841
+ y
17842
+ }) {
17843
+ x = Math.round(x);
17844
+ y = Math.round(y);
17845
 
17846
+ if (x !== onFrame.x || y !== onFrame.y) {
17847
+ onFrameChange({
17848
+ x,
17849
+ y
17850
+ });
17851
+ onFrame.x = x;
17852
+ onFrame.y = y;
17853
+ }
17854
+ }
17855
 
17856
+ onFrame.x = 0;
17857
+ onFrame.y = 0;
17858
+ (0,web_cjs/* useSpring */.q_)({
17859
+ from: {
17860
+ x: transform.x,
17861
+ y: transform.y
17862
+ },
17863
+ to: {
17864
+ x: 0,
17865
+ y: 0
17866
+ },
17867
+ reset: triggeredAnimation !== finishedAnimation,
17868
+ config: {
17869
+ mass: 5,
17870
+ tension: 2000,
17871
+ friction: 200
17872
+ },
17873
+ immediate: prefersReducedMotion,
17874
+ onFrame
17875
+ });
17876
+ return ref;
17877
+ }
17878
 
17879
+ /* harmony default export */ var use_moving_animation = (useMovingAnimation);
17880
  //# sourceMappingURL=index.js.map
17881
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/utils/dom.js
17882
+ const BLOCK_SELECTOR = '.block-editor-block-list__block';
17883
+ const APPENDER_SELECTOR = '.block-list-appender';
17884
+ /**
17885
+ * Returns true if two elements are contained within the same block.
17886
+ *
17887
+ * @param {Element} a First element.
17888
+ * @param {Element} b Second element.
17889
+ *
17890
+ * @return {boolean} Whether elements are in the same block.
17891
+ */
17892
+
17893
+ function isInSameBlock(a, b) {
17894
+ return a.closest(BLOCK_SELECTOR) === b.closest(BLOCK_SELECTOR);
17895
+ }
17896
+ /**
17897
+ * Returns true if an element is considered part of the block and not its inner
17898
+ * blocks or appender.
17899
+ *
17900
+ * @param {Element} blockElement Block container element.
17901
+ * @param {Element} element Element.
17902
+ *
17903
+ * @return {boolean} Whether an element is considered part of the block and not
17904
+ * its inner blocks or appender.
17905
+ */
17906
+
17907
+ function isInsideRootBlock(blockElement, element) {
17908
+ const parentBlock = element.closest([BLOCK_SELECTOR, APPENDER_SELECTOR].join(','));
17909
+ return parentBlock === blockElement;
17910
+ }
17911
+ /**
17912
+ * Finds the block client ID given any DOM node inside the block.
17913
+ *
17914
+ * @param {Node?} node DOM node.
17915
+ *
17916
+ * @return {string|undefined} Client ID or undefined if the node is not part of
17917
+ * a block.
17918
+ */
17919
+
17920
+ function getBlockClientId(node) {
17921
+ while (node && node.nodeType !== node.ELEMENT_NODE) {
17922
+ node = node.parentNode;
17923
+ }
17924
+
17925
+ if (!node) {
17926
+ return;
17927
+ }
17928
 
17929
+ const elementNode =
17930
+ /** @type {Element} */
17931
+ node;
17932
+ const blockNode = elementNode.closest(BLOCK_SELECTOR);
17933
 
17934
+ if (!blockNode) {
17935
+ return;
17936
+ }
17937
 
17938
+ return blockNode.id.slice('block-'.length);
17939
+ }
17940
+ //# sourceMappingURL=dom.js.map
17941
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-list/use-block-props/use-focus-first-element.js
17942
  /**
17943
  * External dependencies
17944
  */
17949
 
17950
 
17951
 
17952
+
17953
  /**
17954
  * Internal dependencies
17955
  */
17956
 
17957
 
17958
 
17959
+ /** @typedef {import('@wordpress/element').RefObject} RefObject */
17960
+
17961
  /**
17962
+ * Returns the initial position if the block needs to be focussed, `undefined`
17963
+ * otherwise. The initial position is either 0 (start) or -1 (end).
17964
  *
17965
+ * @param {string} clientId Block client ID.
17966
  *
17967
+ * @return {number} The initial position, either 0 (start) or -1 (end).
17968
  */
17969
 
17970
+ function useInitialPosition(clientId) {
17971
+ return (0,external_wp_data_namespaceObject.useSelect)(select => {
17972
+ const {
17973
+ getSelectedBlocksInitialCaretPosition,
17974
+ isMultiSelecting,
17975
+ isNavigationMode,
17976
+ isBlockSelected
17977
+ } = select(store);
 
17978
 
17979
+ if (!isBlockSelected(clientId)) {
17980
+ return;
17981
+ }
17982
 
17983
+ if (isMultiSelecting() || isNavigationMode()) {
17984
+ return;
17985
+ } // If there's no initial position, return 0 to focus the start.
17986
+
17987
+
17988
+ return getSelectedBlocksInitialCaretPosition();
17989
+ }, [clientId]);
17990
+ }
17991
  /**
17992
+ * Transitions focus to the block or inner tabbable when the block becomes
17993
+ * selected and an initial position is set.
17994
  *
17995
+ * @param {string} clientId Block client ID.
 
17996
  *
17997
+ * @return {RefObject} React ref with the block element.
17998
  */
17999
 
18000
 
18001
+ function useFocusFirstElement(clientId) {
18002
+ const ref = (0,external_wp_element_namespaceObject.useRef)();
18003
+ const initialPosition = useInitialPosition(clientId);
18004
+ (0,external_wp_element_namespaceObject.useEffect)(() => {
18005
+ if (initialPosition === undefined || initialPosition === null) {
18006
+ return;
18007
+ }
 
 
 
 
 
 
 
 
 
 
 
18008
 
18009
+ if (!ref.current) {
18010
+ return;
18011
+ }
 
 
 
18012
 
18013
+ const {
18014
+ ownerDocument
18015
+ } = ref.current; // Do not focus the block if it already contains the active element.
 
 
 
 
 
18016
 
18017
+ if (ref.current.contains(ownerDocument.activeElement)) {
18018
+ return;
18019
+ } // Find all tabbables within node.
 
 
 
 
 
 
18020
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18021
 
18022
+ const textInputs = external_wp_dom_namespaceObject.focus.tabbable.find(ref.current).filter(node => (0,external_wp_dom_namespaceObject.isTextField)(node)); // If reversed (e.g. merge via backspace), use the last in the set of
18023
+ // tabbables.
 
 
 
 
 
18024
 
18025
+ const isReverse = -1 === initialPosition;
18026
+ const target = (isReverse ? external_lodash_namespaceObject.last : external_lodash_namespaceObject.first)(textInputs) || ref.current;
 
18027
 
18028
+ if (!isInsideRootBlock(ref.current, target)) {
18029
+ ref.current.focus();
18030
+ return;
18031
+ }
 
 
 
18032
 
18033
+ (0,external_wp_dom_namespaceObject.placeCaretAtHorizontalEdge)(target, isReverse);
18034
+ }, [initialPosition]);
18035
+ return ref;
18036
  }
18037
+ //# sourceMappingURL=use-focus-first-element.js.map
18038
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-list/use-block-props/use-is-hovered.js
18039
  /**
18040
+ * WordPress dependencies
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18041
  */
18042
 
18043
 
18044
+ /**
18045
+ * Internal dependencies
18046
+ */
18047
+
18048
+
18049
+
18050
+ function listener(event) {
18051
+ if (event.defaultPrevented) {
18052
+ return;
18053
+ }
18054
+
18055
+ const action = event.type === 'mouseover' ? 'add' : 'remove';
18056
+ event.preventDefault();
18057
+ event.currentTarget.classList[action]('is-hovered');
18058
  }
18059
  /**
18060
+ * Adds `is-hovered` class when the block is hovered and in navigation or
18061
+ * outline mode.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18062
  */
18063
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18064
 
18065
+ function useIsHovered() {
18066
+ const isEnabled = (0,external_wp_data_namespaceObject.useSelect)(select => {
18067
+ const {
18068
+ isNavigationMode,
18069
+ getSettings
18070
+ } = select(store);
18071
+ return isNavigationMode() || getSettings().outlineMode;
18072
+ }, []);
18073
+ return (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
18074
+ if (isEnabled) {
18075
+ node.addEventListener('mouseout', listener);
18076
+ node.addEventListener('mouseover', listener);
18077
+ return () => {
18078
+ node.removeEventListener('mouseout', listener);
18079
+ node.removeEventListener('mouseover', listener); // Remove class in case it lingers.
18080
 
18081
+ node.classList.remove('is-hovered');
18082
+ };
18083
+ }
18084
+ }, [isEnabled]);
18085
+ }
18086
+ //# sourceMappingURL=use-is-hovered.js.map
18087
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-list/use-block-props/use-block-class-names.js
18088
  /**
18089
  * External dependencies
18090
  */
18100
  */
18101
 
18102
 
 
 
18103
  /**
18104
+ * Returns the class names used for the different states of the block.
 
18105
  *
18106
+ * @param {string} clientId The block client ID.
 
 
18107
  *
18108
+ * @return {string} The class names.
18109
  */
18110
 
18111
+ function useBlockClassNames(clientId) {
18112
+ return (0,external_wp_data_namespaceObject.useSelect)(select => {
18113
+ const {
18114
+ isBlockBeingDragged,
18115
+ isBlockHighlighted,
18116
+ isBlockSelected,
18117
+ isBlockMultiSelected,
18118
+ getBlockName,
18119
+ getSettings,
18120
+ hasSelectedInnerBlock,
18121
+ isTyping,
18122
+ __experimentalGetActiveBlockIdByBlockNames: getActiveBlockIdByBlockNames
18123
+ } = select(store);
18124
+ const {
18125
+ __experimentalSpotlightEntityBlocks: spotlightEntityBlocks,
18126
+ outlineMode
18127
+ } = getSettings();
18128
+ const isDragging = isBlockBeingDragged(clientId);
18129
+ const isSelected = isBlockSelected(clientId);
18130
+ const name = getBlockName(clientId);
18131
+ const checkDeep = true; // "ancestor" is the more appropriate label due to "deep" check
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18132
 
18133
+ const isAncestorOfSelectedBlock = hasSelectedInnerBlock(clientId, checkDeep);
18134
+ const activeEntityBlockId = getActiveBlockIdByBlockNames(spotlightEntityBlocks);
18135
+ return classnames_default()({
18136
+ 'is-selected': isSelected,
18137
+ 'is-highlighted': isBlockHighlighted(clientId),
18138
+ 'is-multi-selected': isBlockMultiSelected(clientId),
18139
+ 'is-reusable': (0,external_wp_blocks_namespaceObject.isReusableBlock)((0,external_wp_blocks_namespaceObject.getBlockType)(name)),
18140
+ 'is-dragging': isDragging,
18141
+ 'has-child-selected': isAncestorOfSelectedBlock,
18142
+ 'has-active-entity': activeEntityBlockId,
18143
+ // Determine if there is an active entity area to spotlight.
18144
+ 'is-active-entity': activeEntityBlockId === clientId,
18145
+ 'remove-outline': isSelected && outlineMode && isTyping()
18146
+ });
18147
+ }, [clientId]);
18148
+ }
18149
+ //# sourceMappingURL=use-block-class-names.js.map
18150
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-list/use-block-props/use-block-default-class-name.js
18151
+ /**
18152
+ * WordPress dependencies
18153
+ */
18154
 
 
 
 
 
 
18155
 
18156
+ /**
18157
+ * Internal dependencies
18158
+ */
 
 
18159
 
18160
 
18161
+ /**
18162
+ * Returns the default class name if the block is a light block and it supports
18163
+ * `className`.
18164
+ *
18165
+ * @param {string} clientId The block client ID.
18166
+ *
18167
+ * @return {string} The class name, e.g. `wp-block-paragraph`.
18168
+ */
18169
 
18170
+ function useBlockDefaultClassName(clientId) {
18171
+ return (0,external_wp_data_namespaceObject.useSelect)(select => {
18172
+ const name = select(store).getBlockName(clientId);
18173
+ const blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(name);
18174
+ const hasLightBlockWrapper = (blockType === null || blockType === void 0 ? void 0 : blockType.apiVersion) > 1 || (0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockType, 'lightBlockWrapper', false);
18175
 
18176
+ if (!hasLightBlockWrapper) {
18177
+ return;
18178
+ }
18179
 
18180
+ return (0,external_wp_blocks_namespaceObject.getBlockDefaultClassName)(name);
18181
+ }, [clientId]);
18182
+ }
18183
+ //# sourceMappingURL=use-block-default-class-name.js.map
18184
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-list/use-block-props/use-block-custom-class-name.js
18185
  /**
18186
  * WordPress dependencies
18187
  */
18188
 
 
 
 
 
 
 
 
 
 
 
18189
 
18190
  /**
18191
+ * Internal dependencies
18192
  */
18193
 
 
 
 
 
 
 
 
 
 
 
18194
 
18195
  /**
18196
+ * Returns the custom class name if the block is a light block.
18197
+ *
18198
+ * @param {string} clientId The block client ID.
18199
+ *
18200
+ * @return {string} The custom class name.
18201
  */
18202
 
18203
+ function useBlockCustomClassName(clientId) {
18204
+ // It's good for this to be a separate selector because it will be executed
18205
+ // on every attribute change, while the other selectors are not re-evaluated
18206
+ // as much.
18207
+ return (0,external_wp_data_namespaceObject.useSelect)(select => {
18208
+ const {
18209
+ getBlockName,
18210
+ getBlockAttributes
18211
+ } = select(store);
18212
+ const attributes = getBlockAttributes(clientId);
18213
 
18214
+ if (!(attributes !== null && attributes !== void 0 && attributes.className)) {
18215
+ return;
18216
+ }
18217
+
18218
+ const blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(getBlockName(clientId));
18219
+ const hasLightBlockWrapper = blockType.apiVersion > 1 || (0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockType, 'lightBlockWrapper', false);
18220
 
18221
+ if (!hasLightBlockWrapper) {
18222
+ return;
18223
+ }
18224
 
18225
+ return attributes.className;
18226
+ }, [clientId]);
18227
+ }
18228
+ //# sourceMappingURL=use-block-custom-class-name.js.map
18229
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-list/use-block-props/use-block-moving-mode-class-names.js
18230
  /**
18231
  * External dependencies
18232
  */
18236
  */
18237
 
18238
 
18239
+ /**
18240
+ * Internal dependencies
18241
+ */
18242
 
18243
 
18244
+ /**
18245
+ * Returns the class names used for block moving mode.
18246
+ *
18247
+ * @param {string} clientId The block client ID to insert above.
18248
+ *
18249
+ * @return {string} The class names.
18250
+ */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18251
 
18252
+ function useBlockMovingModeClassNames(clientId) {
18253
+ return (0,external_wp_data_namespaceObject.useSelect)(select => {
18254
+ const {
18255
+ hasBlockMovingClientId,
18256
+ canInsertBlockType,
18257
+ getBlockName,
18258
+ getBlockRootClientId,
18259
+ isBlockSelected
18260
+ } = select(store); // The classes are only relevant for the selected block. Avoid
18261
+ // re-rendering all blocks!
18262
 
18263
+ if (!isBlockSelected(clientId)) {
18264
+ return;
18265
+ }
18266
 
18267
+ const movingClientId = hasBlockMovingClientId();
18268
 
18269
+ if (!movingClientId) {
18270
+ return;
18271
+ }
18272
 
18273
+ return classnames_default()('is-block-moving-mode', {
18274
+ 'can-insert-moving-block': canInsertBlockType(getBlockName(movingClientId), getBlockRootClientId(clientId))
18275
+ });
18276
+ }, [clientId]);
 
 
 
 
 
18277
  }
18278
+ //# sourceMappingURL=use-block-moving-mode-class-names.js.map
18279
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-list/use-block-props/use-focus-handler.js
18280
  /**
18281
+ * WordPress dependencies
18282
  */
 
 
 
18283
 
 
18284
 
18285
+ /**
18286
+ * Internal dependencies
18287
+ */
18288
 
 
18289
 
 
18290
 
 
18291
  /**
18292
+ * Selects the block if it receives focus.
 
 
18293
  *
18294
+ * @param {string} clientId Block client ID.
18295
  */
18296
 
18297
+ function useFocusHandler(clientId) {
18298
+ const {
18299
+ isBlockSelected
18300
+ } = (0,external_wp_data_namespaceObject.useSelect)(store);
18301
+ const {
18302
+ selectBlock,
18303
+ selectionChange
18304
+ } = (0,external_wp_data_namespaceObject.useDispatch)(store);
18305
+ return (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
18306
+ /**
18307
+ * Marks the block as selected when focused and not already
18308
+ * selected. This specifically handles the case where block does not
18309
+ * set focus on its own (via `setFocus`), typically if there is no
18310
+ * focusable input in the block.
18311
+ *
18312
+ * @param {FocusEvent} event Focus event.
18313
+ */
18314
+ function onFocus(event) {
18315
+ // Check synchronously because a non-selected block might be
18316
+ // getting data through `useSelect` asynchronously.
18317
+ if (isBlockSelected(clientId)) {
18318
+ // Potentially change selection away from rich text.
18319
+ if (!event.target.isContentEditable) {
18320
+ selectionChange(clientId);
18321
+ }
18322
+
18323
+ return;
18324
+ } // If an inner block is focussed, that block is resposible for
18325
+ // setting the selected block.
18326
 
 
 
 
 
 
18327
 
18328
+ if (!isInsideRootBlock(node, event.target)) {
18329
+ return;
18330
+ }
18331
 
18332
+ selectBlock(clientId);
18333
+ }
18334
+
18335
+ node.addEventListener('focusin', onFocus);
18336
+ return () => {
18337
+ node.removeEventListener('focusin', onFocus);
18338
+ };
18339
+ }, [isBlockSelected, selectBlock]);
18340
  }
18341
+ //# sourceMappingURL=use-focus-handler.js.map
18342
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.js
18343
  /**
18344
+ * WordPress dependencies
 
 
 
 
18345
  */
18346
 
18347
 
 
 
 
 
 
 
 
 
18348
 
 
 
 
 
 
 
18349
 
18350
+ /**
18351
+ * Internal dependencies
18352
+ */
18353
 
 
 
 
 
 
 
18354
 
 
 
 
 
 
18355
  /**
18356
+ * Adds block behaviour:
18357
+ * - Removes the block on BACKSPACE.
18358
+ * - Inserts a default block on ENTER.
18359
+ * - Disables dragging of block contents.
 
18360
  *
18361
+ * @param {string} clientId Block client ID.
18362
  */
18363
 
18364
+ function useEventHandlers(clientId) {
18365
+ const isSelected = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).isBlockSelected(clientId), [clientId]);
18366
+ const {
18367
+ getBlockRootClientId,
18368
+ getBlockIndex
18369
+ } = (0,external_wp_data_namespaceObject.useSelect)(store);
18370
+ const {
18371
+ insertDefaultBlock,
18372
+ removeBlock
18373
+ } = (0,external_wp_data_namespaceObject.useDispatch)(store);
18374
+ return (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
18375
+ if (!isSelected) {
18376
+ return;
18377
+ }
18378
+ /**
18379
+ * Interprets keydown event intent to remove or insert after block if
18380
+ * key event occurs on wrapper node. This can occur when the block has
18381
+ * no text fields of its own, particularly after initial insertion, to
18382
+ * allow for easy deletion and continuous writing flow to add additional
18383
+ * content.
18384
+ *
18385
+ * @param {KeyboardEvent} event Keydown event.
18386
+ */
18387
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18388
 
18389
+ function onKeyDown(event) {
18390
+ const {
18391
+ keyCode,
18392
+ target
18393
+ } = event;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18394
 
18395
+ if (keyCode !== external_wp_keycodes_namespaceObject.ENTER && keyCode !== external_wp_keycodes_namespaceObject.BACKSPACE && keyCode !== external_wp_keycodes_namespaceObject.DELETE) {
18396
+ return;
18397
+ }
 
 
 
 
 
18398
 
18399
+ if (target !== node || (0,external_wp_dom_namespaceObject.isTextField)(target)) {
18400
+ return;
18401
+ }
18402
+
18403
+ event.preventDefault();
18404
+
18405
+ if (keyCode === external_wp_keycodes_namespaceObject.ENTER) {
18406
+ insertDefaultBlock({}, getBlockRootClientId(clientId), getBlockIndex(clientId) + 1);
18407
+ } else {
18408
+ removeBlock(clientId);
18409
+ }
18410
  }
18411
+ /**
18412
+ * Prevents default dragging behavior within a block. To do: we must
18413
+ * handle this in the future and clean up the drag target.
18414
+ *
18415
+ * @param {DragEvent} event Drag event.
18416
+ */
18417
 
18418
 
18419
+ function onDragStart(event) {
18420
+ event.preventDefault();
18421
+ }
18422
 
18423
+ node.addEventListener('keydown', onKeyDown);
18424
+ node.addEventListener('dragstart', onDragStart);
18425
+ return () => {
18426
+ node.removeEventListener('keydown', onKeyDown);
18427
+ node.removeEventListener('dragstart', onDragStart);
18428
+ };
18429
+ }, [clientId, isSelected, getBlockRootClientId, getBlockIndex, insertDefaultBlock, removeBlock]);
18430
  }
18431
+ //# sourceMappingURL=use-selected-block-event-handlers.js.map
18432
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-list/use-block-props/use-nav-mode-exit.js
18433
  /**
18434
  * WordPress dependencies
18435
  */
18436
 
18437
 
 
18438
  /**
18439
  * Internal dependencies
18440
  */
18441
 
18442
 
18443
  /**
18444
+ * Allows navigation mode to be exited by clicking in the selected block.
18445
  *
18446
+ * @param {string} clientId Block client ID.
 
 
18447
  */
18448
 
18449
+ function useNavModeExit(clientId) {
18450
  const {
18451
+ isNavigationMode,
18452
+ isBlockSelected
18453
+ } = (0,external_wp_data_namespaceObject.useSelect)(store);
18454
+ const {
18455
+ setNavigationMode,
18456
+ selectBlock
18457
+ } = (0,external_wp_data_namespaceObject.useDispatch)(store);
18458
+ return (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
18459
+ function onMouseDown(event) {
18460
+ // Don't select a block if it's already handled by a child
18461
+ // block.
18462
+ if (isNavigationMode() && !event.defaultPrevented) {
18463
+ // Prevent focus from moving to the block.
18464
+ event.preventDefault(); // When clicking on a selected block, exit navigation mode.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18465
 
18466
+ if (isBlockSelected(clientId)) {
18467
+ setNavigationMode(false);
18468
+ } else {
18469
+ selectBlock(clientId);
18470
+ }
18471
+ }
18472
+ }
18473
 
18474
+ node.addEventListener('mousedown', onMouseDown);
18475
+ return () => {
18476
+ node.addEventListener('mousedown', onMouseDown);
18477
+ };
18478
+ }, [clientId, isNavigationMode, isBlockSelected, setNavigationMode]);
18479
+ }
18480
+ //# sourceMappingURL=use-nav-mode-exit.js.map
18481
+ // EXTERNAL MODULE: ./node_modules/dom-scroll-into-view/lib/index.js
18482
+ var dom_scroll_into_view_lib = __webpack_require__(4979);
18483
+ var lib_default = /*#__PURE__*/__webpack_require__.n(dom_scroll_into_view_lib);
18484
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-list/use-block-props/use-scroll-into-view.js
18485
  /**
18486
  * External dependencies
18487
  */
18490
  * WordPress dependencies
18491
  */
18492
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18493
  /**
18494
  * WordPress dependencies
18495
  */
18502
  */
18503
 
18504
 
18505
+ function useScrollIntoView(clientId) {
18506
+ const ref = (0,external_wp_element_namespaceObject.useRef)();
18507
+ const isSelectionEnd = (0,external_wp_data_namespaceObject.useSelect)(select => {
18508
+ const {
18509
+ isBlockSelected,
18510
+ getBlockSelectionEnd
18511
+ } = select(store);
18512
+ return isBlockSelected(clientId) || getBlockSelectionEnd() === clientId;
18513
+ }, [clientId]); // Note that we can't use `useRefEffect` here, since an element change does
18514
+ // not mean we can scroll. `isSelectionEnd` should be the sole dependency,
18515
+ // while with `useRefEffect`, the element is a dependency as well.
18516
 
18517
+ (0,external_wp_element_namespaceObject.useEffect)(() => {
18518
+ if (!isSelectionEnd) {
18519
+ return;
18520
+ }
18521
 
18522
+ const extentNode = ref.current;
18523
 
18524
+ if (!extentNode) {
18525
+ return;
18526
+ } // If the block is focused, the browser will already have scrolled into
18527
+ // view if necessary.
 
 
 
 
18528
 
 
 
 
 
 
18529
 
18530
+ if (extentNode.contains(extentNode.ownerDocument.activeElement)) {
18531
+ return;
18532
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18533
 
18534
+ const scrollContainer = (0,external_wp_dom_namespaceObject.getScrollContainer)(extentNode) || extentNode.ownerDocument.defaultView; // If there's no scroll container, it follows that there's no scrollbar
18535
+ // and thus there's no need to try to scroll into view.
 
18536
 
18537
+ if (!scrollContainer) {
18538
+ return;
 
 
 
 
 
 
 
 
18539
  }
18540
 
18541
+ lib_default()(extentNode, scrollContainer, {
18542
+ onlyScrollIfNeeded: true
18543
+ });
18544
+ }, [isSelectionEnd]);
18545
+ return ref;
18546
  }
18547
+ //# sourceMappingURL=use-scroll-into-view.js.map
18548
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-list/use-block-props/use-multi-selection.js
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18549
  /**
18550
  * WordPress dependencies
18551
  */
18552
 
18553
 
 
 
 
18554
  /**
18555
  * Internal dependencies
18556
  */
18557
 
18558
 
18559
 
18560
+
18561
+ function toggleRichText(container, toggle) {
18562
+ Array.from(container.closest('.is-root-container').querySelectorAll('.rich-text')).forEach(node => {
18563
+ if (toggle) {
18564
+ node.setAttribute('contenteditable', true);
18565
+ } else {
18566
+ node.removeAttribute('contenteditable');
18567
+ }
18568
+ });
18569
+ }
18570
  /**
18571
+ * Sets a multi-selection based on the native selection across blocks.
 
18572
  *
18573
+ * @param {string} clientId Block client ID.
18574
  */
18575
 
 
18576
 
18577
+ function useMultiSelection(clientId) {
 
 
18578
  const {
18579
+ startMultiSelect,
18580
+ stopMultiSelect,
18581
+ multiSelect,
18582
+ selectBlock
18583
+ } = (0,external_wp_data_namespaceObject.useDispatch)(store);
18584
+ const {
18585
+ isSelectionEnabled,
18586
+ isBlockSelected,
18587
+ getBlockParents,
18588
+ getBlockSelectionStart,
18589
+ hasMultiSelection
18590
+ } = (0,external_wp_data_namespaceObject.useSelect)(store);
18591
+ return (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
18592
+ const {
18593
+ ownerDocument
18594
+ } = node;
18595
+ const {
18596
+ defaultView
18597
+ } = ownerDocument;
18598
+ let anchorElement;
18599
+ let rafId;
18600
 
18601
+ function onSelectionChange({
18602
+ isSelectionEnd
18603
+ }) {
18604
+ const selection = defaultView.getSelection(); // If no selection is found, end multi selection and enable all rich
18605
+ // text areas.
18606
 
18607
+ if (!selection.rangeCount || selection.isCollapsed) {
18608
+ toggleRichText(node, true);
18609
+ return;
 
18610
  }
18611
 
18612
+ const endClientId = getBlockClientId(selection.focusNode);
18613
+ const isSingularSelection = clientId === endClientId;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18614
 
18615
+ if (isSingularSelection) {
18616
+ selectBlock(clientId); // If the selection is complete (on mouse up), and no
18617
+ // multiple blocks have been selected, set focus back to the
18618
+ // anchor element. if the anchor element contains the
18619
+ // selection. Additionally, rich text elements that were
18620
+ // previously disabled can now be enabled again.
 
 
18621
 
18622
+ if (isSelectionEnd) {
18623
+ toggleRichText(node, true);
18624
 
18625
+ if (selection.rangeCount) {
18626
+ const {
18627
+ commonAncestorContainer
18628
+ } = selection.getRangeAt(0);
18629
 
18630
+ if (anchorElement.contains(commonAncestorContainer)) {
18631
+ anchorElement.focus();
18632
+ }
18633
+ }
18634
+ }
18635
+ } else {
18636
+ const startPath = [...getBlockParents(clientId), clientId];
18637
+ const endPath = [...getBlockParents(endClientId), endClientId];
18638
+ const depth = Math.min(startPath.length, endPath.length) - 1;
18639
+ multiSelect(startPath[depth], endPath[depth]);
18640
+ }
18641
+ }
18642
 
18643
+ function onSelectionEnd() {
18644
+ ownerDocument.removeEventListener('selectionchange', onSelectionChange); // Equivalent to attaching the listener once.
 
18645
 
18646
+ defaultView.removeEventListener('mouseup', onSelectionEnd); // The browser selection won't have updated yet at this point,
18647
+ // so wait until the next animation frame to get the browser
18648
+ // selection.
 
 
 
 
 
 
18649
 
18650
+ rafId = defaultView.requestAnimationFrame(() => {
18651
+ onSelectionChange({
18652
+ isSelectionEnd: true
18653
+ });
18654
+ stopMultiSelect();
18655
+ });
18656
+ }
18657
 
18658
+ function onMouseLeave({
18659
+ buttons
18660
+ }) {
18661
+ // The primary button must be pressed to initiate selection.
18662
+ // See https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
18663
+ if (buttons !== 1) {
18664
+ return;
18665
+ }
18666
 
18667
+ if (!isSelectionEnabled() || !isBlockSelected(clientId)) {
18668
+ return;
18669
+ }
18670
 
18671
+ anchorElement = ownerDocument.activeElement;
18672
+ startMultiSelect(); // `onSelectionStart` is called after `mousedown` and
18673
+ // `mouseleave` (from a block). The selection ends when
18674
+ // `mouseup` happens anywhere in the window.
18675
 
18676
+ ownerDocument.addEventListener('selectionchange', onSelectionChange);
18677
+ defaultView.addEventListener('mouseup', onSelectionEnd); // Removing the contenteditable attributes within the block
18678
+ // editor is essential for selection to work across editable
18679
+ // areas. The edible hosts are removed, allowing selection to be
18680
+ // extended outside the DOM element. `startMultiSelect` sets a
18681
+ // flag in the store so the rich text components are updated,
18682
+ // but the rerender may happen very slowly, especially in Safari
18683
+ // for the blocks that are asynchonously rendered. To ensure the
18684
+ // browser instantly removes the selection boundaries, we remove
18685
+ // the contenteditable attributes manually.
18686
 
18687
+ toggleRichText(node, false);
18688
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18689
 
18690
+ function onMouseDown(event) {
18691
+ // The main button.
18692
+ // https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button
18693
+ if (!isSelectionEnabled() || event.button !== 0) {
18694
+ return;
18695
+ }
18696
 
18697
+ if (event.shiftKey) {
18698
+ const blockSelectionStart = getBlockSelectionStart(); // Handle the case where we select a single block by
18699
+ // holding the `shiftKey` and don't mark this action
18700
+ // as multiselection.
18701
 
18702
+ if (blockSelectionStart && blockSelectionStart !== clientId) {
18703
+ toggleRichText(node, false);
18704
+ multiSelect(blockSelectionStart, clientId);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18705
  event.preventDefault();
 
18706
  }
18707
+ } else if (hasMultiSelection()) {
18708
+ // Allow user to escape out of a multi-selection to a
18709
+ // singular selection of a block via click. This is handled
18710
+ // here since focus handling excludes blocks when there is
18711
+ // multiselection, as focus can be incurred by starting a
18712
+ // multiselection (focus moved to first block's multi-
18713
+ // controls).
18714
+ selectBlock(clientId);
18715
+ }
18716
+ }
18717
 
18718
+ node.addEventListener('mousedown', onMouseDown);
18719
+ node.addEventListener('mouseleave', onMouseLeave);
18720
+ return () => {
18721
+ node.removeEventListener('mousedown', onMouseDown);
18722
+ node.removeEventListener('mouseleave', onMouseLeave);
18723
+ ownerDocument.removeEventListener('selectionchange', onSelectionChange);
18724
+ defaultView.removeEventListener('mouseup', onSelectionEnd);
18725
+ defaultView.cancelAnimationFrame(rafId);
18726
+ };
18727
+ }, [clientId, startMultiSelect, stopMultiSelect, multiSelect, selectBlock, isSelectionEnabled, isBlockSelected, getBlockParents]);
 
 
 
 
 
 
 
18728
  }
18729
+ //# sourceMappingURL=use-multi-selection.js.map
18730
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-list/use-block-props/use-intersection-observer.js
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18731
  /**
18732
  * WordPress dependencies
18733
  */
18738
  */
18739
 
18740
 
18741
+ function useIntersectionObserver() {
18742
+ const observer = (0,external_wp_element_namespaceObject.useContext)(IntersectionObserver);
18743
+ return (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
18744
+ if (observer) {
18745
+ observer.observe(node);
18746
+ return () => {
18747
+ observer.unobserve(node);
18748
+ };
18749
+ }
18750
+ }, [observer]);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18751
  }
18752
+ //# sourceMappingURL=use-intersection-observer.js.map
18753
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-list/use-block-props/index.js
18754
  /**
18755
  * External dependencies
18756
  */
18761
 
18762
 
18763
 
18764
+
18765
+
18766
+
18767
+
18768
  /**
18769
  * Internal dependencies
18770
  */
18771
 
18772
 
18773
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18774
 
 
 
 
 
 
 
 
 
 
 
 
18775
 
 
 
 
 
 
 
18776
 
 
 
 
18777
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18778
 
 
 
 
 
 
18779
 
 
 
 
 
18780
 
18781
 
 
 
 
18782
 
18783
 
18784
 
18785
 
 
 
 
18786
 
18787
 
18788
 
18789
  /**
18790
+ * If the block count exceeds the threshold, we disable the reordering animation
18791
+ * to avoid laginess.
18792
+ */
18793
+
18794
+ const BLOCK_ANIMATION_THRESHOLD = 200;
18795
+ /**
18796
+ * This hook is used to lightly mark an element as a block element. The element
18797
+ * should be the outermost element of a block. Call this hook and pass the
18798
+ * returned props to the element to mark as a block. If you define a ref for the
18799
+ * element, it is important to pass the ref to this hook, which the hook in turn
18800
+ * will pass to the component through the props it returns. Optionally, you can
18801
+ * also pass any other props through this hook, and they will be merged and
18802
+ * returned.
18803
  *
18804
+ * @param {Object} props Optional. Props to pass to the element. Must contain
18805
+ * the ref if one is defined.
18806
+ * @param {Object} options Options for internal use only.
18807
+ * @param {boolean} options.__unstableIsHtml
18808
+ *
18809
+ * @return {Object} Props to pass to the element to mark as a block.
18810
  */
18811
 
18812
+ function useBlockProps(props = {}, {
18813
+ __unstableIsHtml
18814
+ } = {}) {
 
 
 
 
18815
  const {
18816
  clientId,
18817
+ className,
18818
+ wrapperProps = {},
18819
+ isAligned
18820
+ } = (0,external_wp_element_namespaceObject.useContext)(BlockListBlockContext);
18821
+ const {
18822
+ index,
18823
+ mode,
18824
+ name,
18825
+ blockTitle,
18826
+ isPartOfSelection,
18827
+ adjustScrolling,
18828
+ enableAnimation,
18829
+ lightBlockWrapper
18830
  } = (0,external_wp_data_namespaceObject.useSelect)(select => {
18831
  const {
18832
+ getBlockRootClientId,
18833
+ getBlockIndex,
18834
+ getBlockMode,
18835
+ getBlockName,
18836
+ isTyping,
18837
+ getGlobalBlockCount,
18838
+ isBlockSelected,
18839
+ isBlockMultiSelected,
18840
+ isAncestorMultiSelected,
18841
+ isFirstMultiSelectedBlock
18842
  } = select(store);
18843
+ const isSelected = isBlockSelected(clientId);
18844
+ const isPartOfMultiSelection = isBlockMultiSelected(clientId) || isAncestorMultiSelected(clientId);
18845
+ const blockName = getBlockName(clientId);
18846
+ const rootClientId = getBlockRootClientId(clientId);
18847
+ const blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(blockName);
18848
  return {
18849
+ index: getBlockIndex(clientId, rootClientId),
18850
+ mode: getBlockMode(clientId),
18851
+ name: blockName,
18852
+ blockTitle: blockType === null || blockType === void 0 ? void 0 : blockType.title,
18853
+ isPartOfSelection: isSelected || isPartOfMultiSelection,
18854
+ adjustScrolling: isSelected || isFirstMultiSelectedBlock(clientId),
18855
+ enableAnimation: !isTyping() && getGlobalBlockCount() <= BLOCK_ANIMATION_THRESHOLD,
18856
+ lightBlockWrapper: (blockType === null || blockType === void 0 ? void 0 : blockType.apiVersion) > 1 || (0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockType, 'lightBlockWrapper', false)
18857
  };
18858
+ }, [clientId]); // translators: %s: Type of block (i.e. Text, Image etc)
 
 
 
 
 
 
18859
 
18860
+ const blockLabel = (0,external_wp_i18n_namespaceObject.sprintf)((0,external_wp_i18n_namespaceObject.__)('Block: %s'), blockTitle);
18861
+ const htmlSuffix = mode === 'html' && !__unstableIsHtml ? '-visual' : '';
18862
+ const mergedRefs = (0,external_wp_compose_namespaceObject.useMergeRefs)([props.ref, useFocusFirstElement(clientId), // Must happen after focus because we check for focus in the block.
18863
+ useScrollIntoView(clientId), useBlockRefProvider(clientId), useFocusHandler(clientId), useMultiSelection(clientId), useEventHandlers(clientId), useNavModeExit(clientId), useIsHovered(), useIntersectionObserver(), use_moving_animation({
18864
+ isSelected: isPartOfSelection,
18865
+ adjustScrolling,
18866
+ enableAnimation,
18867
+ triggerAnimationOnChange: index
18868
+ })]);
18869
+ const blockEditContext = useBlockEditContext(); // Ensures it warns only inside the `edit` implementation for the block.
18870
 
18871
+ if (!lightBlockWrapper && clientId === blockEditContext.clientId) {
18872
+ typeof process !== "undefined" && process.env && "production" !== "production" ? external_wp_warning_default()(`Block type "${name}" must support API version 2 or higher to work correctly with "useBlockProps" method.`) : void 0;
18873
+ }
18874
 
18875
+ return { ...wrapperProps,
18876
+ ...props,
18877
+ ref: mergedRefs,
18878
+ id: `block-${clientId}${htmlSuffix}`,
18879
+ tabIndex: 0,
18880
+ role: 'document',
18881
+ 'aria-label': blockLabel,
18882
+ 'data-block': clientId,
18883
+ 'data-type': name,
18884
+ 'data-title': blockTitle,
18885
+ className: classnames_default()( // The wp-block className is important for editor styles.
18886
+ classnames_default()('block-editor-block-list__block', {
18887
+ 'wp-block': !isAligned
18888
+ }), className, props.className, wrapperProps.className, useBlockClassNames(clientId), useBlockDefaultClassName(clientId), useBlockCustomClassName(clientId), useBlockMovingModeClassNames(clientId)),
18889
+ style: { ...wrapperProps.style,
18890
+ ...props.style
18891
+ }
18892
+ };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18893
  }
18894
+ /**
18895
+ * Call within a save function to get the props for the block wrapper.
18896
+ *
18897
+ * @param {Object} props Optional. Props to pass to the element.
18898
+ */
18899
 
18900
+ useBlockProps.save = external_wp_blocks_namespaceObject.__unstableGetBlockProps;
18901
  //# sourceMappingURL=index.js.map
18902
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-list/block.js
 
18903
 
18904
 
18905
  /**
18906
+ * External dependencies
18907
  */
18908
 
18909
 
18910
  /**
18911
+ * WordPress dependencies
18912
  */
18913
 
18914
 
 
 
 
18915
 
18916
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18917
 
18918
 
 
 
 
18919
 
18920
+ /**
18921
+ * Internal dependencies
18922
+ */
18923
 
 
 
 
 
 
 
18924
 
 
18925
 
 
 
 
 
 
 
 
 
 
 
 
 
18926
 
18927
 
 
 
 
18928
 
 
18929
 
18930
+
18931
+ const BlockListBlockContext = (0,external_wp_element_namespaceObject.createContext)();
18932
  /**
18933
+ * Merges wrapper props with special handling for classNames and styles.
18934
  *
18935
+ * @param {Object} propsA
18936
+ * @param {Object} propsB
18937
+ *
18938
+ * @return {Object} Merged props.
18939
  */
18940
 
18941
+ function mergeWrapperProps(propsA, propsB) {
18942
+ const newProps = { ...propsA,
18943
+ ...propsB
18944
+ };
18945
 
18946
+ if (propsA && propsB && propsA.className && propsB.className) {
18947
+ newProps.className = classnames_default()(propsA.className, propsB.className);
18948
+ }
 
 
 
 
 
18949
 
18950
+ if (propsA && propsB && propsA.style && propsB.style) {
18951
+ newProps.style = { ...propsA.style,
18952
+ ...propsB.style
18953
+ };
18954
+ }
18955
+
18956
+ return newProps;
18957
+ }
18958
+
18959
+ function Block({
18960
+ children,
18961
+ isHtml,
18962
+ ...props
18963
  }) {
18964
+ return (0,external_wp_element_namespaceObject.createElement)("div", useBlockProps(props, {
18965
+ __unstableIsHtml: isHtml
18966
+ }), children);
 
 
 
 
 
18967
  }
 
 
 
18968
 
18969
+ function BlockListBlock({
18970
+ mode,
18971
+ isLocked,
18972
+ clientId,
18973
+ isSelected,
18974
+ isSelectionEnabled,
18975
+ className,
18976
+ name,
18977
+ isValid,
18978
+ attributes,
18979
+ wrapperProps,
18980
+ setAttributes,
18981
+ onReplace,
18982
+ onInsertBlocksAfter,
18983
+ onMerge,
18984
+ toggleSelection
18985
+ }) {
18986
+ const {
18987
+ removeBlock
18988
+ } = (0,external_wp_data_namespaceObject.useDispatch)(store);
18989
+ const onRemove = (0,external_wp_element_namespaceObject.useCallback)(() => removeBlock(clientId), [clientId]); // We wrap the BlockEdit component in a div that hides it when editing in
18990
+ // HTML mode. This allows us to render all of the ancillary pieces
18991
+ // (InspectorControls, etc.) which are inside `BlockEdit` but not
18992
+ // `BlockHTML`, even in HTML mode.
18993
+
18994
+ let blockEdit = (0,external_wp_element_namespaceObject.createElement)(BlockEdit, {
18995
+ name: name,
18996
+ isSelected: isSelected,
18997
+ attributes: attributes,
18998
+ setAttributes: setAttributes,
18999
+ insertBlocksAfter: isLocked ? undefined : onInsertBlocksAfter,
19000
+ onReplace: isLocked ? undefined : onReplace,
19001
+ onRemove: isLocked ? undefined : onRemove,
19002
+ mergeBlocks: isLocked ? undefined : onMerge,
19003
+ clientId: clientId,
19004
+ isSelectionEnabled: isSelectionEnabled,
19005
+ toggleSelection: toggleSelection
19006
+ });
19007
+ const blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(name);
19008
+ const lightBlockWrapper = blockType.apiVersion > 1 || (0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockType, 'lightBlockWrapper', false); // Determine whether the block has props to apply to the wrapper.
19009
 
19010
+ if (blockType.getEditWrapperProps) {
19011
+ wrapperProps = mergeWrapperProps(wrapperProps, blockType.getEditWrapperProps(attributes));
19012
+ }
19013
 
19014
+ const isAligned = wrapperProps && !!wrapperProps['data-align']; // For aligned blocks, provide a wrapper element so the block can be
19015
+ // positioned relative to the block column.
19016
 
19017
+ if (isAligned) {
19018
+ blockEdit = (0,external_wp_element_namespaceObject.createElement)("div", {
19019
+ className: "wp-block",
19020
+ "data-align": wrapperProps['data-align']
19021
+ }, blockEdit);
19022
+ }
19023
 
19024
+ let block;
19025
 
19026
+ if (!isValid) {
19027
+ const saveContent = (0,external_wp_blocks_namespaceObject.getSaveContent)(blockType, attributes);
19028
+ block = (0,external_wp_element_namespaceObject.createElement)(Block, {
19029
+ className: "has-warning"
19030
+ }, (0,external_wp_element_namespaceObject.createElement)(block_invalid_warning, {
19031
+ clientId: clientId
19032
+ }), (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.RawHTML, null, (0,external_wp_dom_namespaceObject.safeHTML)(saveContent)));
19033
+ } else if (mode === 'html') {
19034
+ // Render blockEdit so the inspector controls don't disappear.
19035
+ // See #8969.
19036
+ block = (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("div", {
19037
+ style: {
19038
+ display: 'none'
19039
+ }
19040
+ }, blockEdit), (0,external_wp_element_namespaceObject.createElement)(Block, {
19041
+ isHtml: true
19042
+ }, (0,external_wp_element_namespaceObject.createElement)(block_html, {
19043
+ clientId: clientId
19044
+ })));
19045
+ } else if (lightBlockWrapper) {
19046
+ block = blockEdit;
19047
+ } else {
19048
+ block = (0,external_wp_element_namespaceObject.createElement)(Block, wrapperProps, blockEdit);
19049
+ }
19050
 
19051
+ const value = {
19052
+ clientId,
19053
+ className,
19054
+ wrapperProps: (0,external_lodash_namespaceObject.omit)(wrapperProps, ['data-align']),
19055
+ isAligned
19056
+ };
19057
+ const memoizedValue = (0,external_wp_element_namespaceObject.useMemo)(() => value, Object.values(value));
19058
+ return (0,external_wp_element_namespaceObject.createElement)(BlockListBlockContext.Provider, {
19059
+ value: memoizedValue
19060
+ }, (0,external_wp_element_namespaceObject.createElement)(block_crash_boundary, {
19061
+ fallback: (0,external_wp_element_namespaceObject.createElement)(Block, {
19062
+ className: "has-warning"
19063
+ }, (0,external_wp_element_namespaceObject.createElement)(block_crash_warning, null))
19064
+ }, block));
19065
+ }
19066
 
19067
+ const applyWithSelect = (0,external_wp_data_namespaceObject.withSelect)((select, {
19068
+ clientId,
19069
+ rootClientId
19070
  }) => {
19071
+ const {
19072
+ isBlockSelected,
19073
+ getBlockMode,
19074
+ isSelectionEnabled,
19075
+ getTemplateLock,
19076
+ __unstableGetBlockWithoutInnerBlocks
19077
+ } = select(store);
 
 
 
 
 
 
 
 
 
19078
 
19079
+ const block = __unstableGetBlockWithoutInnerBlocks(clientId);
19080
 
19081
+ const isSelected = isBlockSelected(clientId);
19082
+ const templateLock = getTemplateLock(rootClientId); // The fallback to `{}` is a temporary fix.
19083
+ // This function should never be called when a block is not present in
19084
+ // the state. It happens now because the order in withSelect rendering
19085
+ // is not correct.
 
 
 
 
 
 
 
 
19086
 
19087
+ const {
19088
+ name,
19089
+ attributes,
19090
+ isValid
19091
+ } = block || {}; // Do not add new properties here, use `useSelect` instead to avoid
19092
+ // leaking new props to the public API (editor.BlockListBlock filter).
 
 
19093
 
19094
+ return {
19095
+ mode: getBlockMode(clientId),
19096
+ isSelectionEnabled: isSelectionEnabled(),
19097
+ isLocked: !!templateLock,
19098
+ // Users of the editor.BlockListBlock filter used to be able to
19099
+ // access the block prop.
19100
+ // Ideally these blocks would rely on the clientId prop only.
19101
+ // This is kept for backward compatibility reasons.
19102
+ block,
19103
+ name,
19104
+ attributes,
19105
+ isValid,
19106
+ isSelected
19107
+ };
19108
  });
19109
+ const applyWithDispatch = (0,external_wp_data_namespaceObject.withDispatch)((dispatch, ownProps, {
19110
+ select
19111
+ }) => {
19112
+ const {
19113
+ updateBlockAttributes,
19114
+ insertBlocks,
19115
+ mergeBlocks,
19116
+ replaceBlocks,
19117
+ toggleSelection,
19118
+ __unstableMarkLastChangeAsPersistent
19119
+ } = dispatch(store); // Do not add new properties here, use `useDispatch` instead to avoid
19120
+ // leaking new props to the public API (editor.BlockListBlock filter).
19121
 
19122
+ return {
19123
+ setAttributes(newAttributes) {
19124
+ const {
19125
+ getMultiSelectedBlockClientIds
19126
+ } = select(store);
19127
+ const multiSelectedBlockClientIds = getMultiSelectedBlockClientIds();
19128
+ const {
19129
+ clientId
19130
+ } = ownProps;
19131
+ const clientIds = multiSelectedBlockClientIds.length ? multiSelectedBlockClientIds : [clientId];
19132
+ updateBlockAttributes(clientIds, newAttributes);
19133
+ },
19134
 
19135
+ onInsertBlocks(blocks, index) {
19136
+ const {
19137
+ rootClientId
19138
+ } = ownProps;
19139
+ insertBlocks(blocks, index, rootClientId);
19140
+ },
19141
+
19142
+ onInsertBlocksAfter(blocks) {
19143
+ const {
19144
+ clientId,
19145
+ rootClientId
19146
+ } = ownProps;
19147
+ const {
19148
+ getBlockIndex
19149
+ } = select(store);
19150
+ const index = getBlockIndex(clientId, rootClientId);
19151
+ insertBlocks(blocks, index + 1, rootClientId);
19152
+ },
19153
 
19154
+ onMerge(forward) {
19155
+ const {
19156
+ clientId
19157
+ } = ownProps;
19158
+ const {
19159
+ getPreviousBlockClientId,
19160
+ getNextBlockClientId
19161
+ } = select(store);
19162
 
19163
+ if (forward) {
19164
+ const nextBlockClientId = getNextBlockClientId(clientId);
 
19165
 
19166
+ if (nextBlockClientId) {
19167
+ mergeBlocks(clientId, nextBlockClientId);
19168
+ }
19169
+ } else {
19170
+ const previousBlockClientId = getPreviousBlockClientId(clientId);
19171
 
19172
+ if (previousBlockClientId) {
19173
+ mergeBlocks(previousBlockClientId, clientId);
19174
+ }
19175
+ }
19176
+ },
19177
 
19178
+ onReplace(blocks, indexToSelect, initialPosition) {
19179
+ if (blocks.length && !(0,external_wp_blocks_namespaceObject.isUnmodifiedDefaultBlock)(blocks[blocks.length - 1])) {
19180
+ __unstableMarkLastChangeAsPersistent();
19181
+ }
19182
 
19183
+ replaceBlocks([ownProps.clientId], blocks, indexToSelect, initialPosition);
19184
+ },
19185
 
19186
+ toggleSelection(selectionEnabled) {
19187
+ toggleSelection(selectionEnabled);
19188
+ }
19189
 
19190
+ };
19191
+ });
19192
+ /* harmony default export */ var block = ((0,external_wp_compose_namespaceObject.compose)(external_wp_compose_namespaceObject.pure, applyWithSelect, applyWithDispatch, // block is sometimes not mounted at the right time, causing it be undefined
19193
+ // see issue for more info
19194
+ // https://github.com/WordPress/gutenberg/issues/17013
19195
+ (0,external_wp_compose_namespaceObject.ifCondition)(({
19196
+ block
19197
+ }) => !!block), (0,external_wp_components_namespaceObject.withFilters)('editor.BlockListBlock'))(BlockListBlock));
19198
+ //# sourceMappingURL=block.js.map
19199
+ ;// CONCATENATED MODULE: external ["wp","htmlEntities"]
19200
+ var external_wp_htmlEntities_namespaceObject = window["wp"]["htmlEntities"];
19201
+ ;// CONCATENATED MODULE: ./packages/icons/build-module/library/plus.js
19202
 
19203
 
19204
  /**
19205
+ * WordPress dependencies
 
 
 
 
 
19206
  */
19207
 
19208
+ const plus = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
19209
+ xmlns: "http://www.w3.org/2000/svg",
19210
+ viewBox: "0 0 24 24"
19211
+ }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
19212
+ d: "M18 11.2h-5.2V6h-1.6v5.2H6v1.6h5.2V18h1.6v-5.2H18z"
19213
+ }));
19214
+ /* harmony default export */ var library_plus = (plus);
19215
+ //# sourceMappingURL=plus.js.map
19216
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/inserter/tips.js
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19217
 
19218
 
19219
  /**
19220
  * WordPress dependencies
19221
  */
19222
 
 
 
 
 
19223
 
19224
 
19225
+ const globalTips = [(0,external_wp_element_namespaceObject.createInterpolateElement)((0,external_wp_i18n_namespaceObject.__)('While writing, you can press <kbd>/</kbd> to quickly insert new blocks.'), {
19226
+ kbd: (0,external_wp_element_namespaceObject.createElement)("kbd", null)
19227
+ }), (0,external_wp_element_namespaceObject.createInterpolateElement)((0,external_wp_i18n_namespaceObject.__)('Indent a list by pressing <kbd>space</kbd> at the beginning of a line.'), {
19228
+ kbd: (0,external_wp_element_namespaceObject.createElement)("kbd", null)
19229
+ }), (0,external_wp_element_namespaceObject.createInterpolateElement)((0,external_wp_i18n_namespaceObject.__)('Outdent a list by pressing <kbd>backspace</kbd> at the beginning of a line.'), {
19230
+ kbd: (0,external_wp_element_namespaceObject.createElement)("kbd", null)
19231
+ }), (0,external_wp_i18n_namespaceObject.__)('Drag files into the editor to automatically insert media blocks.'), (0,external_wp_i18n_namespaceObject.__)("Change a block's type by pressing the block icon on the toolbar.")];
19232
 
19233
+ function Tips() {
19234
+ const [randomIndex] = (0,external_wp_element_namespaceObject.useState)( // Disable Reason: I'm not generating an HTML id.
19235
+ // eslint-disable-next-line no-restricted-syntax
19236
+ Math.floor(Math.random() * globalTips.length));
19237
+ return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Tip, null, globalTips[randomIndex]);
 
 
 
 
 
 
 
 
 
 
 
 
19238
  }
 
 
 
 
 
 
 
19239
 
19240
+ /* harmony default export */ var tips = (Tips);
19241
+ //# sourceMappingURL=tips.js.map
19242
+ ;// CONCATENATED MODULE: ./packages/icons/build-module/library/block-default.js
 
 
 
 
 
 
19243
 
19244
 
19245
  /**
19246
  * WordPress dependencies
19247
  */
19248
 
19249
+ const blockDefault = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
19250
  xmlns: "http://www.w3.org/2000/svg",
19251
  viewBox: "0 0 24 24"
19252
  }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
19253
+ d: "M19 8h-1V6h-5v2h-2V6H6v2H5c-1.1 0-2 .9-2 2v8c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2v-8c0-1.1-.9-2-2-2zm.5 10c0 .3-.2.5-.5.5H5c-.3 0-.5-.2-.5-.5v-8c0-.3.2-.5.5-.5h14c.3 0 .5.2.5.5v8z"
19254
  }));
19255
+ /* harmony default export */ var block_default = (blockDefault);
19256
+ //# sourceMappingURL=block-default.js.map
19257
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-icon/index.js
19258
+
19259
+
 
 
19260
  /**
19261
  * External dependencies
19262
  */
19267
 
19268
 
19269
 
19270
+ function BlockIcon({
19271
+ icon,
19272
+ showColors = false,
19273
+ className
19274
+ }) {
19275
+ var _icon;
19276
+
19277
+ if (((_icon = icon) === null || _icon === void 0 ? void 0 : _icon.src) === 'block-default') {
19278
+ icon = {
19279
+ src: block_default
19280
+ };
19281
+ }
19282
+
19283
+ const renderedIcon = (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Icon, {
19284
+ icon: icon && icon.src ? icon.src : icon
19285
+ });
19286
+ const style = showColors ? {
19287
+ backgroundColor: icon && icon.background,
19288
+ color: icon && icon.foreground
19289
+ } : {};
19290
+ return (0,external_wp_element_namespaceObject.createElement)("span", {
19291
+ style: style,
19292
+ className: classnames_default()('block-editor-block-icon', className, {
19293
+ 'has-colors': showColors
19294
+ })
19295
+ }, renderedIcon);
19296
+ }
19297
+ //# sourceMappingURL=index.js.map
19298
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-card/index.js
19299
+
19300
 
19301
  /**
19302
+ * WordPress dependencies
 
 
 
19303
  */
19304
 
 
 
 
 
 
 
 
 
19305
  /**
19306
+ * Internal dependencies
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19307
  */
19308
 
19309
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19310
 
19311
+ function BlockCard({
19312
+ title,
19313
+ icon,
19314
+ description,
19315
+ blockType
19316
+ }) {
19317
+ if (blockType) {
19318
+ external_wp_deprecated_default()('`blockType` property in `BlockCard component`', {
19319
+ since: '5.7',
19320
+ alternative: '`title, icon and description` properties'
19321
  });
19322
+ ({
19323
+ title,
19324
+ icon,
19325
+ description
19326
+ } = blockType);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19327
  }
19328
 
19329
+ return (0,external_wp_element_namespaceObject.createElement)("div", {
19330
+ className: "block-editor-block-card"
19331
+ }, (0,external_wp_element_namespaceObject.createElement)(BlockIcon, {
19332
+ icon: icon,
19333
+ showColors: true
19334
+ }), (0,external_wp_element_namespaceObject.createElement)("div", {
19335
+ className: "block-editor-block-card__content"
19336
+ }, (0,external_wp_element_namespaceObject.createElement)("h2", {
19337
+ className: "block-editor-block-card__title"
19338
+ }, title), (0,external_wp_element_namespaceObject.createElement)("span", {
19339
+ className: "block-editor-block-card__description"
19340
+ }, description)));
 
 
 
 
 
 
 
 
 
19341
  }
19342
 
19343
+ /* harmony default export */ var block_card = (BlockCard);
19344
  //# sourceMappingURL=index.js.map
19345
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/provider/with-registry-provider.js
 
 
19346
 
 
 
 
19347
 
19348
 
19349
  /**
19351
  */
19352
 
19353
 
19354
+
19355
  /**
19356
  * Internal dependencies
19357
  */
19358
 
19359
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19360
 
19361
+ const withRegistryProvider = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(WrappedComponent => {
19362
+ return (0,external_wp_data_namespaceObject.withRegistry)(({
19363
+ useSubRegistry = true,
19364
+ registry,
19365
+ ...props
19366
+ }) => {
19367
+ if (!useSubRegistry) {
19368
+ return (0,external_wp_element_namespaceObject.createElement)(WrappedComponent, _extends({
19369
+ registry: registry
19370
+ }, props));
19371
+ }
19372
 
19373
+ const [subRegistry, setSubRegistry] = (0,external_wp_element_namespaceObject.useState)(null);
19374
+ (0,external_wp_element_namespaceObject.useEffect)(() => {
19375
+ const newRegistry = (0,external_wp_data_namespaceObject.createRegistry)({}, registry);
19376
+ newRegistry.registerStore(STORE_NAME, storeConfig);
19377
+ setSubRegistry(newRegistry);
19378
+ }, [registry]);
 
 
 
19379
 
19380
+ if (!subRegistry) {
19381
+ return null;
19382
+ }
19383
 
19384
+ return (0,external_wp_element_namespaceObject.createElement)(external_wp_data_namespaceObject.RegistryProvider, {
19385
+ value: subRegistry
19386
+ }, (0,external_wp_element_namespaceObject.createElement)(WrappedComponent, _extends({
19387
+ registry: subRegistry
19388
+ }, props)));
19389
+ });
19390
+ }, 'withRegistryProvider');
19391
+ /* harmony default export */ var with_registry_provider = (withRegistryProvider);
19392
+ //# sourceMappingURL=with-registry-provider.js.map
19393
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/provider/use-block-sync.js
19394
  /**
19395
+ * External dependencies
19396
  */
19397
 
 
 
 
 
 
 
 
 
 
 
 
19398
  /**
19399
  * WordPress dependencies
19400
  */
19401
 
19402
+
 
 
 
 
 
 
 
 
19403
 
19404
 
19405
  /**
19406
+ * Internal dependencies
19407
  */
19408
 
19409
+
 
 
 
 
 
 
 
 
19410
  /**
19411
+ * A function to call when the block value has been updated in the block-editor
19412
+ * store.
19413
+ *
19414
+ * @callback onBlockUpdate
19415
+ * @param {Object[]} blocks The updated blocks.
19416
+ * @param {Object} options The updated block options, such as selectionStart
19417
+ * and selectionEnd.
19418
  */
19419
 
19420
  /**
19421
+ * useBlockSync is a side effect which handles bidirectional sync between the
19422
+ * block-editor store and a controlling data source which provides blocks. This
19423
+ * is most commonly used by the BlockEditorProvider to synchronize the contents
19424
+ * of the block-editor store with the root entity, like a post.
19425
  *
19426
+ * Another example would be the template part block, which provides blocks from
19427
+ * a separate entity data source than a root entity. This hook syncs edits to
19428
+ * the template part in the block editor back to the entity and vice-versa.
 
 
 
 
 
 
 
19429
  *
19430
+ * Here are some of its basic functions:
19431
+ * - Initalizes the block-editor store for the given clientID to the blocks
19432
+ * given via props.
19433
+ * - Adds incoming changes (like undo) to the block-editor store.
19434
+ * - Adds outgoing changes (like editing content) to the controlling entity,
19435
+ * determining if a change should be considered persistent or not.
19436
+ * - Handles edge cases and race conditions which occur in those operations.
19437
+ * - Ignores changes which happen to other entities (like nested inner block
19438
+ * controllers.
19439
+ * - Passes selection state from the block-editor store to the controlling entity.
19440
+ *
19441
+ * @param {Object} props Props for the block sync hook
19442
+ * @param {string} props.clientId The client ID of the inner block controller.
19443
+ * If none is passed, then it is assumed to be a
19444
+ * root controller rather than an inner block
19445
+ * controller.
19446
+ * @param {Object[]} props.value The control value for the blocks. This value
19447
+ * is used to initalize the block-editor store
19448
+ * and for resetting the blocks to incoming
19449
+ * changes like undo.
19450
+ * @param {Object} props.selection The selection state responsible to restore the selection on undo/redo.
19451
+ * @param {onBlockUpdate} props.onChange Function to call when a persistent
19452
+ * change has been made in the block-editor blocks
19453
+ * for the given clientId. For example, after
19454
+ * this function is called, an entity is marked
19455
+ * dirty because it has changes to save.
19456
+ * @param {onBlockUpdate} props.onInput Function to call when a non-persistent
19457
+ * change has been made in the block-editor blocks
19458
+ * for the given clientId. When this is called,
19459
+ * controlling sources do not become dirty.
19460
  */
19461
 
19462
+ function useBlockSync({
19463
+ clientId = null,
19464
+ value: controlledBlocks,
19465
+ selection: controlledSelection,
19466
+ onChange = external_lodash_namespaceObject.noop,
19467
+ onInput = external_lodash_namespaceObject.noop
19468
+ }) {
19469
+ const registry = (0,external_wp_data_namespaceObject.useRegistry)();
19470
+ const {
19471
+ resetBlocks,
19472
+ resetSelection,
19473
+ replaceInnerBlocks,
19474
+ setHasControlledInnerBlocks,
19475
+ __unstableMarkNextChangeAsNotPersistent
19476
+ } = registry.dispatch(store);
19477
+ const {
19478
+ getBlockName,
19479
+ getBlocks
19480
+ } = registry.select(store);
19481
+ const pendingChanges = (0,external_wp_element_namespaceObject.useRef)({
19482
+ incoming: null,
19483
+ outgoing: []
19484
+ });
19485
+ const subscribed = (0,external_wp_element_namespaceObject.useRef)(false);
19486
 
19487
+ const setControlledBlocks = () => {
19488
+ if (!controlledBlocks) {
19489
+ return;
19490
+ } // We don't need to persist this change because we only replace
19491
+ // controlled inner blocks when the change was caused by an entity,
19492
+ // and so it would already be persisted.
19493
 
 
 
19494
 
19495
+ __unstableMarkNextChangeAsNotPersistent();
 
19496
 
19497
+ if (clientId) {
19498
+ setHasControlledInnerBlocks(clientId, true);
 
19499
 
19500
+ __unstableMarkNextChangeAsNotPersistent();
 
 
 
19501
 
19502
+ const storeBlocks = controlledBlocks.map(block => (0,external_wp_blocks_namespaceObject.cloneBlock)(block));
 
 
19503
 
19504
+ if (subscribed.current) {
19505
+ pendingChanges.current.incoming = storeBlocks;
19506
+ }
 
19507
 
19508
+ replaceInnerBlocks(clientId, storeBlocks);
19509
+ } else {
19510
+ if (subscribed.current) {
19511
+ pendingChanges.current.incoming = controlledBlocks;
19512
+ }
19513
 
19514
+ resetBlocks(controlledBlocks);
 
 
19515
  }
19516
+ }; // Add a subscription to the block-editor registry to detect when changes
19517
+ // have been made. This lets us inform the data source of changes. This
19518
+ // is an effect so that the subscriber can run synchronously without
19519
+ // waiting for React renders for changes.
19520
 
 
 
 
19521
 
19522
+ const onInputRef = (0,external_wp_element_namespaceObject.useRef)(onInput);
19523
+ const onChangeRef = (0,external_wp_element_namespaceObject.useRef)(onChange);
19524
+ (0,external_wp_element_namespaceObject.useEffect)(() => {
19525
+ onInputRef.current = onInput;
19526
+ onChangeRef.current = onChange;
19527
+ }, [onInput, onChange]); // Determine if blocks need to be reset when they change.
19528
 
19529
+ (0,external_wp_element_namespaceObject.useEffect)(() => {
19530
+ if (pendingChanges.current.outgoing.includes(controlledBlocks)) {
19531
+ // Skip block reset if the value matches expected outbound sync
19532
+ // triggered by this component by a preceding change detection.
19533
+ // Only skip if the value matches expectation, since a reset should
19534
+ // still occur if the value is modified (not equal by reference),
19535
+ // to allow that the consumer may apply modifications to reflect
19536
+ // back on the editor.
19537
+ if ((0,external_lodash_namespaceObject.last)(pendingChanges.current.outgoing) === controlledBlocks) {
19538
+ pendingChanges.current.outgoing = [];
19539
+ }
19540
+ } else if (getBlocks(clientId) !== controlledBlocks) {
19541
+ // Reset changing value in all other cases than the sync described
19542
+ // above. Since this can be reached in an update following an out-
19543
+ // bound sync, unset the outbound value to avoid considering it in
19544
+ // subsequent renders.
19545
+ pendingChanges.current.outgoing = [];
19546
+ setControlledBlocks();
19547
 
19548
+ if (controlledSelection) {
19549
+ resetSelection(controlledSelection.selectionStart, controlledSelection.selectionEnd, controlledSelection.initialPosition);
19550
+ }
19551
  }
19552
+ }, [controlledBlocks, clientId]);
19553
+ (0,external_wp_element_namespaceObject.useEffect)(() => {
19554
+ const {
19555
+ getSelectionStart,
19556
+ getSelectionEnd,
19557
+ getSelectedBlocksInitialCaretPosition,
19558
+ isLastBlockChangePersistent,
19559
+ __unstableIsLastBlockChangeIgnored
19560
+ } = registry.select(store);
19561
+ let blocks = getBlocks(clientId);
19562
+ let isPersistent = isLastBlockChangePersistent();
19563
+ let previousAreBlocksDifferent = false;
19564
+ subscribed.current = true;
19565
+ const unsubscribe = registry.subscribe(() => {
19566
+ // Sometimes, when changing block lists, lingering subscriptions
19567
+ // might trigger before they are cleaned up. If the block for which
19568
+ // the subscription runs is no longer in the store, this would clear
19569
+ // its parent entity's block list. To avoid this, we bail out if
19570
+ // the subscription is triggering for a block (`clientId !== null`)
19571
+ // and its block name can't be found because it's not on the list.
19572
+ // (`getBlockName( clientId ) === null`).
19573
+ if (clientId !== null && getBlockName(clientId) === null) return;
19574
+ const newIsPersistent = isLastBlockChangePersistent();
19575
+ const newBlocks = getBlocks(clientId);
19576
+ const areBlocksDifferent = newBlocks !== blocks;
19577
+ blocks = newBlocks;
19578
 
19579
+ if (areBlocksDifferent && (pendingChanges.current.incoming || __unstableIsLastBlockChangeIgnored())) {
19580
+ pendingChanges.current.incoming = null;
19581
+ isPersistent = newIsPersistent;
19582
+ return;
19583
+ } // Since we often dispatch an action to mark the previous action as
19584
+ // persistent, we need to make sure that the blocks changed on the
19585
+ // previous action before committing the change.
19586
 
 
 
 
 
19587
 
19588
+ const didPersistenceChange = previousAreBlocksDifferent && !areBlocksDifferent && newIsPersistent && !isPersistent;
 
 
 
19589
 
19590
+ if (areBlocksDifferent || didPersistenceChange) {
19591
+ isPersistent = newIsPersistent; // We know that onChange/onInput will update controlledBlocks.
19592
+ // We need to be aware that it was caused by an outgoing change
19593
+ // so that we do not treat it as an incoming change later on,
19594
+ // which would cause a block reset.
19595
 
19596
+ pendingChanges.current.outgoing.push(blocks); // Inform the controlling entity that changes have been made to
19597
+ // the block-editor store they should be aware about.
 
19598
 
19599
+ const updateParent = isPersistent ? onChangeRef.current : onInputRef.current;
19600
+ updateParent(blocks, {
19601
+ selection: {
19602
+ selectionStart: getSelectionStart(),
19603
+ selectionEnd: getSelectionEnd(),
19604
+ initialPosition: getSelectedBlocksInitialCaretPosition()
19605
+ }
19606
+ });
19607
+ }
19608
 
19609
+ previousAreBlocksDifferent = areBlocksDifferent;
19610
+ });
19611
+ return () => unsubscribe();
19612
+ }, [registry, clientId]);
 
19613
  }
19614
+ //# sourceMappingURL=use-block-sync.js.map
19615
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/provider/index.js
19616
+
19617
+
19618
  /**
19619
+ * WordPress dependencies
 
 
 
 
 
 
 
 
 
19620
  */
19621
 
 
 
19622
 
19623
+ /**
19624
+ * Internal dependencies
19625
+ */
19626
+
19627
 
 
 
 
19628
 
 
 
 
 
19629
 
 
 
 
 
 
 
 
19630
 
19631
+ /** @typedef {import('@wordpress/data').WPDataRegistry} WPDataRegistry */
19632
 
19633
+ function BlockEditorProvider(props) {
19634
+ const {
19635
+ children,
19636
+ settings
19637
+ } = props;
19638
+ const {
19639
+ updateSettings
19640
+ } = (0,external_wp_data_namespaceObject.useDispatch)(store);
19641
+ (0,external_wp_element_namespaceObject.useEffect)(() => {
19642
+ updateSettings(settings);
19643
+ }, [settings]); // Syncs the entity provider with changes in the block-editor store.
19644
 
19645
+ useBlockSync(props);
19646
+ return (0,external_wp_element_namespaceObject.createElement)(BlockRefsProvider, null, children);
19647
+ }
19648
+
19649
+ /* harmony default export */ var provider = (with_registry_provider(BlockEditorProvider));
19650
+ //# sourceMappingURL=index.js.map
19651
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-preview/live.js
19652
 
19653
 
19654
  /**
19655
  * WordPress dependencies
19656
  */
19657
 
 
 
 
 
 
 
19658
  /**
19659
  * Internal dependencies
19660
  */
19661
 
19662
 
19663
+ function LiveBlockPreview({
19664
+ onClick
19665
+ }) {
19666
+ return (0,external_wp_element_namespaceObject.createElement)("div", {
19667
+ tabIndex: 0,
19668
+ role: "button",
19669
+ onClick: onClick,
19670
+ onKeyPress: onClick
19671
+ }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Disabled, null, (0,external_wp_element_namespaceObject.createElement)(BlockList, null)));
19672
+ }
19673
+ //# sourceMappingURL=live.js.map
19674
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-selection-clearer/index.js
19675
 
19676
 
19677
 
19678
+ /**
19679
+ * WordPress dependencies
19680
+ */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19681
 
 
 
 
 
 
19682
 
19683
+ /**
19684
+ * Internal dependencies
19685
+ */
 
 
19686
 
 
 
19687
 
19688
+ /**
19689
+ * Pass the returned ref callback to an element that should clear block
19690
+ * selection. Selection will only be cleared if the element is clicked directly,
19691
+ * not if a child element is clicked.
19692
+ *
19693
+ * @return {import('react').RefCallback} Ref callback.
19694
+ */
19695
 
19696
+ function useBlockSelectionClearer() {
 
 
 
 
 
 
 
19697
  const {
19698
+ hasSelectedBlock,
19699
+ hasMultiSelection
19700
+ } = (0,external_wp_data_namespaceObject.useSelect)(store);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19701
  const {
19702
+ clearSelectedBlock
 
19703
  } = (0,external_wp_data_namespaceObject.useDispatch)(store);
19704
+ return (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
19705
+ function onMouseDown(event) {
19706
+ if (!hasSelectedBlock() && !hasMultiSelection()) {
19707
+ return;
19708
+ } // Only handle clicks on the element, not the children.
19709
 
 
 
19710
 
19711
+ if (event.target !== node) {
19712
+ return;
19713
+ }
19714
+
19715
+ clearSelectedBlock();
19716
  }
 
19717
 
19718
+ node.addEventListener('mousedown', onMouseDown);
19719
+ return () => {
19720
+ node.removeEventListener('mousedown', onMouseDown);
19721
+ };
19722
+ }, [hasSelectedBlock, hasMultiSelection, clearSelectedBlock]);
19723
+ }
19724
+ function BlockSelectionClearer(props) {
19725
+ return (0,external_wp_element_namespaceObject.createElement)("div", _extends({
19726
+ ref: useBlockSelectionClearer()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19727
  }, props));
19728
+ }
19729
+ //# sourceMappingURL=index.js.map
19730
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/writing-flow/use-multi-selection.js
19731
  /**
19732
+ * External dependencies
19733
  */
19734
 
 
 
 
 
 
 
 
 
 
19735
  /**
19736
  * WordPress dependencies
19737
  */
19738
 
 
 
 
 
 
 
 
 
 
 
19739
 
 
 
 
19740
 
19741
  /**
19742
+ * Internal dependencies
19743
  */
19744
 
19745
 
19746
 
19747
 
19748
+ function use_multi_selection_toggleRichText(container, toggle) {
19749
+ Array.from(container.querySelectorAll('.rich-text')).forEach(node => {
19750
+ if (toggle) {
19751
+ node.setAttribute('contenteditable', true);
19752
+ } else {
19753
+ node.removeAttribute('contenteditable');
19754
+ }
19755
+ });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19756
  }
19757
  /**
19758
+ * Returns for the deepest node at the start or end of a container node. Ignores
19759
+ * any text nodes that only contain HTML formatting whitespace.
19760
+ *
19761
+ * @param {Element} node Container to search.
19762
+ * @param {string} type 'start' or 'end'.
19763
  */
19764
 
19765
 
19766
+ function getDeepestNode(node, type) {
19767
+ const child = type === 'start' ? 'firstChild' : 'lastChild';
19768
+ const sibling = type === 'start' ? 'nextSibling' : 'previousSibling';
 
 
 
19769
 
19770
+ while (node[child]) {
19771
+ node = node[child];
 
19772
 
19773
+ while (node.nodeType === node.TEXT_NODE && /^[ \t\n]*$/.test(node.data) && node[sibling]) {
19774
+ node = node[sibling];
19775
+ }
19776
+ }
19777
 
19778
+ return node;
19779
+ }
19780
 
19781
+ function selector(select) {
19782
+ const {
19783
+ isMultiSelecting,
19784
+ getMultiSelectedBlockClientIds,
19785
+ hasMultiSelection,
19786
+ getSelectedBlockClientId
19787
+ } = select(store);
19788
+ return {
19789
+ isMultiSelecting: isMultiSelecting(),
19790
+ multiSelectedBlockClientIds: getMultiSelectedBlockClientIds(),
19791
+ hasMultiSelection: hasMultiSelection(),
19792
+ selectedBlockClientId: getSelectedBlockClientId()
19793
+ };
 
 
 
 
 
 
 
 
 
 
 
 
19794
  }
 
 
19795
 
19796
+ function use_multi_selection_useMultiSelection() {
19797
+ const {
19798
+ isMultiSelecting,
19799
+ multiSelectedBlockClientIds,
19800
+ hasMultiSelection,
19801
+ selectedBlockClientId
19802
+ } = (0,external_wp_data_namespaceObject.useSelect)(selector, []);
19803
+ const selectedRef = useBlockRef(selectedBlockClientId); // These must be in the right DOM order.
19804
 
19805
+ const startRef = useBlockRef((0,external_lodash_namespaceObject.first)(multiSelectedBlockClientIds));
19806
+ const endRef = useBlockRef((0,external_lodash_namespaceObject.last)(multiSelectedBlockClientIds));
19807
+ /**
19808
+ * When the component updates, and there is multi selection, we need to
19809
+ * select the entire block contents.
19810
+ */
19811
 
19812
+ return (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
19813
+ const {
19814
+ ownerDocument
19815
+ } = node;
19816
+ const {
19817
+ defaultView
19818
+ } = ownerDocument;
19819
 
19820
+ if (!hasMultiSelection || isMultiSelecting) {
19821
+ if (!selectedBlockClientId || isMultiSelecting) {
19822
+ return;
19823
+ }
19824
 
19825
+ const selection = defaultView.getSelection();
 
 
19826
 
19827
+ if (selection.rangeCount && !selection.isCollapsed) {
19828
+ const blockNode = selectedRef.current;
19829
+ const {
19830
+ startContainer,
19831
+ endContainer
19832
+ } = selection.getRangeAt(0);
19833
 
19834
+ if (!!blockNode && (!blockNode.contains(startContainer) || !blockNode.contains(endContainer))) {
19835
+ selection.removeAllRanges();
19836
+ }
19837
+ }
19838
 
19839
+ return;
19840
+ }
 
19841
 
19842
+ const {
19843
+ length
19844
+ } = multiSelectedBlockClientIds;
19845
 
19846
+ if (length < 2) {
19847
+ return;
19848
+ } // For some browsers, like Safari, it is important that focus happens
19849
+ // BEFORE selection.
19850
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19851
 
19852
+ node.focus();
19853
+ const selection = defaultView.getSelection();
19854
+ const range = ownerDocument.createRange(); // These must be in the right DOM order.
19855
+ // The most stable way to select the whole block contents is to start
19856
+ // and end at the deepest points.
19857
 
19858
+ const startNode = getDeepestNode(startRef.current, 'start');
19859
+ const endNode = getDeepestNode(endRef.current, 'end'); // While rich text will be disabled with a delay when there is a multi
19860
+ // selection, we must do it immediately because it's not possible to set
19861
+ // selection across editable hosts.
19862
 
19863
+ use_multi_selection_toggleRichText(node, false);
19864
+ range.setStartBefore(startNode);
19865
+ range.setEndAfter(endNode);
19866
+ selection.removeAllRanges();
19867
+ selection.addRange(range);
19868
+ }, [hasMultiSelection, isMultiSelecting, multiSelectedBlockClientIds, selectedBlockClientId]);
 
 
 
 
 
 
 
 
 
 
 
 
 
19869
  }
19870
+ //# sourceMappingURL=use-multi-selection.js.map
19871
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/writing-flow/use-tab-nav.js
 
 
19872
 
19873
 
19874
  /**
19879
 
19880
 
19881
 
 
19882
  /**
19883
  * Internal dependencies
19884
  */
19885
 
19886
 
19887
 
19888
+ function isFormElement(element) {
19889
+ const {
19890
+ tagName
19891
+ } = element;
19892
+ return tagName === 'INPUT' || tagName === 'BUTTON' || tagName === 'SELECT' || tagName === 'TEXTAREA';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19893
  }
19894
 
19895
+ function useTabNav() {
19896
+ const container = (0,external_wp_element_namespaceObject.useRef)();
19897
+ const focusCaptureBeforeRef = (0,external_wp_element_namespaceObject.useRef)();
19898
+ const focusCaptureAfterRef = (0,external_wp_element_namespaceObject.useRef)();
19899
+ const lastFocus = (0,external_wp_element_namespaceObject.useRef)();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19900
  const {
19901
+ hasMultiSelection,
19902
+ getSelectedBlockClientId
19903
+ } = (0,external_wp_data_namespaceObject.useSelect)(store);
19904
+ const {
19905
+ setNavigationMode
19906
+ } = (0,external_wp_data_namespaceObject.useDispatch)(store);
19907
+ const isNavigationMode = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).isNavigationMode(), []); // Don't allow tabbing to this element in Navigation mode.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19908
 
19909
+ const focusCaptureTabIndex = !isNavigationMode ? '0' : undefined; // Reference that holds the a flag for enabling or disabling
19910
+ // capturing on the focus capture elements.
 
 
 
 
 
19911
 
19912
+ const noCapture = (0,external_wp_element_namespaceObject.useRef)();
 
 
 
 
19913
 
19914
+ function onFocusCapture(event) {
19915
+ // Do not capture incoming focus if set by us in WritingFlow.
19916
+ if (noCapture.current) {
19917
+ noCapture.current = null;
19918
+ } else if (hasMultiSelection()) {
19919
+ container.current.focus();
19920
+ } else if (getSelectedBlockClientId()) {
19921
+ lastFocus.current.focus();
19922
+ } else {
19923
+ setNavigationMode(true);
19924
+ const isBefore = // eslint-disable-next-line no-bitwise
19925
+ event.target.compareDocumentPosition(container.current) & event.target.DOCUMENT_POSITION_FOLLOWING;
19926
+ const action = isBefore ? 'findNext' : 'findPrevious';
19927
+ external_wp_dom_namespaceObject.focus.tabbable[action](event.target).focus();
19928
  }
 
 
19929
  }
19930
 
19931
+ const before = (0,external_wp_element_namespaceObject.createElement)("div", {
19932
+ ref: focusCaptureBeforeRef,
19933
+ tabIndex: focusCaptureTabIndex,
19934
+ onFocus: onFocusCapture
19935
+ });
19936
+ const after = (0,external_wp_element_namespaceObject.createElement)("div", {
19937
+ ref: focusCaptureAfterRef,
19938
+ tabIndex: focusCaptureTabIndex,
19939
+ onFocus: onFocusCapture
19940
+ });
19941
+ const ref = (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
19942
+ function onKeyDown(event) {
19943
+ if (event.defaultPrevented) {
19944
+ return;
19945
+ }
 
19946
 
19947
+ if (event.keyCode === external_wp_keycodes_namespaceObject.ESCAPE && !hasMultiSelection()) {
19948
+ event.preventDefault();
19949
+ setNavigationMode(true);
19950
+ return;
19951
+ } // In Edit mode, Tab should focus the first tabbable element after
19952
+ // the content, which is normally the sidebar (with block controls)
19953
+ // and Shift+Tab should focus the first tabbable element before the
19954
+ // content, which is normally the block toolbar.
19955
+ // Arrow keys can be used, and Tab and arrow keys can be used in
19956
+ // Navigation mode (press Esc), to navigate through blocks.
19957
 
19958
 
19959
+ if (event.keyCode !== external_wp_keycodes_namespaceObject.TAB) {
19960
+ return;
19961
+ }
19962
 
19963
+ const isShift = event.shiftKey;
19964
+ const direction = isShift ? 'findPrevious' : 'findNext';
 
19965
 
19966
+ if (!hasMultiSelection() && !getSelectedBlockClientId()) {
19967
+ // Preserve the behaviour of entering navigation mode when
19968
+ // tabbing into the content without a block selection.
19969
+ // `onFocusCapture` already did this previously, but we need to
19970
+ // do it again here because after clearing block selection,
19971
+ // focus land on the writing flow container and pressing Tab
19972
+ // will no longer send focus through the focus capture element.
19973
+ if (event.target === node) setNavigationMode(true);
19974
+ return;
19975
+ } // Allow tabbing between form elements rendered in a block,
19976
+ // such as inside a placeholder. Form elements are generally
19977
+ // meant to be UI rather than part of the content. Ideally
19978
+ // these are not rendered in the content and perhaps in the
19979
+ // future they can be rendered in an iframe or shadow DOM.
19980
 
19981
 
19982
+ if (isFormElement(event.target) && isFormElement(external_wp_dom_namespaceObject.focus.tabbable[direction](event.target))) {
19983
+ return;
19984
+ }
 
 
 
 
 
19985
 
19986
+ const next = isShift ? focusCaptureBeforeRef : focusCaptureAfterRef; // Disable focus capturing on the focus capture element, so it
19987
+ // doesn't refocus this block and so it allows default behaviour
19988
+ // (moving focus to the next tabbable element).
19989
 
19990
+ noCapture.current = true; // Focusing the focus capture element, which is located above and
19991
+ // below the editor, should not scroll the page all the way up or
19992
+ // down.
 
 
 
 
19993
 
19994
+ next.current.focus({
19995
+ preventScroll: true
 
19996
  });
19997
  }
 
19998
 
19999
+ function onFocusOut(event) {
20000
+ lastFocus.current = event.target;
20001
+ } // When tabbing back to an element in block list, this event handler prevents scrolling if the
20002
+ // focus capture divs (before/after) are outside of the viewport. (For example shift+tab back to a paragraph
20003
+ // when focus is on a sidebar element. This prevents the scrollable writing area from jumping either to the
20004
+ // top or bottom of the document.
20005
+ //
20006
+ // Note that it isn't possible to disable scrolling in the onFocus event. We need to intercept this
20007
+ // earlier in the keypress handler, and call focus( { preventScroll: true } ) instead.
20008
+ // https://developer.mozilla.org/en-US/docs/Web/API/HTMLOrForeignElement/focus#parameters
20009
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20010
 
20011
+ function preventScrollOnTab(event) {
20012
+ var _event$target;
 
 
 
 
 
 
 
 
 
 
 
20013
 
20014
+ if (event.keyCode !== external_wp_keycodes_namespaceObject.TAB) {
20015
+ return;
20016
+ }
 
 
 
 
 
 
 
 
 
20017
 
20018
+ if (((_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.getAttribute('role')) === 'region') {
20019
+ return;
20020
+ }
 
20021
 
20022
+ if (container.current === event.target) {
20023
+ return;
20024
+ }
20025
 
20026
+ const isShift = event.shiftKey;
20027
+ const direction = isShift ? 'findPrevious' : 'findNext';
20028
+ const target = external_wp_dom_namespaceObject.focus.tabbable[direction](event.target); // only do something when the next tabbable is a focus capture div (before/after)
 
20029
 
20030
+ if (target === focusCaptureBeforeRef.current || target === focusCaptureAfterRef.current) {
20031
+ event.preventDefault();
20032
+ target.focus({
20033
+ preventScroll: true
20034
+ });
20035
+ }
20036
+ }
20037
 
20038
+ const {
20039
+ ownerDocument
20040
+ } = node;
20041
+ const {
20042
+ defaultView
20043
+ } = ownerDocument;
20044
+ defaultView.addEventListener('keydown', preventScrollOnTab);
20045
+ node.addEventListener('keydown', onKeyDown);
20046
+ node.addEventListener('focusout', onFocusOut);
20047
+ return () => {
20048
+ defaultView.removeEventListener('keydown', preventScrollOnTab);
20049
+ node.removeEventListener('keydown', onKeyDown);
20050
+ node.removeEventListener('focusout', onFocusOut);
20051
+ };
20052
+ }, []);
20053
+ const mergedRefs = (0,external_wp_compose_namespaceObject.useMergeRefs)([container, ref]);
20054
+ return [before, mergedRefs, after];
20055
  }
20056
+ //# sourceMappingURL=use-tab-nav.js.map
20057
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/writing-flow/use-arrow-nav.js
20058
  /**
20059
  * External dependencies
20060
  */
20066
 
20067
 
20068
 
20069
+
20070
  /**
20071
  * Internal dependencies
20072
  */
20073
 
20074
 
20075
 
 
 
20076
  /**
20077
+ * Returns true if the element should consider edge navigation upon a keyboard
20078
+ * event of the given directional key code, or false otherwise.
20079
  *
20080
+ * @param {Element} element HTML element to test.
20081
+ * @param {number} keyCode KeyboardEvent keyCode to test.
20082
+ * @param {boolean} hasModifier Whether a modifier is pressed.
20083
  *
20084
+ * @return {boolean} Whether element should consider edge navigation.
20085
  */
20086
 
20087
+ function isNavigationCandidate(element, keyCode, hasModifier) {
20088
+ const isVertical = keyCode === external_wp_keycodes_namespaceObject.UP || keyCode === external_wp_keycodes_namespaceObject.DOWN; // Currently, all elements support unmodified vertical navigation.
 
 
 
 
 
 
 
 
 
 
20089
 
20090
+ if (isVertical && !hasModifier) {
20091
+ return true;
20092
+ } // Native inputs should not navigate horizontally.
20093
 
20094
 
20095
+ const {
20096
+ tagName
20097
+ } = element;
20098
+ return tagName !== 'INPUT' && tagName !== 'TEXTAREA';
20099
  }
20100
  /**
20101
+ * Returns the optimal tab target from the given focused element in the desired
20102
+ * direction. A preference is made toward text fields, falling back to the block
20103
+ * focus stop if no other candidates exist for the block.
20104
  *
20105
+ * @param {Element} target Currently focused text field.
20106
+ * @param {boolean} isReverse True if considering as the first field.
20107
+ * @param {Element} containerElement Element containing all blocks.
20108
+ * @param {boolean} onlyVertical Whether to only consider tabbable elements
20109
+ * that are visually above or under the
20110
+ * target.
20111
  *
20112
+ * @return {?Element} Optimal tab target, if one exists.
20113
  */
20114
 
20115
+ function getClosestTabbable(target, isReverse, containerElement, onlyVertical) {
20116
+ // Since the current focus target is not guaranteed to be a text field, find
20117
+ // all focusables. Tabbability is considered later.
20118
+ let focusableNodes = external_wp_dom_namespaceObject.focus.focusable.find(containerElement);
20119
 
20120
+ if (isReverse) {
20121
+ focusableNodes = (0,external_lodash_namespaceObject.reverse)(focusableNodes);
20122
+ } // Consider as candidates those focusables after the current target. It's
20123
+ // assumed this can only be reached if the target is focusable (on its
20124
+ // keydown event), so no need to verify it exists in the set.
 
 
 
 
 
 
20125
 
 
 
 
20126
 
20127
+ focusableNodes = focusableNodes.slice(focusableNodes.indexOf(target) + 1);
20128
+ let targetRect;
 
20129
 
20130
+ if (onlyVertical) {
20131
+ targetRect = target.getBoundingClientRect();
20132
+ }
20133
 
20134
+ function isTabCandidate(node) {
20135
+ // Not a candidate if the node is not tabbable.
20136
+ if (!external_wp_dom_namespaceObject.focus.tabbable.isTabbableIndex(node)) {
20137
+ return false;
20138
+ } // Skip focusable elements such as links within content editable nodes.
20139
 
 
 
20140
 
20141
+ if (node.isContentEditable && node.contentEditable !== 'true') {
20142
+ return false;
 
20143
  }
20144
 
20145
+ if (onlyVertical) {
20146
+ const nodeRect = node.getBoundingClientRect();
 
 
 
 
 
 
 
 
 
 
 
 
 
20147
 
20148
+ if (nodeRect.left >= targetRect.right || nodeRect.right <= targetRect.left) {
20149
+ return false;
20150
+ }
20151
+ }
20152
 
20153
+ return true;
 
 
20154
  }
20155
 
20156
+ return (0,external_lodash_namespaceObject.find)(focusableNodes, isTabCandidate);
 
 
20157
  }
20158
+ function useArrowNav() {
20159
+ const {
20160
+ getSelectedBlockClientId,
20161
+ getMultiSelectedBlocksStartClientId,
20162
+ getMultiSelectedBlocksEndClientId,
20163
+ getPreviousBlockClientId,
20164
+ getNextBlockClientId,
20165
+ getFirstMultiSelectedBlockClientId,
20166
+ getLastMultiSelectedBlockClientId,
20167
+ getSettings,
20168
+ hasMultiSelection
20169
+ } = (0,external_wp_data_namespaceObject.useSelect)(store);
20170
+ const {
20171
+ multiSelect,
20172
+ selectBlock
20173
+ } = (0,external_wp_data_namespaceObject.useDispatch)(store);
20174
  return (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
20175
+ // Here a DOMRect is stored while moving the caret vertically so
20176
+ // vertical position of the start position can be restored. This is to
20177
+ // recreate browser behaviour across blocks.
20178
+ let verticalRect;
 
 
20179
 
20180
+ function onMouseDown() {
20181
+ verticalRect = null;
20182
  }
 
 
 
 
 
 
 
 
 
 
 
 
20183
 
20184
+ function expandSelection(isReverse) {
20185
+ const selectedBlockClientId = getSelectedBlockClientId();
20186
+ const selectionStartClientId = getMultiSelectedBlocksStartClientId();
20187
+ const selectionEndClientId = getMultiSelectedBlocksEndClientId();
20188
+ const selectionBeforeEndClientId = getPreviousBlockClientId(selectionEndClientId || selectedBlockClientId);
20189
+ const selectionAfterEndClientId = getNextBlockClientId(selectionEndClientId || selectedBlockClientId);
20190
+ const nextSelectionEndClientId = isReverse ? selectionBeforeEndClientId : selectionAfterEndClientId;
20191
 
20192
+ if (nextSelectionEndClientId) {
20193
+ if (selectionStartClientId === nextSelectionEndClientId) {
20194
+ selectBlock(nextSelectionEndClientId);
20195
+ } else {
20196
+ multiSelect(selectionStartClientId || selectedBlockClientId, nextSelectionEndClientId);
20197
+ }
20198
+ }
20199
+ }
20200
 
20201
+ function moveSelection(isReverse) {
20202
+ const selectedFirstClientId = getFirstMultiSelectedBlockClientId();
20203
+ const selectedLastClientId = getLastMultiSelectedBlockClientId();
20204
+ const focusedBlockClientId = isReverse ? selectedFirstClientId : selectedLastClientId;
20205
 
20206
+ if (focusedBlockClientId) {
20207
+ selectBlock(focusedBlockClientId);
20208
+ }
20209
+ }
20210
+ /**
20211
+ * Returns true if the given target field is the last in its block which
20212
+ * can be considered for tab transition. For example, in a block with
20213
+ * two text fields, this would return true when reversing from the first
20214
+ * of the two fields, but false when reversing from the second.
20215
+ *
20216
+ * @param {Element} target Currently focused text field.
20217
+ * @param {boolean} isReverse True if considering as the first field.
20218
+ *
20219
+ * @return {boolean} Whether field is at edge for tab transition.
20220
+ */
20221
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20222
 
20223
+ function isTabbableEdge(target, isReverse) {
20224
+ const closestTabbable = getClosestTabbable(target, isReverse, node);
20225
+ return !closestTabbable || !isInSameBlock(target, closestTabbable);
20226
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20227
 
20228
+ function onKeyDown(event) {
20229
+ const {
20230
+ keyCode,
20231
+ target
20232
+ } = event;
20233
+ const isUp = keyCode === external_wp_keycodes_namespaceObject.UP;
20234
+ const isDown = keyCode === external_wp_keycodes_namespaceObject.DOWN;
20235
+ const isLeft = keyCode === external_wp_keycodes_namespaceObject.LEFT;
20236
+ const isRight = keyCode === external_wp_keycodes_namespaceObject.RIGHT;
20237
+ const isReverse = isUp || isLeft;
20238
+ const isHorizontal = isLeft || isRight;
20239
+ const isVertical = isUp || isDown;
20240
+ const isNav = isHorizontal || isVertical;
20241
+ const isShift = event.shiftKey;
20242
+ const hasModifier = isShift || event.ctrlKey || event.altKey || event.metaKey;
20243
+ const isNavEdge = isVertical ? external_wp_dom_namespaceObject.isVerticalEdge : external_wp_dom_namespaceObject.isHorizontalEdge;
20244
+ const {
20245
+ ownerDocument
20246
+ } = node;
20247
+ const {
20248
+ defaultView
20249
+ } = ownerDocument;
20250
 
20251
+ if (hasMultiSelection()) {
20252
+ if (isNav) {
20253
+ const action = isShift ? expandSelection : moveSelection;
20254
+ action(isReverse);
20255
+ event.preventDefault();
20256
+ }
20257
 
20258
+ return;
20259
+ } // When presing any key other than up or down, the initial vertical
20260
+ // position must ALWAYS be reset. The vertical position is saved so
20261
+ // it can be restored as well as possible on sebsequent vertical
20262
+ // arrow key presses. It may not always be possible to restore the
20263
+ // exact same position (such as at an empty line), so it wouldn't be
20264
+ // good to compute the position right before any vertical arrow key
20265
+ // press.
20266
 
 
 
 
 
 
 
 
 
20267
 
20268
+ if (!isVertical) {
20269
+ verticalRect = null;
20270
+ } else if (!verticalRect) {
20271
+ verticalRect = (0,external_wp_dom_namespaceObject.computeCaretRect)(defaultView);
20272
+ } // Abort if navigation has already been handled (e.g. RichText
20273
+ // inline boundaries).
20274
 
 
 
 
20275
 
20276
+ if (event.defaultPrevented) {
20277
+ return;
20278
+ }
 
 
 
 
 
20279
 
20280
+ if (!isNav) {
20281
+ return;
20282
+ } // Abort if our current target is not a candidate for navigation
20283
+ // (e.g. preserve native input behaviors).
20284
 
 
 
 
20285
 
20286
+ if (!isNavigationCandidate(target, keyCode, hasModifier)) {
20287
+ return;
20288
+ } // In the case of RTL scripts, right means previous and left means
20289
+ // next, which is the exact reverse of LTR.
20290
 
 
 
 
 
 
 
 
20291
 
20292
+ const isReverseDir = (0,external_wp_dom_namespaceObject.isRTL)(target) ? !isReverse : isReverse;
20293
+ const {
20294
+ keepCaretInsideBlock
20295
+ } = getSettings();
20296
+ const selectedBlockClientId = getSelectedBlockClientId();
 
 
 
 
 
 
 
20297
 
20298
+ if (isShift) {
20299
+ const selectionEndClientId = getMultiSelectedBlocksEndClientId();
20300
+ const selectionBeforeEndClientId = getPreviousBlockClientId(selectionEndClientId || selectedBlockClientId);
20301
+ const selectionAfterEndClientId = getNextBlockClientId(selectionEndClientId || selectedBlockClientId);
20302
 
20303
+ if ( // Ensure that there is a target block.
20304
+ (isReverse && selectionBeforeEndClientId || !isReverse && selectionAfterEndClientId) && isTabbableEdge(target, isReverse) && isNavEdge(target, isReverse)) {
20305
+ // Shift key is down, and there is multi selection or we're
20306
+ // at the end of the current block.
20307
+ expandSelection(isReverse);
20308
+ event.preventDefault();
20309
+ }
20310
+ } else if (isVertical && (0,external_wp_dom_namespaceObject.isVerticalEdge)(target, isReverse) && !keepCaretInsideBlock) {
20311
+ const closestTabbable = getClosestTabbable(target, isReverse, node, true);
20312
 
20313
+ if (closestTabbable) {
20314
+ (0,external_wp_dom_namespaceObject.placeCaretAtVerticalEdge)(closestTabbable, isReverse, verticalRect);
20315
+ event.preventDefault();
20316
+ }
20317
+ } else if (isHorizontal && defaultView.getSelection().isCollapsed && (0,external_wp_dom_namespaceObject.isHorizontalEdge)(target, isReverseDir) && !keepCaretInsideBlock) {
20318
+ const closestTabbable = getClosestTabbable(target, isReverseDir, node);
20319
+ (0,external_wp_dom_namespaceObject.placeCaretAtHorizontalEdge)(closestTabbable, isReverse);
20320
+ event.preventDefault();
20321
+ }
20322
  }
20323
 
20324
+ node.addEventListener('mousedown', onMouseDown);
20325
+ node.addEventListener('keydown', onKeyDown);
20326
+ return () => {
20327
+ node.removeEventListener('mousedown', onMouseDown);
20328
+ node.removeEventListener('keydown', onKeyDown);
20329
+ };
20330
+ }, []);
20331
  }
20332
+ //# sourceMappingURL=use-arrow-nav.js.map
20333
+ ;// CONCATENATED MODULE: external ["wp","keyboardShortcuts"]
20334
+ var external_wp_keyboardShortcuts_namespaceObject = window["wp"]["keyboardShortcuts"];
20335
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/writing-flow/use-select-all.js
20336
  /**
20337
  * External dependencies
20338
  */
20342
  */
20343
 
20344
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20345
 
 
 
 
 
 
 
 
 
 
 
20346
 
20347
 
20348
  /**
20350
  */
20351
 
20352
 
20353
+ function useSelectAll() {
 
 
 
 
 
 
 
20354
  const {
20355
+ getBlockOrder,
20356
+ getSelectedBlockClientIds,
20357
+ getBlockRootClientId
20358
  } = (0,external_wp_data_namespaceObject.useSelect)(store);
20359
  const {
20360
+ multiSelect
 
20361
  } = (0,external_wp_data_namespaceObject.useDispatch)(store);
20362
+ const isMatch = (0,external_wp_keyboardShortcuts_namespaceObject.__unstableUseShortcutEventMatch)();
20363
  return (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
20364
+ function onKeyDown(event) {
20365
+ if (!isMatch('core/block-editor/select-all', event)) {
20366
+ return;
20367
+ }
 
 
 
 
 
 
 
 
 
 
 
 
20368
 
20369
+ if (!(0,external_wp_dom_namespaceObject.isEntirelySelected)(event.target)) {
20370
  return;
20371
+ }
20372
+
20373
+ const selectedClientIds = getSelectedBlockClientIds();
20374
+ const [firstSelectedClientId] = selectedClientIds;
20375
+ const rootClientId = getBlockRootClientId(firstSelectedClientId);
20376
+ let blockClientIds = getBlockOrder(rootClientId); // If we have selected all sibling nested blocks, try selecting up a
20377
+ // level. See: https://github.com/WordPress/gutenberg/pull/31859/
20378
 
20379
+ if (selectedClientIds.length === blockClientIds.length) {
20380
+ blockClientIds = getBlockOrder(getBlockRootClientId(rootClientId));
20381
+ }
20382
 
20383
+ const firstClientId = (0,external_lodash_namespaceObject.first)(blockClientIds);
20384
+ const lastClientId = (0,external_lodash_namespaceObject.last)(blockClientIds);
20385
+
20386
+ if (firstClientId === lastClientId) {
20387
  return;
20388
  }
20389
 
20390
+ multiSelect(firstClientId, lastClientId);
20391
+ event.preventDefault();
20392
  }
20393
 
20394
+ node.addEventListener('keydown', onKeyDown);
20395
  return () => {
20396
+ node.removeEventListener('keydown', onKeyDown);
20397
  };
20398
+ }, []);
20399
  }
20400
+ //# sourceMappingURL=use-select-all.js.map
20401
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/writing-flow/index.js
20402
+
20403
+
20404
+
20405
+ /**
20406
+ * External dependencies
20407
+ */
20408
+
20409
  /**
20410
  * WordPress dependencies
20411
  */
20413
 
20414
 
20415
 
20416
+
20417
  /**
20418
  * Internal dependencies
20419
  */
20420
 
20421
 
 
 
 
 
 
 
 
 
20422
 
20423
+
20424
+
20425
+
20426
+ function useWritingFlow() {
20427
+ const [before, ref, after] = useTabNav();
20428
+ const hasMultiSelection = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).hasMultiSelection(), []);
20429
+ return [before, (0,external_wp_compose_namespaceObject.useMergeRefs)([ref, use_multi_selection_useMultiSelection(), useSelectAll(), useArrowNav(), (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
20430
+ node.tabIndex = -1;
20431
+
20432
+ if (!hasMultiSelection) {
 
 
20433
  return;
20434
  }
 
 
 
 
 
 
 
 
 
20435
 
20436
+ node.setAttribute('aria-label', (0,external_wp_i18n_namespaceObject.__)('Multiple selected blocks'));
20437
+ return () => {
20438
+ node.removeAttribute('aria-label');
20439
+ };
20440
+ }, [hasMultiSelection])]), after];
20441
+ }
20442
 
20443
+ function WritingFlow({
20444
+ children,
20445
+ ...props
20446
+ }, forwardedRef) {
20447
+ const [before, ref, after] = useWritingFlow();
20448
+ return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, before, (0,external_wp_element_namespaceObject.createElement)("div", _extends({}, props, {
20449
+ ref: (0,external_wp_compose_namespaceObject.useMergeRefs)([ref, forwardedRef]),
20450
+ className: classnames_default()(props.className, 'block-editor-writing-flow')
20451
+ }), children), after);
20452
+ }
20453
+ /**
20454
+ * Handles selection and navigation across blocks. This component should be
20455
+ * wrapped around BlockList.
20456
+ *
20457
+ * @param {Object} props Component properties.
20458
+ * @param {WPElement} props.children Children to be rendered.
20459
+ */
20460
 
 
 
 
20461
 
20462
+ /* harmony default export */ var writing_flow = ((0,external_wp_element_namespaceObject.forwardRef)(WritingFlow));
20463
+ //# sourceMappingURL=index.js.map
20464
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/iframe/index.js
20465
 
 
 
 
 
 
 
 
 
 
 
 
 
20466
 
20467
 
20468
+ /**
20469
+ * External dependencies
20470
+ */
20471
 
 
 
 
 
 
 
 
 
 
 
20472
  /**
20473
  * WordPress dependencies
20474
  */
20475
 
20476
 
20477
+
20478
+
20479
+
20480
  /**
20481
  * Internal dependencies
20482
  */
20483
 
20484
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20485
 
20486
+ const BODY_CLASS_NAME = 'editor-styles-wrapper';
20487
+ const BLOCK_PREFIX = 'wp-block';
20488
  /**
20489
+ * Clones stylesheets targetting the editor canvas to the given document. A
20490
+ * stylesheet is considered targetting the editor a canvas if it contains the
20491
+ * `editor-styles-wrapper`, `wp-block`, or `wp-block-*` class selectors.
20492
+ *
20493
+ * Ideally, this hook should be removed in the future and styles should be added
20494
+ * explicitly as editor styles.
20495
+ *
20496
+ * @param {Document} doc The document to append cloned stylesheets to.
20497
  */
20498
 
20499
+ function styleSheetsCompat(doc) {
20500
+ // Search the document for stylesheets targetting the editor canvas.
20501
+ Array.from(document.styleSheets).forEach(styleSheet => {
20502
+ try {
20503
+ // May fail for external styles.
20504
+ // eslint-disable-next-line no-unused-expressions
20505
+ styleSheet.cssRules;
20506
+ } catch (e) {
 
 
 
 
 
 
 
20507
  return;
20508
  }
20509
 
20510
+ const {
20511
+ ownerNode,
20512
+ cssRules
20513
+ } = styleSheet;
20514
 
20515
+ if (!cssRules) {
20516
  return;
20517
+ } // Generally, ignore inline styles. We add inline styles belonging to a
20518
+ // stylesheet later, which may or may not match the selectors.
20519
 
20520
 
20521
+ if (ownerNode.tagName !== 'LINK') {
20522
  return;
20523
+ } // Don't try to add the reset styles, which were removed as a dependency
20524
+ // from `edit-blocks` for the iframe since we don't need to reset admin
20525
+ // styles.
20526
 
 
 
20527
 
20528
+ if (ownerNode.id === 'wp-reset-editor-styles-css') {
20529
  return;
20530
  }
20531
 
20532
+ const isMatch = Array.from(cssRules).find(({
20533
+ selectorText
20534
+ }) => selectorText && (selectorText.includes(`.${BODY_CLASS_NAME}`) || selectorText.includes(`.${BLOCK_PREFIX}`)));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20535
 
20536
+ if (isMatch && !doc.getElementById(ownerNode.id)) {
20537
+ // eslint-disable-next-line no-console
20538
+ console.error(`Stylesheet ${ownerNode.id} was not properly added.
20539
+ For blocks, use the block API's style (https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/#style) or editorStyle (https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/#editor-style).
20540
+ For themes, use add_editor_style (https://developer.wordpress.org/block-editor/how-to-guides/themes/theme-support/#editor-styles).`, ownerNode.outerHTML);
20541
+ doc.head.appendChild(ownerNode.cloneNode(true)); // Add inline styles belonging to the stylesheet.
20542
 
20543
+ const inlineCssId = ownerNode.id.replace('-css', '-inline-css');
20544
+ const inlineCssElement = document.getElementById(inlineCssId);
20545
 
20546
+ if (inlineCssElement) {
20547
+ doc.head.appendChild(inlineCssElement.cloneNode(true));
20548
+ }
 
 
 
20549
  }
20550
  });
20551
  }
20552
  /**
20553
+ * Bubbles some event types (keydown, keypress, and dragover) to parent document
20554
+ * document to ensure that the keyboard shortcuts and drag and drop work.
20555
  *
20556
+ * Ideally, we should remove event bubbling in the future. Keyboard shortcuts
20557
+ * should be context dependent, e.g. actions on blocks like Cmd+A should not
20558
+ * work globally outside the block editor.
20559
+ *
20560
+ * @param {Document} doc Document to attach listeners to.
20561
  */
20562
 
20563
 
20564
+ function bubbleEvents(doc) {
20565
  const {
20566
+ defaultView
20567
+ } = doc;
 
 
 
20568
  const {
20569
+ frameElement
20570
+ } = defaultView;
 
 
 
 
 
 
 
 
 
 
 
 
 
20571
 
20572
+ function bubbleEvent(event) {
20573
+ const prototype = Object.getPrototypeOf(event);
20574
+ const constructorName = prototype.constructor.name;
20575
+ const Constructor = window[constructorName];
20576
+ const init = {};
20577
 
20578
+ for (const key in event) {
20579
+ init[key] = event[key];
20580
+ }
 
20581
 
20582
+ if (event instanceof defaultView.MouseEvent) {
20583
+ const rect = frameElement.getBoundingClientRect();
20584
+ init.clientX += rect.left;
20585
+ init.clientY += rect.top;
20586
+ }
20587
 
20588
+ const newEvent = new Constructor(event.type, init);
20589
+ const cancelled = !frameElement.dispatchEvent(newEvent);
 
 
 
 
20590
 
20591
+ if (cancelled) {
20592
+ event.preventDefault();
20593
+ }
20594
+ }
20595
 
20596
+ const eventTypes = ['keydown', 'keypress', 'dragover'];
 
 
 
20597
 
20598
+ for (const name of eventTypes) {
20599
+ doc.addEventListener(name, bubbleEvent);
20600
+ }
20601
+ }
 
 
 
 
 
 
 
 
20602
 
20603
+ function useParsedAssets(html) {
20604
+ return (0,external_wp_element_namespaceObject.useMemo)(() => {
20605
+ const doc = document.implementation.createHTMLDocument('');
20606
+ doc.body.innerHTML = html;
20607
+ return Array.from(doc.body.children);
20608
+ }, [html]);
20609
+ }
20610
 
20611
+ async function loadScript(head, {
20612
+ id,
20613
+ src
20614
+ }) {
20615
+ return new Promise((resolve, reject) => {
20616
+ const script = head.ownerDocument.createElement('script');
20617
+ script.id = id;
20618
 
20619
+ if (src) {
20620
+ script.src = src;
20621
+
20622
+ script.onload = () => resolve();
20623
+
20624
+ script.onerror = () => reject();
20625
+ } else {
20626
+ resolve();
20627
  }
20628
 
20629
+ head.appendChild(script);
20630
+ });
20631
+ }
 
 
 
 
 
20632
 
20633
+ function Iframe({
20634
+ contentRef,
20635
+ children,
20636
+ head,
20637
+ tabIndex = 0,
20638
+ ...props
20639
+ }, ref) {
20640
+ const [, forceRender] = (0,external_wp_element_namespaceObject.useReducer)(() => ({}));
20641
+ const [iframeDocument, setIframeDocument] = (0,external_wp_element_namespaceObject.useState)();
20642
+ const [bodyClasses, setBodyClasses] = (0,external_wp_element_namespaceObject.useState)([]);
20643
+ const styles = useParsedAssets(window.__editorAssets.styles);
20644
+ const scripts = useParsedAssets(window.__editorAssets.scripts);
20645
+ const clearerRef = useBlockSelectionClearer();
20646
+ const [before, writingFlowRef, after] = useWritingFlow();
20647
+ const setRef = (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
20648
+ function setDocumentIfReady() {
20649
+ const {
20650
+ contentDocument,
20651
+ ownerDocument
20652
+ } = node;
20653
+ const {
20654
+ readyState,
20655
+ documentElement
20656
+ } = contentDocument;
20657
 
20658
+ if (readyState !== 'interactive' && readyState !== 'complete') {
20659
+ return false;
20660
+ }
 
20661
 
20662
+ bubbleEvents(contentDocument);
20663
+ setIframeDocument(contentDocument);
20664
+ clearerRef(documentElement); // Ideally ALL classes that are added through get_body_class should
20665
+ // be added in the editor too, which we'll somehow have to get from
20666
+ // the server in the future (which will run the PHP filters).
 
 
 
 
 
20667
 
20668
+ setBodyClasses(Array.from(ownerDocument.body.classList).filter(name => name.startsWith('admin-color-') || name === 'wp-embed-responsive'));
20669
+ contentDocument.dir = ownerDocument.dir;
20670
+ documentElement.removeChild(contentDocument.head);
20671
+ documentElement.removeChild(contentDocument.body);
20672
+ return true;
20673
  }
20674
 
20675
+ if (setDocumentIfReady()) {
20676
+ return;
20677
+ } // Document is not immediately loaded in Firefox.
 
 
 
20678
 
 
 
20679
 
20680
+ node.addEventListener('load', () => {
20681
+ setDocumentIfReady();
20682
+ });
20683
+ }, []);
20684
+ const headRef = (0,external_wp_compose_namespaceObject.useRefEffect)(element => {
20685
+ scripts.reduce((promise, script) => promise.then(() => loadScript(element, script)), Promise.resolve()).finally(() => {
20686
+ // When script are loaded, re-render blocks to allow them
20687
+ // to initialise.
20688
+ forceRender();
20689
+ });
20690
+ }, []);
20691
+ const bodyRef = (0,external_wp_compose_namespaceObject.useMergeRefs)([contentRef, clearerRef, writingFlowRef]);
20692
+ (0,external_wp_element_namespaceObject.useEffect)(() => {
20693
+ if (iframeDocument) {
20694
+ styleSheetsCompat(iframeDocument);
20695
  }
20696
+ }, [iframeDocument]);
20697
+ head = (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("style", null, 'body{margin:0}'), styles.map(({
20698
+ tagName,
20699
+ href,
20700
+ id,
20701
+ rel,
20702
+ media,
20703
+ textContent
20704
+ }) => {
20705
+ const TagName = tagName.toLowerCase();
20706
 
20707
+ if (TagName === 'style') {
20708
+ return (0,external_wp_element_namespaceObject.createElement)(TagName, {
20709
+ id,
20710
+ key: id
20711
+ }, textContent);
20712
+ }
 
 
 
 
 
 
 
 
 
20713
 
20714
+ return (0,external_wp_element_namespaceObject.createElement)(TagName, {
20715
+ href,
20716
+ id,
20717
+ rel,
20718
+ media,
20719
+ key: id
20720
+ });
20721
+ }), head);
20722
+ return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, tabIndex >= 0 && before, (0,external_wp_element_namespaceObject.createElement)("iframe", _extends({}, props, {
20723
+ ref: (0,external_wp_compose_namespaceObject.useMergeRefs)([ref, setRef]),
20724
+ tabIndex: tabIndex,
20725
+ title: (0,external_wp_i18n_namespaceObject.__)('Editor canvas')
20726
+ }), iframeDocument && (0,external_wp_element_namespaceObject.createPortal)((0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("head", {
20727
+ ref: headRef
20728
+ }, head), (0,external_wp_element_namespaceObject.createElement)("body", {
20729
+ ref: bodyRef,
20730
+ className: classnames_default()(BODY_CLASS_NAME, ...bodyClasses)
20731
+ }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalStyleProvider, {
20732
+ document: iframeDocument
20733
+ }, children))), iframeDocument.documentElement)), tabIndex >= 0 && after);
20734
+ }
20735
 
20736
+ /* harmony default export */ var iframe = ((0,external_wp_element_namespaceObject.forwardRef)(Iframe));
20737
+ //# sourceMappingURL=index.js.map
20738
+ // EXTERNAL MODULE: ./node_modules/traverse/index.js
20739
+ var traverse = __webpack_require__(3692);
20740
+ var traverse_default = /*#__PURE__*/__webpack_require__.n(traverse);
20741
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/utils/transform-styles/ast/parse.js
20742
+ /* eslint-disable @wordpress/no-unused-vars-before-return */
20743
+ // Adapted from https://github.com/reworkcss/css
20744
+ // because we needed to remove source map support.
20745
+ // http://www.w3.org/TR/CSS21/grammar.htm
20746
+ // https://github.com/visionmedia/css-parse/pull/49#issuecomment-30088027
20747
+ const commentre = /\/\*[^*]*\*+([^/*][^*]*\*+)*\//g;
20748
+ /* harmony default export */ function parse(css, options) {
20749
+ options = options || {};
20750
+ /**
20751
+ * Positional.
20752
+ */
20753
 
20754
+ let lineno = 1;
20755
+ let column = 1;
20756
+ /**
20757
+ * Update lineno and column based on `str`.
20758
+ */
 
 
 
 
20759
 
20760
+ function updatePosition(str) {
20761
+ const lines = str.match(/\n/g);
20762
 
20763
+ if (lines) {
20764
+ lineno += lines.length;
20765
+ }
20766
 
20767
+ const i = str.lastIndexOf('\n'); // eslint-disable-next-line no-bitwise
20768
 
20769
+ column = ~i ? str.length - i : column + str.length;
20770
+ }
20771
+ /**
20772
+ * Mark position and patch `node.position`.
20773
+ */
20774
 
 
 
 
 
 
 
 
20775
 
20776
+ function position() {
20777
+ const start = {
20778
+ line: lineno,
20779
+ column
20780
+ };
20781
+ return function (node) {
20782
+ node.position = new Position(start);
20783
+ whitespace();
20784
+ return node;
20785
+ };
20786
+ }
20787
+ /**
20788
+ * Store position information for a node
20789
+ */
20790
 
 
 
 
20791
 
20792
+ function Position(start) {
20793
+ this.start = start;
20794
+ this.end = {
20795
+ line: lineno,
20796
+ column
20797
+ };
20798
+ this.source = options.source;
20799
+ }
20800
+ /**
20801
+ * Non-enumerable source string
20802
+ */
20803
 
 
 
 
20804
 
20805
+ Position.prototype.content = css;
20806
+ /**
20807
+ * Error `msg`.
20808
+ */
20809
 
20810
+ const errorsList = [];
20811
 
20812
+ function error(msg) {
20813
+ const err = new Error(options.source + ':' + lineno + ':' + column + ': ' + msg);
20814
+ err.reason = msg;
20815
+ err.filename = options.source;
20816
+ err.line = lineno;
20817
+ err.column = column;
20818
+ err.source = css;
20819
 
20820
+ if (options.silent) {
20821
+ errorsList.push(err);
20822
+ } else {
20823
+ throw err;
20824
+ }
 
 
 
 
 
 
 
 
 
 
 
20825
  }
20826
+ /**
20827
+ * Parse stylesheet.
20828
+ */
20829
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20830
 
20831
+ function stylesheet() {
20832
+ const rulesList = rules();
20833
+ return {
20834
+ type: 'stylesheet',
20835
+ stylesheet: {
20836
+ source: options.source,
20837
+ rules: rulesList,
20838
+ parsingErrors: errorsList
20839
+ }
20840
+ };
20841
+ }
20842
+ /**
20843
+ * Opening brace.
20844
+ */
20845
 
20846
 
20847
+ function open() {
20848
+ return match(/^{\s*/);
20849
+ }
20850
+ /**
20851
+ * Closing brace.
20852
+ */
20853
 
 
 
 
20854
 
20855
+ function close() {
20856
+ return match(/^}/);
20857
+ }
20858
+ /**
20859
+ * Parse ruleset.
20860
+ */
20861
 
20862
 
20863
+ function rules() {
20864
+ let node;
20865
+ const accumulator = [];
20866
+ whitespace();
20867
+ comments(accumulator);
20868
 
20869
+ while (css.length && css.charAt(0) !== '}' && (node = atrule() || rule())) {
20870
+ if (node !== false) {
20871
+ accumulator.push(node);
20872
+ comments(accumulator);
20873
+ }
20874
+ }
20875
 
20876
+ return accumulator;
20877
+ }
20878
+ /**
20879
+ * Match `re` and return captures.
20880
+ */
20881
 
 
 
 
 
 
 
 
 
 
 
 
20882
 
20883
+ function match(re) {
20884
+ const m = re.exec(css);
 
 
 
 
20885
 
20886
+ if (!m) {
20887
+ return;
20888
  }
20889
 
20890
+ const str = m[0];
20891
+ updatePosition(str);
20892
+ css = css.slice(str.length);
20893
+ return m;
20894
+ }
20895
+ /**
20896
+ * Parse whitespace.
20897
+ */
 
 
 
 
 
 
 
 
 
20898
 
20899
 
20900
+ function whitespace() {
20901
+ match(/^\s*/);
20902
+ }
20903
+ /**
20904
+ * Parse comments;
20905
+ */
20906
 
20907
 
20908
+ function comments(accumulator) {
20909
+ let c;
20910
+ accumulator = accumulator || []; // eslint-disable-next-line no-cond-assign
20911
 
20912
+ while (c = comment()) {
20913
+ if (c !== false) {
20914
+ accumulator.push(c);
20915
+ }
20916
+ }
20917
 
20918
+ return accumulator;
20919
+ }
20920
+ /**
20921
+ * Parse comment.
20922
+ */
 
 
 
 
20923
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20924
 
20925
+ function comment() {
20926
+ const pos = position();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20927
 
20928
+ if ('/' !== css.charAt(0) || '*' !== css.charAt(1)) {
 
20929
  return;
20930
+ }
 
 
20931
 
20932
+ let i = 2;
20933
 
20934
+ while ('' !== css.charAt(i) && ('*' !== css.charAt(i) || '/' !== css.charAt(i + 1))) {
20935
+ ++i;
20936
+ }
20937
 
20938
+ i += 2;
 
20939
 
20940
+ if ('' === css.charAt(i - 1)) {
20941
+ return error('End of comment missing');
20942
+ }
20943
 
20944
+ const str = css.slice(2, i - 2);
20945
+ column += 2;
20946
+ updatePosition(str);
20947
+ css = css.slice(i);
20948
+ column += 2;
20949
+ return pos({
20950
+ type: 'comment',
20951
+ comment: str
20952
+ });
20953
+ }
20954
+ /**
20955
+ * Parse selector.
20956
+ */
20957
 
 
 
 
20958
 
20959
+ function selector() {
20960
+ const m = match(/^([^{]+)/);
 
 
 
20961
 
20962
+ if (!m) {
20963
+ return;
20964
+ } // FIXME: Remove all comments from selectors http://ostermiller.org/findcomment.html
 
 
 
20965
 
20966
 
20967
+ return trim(m[0]).replace(/\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*\/+/g, '').replace(/"(?:\\"|[^"])*"|'(?:\\'|[^'])*'/g, function (matched) {
20968
+ return matched.replace(/,/g, '\u200C');
20969
+ }).split(/\s*(?![^(]*\)),\s*/).map(function (s) {
20970
+ return s.replace(/\u200C/g, ',');
20971
+ });
20972
+ }
20973
+ /**
20974
+ * Parse declaration.
20975
+ */
20976
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20977
 
20978
+ function declaration() {
20979
+ const pos = position(); // prop
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20980
 
20981
+ let prop = match(/^(\*?[-#\/\*\\\w]+(\[[0-9a-z_-]+\])?)\s*/);
 
 
 
 
 
 
20982
 
20983
+ if (!prop) {
20984
+ return;
20985
+ }
20986
 
20987
+ prop = trim(prop[0]); // :
20988
 
20989
+ if (!match(/^:\s*/)) {
20990
+ return error("property missing ':'");
20991
+ } // val
 
 
20992
 
 
 
20993
 
20994
+ const val = match(/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^\)]*?\)|[^};])+)/);
20995
+ const ret = pos({
20996
+ type: 'declaration',
20997
+ property: prop.replace(commentre, ''),
20998
+ value: val ? trim(val[0]).replace(commentre, '') : ''
20999
+ }); // ;
 
 
 
21000
 
21001
+ match(/^[;\s]*/);
21002
+ return ret;
21003
+ }
21004
+ /**
21005
+ * Parse declarations.
21006
+ */
 
21007
 
21008
 
21009
+ function declarations() {
21010
+ const decls = [];
 
21011
 
21012
+ if (!open()) {
21013
+ return error("missing '{'");
21014
+ }
21015
 
21016
+ comments(decls); // declarations
 
 
21017
 
21018
+ let decl; // eslint-disable-next-line no-cond-assign
21019
 
21020
+ while (decl = declaration()) {
21021
+ if (decl !== false) {
21022
+ decls.push(decl);
21023
+ comments(decls);
21024
+ }
21025
+ }
21026
 
21027
+ if (!close()) {
21028
+ return error("missing '}'");
21029
+ }
21030
 
21031
+ return decls;
21032
+ }
21033
+ /**
21034
+ * Parse keyframe.
21035
+ */
21036
 
 
21037
 
21038
+ function keyframe() {
21039
+ let m;
21040
+ const vals = [];
21041
+ const pos = position(); // eslint-disable-next-line no-cond-assign
 
 
 
 
 
 
 
21042
 
21043
+ while (m = match(/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/)) {
21044
+ vals.push(m[1]);
21045
+ match(/^,\s*/);
21046
+ }
21047
 
21048
+ if (!vals.length) {
21049
+ return;
21050
+ }
21051
 
21052
+ return pos({
21053
+ type: 'keyframe',
21054
+ values: vals,
21055
+ declarations: declarations()
21056
+ });
21057
+ }
21058
+ /**
21059
+ * Parse keyframes.
21060
+ */
21061
 
 
 
 
21062
 
21063
+ function atkeyframes() {
21064
+ const pos = position();
21065
+ let m = match(/^@([-\w]+)?keyframes\s*/);
21066
 
21067
+ if (!m) {
21068
+ return;
21069
+ }
21070
 
21071
+ const vendor = m[1]; // identifier
 
 
 
 
 
 
 
 
 
 
 
21072
 
21073
+ m = match(/^([-\w]+)\s*/);
21074
 
21075
+ if (!m) {
21076
+ return error('@keyframes missing name');
21077
+ }
21078
 
21079
+ const name = m[1];
21080
 
21081
+ if (!open()) {
21082
+ return error("@keyframes missing '{'");
21083
+ }
21084
 
21085
+ let frame;
21086
+ let frames = comments(); // eslint-disable-next-line no-cond-assign
21087
 
21088
+ while (frame = keyframe()) {
21089
+ frames.push(frame);
21090
+ frames = frames.concat(comments());
21091
+ }
21092
 
21093
+ if (!close()) {
21094
+ return error("@keyframes missing '}'");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21095
  }
 
 
 
 
 
 
 
 
 
 
 
21096
 
21097
+ return pos({
21098
+ type: 'keyframes',
21099
+ name,
21100
+ vendor,
21101
+ keyframes: frames
21102
+ });
21103
+ }
21104
+ /**
21105
+ * Parse supports.
21106
+ */
21107
 
21108
 
21109
+ function atsupports() {
21110
+ const pos = position();
21111
+ const m = match(/^@supports *([^{]+)/);
21112
 
21113
+ if (!m) {
21114
+ return;
21115
+ }
21116
+
21117
+ const supports = trim(m[1]);
21118
 
21119
+ if (!open()) {
21120
+ return error("@supports missing '{'");
21121
+ }
21122
 
21123
+ const style = comments().concat(rules());
21124
 
21125
+ if (!close()) {
21126
+ return error("@supports missing '}'");
21127
+ }
21128
 
21129
+ return pos({
21130
+ type: 'supports',
21131
+ supports,
21132
+ rules: style
21133
+ });
21134
+ }
21135
+ /**
21136
+ * Parse host.
21137
+ */
21138
 
21139
 
21140
+ function athost() {
21141
+ const pos = position();
21142
+ const m = match(/^@host\s*/);
21143
 
21144
+ if (!m) {
21145
+ return;
21146
+ }
21147
 
21148
+ if (!open()) {
21149
+ return error("@host missing '{'");
21150
+ }
 
 
 
 
 
 
 
 
 
 
 
 
21151
 
21152
+ const style = comments().concat(rules());
 
 
21153
 
21154
+ if (!close()) {
21155
+ return error("@host missing '}'");
21156
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21157
 
21158
+ return pos({
21159
+ type: 'host',
21160
+ rules: style
21161
+ });
21162
+ }
21163
+ /**
21164
+ * Parse media.
21165
+ */
21166
 
21167
 
21168
+ function atmedia() {
21169
+ const pos = position();
21170
+ const m = match(/^@media *([^{]+)/);
21171
 
21172
+ if (!m) {
21173
+ return;
21174
+ }
21175
 
21176
+ const media = trim(m[1]);
 
 
21177
 
21178
+ if (!open()) {
21179
+ return error("@media missing '{'");
21180
+ }
21181
 
21182
+ const style = comments().concat(rules());
21183
 
21184
+ if (!close()) {
21185
+ return error("@media missing '}'");
21186
+ }
21187
 
21188
+ return pos({
21189
+ type: 'media',
21190
+ media,
21191
+ rules: style
21192
+ });
21193
+ }
21194
+ /**
21195
+ * Parse custom-media.
21196
+ */
21197
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21198
 
21199
+ function atcustommedia() {
21200
+ const pos = position();
21201
+ const m = match(/^@custom-media\s+(--[^\s]+)\s*([^{;]+);/);
 
 
 
21202
 
21203
+ if (!m) {
21204
+ return;
21205
+ }
 
21206
 
21207
+ return pos({
21208
+ type: 'custom-media',
21209
+ name: trim(m[1]),
21210
+ media: trim(m[2])
21211
+ });
21212
+ }
21213
+ /**
21214
+ * Parse paged media.
21215
+ */
21216
 
21217
 
21218
+ function atpage() {
21219
+ const pos = position();
21220
+ const m = match(/^@page */);
21221
 
21222
+ if (!m) {
21223
+ return;
21224
+ }
21225
 
21226
+ const sel = selector() || [];
 
 
21227
 
21228
+ if (!open()) {
21229
+ return error("@page missing '{'");
21230
+ }
21231
 
21232
+ let decls = comments(); // declarations
21233
 
21234
+ let decl; // eslint-disable-next-line no-cond-assign
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21235
 
21236
+ while (decl = declaration()) {
21237
+ decls.push(decl);
21238
+ decls = decls.concat(comments());
21239
  }
21240
 
21241
+ if (!close()) {
21242
+ return error("@page missing '}'");
21243
  }
21244
 
21245
+ return pos({
21246
+ type: 'page',
21247
+ selectors: sel,
21248
+ declarations: decls
21249
+ });
21250
+ }
21251
+ /**
21252
+ * Parse document.
21253
+ */
21254
 
 
 
 
21255
 
21256
+ function atdocument() {
21257
+ const pos = position();
21258
+ const m = match(/^@([-\w]+)?document *([^{]+)/);
21259
 
21260
+ if (!m) {
21261
+ return;
21262
+ }
21263
 
21264
+ const vendor = trim(m[1]);
21265
+ const doc = trim(m[2]);
 
 
 
 
 
 
 
 
 
21266
 
21267
+ if (!open()) {
21268
+ return error("@document missing '{'");
21269
+ }
21270
 
21271
+ const style = comments().concat(rules());
 
 
21272
 
21273
+ if (!close()) {
21274
+ return error("@document missing '}'");
21275
+ }
21276
 
21277
+ return pos({
21278
+ type: 'document',
21279
+ document: doc,
21280
+ vendor,
21281
+ rules: style
21282
+ });
21283
+ }
21284
+ /**
21285
+ * Parse font-face.
21286
+ */
21287
 
 
 
 
21288
 
21289
+ function atfontface() {
21290
+ const pos = position();
21291
+ const m = match(/^@font-face\s*/);
21292
 
21293
+ if (!m) {
21294
+ return;
21295
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21296
 
21297
+ if (!open()) {
21298
+ return error("@font-face missing '{'");
21299
+ }
21300
 
21301
+ let decls = comments(); // declarations
 
 
21302
 
21303
+ let decl; // eslint-disable-next-line no-cond-assign
 
 
21304
 
21305
+ while (decl = declaration()) {
21306
+ decls.push(decl);
21307
+ decls = decls.concat(comments());
21308
+ }
21309
 
21310
+ if (!close()) {
21311
+ return error("@font-face missing '}'");
21312
+ }
21313
 
21314
+ return pos({
21315
+ type: 'font-face',
21316
+ declarations: decls
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21317
  });
21318
+ }
21319
+ /**
21320
+ * Parse import
21321
+ */
21322
 
 
 
 
21323
 
21324
+ const atimport = _compileAtrule('import');
21325
+ /**
21326
+ * Parse charset
21327
+ */
21328
 
21329
 
21330
+ const atcharset = _compileAtrule('charset');
21331
+ /**
21332
+ * Parse namespace
21333
+ */
21334
 
 
 
 
21335
 
21336
+ const atnamespace = _compileAtrule('namespace');
21337
+ /**
21338
+ * Parse non-block at-rules
21339
+ */
21340
 
21341
 
21342
+ function _compileAtrule(name) {
21343
+ const re = new RegExp('^@' + name + '\\s*([^;]+);');
21344
+ return function () {
21345
+ const pos = position();
21346
+ const m = match(re);
21347
+
21348
+ if (!m) {
21349
+ return;
21350
+ }
21351
+
21352
+ const ret = {
21353
+ type: name
21354
+ };
21355
+ ret[name] = m[1].trim();
21356
+ return pos(ret);
21357
+ };
21358
+ }
21359
+ /**
21360
+ * Parse at rule.
21361
+ */
21362
+
21363
+
21364
+ function atrule() {
21365
+ if (css[0] !== '@') {
21366
+ return;
21367
+ }
21368
+
21369
+ return atkeyframes() || atmedia() || atcustommedia() || atsupports() || atimport() || atcharset() || atnamespace() || atdocument() || atpage() || athost() || atfontface();
21370
+ }
21371
+ /**
21372
+ * Parse rule.
21373
+ */
21374
 
 
 
 
21375
 
21376
+ function rule() {
21377
+ const pos = position();
21378
+ const sel = selector();
21379
 
21380
+ if (!sel) {
21381
+ return error('selector missing');
21382
+ }
21383
 
21384
+ comments();
21385
+ return pos({
21386
+ type: 'rule',
21387
+ selectors: sel,
21388
+ declarations: declarations()
21389
+ });
21390
+ }
21391
 
21392
+ return addParent(stylesheet());
21393
+ }
21394
  /**
21395
+ * Trim `str`.
 
 
 
 
21396
  */
21397
 
21398
+ function trim(str) {
21399
+ return str ? str.replace(/^\s+|\s+$/g, '') : '';
 
 
 
21400
  }
21401
+ /**
21402
+ * Adds non-enumerable parent node reference to each node.
21403
+ */
21404
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21405
 
21406
+ function addParent(obj, parent) {
21407
+ const isNode = obj && typeof obj.type === 'string';
21408
+ const childParent = isNode ? obj : parent;
 
 
 
 
21409
 
21410
+ for (const k in obj) {
21411
+ const value = obj[k];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21412
 
21413
+ if (Array.isArray(value)) {
21414
+ value.forEach(function (v) {
21415
+ addParent(v, childParent);
21416
+ });
21417
+ } else if (value && typeof value === 'object') {
21418
+ addParent(value, childParent);
21419
+ }
21420
+ }
 
 
21421
 
21422
+ if (isNode) {
21423
+ Object.defineProperty(obj, 'parent', {
21424
+ configurable: true,
21425
+ writable: true,
21426
+ enumerable: false,
21427
+ value: parent || null
21428
+ });
21429
+ }
21430
 
21431
+ return obj;
 
 
 
 
 
 
 
 
 
 
 
 
21432
  }
21433
+ /* eslint-enable @wordpress/no-unused-vars-before-return */
21434
+ //# sourceMappingURL=parse.js.map
21435
+ // EXTERNAL MODULE: ./node_modules/inherits/inherits_browser.js
21436
+ var inherits_browser = __webpack_require__(5717);
21437
+ var inherits_browser_default = /*#__PURE__*/__webpack_require__.n(inherits_browser);
21438
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/utils/transform-styles/ast/stringify/compiler.js
21439
+ // Adapted from https://github.com/reworkcss/css
21440
+ // because we needed to remove source map support.
21441
 
21442
+ /**
21443
+ * Expose `Compiler`.
21444
+ */
21445
+ /* harmony default export */ var compiler = (Compiler);
21446
+ /**
21447
+ * Initialize a compiler.
21448
+ */
21449
 
21450
+ function Compiler(opts) {
21451
+ this.options = opts || {};
21452
+ }
21453
+ /**
21454
+ * Emit `str`
21455
+ */
21456
 
21457
 
21458
+ Compiler.prototype.emit = function (str) {
21459
+ return str;
21460
+ };
21461
  /**
21462
+ * Visit `node`.
21463
  */
21464
 
21465
 
21466
+ Compiler.prototype.visit = function (node) {
21467
+ return this[node.type](node);
21468
+ };
21469
+ /**
21470
+ * Map visit over array of `nodes`, optionally using a `delim`
21471
+ */
21472
 
21473
 
21474
+ Compiler.prototype.mapVisit = function (nodes, delim) {
21475
+ let buf = '';
21476
+ delim = delim || '';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21477
 
21478
+ for (let i = 0, length = nodes.length; i < length; i++) {
21479
+ buf += this.visit(nodes[i]);
 
21480
 
21481
+ if (delim && i < length - 1) {
21482
+ buf += this.emit(delim);
21483
+ }
21484
+ }
21485
 
21486
+ return buf;
21487
+ };
21488
+ //# sourceMappingURL=compiler.js.map
21489
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/utils/transform-styles/ast/stringify/compress.js
21490
+ // Adapted from https://github.com/reworkcss/css
21491
+ // because we needed to remove source map support.
21492
 
21493
  /**
21494
+ * External dependencies
21495
  */
21496
 
 
21497
  /**
21498
  * Internal dependencies
21499
  */
21500
 
21501
 
21502
+ /**
21503
+ * Expose compiler.
21504
+ */
21505
 
21506
+ /* harmony default export */ var compress = (compress_Compiler);
21507
+ /**
21508
+ * Initialize a new `Compiler`.
21509
+ */
 
 
 
 
21510
 
21511
+ function compress_Compiler(options) {
21512
+ compiler.call(this, options);
21513
+ }
21514
+ /**
21515
+ * Inherit from `Base.prototype`.
21516
+ */
21517
 
21518
 
21519
+ inherits_browser_default()(compress_Compiler, compiler);
21520
  /**
21521
+ * Compile `node`.
21522
  */
21523
 
21524
+ compress_Compiler.prototype.compile = function (node) {
21525
+ return node.stylesheet.rules.map(this.visit, this).join('');
21526
+ };
21527
  /**
21528
+ * Visit comment node.
21529
  */
21530
 
21531
 
21532
+ compress_Compiler.prototype.comment = function (node) {
21533
+ return this.emit('', node.position);
21534
+ };
21535
+ /**
21536
+ * Visit import node.
21537
+ */
21538
 
21539
 
21540
+ compress_Compiler.prototype.import = function (node) {
21541
+ return this.emit('@import ' + node.import + ';', node.position);
21542
+ };
21543
+ /**
21544
+ * Visit media node.
21545
+ */
21546
 
 
 
 
21547
 
21548
+ compress_Compiler.prototype.media = function (node) {
21549
+ return this.emit('@media ' + node.media, node.position) + this.emit('{') + this.mapVisit(node.rules) + this.emit('}');
21550
+ };
21551
+ /**
21552
+ * Visit document node.
21553
+ */
21554
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21555
 
21556
+ compress_Compiler.prototype.document = function (node) {
21557
+ const doc = '@' + (node.vendor || '') + 'document ' + node.document;
21558
+ return this.emit(doc, node.position) + this.emit('{') + this.mapVisit(node.rules) + this.emit('}');
21559
+ };
21560
+ /**
21561
+ * Visit charset node.
21562
+ */
21563
 
21564
 
21565
+ compress_Compiler.prototype.charset = function (node) {
21566
+ return this.emit('@charset ' + node.charset + ';', node.position);
21567
+ };
21568
  /**
21569
+ * Visit namespace node.
21570
  */
21571
 
21572
 
21573
+ compress_Compiler.prototype.namespace = function (node) {
21574
+ return this.emit('@namespace ' + node.namespace + ';', node.position);
21575
+ };
21576
+ /**
21577
+ * Visit supports node.
21578
+ */
 
 
 
 
 
 
 
 
 
 
 
 
 
21579
 
21580
 
21581
+ compress_Compiler.prototype.supports = function (node) {
21582
+ return this.emit('@supports ' + node.supports, node.position) + this.emit('{') + this.mapVisit(node.rules) + this.emit('}');
21583
+ };
21584
  /**
21585
+ * Visit keyframes node.
21586
  */
21587
 
21588
+
21589
+ compress_Compiler.prototype.keyframes = function (node) {
21590
+ return this.emit('@' + (node.vendor || '') + 'keyframes ' + node.name, node.position) + this.emit('{') + this.mapVisit(node.keyframes) + this.emit('}');
21591
+ };
21592
  /**
21593
+ * Visit keyframe node.
21594
  */
21595
 
21596
 
21597
+ compress_Compiler.prototype.keyframe = function (node) {
21598
+ const decls = node.declarations;
21599
+ return this.emit(node.values.join(','), node.position) + this.emit('{') + this.mapVisit(decls) + this.emit('}');
21600
+ };
21601
+ /**
21602
+ * Visit page node.
21603
+ */
21604
 
21605
 
21606
+ compress_Compiler.prototype.page = function (node) {
21607
+ const sel = node.selectors.length ? node.selectors.join(', ') : '';
21608
+ return this.emit('@page ' + sel, node.position) + this.emit('{') + this.mapVisit(node.declarations) + this.emit('}');
21609
+ };
21610
+ /**
21611
+ * Visit font-face node.
21612
+ */
21613
 
21614
 
21615
+ compress_Compiler.prototype['font-face'] = function (node) {
21616
+ return this.emit('@font-face', node.position) + this.emit('{') + this.mapVisit(node.declarations) + this.emit('}');
21617
+ };
21618
+ /**
21619
+ * Visit host node.
21620
+ */
 
 
 
 
 
 
 
 
 
21621
 
21622
 
21623
+ compress_Compiler.prototype.host = function (node) {
21624
+ return this.emit('@host', node.position) + this.emit('{') + this.mapVisit(node.rules) + this.emit('}');
21625
+ };
21626
  /**
21627
+ * Visit custom-media node.
21628
  */
21629
 
21630
+
21631
+ compress_Compiler.prototype['custom-media'] = function (node) {
21632
+ return this.emit('@custom-media ' + node.name + ' ' + node.media + ';', node.position);
21633
+ };
21634
  /**
21635
+ * Visit rule node.
21636
  */
21637
 
21638
 
21639
+ compress_Compiler.prototype.rule = function (node) {
21640
+ const decls = node.declarations;
21641
 
21642
+ if (!decls.length) {
21643
+ return '';
21644
+ }
21645
 
21646
+ return this.emit(node.selectors.join(','), node.position) + this.emit('{') + this.mapVisit(decls) + this.emit('}');
21647
+ };
21648
  /**
21649
+ * Visit declaration node.
21650
  */
21651
 
21652
 
21653
+ compress_Compiler.prototype.declaration = function (node) {
21654
+ return this.emit(node.property + ':' + node.value, node.position) + this.emit(';');
21655
+ };
21656
+ //# sourceMappingURL=compress.js.map
21657
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/utils/transform-styles/ast/stringify/identity.js
21658
+ /* eslint-disable @wordpress/no-unused-vars-before-return */
21659
+ // Adapted from https://github.com/reworkcss/css
21660
+ // because we needed to remove source map support.
21661
 
21662
+ /**
21663
+ * External dependencies
21664
+ */
21665
 
21666
+ /**
21667
+ * Internal dependencies
21668
+ */
21669
 
21670
 
 
 
 
21671
  /**
21672
+ * Expose compiler.
 
 
 
21673
  */
21674
 
21675
+ /* harmony default export */ var identity = (identity_Compiler);
21676
+ /**
21677
+ * Initialize a new `Compiler`.
21678
+ */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21679
 
21680
+ function identity_Compiler(options) {
21681
+ options = options || {};
21682
+ compiler.call(this, options);
21683
+ this.indentation = options.indent;
21684
+ }
21685
+ /**
21686
+ * Inherit from `Base.prototype`.
21687
+ */
21688
 
 
 
 
 
 
 
 
21689
 
21690
+ inherits_browser_default()(identity_Compiler, compiler);
21691
+ /**
21692
+ * Compile `node`.
21693
+ */
21694
 
21695
+ identity_Compiler.prototype.compile = function (node) {
21696
+ return this.stylesheet(node);
21697
+ };
21698
+ /**
21699
+ * Visit stylesheet node.
21700
+ */
 
 
 
 
 
 
 
21701
 
 
 
 
21702
 
21703
+ identity_Compiler.prototype.stylesheet = function (node) {
21704
+ return this.mapVisit(node.stylesheet.rules, '\n\n');
21705
+ };
21706
+ /**
21707
+ * Visit comment node.
21708
+ */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21709
 
 
 
 
21710
 
21711
+ identity_Compiler.prototype.comment = function (node) {
21712
+ return this.emit(this.indent() + '/*' + node.comment + '*/', node.position);
21713
+ };
21714
+ /**
21715
+ * Visit import node.
21716
+ */
 
 
 
 
 
 
 
 
 
21717
 
21718
 
21719
+ identity_Compiler.prototype.import = function (node) {
21720
+ return this.emit('@import ' + node.import + ';', node.position);
21721
+ };
21722
  /**
21723
+ * Visit media node.
21724
  */
21725
 
21726
+
21727
+ identity_Compiler.prototype.media = function (node) {
21728
+ return this.emit('@media ' + node.media, node.position) + this.emit(' {\n' + this.indent(1)) + this.mapVisit(node.rules, '\n\n') + this.emit(this.indent(-1) + '\n}');
21729
+ };
21730
  /**
21731
+ * Visit document node.
21732
  */
21733
 
21734
 
21735
+ identity_Compiler.prototype.document = function (node) {
21736
+ const doc = '@' + (node.vendor || '') + 'document ' + node.document;
21737
+ return this.emit(doc, node.position) + this.emit(' ' + ' {\n' + this.indent(1)) + this.mapVisit(node.rules, '\n\n') + this.emit(this.indent(-1) + '\n}');
21738
+ };
21739
+ /**
21740
+ * Visit charset node.
21741
+ */
21742
 
21743
 
21744
+ identity_Compiler.prototype.charset = function (node) {
21745
+ return this.emit('@charset ' + node.charset + ';', node.position);
21746
+ };
21747
+ /**
21748
+ * Visit namespace node.
21749
+ */
 
 
 
 
 
 
 
 
 
 
21750
 
 
 
 
21751
 
21752
+ identity_Compiler.prototype.namespace = function (node) {
21753
+ return this.emit('@namespace ' + node.namespace + ';', node.position);
21754
+ };
21755
+ /**
21756
+ * Visit supports node.
21757
+ */
21758
 
21759
 
21760
+ identity_Compiler.prototype.supports = function (node) {
21761
+ return this.emit('@supports ' + node.supports, node.position) + this.emit(' {\n' + this.indent(1)) + this.mapVisit(node.rules, '\n\n') + this.emit(this.indent(-1) + '\n}');
21762
+ };
21763
+ /**
21764
+ * Visit keyframes node.
21765
+ */
21766
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21767
 
21768
+ identity_Compiler.prototype.keyframes = function (node) {
21769
+ return this.emit('@' + (node.vendor || '') + 'keyframes ' + node.name, node.position) + this.emit(' {\n' + this.indent(1)) + this.mapVisit(node.keyframes, '\n') + this.emit(this.indent(-1) + '}');
21770
+ };
 
 
21771
  /**
21772
+ * Visit keyframe node.
21773
  */
21774
 
21775
+
21776
+ identity_Compiler.prototype.keyframe = function (node) {
21777
+ const decls = node.declarations;
21778
+ return this.emit(this.indent()) + this.emit(node.values.join(', '), node.position) + this.emit(' {\n' + this.indent(1)) + this.mapVisit(decls, '\n') + this.emit(this.indent(-1) + '\n' + this.indent() + '}\n');
21779
+ };
21780
  /**
21781
+ * Visit page node.
21782
  */
21783
 
21784
 
21785
+ identity_Compiler.prototype.page = function (node) {
21786
+ const sel = node.selectors.length ? node.selectors.join(', ') + ' ' : '';
21787
+ return this.emit('@page ' + sel, node.position) + this.emit('{\n') + this.emit(this.indent(1)) + this.mapVisit(node.declarations, '\n') + this.emit(this.indent(-1)) + this.emit('\n}');
21788
+ };
21789
+ /**
21790
+ * Visit font-face node.
21791
+ */
21792
 
21793
 
21794
+ identity_Compiler.prototype['font-face'] = function (node) {
21795
+ return this.emit('@font-face ', node.position) + this.emit('{\n') + this.emit(this.indent(1)) + this.mapVisit(node.declarations, '\n') + this.emit(this.indent(-1)) + this.emit('\n}');
21796
+ };
21797
+ /**
21798
+ * Visit host node.
21799
+ */
21800
 
21801
 
21802
+ identity_Compiler.prototype.host = function (node) {
21803
+ return this.emit('@host', node.position) + this.emit(' {\n' + this.indent(1)) + this.mapVisit(node.rules, '\n\n') + this.emit(this.indent(-1) + '\n}');
21804
+ };
21805
  /**
21806
+ * Visit custom-media node.
21807
  */
21808
 
21809
 
21810
+ identity_Compiler.prototype['custom-media'] = function (node) {
21811
+ return this.emit('@custom-media ' + node.name + ' ' + node.media + ';', node.position);
21812
+ };
21813
  /**
21814
+ * Visit rule node.
 
 
 
 
 
21815
  */
21816
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21817
 
21818
+ identity_Compiler.prototype.rule = function (node) {
21819
+ const indent = this.indent();
21820
+ const decls = node.declarations;
21821
+
21822
+ if (!decls.length) {
21823
+ return '';
21824
+ }
21825
 
21826
+ return this.emit(node.selectors.map(function (s) {
21827
+ return indent + s;
21828
+ }).join(',\n'), node.position) + this.emit(' {\n') + this.emit(this.indent(1)) + this.mapVisit(decls, '\n') + this.emit(this.indent(-1)) + this.emit('\n' + this.indent() + '}');
21829
+ };
21830
+ /**
21831
+ * Visit declaration node.
21832
+ */
21833
 
21834
 
21835
+ identity_Compiler.prototype.declaration = function (node) {
21836
+ return this.emit(this.indent()) + this.emit(node.property + ': ' + node.value, node.position) + this.emit(';');
21837
+ };
21838
  /**
21839
+ * Increase, decrease or return current indentation.
21840
  */
21841
 
21842
 
21843
+ identity_Compiler.prototype.indent = function (level) {
21844
+ this.level = this.level || 1;
21845
+
21846
+ if (null !== level) {
21847
+ this.level += level;
21848
+ return '';
21849
+ }
21850
 
21851
+ return Array(this.level).join(this.indentation || ' ');
21852
+ };
21853
+ /* eslint-enable @wordpress/no-unused-vars-before-return */
21854
+ //# sourceMappingURL=identity.js.map
21855
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/utils/transform-styles/ast/stringify/index.js
21856
+ // Adapted from https://github.com/reworkcss/css
21857
+ // because we needed to remove source map support.
21858
 
21859
  /**
21860
  * Internal dependencies
21861
  */
21862
 
21863
 
21864
+ /**
21865
+ * Stringfy the given AST `node`.
21866
+ *
21867
+ * Options:
21868
+ *
21869
+ * - `compress` space-optimized output
21870
+ * - `sourcemap` return an object with `.code` and `.map`
21871
+ *
21872
+ * @param {Object} node
21873
+ * @param {Object} [options]
21874
+ * @return {string}
21875
+ */
21876
 
21877
+ /* harmony default export */ function stringify(node, options) {
21878
+ options = options || {};
21879
+ const compiler = options.compress ? new compress(options) : new identity(options);
21880
+ const code = compiler.compile(node);
21881
+ return code;
21882
+ }
21883
+ //# sourceMappingURL=index.js.map
21884
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/utils/transform-styles/traverse.js
21885
+ /**
21886
+ * External dependencies
21887
+ */
21888
 
21889
+ /**
21890
+ * Internal dependencies
21891
+ */
21892
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21893
 
 
 
 
 
 
21894
 
21895
+ function traverseCSS(css, callback) {
21896
+ try {
21897
+ const parsed = parse(css);
21898
+ const updated = traverse_default().map(parsed, function (node) {
21899
+ if (!node) {
21900
+ return node;
21901
+ }
21902
+
21903
+ const updatedNode = callback(node);
21904
+ return this.update(updatedNode);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21905
  });
21906
+ return stringify(updated);
21907
+ } catch (err) {
21908
+ // eslint-disable-next-line no-console
21909
+ console.warn('Error while traversing the CSS: ' + err);
21910
+ return null;
21911
+ }
21912
  }
21913
 
21914
+ /* harmony default export */ var transform_styles_traverse = (traverseCSS);
21915
+ //# sourceMappingURL=traverse.js.map
21916
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/utils/transform-styles/transforms/url-rewrite.js
 
 
21917
  /**
21918
+ * Return `true` if the given path is http/https.
21919
+ *
21920
+ * @param {string} filePath path
21921
+ *
21922
+ * @return {boolean} is remote path.
21923
+ */
21924
+ function isRemotePath(filePath) {
21925
+ return /^(?:https?:)?\/\//.test(filePath);
21926
+ }
21927
+ /**
21928
+ * Return `true` if the given filePath is an absolute url.
21929
+ *
21930
+ * @param {string} filePath path
21931
+ *
21932
+ * @return {boolean} is absolute path.
21933
  */
21934
 
21935
+
21936
+ function isAbsolutePath(filePath) {
21937
+ return /^\/(?!\/)/.test(filePath);
21938
+ }
21939
  /**
21940
+ * Whether or not the url should be inluded.
21941
+ *
21942
+ * @param {Object} meta url meta info
21943
+ *
21944
+ * @return {boolean} is valid.
21945
  */
21946
 
21947
 
21948
+ function isValidURL(meta) {
21949
+ // ignore hashes or data uris
21950
+ if (meta.value.indexOf('data:') === 0 || meta.value.indexOf('#') === 0) {
21951
+ return false;
21952
+ }
21953
+
21954
+ if (isAbsolutePath(meta.value)) {
21955
+ return false;
21956
+ } // do not handle the http/https urls if `includeRemote` is false
21957
+
21958
 
21959
+ if (isRemotePath(meta.value)) {
21960
+ return false;
21961
+ }
21962
 
21963
+ return true;
21964
+ }
21965
  /**
21966
+ * Get the absolute path of the url, relative to the basePath
21967
+ *
21968
+ * @param {string} str the url
21969
+ * @param {string} baseURL base URL
21970
+ *
21971
+ * @return {string} the full path to the file
21972
  */
21973
 
21974
 
21975
+ function getResourcePath(str, baseURL) {
21976
+ return new URL(str, baseURL).toString();
21977
+ }
21978
+ /**
21979
+ * Process the single `url()` pattern
21980
+ *
21981
+ * @param {string} baseURL the base URL for relative URLs.
21982
+ *
21983
+ * @return {Promise} the Promise.
21984
+ */
21985
 
21986
 
21987
+ function processURL(baseURL) {
21988
+ return meta => ({ ...meta,
21989
+ newUrl: 'url(' + meta.before + meta.quote + getResourcePath(meta.value, baseURL) + meta.quote + meta.after + ')'
21990
+ });
21991
+ }
21992
+ /**
21993
+ * Get all `url()`s, and return the meta info
21994
+ *
21995
+ * @param {string} value decl.value.
21996
+ *
21997
+ * @return {Array} the urls.
21998
+ */
21999
 
 
 
 
 
 
 
 
22000
 
22001
+ function getURLs(value) {
22002
+ const reg = /url\((\s*)(['"]?)(.+?)\2(\s*)\)/g;
22003
+ let match;
22004
+ const URLs = [];
22005
 
22006
+ while ((match = reg.exec(value)) !== null) {
22007
+ const meta = {
22008
+ source: match[0],
22009
+ before: match[1],
22010
+ quote: match[2],
22011
+ value: match[3],
22012
+ after: match[4]
22013
+ };
 
 
 
 
 
 
 
22014
 
22015
+ if (isValidURL(meta)) {
22016
+ URLs.push(meta);
22017
+ }
22018
+ }
 
 
22019
 
22020
+ return URLs;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22021
  }
22022
+ /**
22023
+ * Replace the raw value's `url()` segment to the new value
22024
+ *
22025
+ * @param {string} raw the raw value.
22026
+ * @param {Array} URLs the URLs to replace.
22027
+ *
22028
+ * @return {string} the new value.
22029
+ */
22030
 
22031
+
22032
+ function replaceURLs(raw, URLs) {
22033
+ URLs.forEach(item => {
22034
+ raw = raw.replace(item.source, item.newUrl);
 
 
 
 
 
 
 
22035
  });
22036
+ return raw;
22037
  }
22038
 
22039
+ const rewrite = rootURL => node => {
22040
+ if (node.type === 'declaration') {
22041
+ const updatedURLs = getURLs(node.value).map(processURL(rootURL));
22042
+ return { ...node,
22043
+ value: replaceURLs(node.value, updatedURLs)
22044
+ };
22045
+ }
22046
 
22047
+ return node;
22048
+ };
22049
 
22050
+ /* harmony default export */ var url_rewrite = (rewrite);
22051
+ //# sourceMappingURL=url-rewrite.js.map
22052
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/utils/transform-styles/transforms/wrap.js
22053
  /**
22054
+ * @constant string IS_ROOT_TAG Regex to check if the selector is a root tag selector.
22055
  */
22056
+ const IS_ROOT_TAG = /^(body|html|:root).*$/;
22057
 
22058
+ const wrap = (namespace, ignore = []) => node => {
22059
+ const updateSelector = selector => {
22060
+ if (ignore.includes(selector.trim())) {
22061
+ return selector;
22062
+ } // Anything other than a root tag is always prefixed.
22063
 
22064
 
22065
+ {
22066
+ if (!selector.match(IS_ROOT_TAG)) {
22067
+ return namespace + ' ' + selector;
22068
+ }
22069
+ } // HTML and Body elements cannot be contained within our container so lets extract their styles.
 
 
 
22070
 
22071
+ return selector.replace(/^(body|html|:root)/, namespace);
22072
+ };
 
22073
 
22074
+ if (node.type === 'rule') {
22075
+ return { ...node,
22076
+ selectors: node.selectors.map(updateSelector)
22077
+ };
22078
+ }
22079
+
22080
+ return node;
22081
+ };
22082
 
22083
+ /* harmony default export */ var transforms_wrap = (wrap);
22084
+ //# sourceMappingURL=wrap.js.map
22085
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/utils/transform-styles/index.js
22086
  /**
22087
+ * External dependencies
22088
  */
22089
 
22090
+ /**
22091
+ * WordPress dependencies
22092
+ */
22093
 
22094
 
22095
  /**
22099
 
22100
 
22101
 
22102
+ /**
22103
+ * Applies a series of CSS rule transforms to wrap selectors inside a given class and/or rewrite URLs depending on the parameters passed.
22104
+ *
22105
+ * @param {Array} styles CSS rules.
22106
+ * @param {string} wrapperClassName Wrapper Class Name.
22107
+ * @return {Array} converted rules.
22108
+ */
22109
 
22110
+ const transformStyles = (styles, wrapperClassName = '') => {
22111
+ return (0,external_lodash_namespaceObject.map)(styles, ({
22112
+ css,
22113
+ baseURL,
22114
+ __experimentalNoWrapper = false
22115
+ }) => {
22116
+ const transforms = [];
22117
 
22118
+ if (wrapperClassName && !__experimentalNoWrapper) {
22119
+ transforms.push(transforms_wrap(wrapperClassName));
22120
+ }
 
 
 
 
 
 
 
 
22121
 
22122
+ if (baseURL) {
22123
+ transforms.push(url_rewrite(baseURL));
22124
+ }
22125
 
22126
+ if (transforms.length) {
22127
+ return transform_styles_traverse(css, (0,external_wp_compose_namespaceObject.compose)(transforms));
22128
+ }
 
 
 
 
 
 
22129
 
22130
+ return css;
22131
+ });
22132
+ };
 
 
 
 
 
 
 
22133
 
22134
+ /* harmony default export */ var transform_styles = (transformStyles);
22135
+ //# sourceMappingURL=index.js.map
22136
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/editor-styles/index.js
22137
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22138
 
 
 
 
 
 
 
 
 
22139
  /**
22140
  * External dependencies
22141
  */
22145
  */
22146
 
22147
 
 
 
 
 
22148
  /**
22149
  * Internal dependencies
22150
  */
22151
 
22152
 
22153
+ const EDITOR_STYLES_SELECTOR = '.editor-styles-wrapper';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22154
 
22155
+ function useDarkThemeBodyClassName(styles) {
22156
+ return (0,external_wp_element_namespaceObject.useCallback)(node => {
22157
+ if (!node) {
22158
+ return;
 
 
 
 
 
 
 
 
22159
  }
22160
 
22161
+ const {
22162
+ ownerDocument
22163
+ } = node;
22164
+ const {
22165
+ defaultView,
22166
+ body
22167
+ } = ownerDocument;
22168
+ const canvas = ownerDocument.querySelector(EDITOR_STYLES_SELECTOR);
22169
+ let backgroundColor;
 
 
 
 
22170
 
22171
+ if (!canvas) {
22172
+ // The real .editor-styles-wrapper element might not exist in the
22173
+ // DOM, so calculate the background color by creating a fake
22174
+ // wrapper.
22175
+ const tempCanvas = ownerDocument.createElement('div');
22176
+ tempCanvas.classList.add('editor-styles-wrapper');
22177
+ body.appendChild(tempCanvas);
22178
+ backgroundColor = defaultView.getComputedStyle(tempCanvas, null).getPropertyValue('background-color');
22179
+ body.removeChild(tempCanvas);
22180
  } else {
22181
+ backgroundColor = defaultView.getComputedStyle(canvas, null).getPropertyValue('background-color');
22182
+ } // If background is transparent, it should be treated as light color.
22183
 
 
 
 
22184
 
22185
+ if (tinycolor_default()(backgroundColor).getLuminance() > 0.5 || tinycolor_default()(backgroundColor).getAlpha() === 0) {
22186
+ body.classList.remove('is-dark-theme');
 
 
 
 
 
22187
  } else {
22188
+ body.classList.add('is-dark-theme');
22189
  }
22190
+ }, [styles]);
 
22191
  }
22192
 
22193
+ function EditorStyles({
22194
+ styles
22195
+ }) {
22196
+ const transformedStyles = (0,external_wp_element_namespaceObject.useMemo)(() => transform_styles(styles, EDITOR_STYLES_SELECTOR), [styles]);
22197
+ return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("style", {
22198
+ ref: useDarkThemeBodyClassName(styles)
22199
+ }), transformedStyles.map((css, index) => (0,external_wp_element_namespaceObject.createElement)("style", {
22200
+ key: index
22201
+ }, css)));
22202
+ }
22203
+ //# sourceMappingURL=index.js.map
22204
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-preview/auto.js
22205
 
 
 
 
22206
 
22207
  /**
22208
  * WordPress dependencies
22210
 
22211
 
22212
 
 
 
 
22213
  /**
22214
  * Internal dependencies
22215
  */
22217
 
22218
 
22219
 
22220
+ // This is used to avoid rendering the block list if the sizes change.
22221
+
22222
+ let MemoizedBlockList;
22223
+
22224
+ function AutoBlockPreview({
22225
+ viewportWidth,
22226
+ __experimentalPadding
22227
+ }) {
22228
+ const [containerResizeListener, {
22229
+ width: containerWidth
22230
+ }] = (0,external_wp_compose_namespaceObject.useResizeObserver)();
22231
+ const [contentResizeListener, {
22232
+ height: contentHeight
22233
+ }] = (0,external_wp_compose_namespaceObject.useResizeObserver)();
22234
+ const styles = (0,external_wp_data_namespaceObject.useSelect)(select => {
22235
+ return select(store).getSettings().styles;
22236
+ }); // Initialize on render instead of module top level, to avoid circular dependency issues.
22237
+
22238
+ MemoizedBlockList = MemoizedBlockList || (0,external_wp_compose_namespaceObject.pure)(BlockList);
22239
+ const scale = containerWidth / viewportWidth;
22240
+ return (0,external_wp_element_namespaceObject.createElement)("div", {
22241
+ className: "block-editor-block-preview__container"
22242
+ }, containerResizeListener, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Disabled, {
22243
+ className: "block-editor-block-preview__content",
22244
+ style: {
22245
+ transform: `scale(${scale})`,
22246
+ height: contentHeight * scale
22247
+ }
22248
+ }, (0,external_wp_element_namespaceObject.createElement)(iframe, {
22249
+ head: (0,external_wp_element_namespaceObject.createElement)(EditorStyles, {
22250
+ styles: styles
22251
+ }),
22252
+ contentRef: (0,external_wp_compose_namespaceObject.useRefEffect)(bodyElement => {
22253
+ const {
22254
+ ownerDocument: {
22255
+ documentElement
22256
+ }
22257
+ } = bodyElement;
22258
+ documentElement.style.position = 'absolute';
22259
+ documentElement.style.width = '100%';
22260
+ bodyElement.style.padding = __experimentalPadding + 'px';
22261
+ }, []),
22262
+ "aria-hidden": true,
22263
+ tabIndex: -1,
22264
+ style: {
22265
+ position: 'absolute',
22266
+ width: viewportWidth,
22267
+ height: contentHeight,
22268
+ pointerEvents: 'none'
22269
+ }
22270
+ }, contentResizeListener, (0,external_wp_element_namespaceObject.createElement)(MemoizedBlockList, {
22271
+ renderAppender: false
22272
+ }))));
22273
+ }
22274
 
22275
+ /* harmony default export */ var auto = (AutoBlockPreview);
22276
+ //# sourceMappingURL=auto.js.map
22277
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-preview/index.js
22278
 
22279
 
22280
+ /**
22281
+ * External dependencies
22282
+ */
22283
 
22284
+ /**
22285
+ * WordPress dependencies
22286
+ */
22287
 
22288
 
22289
 
 
22290
  /**
22291
+ * Internal dependencies
 
 
 
22292
  */
22293
 
 
22294
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22295
 
 
 
 
 
22296
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22297
 
22298
+ function BlockPreview({
22299
+ blocks,
22300
+ __experimentalPadding = 0,
22301
+ viewportWidth = 1200,
22302
+ __experimentalLive = false,
22303
+ __experimentalOnClick
22304
+ }) {
22305
+ const originalSettings = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).getSettings(), []);
22306
+ const settings = (0,external_wp_element_namespaceObject.useMemo)(() => {
22307
+ const _settings = { ...originalSettings
22308
+ };
22309
+ _settings.__experimentalBlockPatterns = [];
22310
+ return _settings;
22311
+ }, [originalSettings]);
22312
+ const renderedBlocks = (0,external_wp_element_namespaceObject.useMemo)(() => (0,external_lodash_namespaceObject.castArray)(blocks), [blocks]);
22313
 
22314
+ if (!blocks || blocks.length === 0) {
22315
  return null;
22316
+ }
22317
+
22318
+ return (0,external_wp_element_namespaceObject.createElement)(provider, {
22319
+ value: renderedBlocks,
22320
+ settings: settings
22321
+ }, __experimentalLive ? (0,external_wp_element_namespaceObject.createElement)(LiveBlockPreview, {
22322
+ onClick: __experimentalOnClick
22323
+ }) : (0,external_wp_element_namespaceObject.createElement)(auto, {
22324
+ viewportWidth: viewportWidth,
22325
+ __experimentalPadding: __experimentalPadding
22326
  }));
22327
  }
22328
+ /**
22329
+ * BlockPreview renders a preview of a block or array of blocks.
22330
+ *
22331
+ * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-preview/README.md
22332
+ *
22333
+ * @param {Object} preview options for how the preview should be shown
22334
+ * @param {Array|Object} preview.blocks A block instance (object) or an array of blocks to be previewed.
22335
+ * @param {number} preview.viewportWidth Width of the preview container in pixels. Controls at what size the blocks will be rendered inside the preview. Default: 700.
22336
+ *
22337
+ * @return {WPComponent} The component to be rendered.
22338
+ */
22339
 
22340
+ /* harmony default export */ var block_preview = ((0,external_wp_element_namespaceObject.memo)(BlockPreview));
22341
+ //# sourceMappingURL=index.js.map
22342
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/inserter/preview-panel.js
22343
 
22344
 
22345
  /**
22347
  */
22348
 
22349
 
22350
+ /**
22351
+ * Internal dependencies
22352
+ */
22353
 
 
 
 
 
 
 
 
 
22354
 
 
 
 
 
 
22355
 
 
 
 
22356
 
22357
+ function InserterPreviewPanel({
22358
+ item
 
 
 
22359
  }) {
22360
+ var _hoveredItemBlockType, _hoveredItemBlockType2;
 
 
 
 
 
 
 
 
 
22361
 
22362
+ const {
22363
+ name,
22364
+ title,
22365
+ icon,
22366
+ description,
22367
+ initialAttributes
22368
+ } = item;
22369
+ const hoveredItemBlockType = (0,external_wp_blocks_namespaceObject.getBlockType)(name);
22370
+ const isReusable = (0,external_wp_blocks_namespaceObject.isReusableBlock)(item);
22371
+ return (0,external_wp_element_namespaceObject.createElement)("div", {
22372
+ className: "block-editor-inserter__preview-container"
22373
+ }, (0,external_wp_element_namespaceObject.createElement)("div", {
22374
+ className: "block-editor-inserter__preview"
22375
+ }, isReusable || hoveredItemBlockType.example ? (0,external_wp_element_namespaceObject.createElement)("div", {
22376
+ className: "block-editor-inserter__preview-content"
22377
+ }, (0,external_wp_element_namespaceObject.createElement)(block_preview, {
22378
+ __experimentalPadding: 16,
22379
+ viewportWidth: (_hoveredItemBlockType = (_hoveredItemBlockType2 = hoveredItemBlockType.example) === null || _hoveredItemBlockType2 === void 0 ? void 0 : _hoveredItemBlockType2.viewportWidth) !== null && _hoveredItemBlockType !== void 0 ? _hoveredItemBlockType : 500,
22380
+ blocks: hoveredItemBlockType.example ? (0,external_wp_blocks_namespaceObject.getBlockFromExample)(item.name, {
22381
+ attributes: { ...hoveredItemBlockType.example.attributes,
22382
+ ...initialAttributes
22383
+ },
22384
+ innerBlocks: hoveredItemBlockType.example.innerBlocks
22385
+ }) : (0,external_wp_blocks_namespaceObject.createBlock)(name, initialAttributes)
22386
+ })) : (0,external_wp_element_namespaceObject.createElement)("div", {
22387
+ className: "block-editor-inserter__preview-content-missing"
22388
+ }, (0,external_wp_i18n_namespaceObject.__)('No Preview Available.'))), !isReusable && (0,external_wp_element_namespaceObject.createElement)(block_card, {
22389
+ title: title,
22390
+ icon: icon,
22391
+ description: description
22392
+ }));
22393
  }
22394
 
22395
+ /* harmony default export */ var preview_panel = (InserterPreviewPanel);
22396
+ //# sourceMappingURL=preview-panel.js.map
22397
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/inserter-listbox/context.js
 
 
22398
  /**
22399
  * WordPress dependencies
22400
  */
22401
 
22402
+ const InserterListboxContext = (0,external_wp_element_namespaceObject.createContext)();
22403
+ /* harmony default export */ var context = (InserterListboxContext);
22404
+ //# sourceMappingURL=context.js.map
22405
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/inserter-listbox/item.js
22406
 
22407
 
22408
 
22409
  /**
22410
+ * WordPress dependencies
22411
  */
22412
 
22413
 
22414
+ /**
22415
+ * Internal dependencies
22416
+ */
22417
 
22418
 
22419
 
22420
+ function InserterListboxItem({
22421
+ isFirst,
22422
+ as: Component,
22423
+ children,
22424
+ ...props
22425
+ }, ref) {
22426
+ const state = (0,external_wp_element_namespaceObject.useContext)(context);
22427
+ return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableCompositeItem, _extends({
22428
+ ref: ref,
22429
+ state: state,
22430
+ role: "option" // Use the CompositeItem `focusable` prop over Button's
22431
+ // isFocusable. The latter was shown to cause an issue
22432
+ // with tab order in the inserter list.
22433
+ ,
22434
+ focusable: true
22435
+ }, props), htmlProps => {
22436
+ const propsWithTabIndex = { ...htmlProps,
22437
+ tabIndex: isFirst ? 0 : htmlProps.tabIndex
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22438
  };
22439
+
22440
+ if (Component) {
22441
+ return (0,external_wp_element_namespaceObject.createElement)(Component, propsWithTabIndex, children);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22442
  }
22443
 
22444
+ if (typeof children === 'function') {
22445
+ return children(propsWithTabIndex);
22446
+ }
22447
+
22448
+ return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, propsWithTabIndex, children);
22449
+ });
22450
+ }
22451
+
22452
+ /* harmony default export */ var inserter_listbox_item = ((0,external_wp_element_namespaceObject.forwardRef)(InserterListboxItem));
22453
+ //# sourceMappingURL=item.js.map
22454
+ ;// CONCATENATED MODULE: ./packages/icons/build-module/library/drag-handle.js
22455
+
22456
+
22457
+ /**
22458
+ * WordPress dependencies
22459
+ */
22460
+
22461
+ const dragHandle = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
22462
+ width: "18",
22463
+ height: "18",
22464
+ xmlns: "http://www.w3.org/2000/svg",
22465
+ viewBox: "0 0 18 18"
22466
+ }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
22467
+ d: "M5 4h2V2H5v2zm6-2v2h2V2h-2zm-6 8h2V8H5v2zm6 0h2V8h-2v2zm-6 6h2v-2H5v2zm6 0h2v-2h-2v2z"
22468
+ }));
22469
+ /* harmony default export */ var drag_handle = (dragHandle);
22470
+ //# sourceMappingURL=drag-handle.js.map
22471
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-draggable/draggable-chip.js
22472
+
22473
+
22474
+ /**
22475
+ * WordPress dependencies
22476
+ */
22477
+
22478
+
22479
+
22480
+ /**
22481
+ * Internal dependencies
22482
+ */
22483
+
22484
+
22485
+ function BlockDraggableChip({
22486
+ count,
22487
+ icon
22488
+ }) {
22489
  return (0,external_wp_element_namespaceObject.createElement)("div", {
22490
+ className: "block-editor-block-draggable-chip-wrapper"
 
 
22491
  }, (0,external_wp_element_namespaceObject.createElement)("div", {
22492
+ className: "block-editor-block-draggable-chip"
22493
+ }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Flex, {
22494
+ justify: "center",
22495
+ className: "block-editor-block-draggable-chip__content"
22496
+ }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, icon ? (0,external_wp_element_namespaceObject.createElement)(BlockIcon, {
22497
+ icon: icon
22498
+ }) : (0,external_wp_i18n_namespaceObject.sprintf)(
22499
+ /* translators: %d: Number of blocks. */
22500
+ (0,external_wp_i18n_namespaceObject._n)('%d block', '%d blocks', count), count)), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_element_namespaceObject.createElement)(BlockIcon, {
22501
+ icon: drag_handle
22502
+ })))));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22503
  }
22504
+ //# sourceMappingURL=draggable-chip.js.map
22505
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/inserter-draggable-blocks/index.js
22506
+
22507
+
22508
+ /**
22509
+ * WordPress dependencies
22510
+ */
22511
+
22512
+ /**
22513
+ * Internal dependencies
22514
+ */
22515
+
22516
+
22517
+
22518
+ const InserterDraggableBlocks = ({
22519
+ isEnabled,
22520
+ blocks,
22521
+ icon,
22522
+ children
22523
+ }) => {
22524
+ const transferData = {
22525
+ type: 'inserter',
22526
+ blocks
22527
+ };
22528
+ return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Draggable, {
22529
+ __experimentalTransferDataType: "wp-blocks",
22530
+ transferData: transferData,
22531
+ __experimentalDragComponent: (0,external_wp_element_namespaceObject.createElement)(BlockDraggableChip, {
22532
+ count: blocks.length,
22533
+ icon: icon
22534
+ })
22535
+ }, ({
22536
+ onDraggableStart,
22537
+ onDraggableEnd
22538
+ }) => {
22539
+ return children({
22540
+ draggable: isEnabled,
22541
+ onDragStart: isEnabled ? onDraggableStart : undefined,
22542
+ onDragEnd: isEnabled ? onDraggableEnd : undefined
22543
+ });
22544
+ });
22545
+ };
22546
+
22547
+ /* harmony default export */ var inserter_draggable_blocks = (InserterDraggableBlocks);
22548
+ //# sourceMappingURL=index.js.map
22549
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/inserter-list-item/index.js
22550
 
 
 
 
22551
 
22552
 
22553
  /**
22561
 
22562
 
22563
 
 
22564
  /**
22565
  * Internal dependencies
22566
  */
22568
 
22569
 
22570
 
22571
+ /**
22572
+ * Return true if platform is MacOS.
22573
+ *
22574
+ * @param {Object} _window window object by default; used for DI testing.
22575
+ *
22576
+ * @return {boolean} True if MacOS; false otherwise.
22577
+ */
22578
 
22579
+ function isAppleOS(_window = window) {
22580
+ const {
22581
+ platform
22582
+ } = _window.navigator;
22583
+ return platform.indexOf('Mac') !== -1 || ['iPad', 'iPhone'].includes(platform);
22584
+ }
22585
 
22586
+ function InserterListItem({
22587
+ className,
22588
+ isFirst,
22589
+ item,
22590
  onSelect,
22591
+ onHover,
22592
+ isDraggable,
22593
+ ...props
22594
  }) {
22595
+ const isDragging = (0,external_wp_element_namespaceObject.useRef)(false);
22596
+ const itemIconStyle = item.icon ? {
22597
+ backgroundColor: item.icon.background,
22598
+ color: item.icon.foreground
22599
+ } : {};
22600
+ const blocks = (0,external_wp_element_namespaceObject.useMemo)(() => {
22601
+ return [(0,external_wp_blocks_namespaceObject.createBlock)(item.name, item.initialAttributes, (0,external_wp_blocks_namespaceObject.createBlocksFromInnerBlocksTemplate)(item.innerBlocks))];
22602
+ }, [item.name, item.initialAttributes, item.initialAttributes]);
22603
+ return (0,external_wp_element_namespaceObject.createElement)(inserter_draggable_blocks, {
22604
+ isEnabled: isDraggable && !item.disabled,
22605
+ blocks: blocks,
22606
+ icon: item.icon
22607
+ }, ({
22608
+ draggable,
22609
+ onDragStart,
22610
+ onDragEnd
22611
+ }) => (0,external_wp_element_namespaceObject.createElement)("div", {
22612
+ className: "block-editor-block-types-list__list-item",
22613
+ draggable: draggable,
22614
+ onDragStart: event => {
22615
+ isDragging.current = true;
22616
+
22617
+ if (onDragStart) {
22618
+ onHover(null);
22619
+ onDragStart(event);
22620
+ }
22621
+ },
22622
+ onDragEnd: event => {
22623
+ isDragging.current = false;
22624
+
22625
+ if (onDragEnd) {
22626
+ onDragEnd(event);
22627
+ }
22628
  }
22629
+ }, (0,external_wp_element_namespaceObject.createElement)(inserter_listbox_item, _extends({
22630
+ isFirst: isFirst,
22631
+ className: classnames_default()('block-editor-block-types-list__item', className),
22632
+ disabled: item.isDisabled,
22633
+ onClick: event => {
22634
+ event.preventDefault();
22635
+ onSelect(item, isAppleOS() ? event.metaKey : event.ctrlKey);
22636
+ onHover(null);
22637
+ },
22638
+ onKeyDown: event => {
22639
+ const {
22640
+ keyCode
22641
+ } = event;
22642
 
22643
+ if (keyCode === external_wp_keycodes_namespaceObject.ENTER) {
22644
+ event.preventDefault();
22645
+ onSelect(item, isAppleOS() ? event.metaKey : event.ctrlKey);
22646
+ onHover(null);
22647
+ }
22648
+ },
22649
+ onFocus: () => {
22650
+ if (isDragging.current) {
22651
+ return;
22652
+ }
22653
 
22654
+ onHover(item);
 
 
 
 
 
 
 
 
 
22655
  },
22656
+ onMouseEnter: () => {
22657
+ if (isDragging.current) {
22658
+ return;
22659
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22660
 
22661
+ onHover(item);
22662
+ },
22663
+ onMouseLeave: () => onHover(null),
22664
+ onBlur: () => onHover(null)
22665
+ }, props), (0,external_wp_element_namespaceObject.createElement)("span", {
22666
+ className: "block-editor-block-types-list__item-icon",
22667
+ style: itemIconStyle
22668
+ }, (0,external_wp_element_namespaceObject.createElement)(BlockIcon, {
22669
+ icon: item.icon,
22670
+ showColors: true
22671
+ })), (0,external_wp_element_namespaceObject.createElement)("span", {
22672
+ className: "block-editor-block-types-list__item-title"
22673
+ }, item.title))));
22674
+ }
22675
 
22676
+ /* harmony default export */ var inserter_list_item = ((0,external_wp_element_namespaceObject.memo)(InserterListItem));
22677
+ //# sourceMappingURL=index.js.map
22678
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/inserter-listbox/group.js
22679
 
 
 
 
22680
 
22681
 
22682
  /**
22686
 
22687
 
22688
 
22689
+ function InserterListboxGroup(props, ref) {
22690
+ const [shouldSpeak, setShouldSpeak] = (0,external_wp_element_namespaceObject.useState)(false);
22691
+ (0,external_wp_element_namespaceObject.useEffect)(() => {
22692
+ if (shouldSpeak) {
22693
+ (0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.__)('Use left and right arrow keys to move through blocks'));
22694
+ }
22695
+ }, [shouldSpeak]);
22696
+ return (0,external_wp_element_namespaceObject.createElement)("div", _extends({
22697
+ ref: ref,
22698
+ role: "listbox",
22699
+ "aria-orientation": "horizontal",
22700
+ onFocus: () => {
22701
+ setShouldSpeak(true);
22702
+ },
22703
+ onBlur: event => {
22704
+ const focusingOutsideGroup = !event.currentTarget.contains(event.relatedTarget);
22705
+
22706
+ if (focusingOutsideGroup) {
22707
+ setShouldSpeak(false);
22708
+ }
22709
+ }
22710
+ }, props));
22711
+ }
22712
+
22713
+ /* harmony default export */ var group = ((0,external_wp_element_namespaceObject.forwardRef)(InserterListboxGroup));
22714
+ //# sourceMappingURL=group.js.map
22715
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/inserter-listbox/row.js
22716
 
22717
 
22718
 
22719
+ /**
22720
+ * WordPress dependencies
22721
+ */
22722
 
22723
 
22724
  /**
22727
 
22728
 
22729
 
22730
+ function InserterListboxRow(props, ref) {
22731
+ const state = (0,external_wp_element_namespaceObject.useContext)(context);
22732
+ return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableCompositeGroup, _extends({
22733
+ state: state,
22734
+ role: "presentation",
22735
+ ref: ref
22736
+ }, props));
22737
+ }
22738
 
22739
+ /* harmony default export */ var inserter_listbox_row = ((0,external_wp_element_namespaceObject.forwardRef)(InserterListboxRow));
22740
+ //# sourceMappingURL=row.js.map
22741
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-types-list/index.js
22742
 
 
 
 
 
 
 
 
 
 
22743
 
22744
+ /**
22745
+ * WordPress dependencies
22746
+ */
 
 
 
22747
 
22748
+ /**
22749
+ * Internal dependencies
22750
+ */
 
22751
 
 
 
 
 
22752
 
 
 
 
 
22753
 
 
 
 
 
 
 
 
 
 
 
 
22754
 
22755
+ function chunk(array, size) {
22756
+ const chunks = [];
22757
+
22758
+ for (let i = 0, j = array.length; i < j; i += size) {
22759
+ chunks.push(array.slice(i, i + size));
 
22760
  }
22761
 
22762
+ return chunks;
22763
+ }
 
 
22764
 
22765
+ function BlockTypesList({
22766
+ items = [],
22767
+ onSelect,
22768
+ onHover = () => {},
22769
+ children,
22770
+ label,
22771
+ isDraggable = true
22772
+ }) {
22773
+ return (0,external_wp_element_namespaceObject.createElement)(group, {
22774
+ className: "block-editor-block-types-list",
22775
+ "aria-label": label
22776
+ }, chunk(items, 3).map((row, i) => (0,external_wp_element_namespaceObject.createElement)(inserter_listbox_row, {
22777
+ key: i
22778
+ }, row.map((item, j) => (0,external_wp_element_namespaceObject.createElement)(inserter_list_item, {
22779
+ key: item.id,
22780
+ item: item,
22781
+ className: (0,external_wp_blocks_namespaceObject.getBlockMenuDefaultClassName)(item.id),
22782
+ onSelect: onSelect,
22783
+ onHover: onHover,
22784
+ isDraggable: isDraggable,
22785
+ isFirst: i === 0 && j === 0
22786
+ })))), children);
22787
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22788
 
22789
+ /* harmony default export */ var block_types_list = (BlockTypesList);
22790
+ //# sourceMappingURL=index.js.map
22791
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/inserter/panel.js
 
 
 
 
 
 
 
22792
 
 
 
 
 
 
 
 
 
22793
 
22794
+ /**
22795
+ * WordPress dependencies
22796
+ */
 
 
22797
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22798
 
22799
+ function InserterPanel({
22800
+ title,
22801
+ icon,
22802
+ children
22803
+ }) {
22804
+ return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("div", {
22805
+ className: "block-editor-inserter__panel-header"
22806
+ }, (0,external_wp_element_namespaceObject.createElement)("h2", {
22807
+ className: "block-editor-inserter__panel-title"
22808
+ }, title), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Icon, {
22809
+ icon: icon
22810
+ })), (0,external_wp_element_namespaceObject.createElement)("div", {
22811
+ className: "block-editor-inserter__panel-content"
22812
+ }, children));
22813
  }
22814
 
22815
+ /* harmony default export */ var panel = (InserterPanel);
22816
+ //# sourceMappingURL=panel.js.map
22817
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/inserter/hooks/use-block-types-state.js
22818
+ /**
22819
+ * WordPress dependencies
22820
+ */
 
 
 
 
 
 
 
22821
 
 
22822
 
 
 
22823
 
22824
+ /**
22825
+ * Internal dependencies
22826
+ */
22827
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22828
 
22829
+ /**
22830
+ * Retrieves the block types inserter state.
22831
+ *
22832
+ * @param {string=} rootClientId Insertion's root client ID.
22833
+ * @param {Function} onInsert function called when inserter a list of blocks.
22834
+ * @return {Array} Returns the block types state. (block types, categories, collections, onSelect handler)
22835
+ */
22836
 
22837
+ const useBlockTypesState = (rootClientId, onInsert) => {
22838
+ const {
22839
+ categories,
22840
+ collections,
22841
+ items
22842
+ } = (0,external_wp_data_namespaceObject.useSelect)(select => {
22843
+ const {
22844
+ getInserterItems
22845
+ } = select(store);
22846
+ const {
22847
+ getCategories,
22848
+ getCollections
22849
+ } = select(external_wp_blocks_namespaceObject.store);
22850
+ return {
22851
+ categories: getCategories(),
22852
+ collections: getCollections(),
22853
+ items: getInserterItems(rootClientId)
22854
+ };
22855
+ }, [rootClientId]);
22856
+ const onSelectItem = (0,external_wp_element_namespaceObject.useCallback)(({
22857
+ name,
22858
+ initialAttributes,
22859
+ innerBlocks
22860
+ }, shouldFocusBlock) => {
22861
+ const insertedBlock = (0,external_wp_blocks_namespaceObject.createBlock)(name, initialAttributes, (0,external_wp_blocks_namespaceObject.createBlocksFromInnerBlocksTemplate)(innerBlocks));
22862
+ onInsert(insertedBlock, undefined, shouldFocusBlock);
22863
+ }, [onInsert]);
22864
+ return [items, categories, collections, onSelectItem];
22865
+ };
22866
 
22867
+ /* harmony default export */ var use_block_types_state = (useBlockTypesState);
22868
+ //# sourceMappingURL=use-block-types-state.js.map
22869
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/inserter-listbox/index.js
22870
 
22871
 
22872
+ /**
22873
+ * WordPress dependencies
22874
+ */
22875
 
22876
+ /**
22877
+ * Internal dependencies
22878
+ */
22879
 
22880
 
 
 
22881
 
 
 
 
 
 
22882
 
 
 
 
22883
 
 
 
 
 
22884
 
22885
+ function InserterListbox({
22886
+ children
22887
+ }) {
22888
+ const compositeState = (0,external_wp_components_namespaceObject.__unstableUseCompositeState)({
22889
+ shift: true,
22890
+ wrap: 'horizontal'
22891
+ });
22892
+ return (0,external_wp_element_namespaceObject.createElement)(context.Provider, {
22893
+ value: compositeState
22894
+ }, children);
22895
+ }
22896
+
22897
+ /* harmony default export */ var inserter_listbox = (InserterListbox);
22898
  //# sourceMappingURL=index.js.map
22899
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/inserter/block-types-tab.js
22900
 
22901
 
22902
  /**
22910
 
22911
 
22912
 
 
 
22913
  /**
22914
  * Internal dependencies
22915
  */
22916
 
22917
 
22918
 
22919
+
22920
+
22921
+
22922
+ const getBlockNamespace = item => item.name.split('/')[0];
22923
+
22924
+ const MAX_SUGGESTED_ITEMS = 6;
22925
  /**
22926
+ * Shared reference to an empty array for cases where it is important to avoid
22927
+ * returning a new array reference on every invocation and rerendering the component.
22928
+ *
22929
+ * @type {Array}
22930
  */
22931
 
22932
+ const block_types_tab_EMPTY_ARRAY = [];
22933
+ function BlockTypesTab({
22934
+ rootClientId,
22935
+ onInsert,
22936
+ onHover,
22937
+ showMostUsedBlocks
 
 
22938
  }) {
22939
+ const [items, categories, collections, onSelectItem] = use_block_types_state(rootClientId, onInsert);
22940
+ const suggestedItems = (0,external_wp_element_namespaceObject.useMemo)(() => {
22941
+ return (0,external_lodash_namespaceObject.orderBy)(items, ['frecency'], ['desc']).slice(0, MAX_SUGGESTED_ITEMS);
22942
+ }, [items]);
22943
+ const uncategorizedItems = (0,external_wp_element_namespaceObject.useMemo)(() => {
22944
+ return items.filter(item => !item.category);
22945
+ }, [items]);
22946
+ const itemsPerCategory = (0,external_wp_element_namespaceObject.useMemo)(() => {
22947
+ return (0,external_lodash_namespaceObject.flow)(itemList => itemList.filter(item => item.category && item.category !== 'reusable'), itemList => (0,external_lodash_namespaceObject.groupBy)(itemList, 'category'))(items);
22948
+ }, [items]);
22949
+ const itemsPerCollection = (0,external_wp_element_namespaceObject.useMemo)(() => {
22950
+ // Create a new Object to avoid mutating collection.
22951
+ const result = { ...collections
22952
+ };
22953
+ Object.keys(collections).forEach(namespace => {
22954
+ result[namespace] = items.filter(item => getBlockNamespace(item) === namespace);
22955
 
22956
+ if (result[namespace].length === 0) {
22957
+ delete result[namespace];
22958
+ }
22959
+ });
22960
+ return result;
22961
+ }, [items, collections]); // Hide block preview on unmount.
22962
 
22963
+ (0,external_wp_element_namespaceObject.useEffect)(() => () => onHover(null), []);
22964
+ /**
22965
+ * The inserter contains a big number of blocks and opening it is a costful operation.
22966
+ * The rendering is the most costful part of it, in order to improve the responsiveness
22967
+ * of the "opening" action, these lazy lists allow us to render the inserter category per category,
22968
+ * once all the categories are rendered, we start rendering the collections and the uncategorized block types.
22969
+ */
22970
+
22971
+ const currentlyRenderedCategories = (0,external_wp_compose_namespaceObject.useAsyncList)(categories);
22972
+ const didRenderAllCategories = categories.length === currentlyRenderedCategories.length; // Async List requires an array
22973
+
22974
+ const collectionEntries = (0,external_wp_element_namespaceObject.useMemo)(() => {
22975
+ return Object.entries(collections);
22976
+ }, [collections]);
22977
+ const currentlyRenderedCollections = (0,external_wp_compose_namespaceObject.useAsyncList)(didRenderAllCategories ? collectionEntries : block_types_tab_EMPTY_ARRAY);
22978
+ return (0,external_wp_element_namespaceObject.createElement)(inserter_listbox, null, (0,external_wp_element_namespaceObject.createElement)("div", null, showMostUsedBlocks && !!suggestedItems.length && (0,external_wp_element_namespaceObject.createElement)(panel, {
22979
+ title: (0,external_wp_i18n_namespaceObject._x)('Most used', 'blocks')
22980
+ }, (0,external_wp_element_namespaceObject.createElement)(block_types_list, {
22981
+ items: suggestedItems,
22982
+ onSelect: onSelectItem,
22983
+ onHover: onHover,
22984
+ label: (0,external_wp_i18n_namespaceObject._x)('Most used', 'blocks')
22985
+ })), (0,external_lodash_namespaceObject.map)(currentlyRenderedCategories, category => {
22986
+ const categoryItems = itemsPerCategory[category.slug];
22987
+
22988
+ if (!categoryItems || !categoryItems.length) {
22989
+ return null;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22990
  }
22991
 
22992
+ return (0,external_wp_element_namespaceObject.createElement)(panel, {
22993
+ key: category.slug,
22994
+ title: category.title,
22995
+ icon: category.icon
22996
+ }, (0,external_wp_element_namespaceObject.createElement)(block_types_list, {
22997
+ items: categoryItems,
22998
+ onSelect: onSelectItem,
22999
+ onHover: onHover,
23000
+ label: category.title
23001
+ }));
23002
+ }), didRenderAllCategories && uncategorizedItems.length > 0 && (0,external_wp_element_namespaceObject.createElement)(panel, {
23003
+ className: "block-editor-inserter__uncategorized-blocks-panel",
23004
+ title: (0,external_wp_i18n_namespaceObject.__)('Uncategorized')
23005
+ }, (0,external_wp_element_namespaceObject.createElement)(block_types_list, {
23006
+ items: uncategorizedItems,
23007
+ onSelect: onSelectItem,
23008
+ onHover: onHover,
23009
+ label: (0,external_wp_i18n_namespaceObject.__)('Uncategorized')
23010
+ })), (0,external_lodash_namespaceObject.map)(currentlyRenderedCollections, ([namespace, collection]) => {
23011
+ const collectionItems = itemsPerCollection[namespace];
23012
+
23013
+ if (!collectionItems || !collectionItems.length) {
23014
+ return null;
23015
+ }
23016
+
23017
+ return (0,external_wp_element_namespaceObject.createElement)(panel, {
23018
+ key: namespace,
23019
+ title: collection.title,
23020
+ icon: collection.icon
23021
+ }, (0,external_wp_element_namespaceObject.createElement)(block_types_list, {
23022
+ items: collectionItems,
23023
+ onSelect: onSelectItem,
23024
+ onHover: onHover,
23025
+ label: collection.title
23026
+ }));
23027
+ })));
23028
+ }
23029
+ /* harmony default export */ var block_types_tab = (BlockTypesTab);
23030
+ //# sourceMappingURL=block-types-tab.js.map
23031
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/inserter/pattern-panel.js
23032
 
23033
 
23034
  /**
23042
 
23043
 
23044
 
23045
+ function PatternInserterPanel({
23046
+ selectedCategory,
23047
+ patternCategories,
23048
+ onClickCategory,
23049
+ children
23050
+ }) {
23051
+ const categoryOptions = () => {
23052
+ const options = [];
23053
+ patternCategories.map(patternCategory => {
23054
+ return options.push({
23055
+ value: patternCategory.name,
23056
+ label: patternCategory.label
23057
+ });
23058
+ });
23059
+ return options;
23060
+ };
23061
 
23062
+ const onChangeSelect = selected => {
23063
+ onClickCategory(patternCategories.find(patternCategory => selected === patternCategory.name));
23064
+ };
23065
 
23066
+ const getPanelHeaderClassName = () => {
23067
+ return classnames_default()('block-editor-inserter__panel-header', 'block-editor-inserter__panel-header-patterns');
23068
+ }; // In iOS-based mobile devices, the onBlur will fire when selecting an option
23069
+ // from a Select element. To prevent closing the useDialog on iOS devices, we
23070
+ // stop propagating the onBlur event if there is no relatedTarget, which means
23071
+ // that the user most likely did not click on an element within the editor canvas.
23072
 
23073
 
23074
+ const onBlur = event => {
23075
+ if (!(event !== null && event !== void 0 && event.relatedTarget)) {
23076
+ event.stopPropagation();
23077
+ }
23078
+ };
23079
+
23080
+ return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("div", {
23081
+ className: getPanelHeaderClassName()
23082
+ }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SelectControl, {
23083
+ className: "block-editor-inserter__panel-dropdown",
23084
+ label: (0,external_wp_i18n_namespaceObject.__)('Filter patterns'),
23085
+ hideLabelFromVision: true,
23086
+ value: selectedCategory.name,
23087
+ onChange: onChangeSelect,
23088
+ onBlur: onBlur,
23089
+ options: categoryOptions()
23090
+ })), (0,external_wp_element_namespaceObject.createElement)("div", {
23091
+ className: "block-editor-inserter__panel-content"
23092
+ }, children));
23093
+ }
23094
+
23095
+ /* harmony default export */ var pattern_panel = (PatternInserterPanel);
23096
+ //# sourceMappingURL=pattern-panel.js.map
23097
+ ;// CONCATENATED MODULE: external ["wp","notices"]
23098
+ var external_wp_notices_namespaceObject = window["wp"]["notices"];
23099
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/inserter/hooks/use-patterns-state.js
23100
+ /**
23101
+ * External dependencies
23102
+ */
23103
+
23104
+ /**
23105
+ * WordPress dependencies
23106
+ */
23107
+
23108
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23109
 
 
 
 
 
 
 
23110
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23111
 
 
 
 
 
 
23112
 
 
 
 
 
 
23113
  /**
23114
+ * Internal dependencies
 
 
23115
  */
23116
 
23117
 
 
 
 
 
 
 
23118
  /**
23119
+ * Retrieves the block patterns inserter state.
23120
+ *
23121
+ * @param {Function} onInsert function called when inserter a list of blocks.
23122
+ * @param {string=} rootClientId Insertion's root client ID.
23123
+ *
23124
+ * @return {Array} Returns the patterns state. (patterns, categories, onSelect handler)
23125
  */
23126
 
23127
+ const usePatternsState = (onInsert, rootClientId) => {
23128
+ const {
23129
+ patternCategories,
23130
+ patterns
23131
+ } = (0,external_wp_data_namespaceObject.useSelect)(select => {
23132
+ const {
23133
+ __experimentalGetAllowedPatterns,
23134
+ getSettings
23135
+ } = select(store);
23136
+ return {
23137
+ patterns: __experimentalGetAllowedPatterns(rootClientId),
23138
+ patternCategories: getSettings().__experimentalBlockPatternCategories
23139
+ };
23140
+ }, [rootClientId]);
23141
+ const {
23142
+ createSuccessNotice
23143
+ } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
23144
+ const onClickPattern = (0,external_wp_element_namespaceObject.useCallback)((pattern, blocks) => {
23145
+ onInsert((0,external_lodash_namespaceObject.map)(blocks, block => (0,external_wp_blocks_namespaceObject.cloneBlock)(block)), pattern.name);
23146
+ createSuccessNotice((0,external_wp_i18n_namespaceObject.sprintf)(
23147
+ /* translators: %s: block pattern title. */
23148
+ (0,external_wp_i18n_namespaceObject.__)('Block pattern "%s" inserted.'), pattern.title), {
23149
+ type: 'snackbar'
23150
+ });
23151
+ }, []);
23152
+ return [patterns, patternCategories, onClickPattern];
23153
+ };
23154
 
23155
+ /* harmony default export */ var use_patterns_state = (usePatternsState);
23156
+ //# sourceMappingURL=use-patterns-state.js.map
23157
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-patterns-list/index.js
23158
 
 
 
 
23159
 
23160
 
23161
  /**
23164
 
23165
 
23166
 
23167
+
23168
  /**
23169
  * Internal dependencies
23170
  */
23173
 
23174
 
23175
 
23176
+ function BlockPattern({
23177
+ isDraggable,
23178
+ pattern,
23179
+ onClick,
23180
+ composite
 
 
 
 
23181
  }) {
23182
+ const {
23183
+ name,
23184
+ viewportWidth
23185
+ } = pattern;
23186
+ const {
23187
+ blocks
23188
+ } = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).__experimentalGetParsedPattern(name), [name]);
23189
+ const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(BlockPattern);
23190
+ const descriptionId = `block-editor-block-patterns-list__item-description-${instanceId}`;
23191
+ return (0,external_wp_element_namespaceObject.createElement)(inserter_draggable_blocks, {
23192
+ isEnabled: isDraggable,
23193
+ blocks: blocks
23194
+ }, ({
23195
+ draggable,
23196
+ onDragStart,
23197
+ onDragEnd
23198
+ }) => (0,external_wp_element_namespaceObject.createElement)("div", {
23199
+ className: "block-editor-block-patterns-list__list-item",
23200
+ "aria-label": pattern.title,
23201
+ "aria-describedby": pattern.description ? descriptionId : undefined,
23202
+ draggable: draggable,
23203
+ onDragStart: onDragStart,
23204
+ onDragEnd: onDragEnd
23205
+ }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableCompositeItem, _extends({
23206
+ role: "option",
23207
+ as: "div"
23208
+ }, composite, {
23209
+ className: "block-editor-block-patterns-list__item",
23210
+ onClick: () => onClick(pattern, blocks)
23211
+ }), (0,external_wp_element_namespaceObject.createElement)(block_preview, {
23212
+ blocks: blocks,
23213
+ viewportWidth: viewportWidth
23214
+ }), (0,external_wp_element_namespaceObject.createElement)("div", {
23215
+ className: "block-editor-block-patterns-list__item-title"
23216
+ }, pattern.title), !!pattern.description && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, {
23217
+ id: descriptionId
23218
+ }, pattern.description))));
23219
+ }
23220
 
23221
+ function BlockPatternPlaceholder() {
23222
+ return (0,external_wp_element_namespaceObject.createElement)("div", {
23223
+ className: "block-editor-block-patterns-list__item is-placeholder"
23224
+ });
23225
+ }
23226
 
23227
+ function BlockPatternList({
23228
+ isDraggable,
23229
+ blockPatterns,
23230
+ shownPatterns,
23231
+ onClickPattern,
23232
+ orientation,
23233
+ label = (0,external_wp_i18n_namespaceObject.__)('Block Patterns')
23234
+ }) {
23235
+ const composite = (0,external_wp_components_namespaceObject.__unstableUseCompositeState)({
23236
+ orientation
23237
+ });
23238
+ return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableComposite, _extends({}, composite, {
23239
+ role: "listbox",
23240
+ className: "block-editor-block-patterns-list",
23241
+ "aria-label": label
23242
+ }), blockPatterns.map(pattern => {
23243
+ const isShown = shownPatterns.includes(pattern);
23244
+ return isShown ? (0,external_wp_element_namespaceObject.createElement)(BlockPattern, {
23245
+ key: pattern.name,
23246
+ pattern: pattern,
23247
+ onClick: onClickPattern,
23248
+ isDraggable: isDraggable,
23249
+ composite: composite
23250
+ }) : (0,external_wp_element_namespaceObject.createElement)(BlockPatternPlaceholder, {
23251
+ key: pattern.name
23252
+ });
23253
+ }));
23254
+ }
23255
 
23256
+ /* harmony default export */ var block_patterns_list = (BlockPatternList);
23257
+ //# sourceMappingURL=index.js.map
23258
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/inserter/block-patterns-tab.js
23259
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23260
 
23261
+ /**
23262
+ * External dependencies
23263
+ */
 
 
 
 
 
 
 
 
 
 
23264
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23265
  /**
23266
  * WordPress dependencies
23267
  */
23268
 
23269
 
23270
 
23271
+
23272
  /**
23273
  * Internal dependencies
23274
  */
23275
 
23276
 
 
23277
 
 
 
 
 
 
 
 
23278
 
 
 
 
 
 
 
 
 
23279
 
23280
+ function BlockPatternsCategory({
23281
+ rootClientId,
23282
+ onInsert,
23283
+ selectedCategory,
23284
+ onClickCategory
23285
+ }) {
23286
+ const [allPatterns, allCategories, onClick] = use_patterns_state(onInsert, rootClientId); // Remove any empty categories
23287
 
23288
+ const populatedCategories = (0,external_wp_element_namespaceObject.useMemo)(() => allCategories.filter(category => allPatterns.some(pattern => {
23289
+ var _pattern$categories;
 
 
 
23290
 
23291
+ return (_pattern$categories = pattern.categories) === null || _pattern$categories === void 0 ? void 0 : _pattern$categories.includes(category.name);
23292
+ })), [allPatterns, allCategories]);
23293
+ const patternCategory = selectedCategory ? selectedCategory : populatedCategories[0];
23294
+ (0,external_wp_element_namespaceObject.useEffect)(() => {
23295
+ if (allPatterns.some(pattern => getPatternIndex(pattern) === Infinity) && !populatedCategories.find(category => category.name === 'uncategorized')) {
23296
+ populatedCategories.push({
23297
+ name: 'uncategorized',
23298
+ label: (0,external_wp_i18n_namespaceObject._x)('Uncategorized')
23299
+ });
23300
+ }
23301
+ }, [populatedCategories, allPatterns]);
23302
+ const getPatternIndex = (0,external_wp_element_namespaceObject.useCallback)(pattern => {
23303
+ if (!pattern.categories || !pattern.categories.length) {
23304
+ return Infinity;
23305
+ }
23306
 
23307
+ const indexedCategories = (0,external_lodash_namespaceObject.fromPairs)(populatedCategories.map(({
23308
+ name
23309
+ }, index) => [name, index]));
23310
+ return Math.min(...pattern.categories.map(cat => indexedCategories[cat] !== undefined ? indexedCategories[cat] : Infinity));
23311
+ }, [populatedCategories]);
23312
+ const currentCategoryPatterns = (0,external_wp_element_namespaceObject.useMemo)(() => allPatterns.filter(pattern => patternCategory.name === 'uncategorized' ? getPatternIndex(pattern) === Infinity : pattern.categories && pattern.categories.includes(patternCategory.name)), [allPatterns, patternCategory]); // Ordering the patterns is important for the async rendering.
 
 
23313
 
23314
+ const orderedPatterns = (0,external_wp_element_namespaceObject.useMemo)(() => {
23315
+ return currentCategoryPatterns.sort((a, b) => {
23316
+ return getPatternIndex(a) - getPatternIndex(b);
23317
+ });
23318
+ }, [currentCategoryPatterns, getPatternIndex]);
23319
+ const currentShownPatterns = (0,external_wp_compose_namespaceObject.useAsyncList)(orderedPatterns);
23320
+ return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, !!currentCategoryPatterns.length && (0,external_wp_element_namespaceObject.createElement)(pattern_panel, {
23321
+ selectedCategory: patternCategory,
23322
+ patternCategories: populatedCategories,
23323
+ onClickCategory: onClickCategory
23324
+ }, (0,external_wp_element_namespaceObject.createElement)(block_patterns_list, {
23325
+ shownPatterns: currentShownPatterns,
23326
+ blockPatterns: currentCategoryPatterns,
23327
+ onClickPattern: onClick,
23328
+ label: patternCategory.label,
23329
+ orientation: "vertical",
23330
+ isDraggable: true
23331
+ })));
23332
+ }
23333
 
23334
+ function BlockPatternsTabs({
23335
+ rootClientId,
23336
+ onInsert,
23337
+ onClickCategory,
23338
+ selectedCategory
23339
+ }) {
23340
+ return (0,external_wp_element_namespaceObject.createElement)(BlockPatternsCategory, {
23341
+ rootClientId: rootClientId,
23342
+ selectedCategory: selectedCategory,
23343
+ onInsert: onInsert,
23344
+ onClickCategory: onClickCategory
23345
+ });
23346
+ }
23347
 
23348
+ /* harmony default export */ var block_patterns_tab = (BlockPatternsTabs);
23349
+ //# sourceMappingURL=block-patterns-tab.js.map
23350
+ ;// CONCATENATED MODULE: external ["wp","url"]
23351
+ var external_wp_url_namespaceObject = window["wp"]["url"];
23352
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/inserter/no-results.js
23353
 
 
 
 
 
 
23354
 
23355
+ /**
23356
+ * WordPress dependencies
23357
+ */
23358
 
 
 
 
23359
 
 
 
 
 
23360
 
23361
+ function InserterNoResults() {
23362
+ return (0,external_wp_element_namespaceObject.createElement)("div", {
23363
+ className: "block-editor-inserter__no-results"
23364
+ }, (0,external_wp_element_namespaceObject.createElement)(icon, {
23365
+ className: "block-editor-inserter__no-results-icon",
23366
+ icon: block_default
23367
+ }), (0,external_wp_element_namespaceObject.createElement)("p", null, (0,external_wp_i18n_namespaceObject.__)('No results found.')));
23368
  }
 
 
 
 
 
 
 
 
 
 
 
 
23369
 
23370
+ /* harmony default export */ var no_results = (InserterNoResults);
23371
+ //# sourceMappingURL=no-results.js.map
23372
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/inserter/reusable-blocks-tab.js
 
 
23373
 
 
23374
 
 
 
 
 
 
 
23375
  /**
23376
+ * WordPress dependencies
 
 
 
 
 
 
23377
  */
23378
 
 
 
 
 
 
 
23379
 
23380
+
 
 
 
 
23381
  /**
23382
+ * Internal dependencies
 
 
 
 
 
23383
  */
23384
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23385
 
 
23386
 
 
23387
 
 
23388
 
 
 
 
23389
 
23390
+ function ReusableBlocksList({
23391
+ onHover,
23392
+ onInsert,
23393
+ rootClientId
23394
+ }) {
23395
+ const [items,,, onSelectItem] = use_block_types_state(rootClientId, onInsert);
23396
+ const filteredItems = (0,external_wp_element_namespaceObject.useMemo)(() => {
23397
+ return items.filter(({
23398
+ category
23399
+ }) => category === 'reusable');
23400
+ }, [items]);
 
 
 
 
 
23401
 
23402
+ if (filteredItems.length === 0) {
23403
+ return (0,external_wp_element_namespaceObject.createElement)(no_results, null);
23404
+ }
23405
+
23406
+ return (0,external_wp_element_namespaceObject.createElement)(panel, {
23407
+ title: (0,external_wp_i18n_namespaceObject.__)('Reusable blocks')
23408
+ }, (0,external_wp_element_namespaceObject.createElement)(block_types_list, {
23409
+ items: filteredItems,
23410
+ onSelect: onSelectItem,
23411
+ onHover: onHover,
23412
+ label: (0,external_wp_i18n_namespaceObject.__)('Reusable blocks')
23413
+ }));
23414
+ } // The unwrapped component is only exported for use by unit tests.
23415
 
23416
  /**
23417
+ * List of reusable blocks shown in the "Reusable" tab of the inserter.
 
 
 
 
 
23418
  *
23419
+ * @param {Object} props Component props.
23420
+ * @param {?string} props.rootClientId Client id of block to insert into.
23421
+ * @param {Function} props.onInsert Callback to run when item is inserted.
23422
+ * @param {Function} props.onHover Callback to run when item is hovered.
23423
  *
23424
+ * @return {WPComponent} The component.
 
 
23425
  */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23426
 
 
 
 
 
 
 
 
23427
 
23428
+ function ReusableBlocksTab({
23429
+ rootClientId,
23430
+ onInsert,
23431
+ onHover
23432
+ }) {
23433
+ return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(ReusableBlocksList, {
23434
+ onHover: onHover,
23435
+ onInsert: onInsert,
23436
+ rootClientId: rootClientId
23437
+ }), (0,external_wp_element_namespaceObject.createElement)("div", {
23438
+ className: "block-editor-inserter__manage-reusable-blocks-container"
23439
+ }, (0,external_wp_element_namespaceObject.createElement)("a", {
23440
+ className: "block-editor-inserter__manage-reusable-blocks",
23441
+ href: (0,external_wp_url_namespaceObject.addQueryArgs)('edit.php', {
23442
+ post_type: 'wp_block'
23443
+ })
23444
+ }, (0,external_wp_i18n_namespaceObject.__)('Manage Reusable blocks'))));
23445
  }
23446
+ /* harmony default export */ var reusable_blocks_tab = (ReusableBlocksTab);
23447
+ //# sourceMappingURL=reusable-blocks-tab.js.map
23448
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/inserter-menu-extension/index.js
23449
  /**
23450
+ * WordPress dependencies
 
 
 
 
 
 
 
 
 
23451
  */
23452
 
23453
+ const {
23454
+ Fill: __unstableInserterMenuExtension,
23455
+ Slot
23456
+ } = (0,external_wp_components_namespaceObject.createSlotFill)('__unstableInserterMenuExtension');
23457
+ __unstableInserterMenuExtension.Slot = Slot;
23458
+ /* harmony default export */ var inserter_menu_extension = (__unstableInserterMenuExtension);
23459
+ //# sourceMappingURL=index.js.map
23460
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/inserter/hooks/use-insertion-point.js
23461
+ /**
23462
+ * External dependencies
23463
+ */
23464
 
 
 
 
 
 
 
 
 
 
23465
  /**
23466
  * WordPress dependencies
23467
  */
23469
 
23470
 
23471
 
23472
+
23473
+
23474
  /**
23475
  * Internal dependencies
23476
  */
23477
 
23478
 
 
 
 
 
23479
  /**
23480
+ * @typedef WPInserterConfig
23481
  *
23482
+ * @property {string=} rootClientId If set, insertion will be into the
23483
+ * block with this ID.
23484
+ * @property {number=} insertionIndex If set, insertion will be into this
23485
+ * explicit position.
23486
+ * @property {string=} clientId If set, insertion will be after the
23487
+ * block with this ID.
23488
+ * @property {boolean=} isAppender Whether the inserter is an appender
23489
+ * or not.
23490
+ * @property {Function=} onSelect Called after insertion.
23491
  */
23492
 
23493
  /**
23494
+ * Returns the insertion point state given the inserter config.
 
 
 
 
 
23495
  *
23496
+ * @param {WPInserterConfig} config Inserter Config.
23497
+ * @return {Array} Insertion Point State (rootClientID, onInsertBlocks and onToggle).
23498
  */
23499
 
23500
+ function useInsertionPoint({
23501
+ rootClientId = '',
23502
+ insertionIndex,
23503
+ clientId,
23504
+ isAppender,
23505
+ onSelect,
23506
+ shouldFocusBlock = true
23507
+ }) {
23508
+ const {
23509
+ getSelectedBlock
23510
+ } = (0,external_wp_data_namespaceObject.useSelect)(store);
23511
+ const {
23512
+ destinationRootClientId,
23513
+ destinationIndex
23514
+ } = (0,external_wp_data_namespaceObject.useSelect)(select => {
23515
+ const {
23516
+ getSelectedBlockClientId,
23517
+ getBlockRootClientId,
23518
+ getBlockIndex,
23519
+ getBlockOrder
23520
+ } = select(store);
23521
+ const selectedBlockClientId = getSelectedBlockClientId();
23522
+ let _destinationRootClientId = rootClientId;
23523
 
23524
+ let _destinationIndex;
 
 
 
 
 
 
23525
 
23526
+ if (insertionIndex !== undefined) {
23527
+ // Insert into a specific index.
23528
+ _destinationIndex = insertionIndex;
23529
+ } else if (clientId) {
23530
+ // Insert after a specific client ID.
23531
+ _destinationIndex = getBlockIndex(clientId, _destinationRootClientId);
23532
+ } else if (!isAppender && selectedBlockClientId) {
23533
+ _destinationRootClientId = getBlockRootClientId(selectedBlockClientId);
23534
+ _destinationIndex = getBlockIndex(selectedBlockClientId, _destinationRootClientId) + 1;
23535
+ } else {
23536
+ // Insert at the end of the list.
23537
+ _destinationIndex = getBlockOrder(_destinationRootClientId).length;
23538
  }
23539
+
23540
+ return {
23541
+ destinationRootClientId: _destinationRootClientId,
23542
+ destinationIndex: _destinationIndex
23543
+ };
23544
+ }, [rootClientId, insertionIndex, clientId, isAppender]);
23545
+ const {
23546
+ replaceBlocks,
23547
+ insertBlocks,
23548
+ showInsertionPoint,
23549
+ hideInsertionPoint
23550
+ } = (0,external_wp_data_namespaceObject.useDispatch)(store);
23551
+ const onInsertBlocks = (0,external_wp_element_namespaceObject.useCallback)((blocks, meta, shouldForceFocusBlock = false) => {
23552
+ const selectedBlock = getSelectedBlock();
23553
+
23554
+ if (!isAppender && selectedBlock && (0,external_wp_blocks_namespaceObject.isUnmodifiedDefaultBlock)(selectedBlock)) {
23555
+ replaceBlocks(selectedBlock.clientId, blocks, null, shouldFocusBlock || shouldForceFocusBlock ? 0 : null, meta);
23556
+ } else {
23557
+ insertBlocks(blocks, destinationIndex, destinationRootClientId, true, shouldFocusBlock || shouldForceFocusBlock ? 0 : null, meta);
23558
+ }
23559
+
23560
+ const message = (0,external_wp_i18n_namespaceObject.sprintf)( // translators: %d: the name of the block that has been added
23561
+ (0,external_wp_i18n_namespaceObject._n)('%d block added.', '%d blocks added.', (0,external_lodash_namespaceObject.castArray)(blocks).length), (0,external_lodash_namespaceObject.castArray)(blocks).length);
23562
+ (0,external_wp_a11y_namespaceObject.speak)(message);
23563
+
23564
+ if (onSelect) {
23565
+ onSelect();
23566
+ }
23567
+ }, [isAppender, getSelectedBlock, replaceBlocks, insertBlocks, destinationRootClientId, destinationIndex, onSelect, shouldFocusBlock]);
23568
+ const onToggleInsertionPoint = (0,external_wp_element_namespaceObject.useCallback)(show => {
23569
+ if (show) {
23570
+ showInsertionPoint(destinationRootClientId, destinationIndex);
23571
+ } else {
23572
+ hideInsertionPoint();
23573
+ }
23574
+ }, [showInsertionPoint, hideInsertionPoint, destinationRootClientId, destinationIndex]);
23575
+ return [destinationRootClientId, onInsertBlocks, onToggleInsertionPoint];
23576
  }
23577
+
23578
+ /* harmony default export */ var use_insertion_point = (useInsertionPoint);
23579
+ //# sourceMappingURL=use-insertion-point.js.map
23580
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/inserter/search-items.js
23581
  /**
23582
+ * External dependencies
 
23583
  */
23584
+ // Default search helpers
23585
+
23586
+ const defaultGetName = item => item.name || '';
23587
+
23588
+ const defaultGetTitle = item => item.title;
23589
 
23590
+ const defaultGetDescription = item => item.description || '';
23591
+
23592
+ const defaultGetKeywords = item => item.keywords || [];
23593
+
23594
+ const defaultGetCategory = item => item.category;
23595
+
23596
+ const defaultGetCollection = () => null;
23597
  /**
23598
+ * Sanitizes the search input string.
23599
  *
23600
+ * @param {string} input The search input to normalize.
23601
+ *
23602
+ * @return {string} The normalized search input.
23603
  */
23604
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23605
 
23606
+ function normalizeSearchInput(input = '') {
23607
+ // Disregard diacritics.
23608
+ // Input: "média"
23609
+ input = (0,external_lodash_namespaceObject.deburr)(input); // Accommodate leading slash, matching autocomplete expectations.
23610
+ // Input: "/media"
 
 
23611
 
23612
+ input = input.replace(/^\//, ''); // Lowercase.
23613
+ // Input: "MEDIA"
 
 
 
 
 
23614
 
23615
+ input = input.toLowerCase();
23616
+ return input;
23617
+ }
23618
+ /**
23619
+ * Converts the search term into a list of normalized terms.
23620
+ *
23621
+ * @param {string} input The search term to normalize.
23622
+ *
23623
+ * @return {string[]} The normalized list of search terms.
23624
+ */
23625
 
23626
+
23627
+ const getNormalizedSearchTerms = (input = '') => {
23628
+ // Extract words.
23629
+ return (0,external_lodash_namespaceObject.words)(normalizeSearchInput(input));
23630
+ };
23631
+
23632
+ const removeMatchingTerms = (unmatchedTerms, unprocessedTerms) => {
23633
+ return (0,external_lodash_namespaceObject.differenceWith)(unmatchedTerms, getNormalizedSearchTerms(unprocessedTerms), (unmatchedTerm, unprocessedTerm) => unprocessedTerm.includes(unmatchedTerm));
23634
+ };
23635
+
23636
+ const searchBlockItems = (items, categories, collections, searchInput) => {
23637
+ const normalizedSearchTerms = getNormalizedSearchTerms(searchInput);
23638
+
23639
+ if (normalizedSearchTerms.length === 0) {
23640
+ return items;
23641
+ }
23642
+
23643
+ const config = {
23644
+ getCategory: item => {
23645
+ var _find;
23646
+
23647
+ return (_find = (0,external_lodash_namespaceObject.find)(categories, {
23648
+ slug: item.category
23649
+ })) === null || _find === void 0 ? void 0 : _find.title;
23650
  },
23651
+ getCollection: item => {
23652
+ var _collections$item$nam;
23653
 
23654
+ return (_collections$item$nam = collections[item.name.split('/')[0]]) === null || _collections$item$nam === void 0 ? void 0 : _collections$item$nam.title;
 
 
 
23655
  }
23656
+ };
23657
+ return searchItems(items, searchInput, config);
23658
+ };
 
 
23659
  /**
23660
+ * Filters an item list given a search term.
23661
+ *
23662
+ * @param {Array} items Item list
23663
+ * @param {string} searchInput Search input.
23664
+ * @param {Object} config Search Config.
23665
+ *
23666
+ * @return {Array} Filtered item list.
23667
  */
23668
 
23669
+ const searchItems = (items = [], searchInput = '', config = {}) => {
23670
+ const normalizedSearchTerms = getNormalizedSearchTerms(searchInput);
23671
+
23672
+ if (normalizedSearchTerms.length === 0) {
23673
+ return items;
23674
+ }
23675
+
23676
+ const rankedItems = items.map(item => {
23677
+ return [item, getItemSearchRank(item, searchInput, config)];
23678
+ }).filter(([, rank]) => rank > 0);
23679
+ rankedItems.sort(([, rank1], [, rank2]) => rank2 - rank1);
23680
+ return rankedItems.map(([item]) => item);
23681
+ };
23682
  /**
23683
+ * Get the search rank for a given item and a specific search term.
23684
+ * The better the match, the higher the rank.
23685
+ * If the rank equals 0, it should be excluded from the results.
23686
  *
23687
+ * @param {Object} item Item to filter.
23688
+ * @param {string} searchTerm Search term.
23689
+ * @param {Object} config Search Config.
23690
+ *
23691
+ * @return {number} Search Rank.
23692
  */
23693
 
23694
+ function getItemSearchRank(item, searchTerm, config = {}) {
23695
+ const {
23696
+ getName = defaultGetName,
23697
+ getTitle = defaultGetTitle,
23698
+ getDescription = defaultGetDescription,
23699
+ getKeywords = defaultGetKeywords,
23700
+ getCategory = defaultGetCategory,
23701
+ getCollection = defaultGetCollection
23702
+ } = config;
23703
+ const name = getName(item);
23704
+ const title = getTitle(item);
23705
+ const description = getDescription(item);
23706
+ const keywords = getKeywords(item);
23707
+ const category = getCategory(item);
23708
+ const collection = getCollection(item);
23709
+ const normalizedSearchInput = normalizeSearchInput(searchTerm);
23710
+ const normalizedTitle = normalizeSearchInput(title);
23711
+ let rank = 0; // Prefers exact matches
23712
+ // Then prefers if the beginning of the title matches the search term
23713
+ // name, keywords, categories, collection, variations match come later.
23714
+
23715
+ if (normalizedSearchInput === normalizedTitle) {
23716
+ rank += 30;
23717
+ } else if (normalizedTitle.startsWith(normalizedSearchInput)) {
23718
+ rank += 20;
23719
+ } else {
23720
+ const terms = [name, title, description, ...keywords, category, collection].join(' ');
23721
+ const normalizedSearchTerms = (0,external_lodash_namespaceObject.words)(normalizedSearchInput);
23722
+ const unmatchedTerms = removeMatchingTerms(normalizedSearchTerms, terms);
23723
+
23724
+ if (unmatchedTerms.length === 0) {
23725
+ rank += 10;
23726
  }
23727
+ } // Give a better rank to "core" namespaced items.
23728
 
 
 
 
 
 
 
 
 
23729
 
23730
+ if (rank !== 0 && name.startsWith('core/')) {
23731
+ rank++;
23732
+ }
23733
 
23734
+ return rank;
 
 
 
 
 
 
 
23735
  }
23736
+ //# sourceMappingURL=search-items.js.map
23737
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/inserter/search-results.js
23738
 
23739
 
23740
  /**
23749
 
23750
 
23751
 
23752
+
23753
  /**
23754
  * Internal dependencies
23755
  */
23758
 
23759
 
23760
 
 
23761
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23762
 
 
 
 
 
 
 
 
 
 
 
23763
 
 
 
 
23764
 
 
 
23765
 
 
 
 
23766
 
23767
+ const INITIAL_INSERTER_RESULTS = 9;
23768
+ /**
23769
+ * Shared reference to an empty array for cases where it is important to avoid
23770
+ * returning a new array reference on every invocation and rerendering the component.
23771
+ *
23772
+ * @type {Array}
23773
+ */
23774
 
23775
+ const search_results_EMPTY_ARRAY = [];
 
 
 
 
 
 
 
 
 
 
 
 
 
23776
 
23777
+ function InserterSearchResults({
23778
+ filterValue,
23779
+ onSelect,
23780
+ onHover,
23781
+ rootClientId,
23782
+ clientId,
23783
+ isAppender,
23784
+ __experimentalInsertionIndex,
23785
+ maxBlockPatterns,
23786
+ maxBlockTypes,
23787
+ showBlockDirectory = false,
23788
+ isDraggable = true,
23789
+ shouldFocusBlock = true
23790
+ }) {
23791
+ const debouncedSpeak = (0,external_wp_compose_namespaceObject.useDebounce)(external_wp_a11y_namespaceObject.speak, 500);
23792
+ const [destinationRootClientId, onInsertBlocks] = use_insertion_point({
23793
+ onSelect,
23794
+ rootClientId,
23795
+ clientId,
23796
+ isAppender,
23797
+ insertionIndex: __experimentalInsertionIndex,
23798
+ shouldFocusBlock
23799
+ });
23800
+ const [blockTypes, blockTypeCategories, blockTypeCollections, onSelectBlockType] = use_block_types_state(destinationRootClientId, onInsertBlocks);
23801
+ const [patterns,, onSelectBlockPattern] = use_patterns_state(onInsertBlocks, destinationRootClientId);
23802
+ const filteredBlockTypes = (0,external_wp_element_namespaceObject.useMemo)(() => {
23803
+ const results = searchBlockItems((0,external_lodash_namespaceObject.orderBy)(blockTypes, ['frecency'], ['desc']), blockTypeCategories, blockTypeCollections, filterValue);
23804
+ return maxBlockTypes !== undefined ? results.slice(0, maxBlockTypes) : results;
23805
+ }, [filterValue, blockTypes, blockTypeCategories, blockTypeCollections, maxBlockTypes]);
23806
+ const filteredBlockPatterns = (0,external_wp_element_namespaceObject.useMemo)(() => {
23807
+ const results = searchItems(patterns, filterValue);
23808
+ return maxBlockPatterns !== undefined ? results.slice(0, maxBlockPatterns) : results;
23809
+ }, [filterValue, patterns, maxBlockPatterns]); // Announce search results on change
23810
 
23811
+ (0,external_wp_element_namespaceObject.useEffect)(() => {
23812
+ if (!filterValue) {
23813
+ return;
 
 
23814
  }
23815
 
23816
+ const count = filteredBlockTypes.length + filteredBlockPatterns.length;
23817
+ const resultsFoundMessage = (0,external_wp_i18n_namespaceObject.sprintf)(
23818
+ /* translators: %d: number of results. */
23819
+ (0,external_wp_i18n_namespaceObject._n)('%d result found.', '%d results found.', count), count);
23820
+ debouncedSpeak(resultsFoundMessage);
23821
+ }, [filterValue, debouncedSpeak]);
23822
+ const currentShownBlockTypes = (0,external_wp_compose_namespaceObject.useAsyncList)(filteredBlockTypes, {
23823
+ step: INITIAL_INSERTER_RESULTS
23824
+ });
23825
+ const currentShownPatterns = (0,external_wp_compose_namespaceObject.useAsyncList)(currentShownBlockTypes.length === filteredBlockTypes.length ? filteredBlockPatterns : search_results_EMPTY_ARRAY);
23826
+ const hasItems = !(0,external_lodash_namespaceObject.isEmpty)(filteredBlockTypes) || !(0,external_lodash_namespaceObject.isEmpty)(filteredBlockPatterns);
23827
+ return (0,external_wp_element_namespaceObject.createElement)(inserter_listbox, null, !showBlockDirectory && !hasItems && (0,external_wp_element_namespaceObject.createElement)(no_results, null), !!filteredBlockTypes.length && (0,external_wp_element_namespaceObject.createElement)(panel, {
23828
+ title: (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, null, (0,external_wp_i18n_namespaceObject.__)('Blocks'))
23829
+ }, (0,external_wp_element_namespaceObject.createElement)(block_types_list, {
23830
+ items: currentShownBlockTypes,
23831
+ onSelect: onSelectBlockType,
23832
+ onHover: onHover,
23833
+ label: (0,external_wp_i18n_namespaceObject.__)('Blocks'),
23834
+ isDraggable: isDraggable
23835
+ })), !!filteredBlockTypes.length && !!filteredBlockPatterns.length && (0,external_wp_element_namespaceObject.createElement)("div", {
23836
+ className: "block-editor-inserter__quick-inserter-separator"
23837
+ }), !!filteredBlockPatterns.length && (0,external_wp_element_namespaceObject.createElement)(panel, {
23838
+ title: (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, null, (0,external_wp_i18n_namespaceObject.__)('Block Patterns'))
23839
+ }, (0,external_wp_element_namespaceObject.createElement)("div", {
23840
+ className: "block-editor-inserter__quick-inserter-patterns"
23841
+ }, (0,external_wp_element_namespaceObject.createElement)(block_patterns_list, {
23842
+ shownPatterns: currentShownPatterns,
23843
+ blockPatterns: filteredBlockPatterns,
23844
+ onClickPattern: onSelectBlockPattern,
23845
+ isDraggable: isDraggable
23846
+ }))), showBlockDirectory && (0,external_wp_element_namespaceObject.createElement)(inserter_menu_extension.Slot, {
23847
+ fillProps: {
23848
+ onSelect: onSelectBlockType,
23849
+ onHover,
23850
+ filterValue,
23851
+ hasItems,
23852
+ rootClientId: destinationRootClientId
23853
+ }
23854
+ }, fills => {
23855
+ if (fills.length) {
23856
+ return fills;
23857
  }
23858
 
23859
+ if (!hasItems) {
23860
+ return (0,external_wp_element_namespaceObject.createElement)(no_results, null);
 
 
 
 
 
 
23861
  }
23862
 
23863
+ return null;
23864
+ }));
23865
+ }
 
 
23866
 
23867
+ /* harmony default export */ var search_results = (InserterSearchResults);
23868
+ //# sourceMappingURL=search-results.js.map
23869
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/inserter/tabs.js
 
 
 
 
 
 
 
23870
 
 
 
 
 
 
 
 
 
23871
 
23872
+ /**
23873
+ * WordPress dependencies
23874
+ */
 
 
 
 
 
 
23875
 
 
 
 
 
 
 
 
 
 
 
23876
 
 
 
 
 
 
23877
 
23878
+ const blocksTab = {
23879
+ name: 'blocks',
 
 
 
 
 
 
23880
 
23881
+ /* translators: Blocks tab title in the block inserter. */
23882
+ title: (0,external_wp_i18n_namespaceObject.__)('Blocks')
23883
+ };
23884
+ const patternsTab = {
23885
+ name: 'patterns',
23886
 
23887
+ /* translators: Patterns tab title in the block inserter. */
23888
+ title: (0,external_wp_i18n_namespaceObject.__)('Patterns')
23889
+ };
23890
+ const reusableBlocksTab = {
23891
+ name: 'reusable',
 
 
 
23892
 
23893
+ /* translators: Reusable blocks tab title in the block inserter. */
23894
+ title: (0,external_wp_i18n_namespaceObject.__)('Reusable')
23895
+ };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23896
 
23897
+ function InserterTabs({
23898
  children,
23899
+ showPatterns = false,
23900
+ showReusableBlocks = false,
23901
+ onSelect
23902
  }) {
23903
+ const tabs = (0,external_wp_element_namespaceObject.useMemo)(() => {
23904
+ const tempTabs = [blocksTab];
23905
+
23906
+ if (showPatterns) {
23907
+ tempTabs.push(patternsTab);
23908
+ }
23909
+
23910
+ if (showReusableBlocks) {
23911
+ tempTabs.push(reusableBlocksTab);
23912
+ }
23913
+
23914
+ return tempTabs;
23915
+ }, [blocksTab, showPatterns, patternsTab, showReusableBlocks, reusableBlocksTab]);
23916
+ return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TabPanel, {
23917
+ className: "block-editor-inserter__tabs",
23918
+ tabs: tabs,
23919
+ onSelect: onSelect
23920
+ }, children);
23921
  }
23922
+
23923
+ /* harmony default export */ var tabs = (InserterTabs);
23924
+ //# sourceMappingURL=tabs.js.map
23925
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/inserter/menu.js
23926
+
23927
+
23928
  /**
23929
  * WordPress dependencies
23930
  */
23931
 
23932
 
23933
 
23934
+
23935
  /**
23936
  * Internal dependencies
23937
  */
23938
 
23939
 
23940
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23941
 
 
 
 
23942
 
 
 
 
23943
 
 
 
 
 
23944
 
 
 
23945
 
 
23946
 
 
 
 
 
23947
 
23948
 
23949
+ function InserterMenu({
23950
+ rootClientId,
23951
+ clientId,
23952
+ isAppender,
23953
+ __experimentalInsertionIndex,
23954
+ onSelect,
23955
+ showInserterHelpPanel,
23956
+ showMostUsedBlocks,
23957
+ shouldFocusBlock = true
23958
+ }) {
23959
+ const [filterValue, setFilterValue] = (0,external_wp_element_namespaceObject.useState)('');
23960
+ const [hoveredItem, setHoveredItem] = (0,external_wp_element_namespaceObject.useState)(null);
23961
+ const [selectedPatternCategory, setSelectedPatternCategory] = (0,external_wp_element_namespaceObject.useState)(null);
23962
+ const [destinationRootClientId, onInsertBlocks, onToggleInsertionPoint] = use_insertion_point({
23963
+ rootClientId,
23964
+ clientId,
23965
+ isAppender,
23966
+ insertionIndex: __experimentalInsertionIndex,
23967
+ shouldFocusBlock
23968
+ });
23969
+ const {
23970
+ showPatterns,
23971
+ hasReusableBlocks
23972
+ } = (0,external_wp_data_namespaceObject.useSelect)(select => {
23973
+ var _getSettings$__experi;
23974
 
23975
+ const {
23976
+ __experimentalGetAllowedPatterns,
23977
+ getSettings
23978
+ } = select(store);
23979
+ return {
23980
+ showPatterns: !!__experimentalGetAllowedPatterns(destinationRootClientId).length,
23981
+ hasReusableBlocks: !!((_getSettings$__experi = getSettings().__experimentalReusableBlocks) !== null && _getSettings$__experi !== void 0 && _getSettings$__experi.length)
23982
+ };
23983
+ }, [destinationRootClientId]);
23984
+ const onInsert = (0,external_wp_element_namespaceObject.useCallback)((blocks, meta, shouldForceFocusBlock) => {
23985
+ onInsertBlocks(blocks, meta, shouldForceFocusBlock);
23986
+ onSelect();
23987
+ }, [onInsertBlocks, onSelect]);
23988
+ const onInsertPattern = (0,external_wp_element_namespaceObject.useCallback)((blocks, patternName) => {
23989
+ onInsertBlocks(blocks, {
23990
+ patternName
23991
+ });
23992
+ onSelect();
23993
+ }, [onInsertBlocks, onSelect]);
23994
+ const onHover = (0,external_wp_element_namespaceObject.useCallback)(item => {
23995
+ onToggleInsertionPoint(!!item);
23996
+ setHoveredItem(item);
23997
+ }, [onToggleInsertionPoint, setHoveredItem]);
23998
+ const onClickPatternCategory = (0,external_wp_element_namespaceObject.useCallback)(patternCategory => {
23999
+ setSelectedPatternCategory(patternCategory);
24000
+ }, [setSelectedPatternCategory]);
24001
+ const blocksTab = (0,external_wp_element_namespaceObject.useMemo)(() => (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("div", {
24002
+ className: "block-editor-inserter__block-list"
24003
+ }, (0,external_wp_element_namespaceObject.createElement)(block_types_tab, {
24004
+ rootClientId: destinationRootClientId,
24005
+ onInsert: onInsert,
24006
+ onHover: onHover,
24007
+ showMostUsedBlocks: showMostUsedBlocks
24008
+ })), showInserterHelpPanel && (0,external_wp_element_namespaceObject.createElement)("div", {
24009
+ className: "block-editor-inserter__tips"
24010
+ }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, {
24011
+ as: "h2"
24012
+ }, (0,external_wp_i18n_namespaceObject.__)('A tip for using the block editor')), (0,external_wp_element_namespaceObject.createElement)(tips, null))), [destinationRootClientId, onInsert, onHover, filterValue, showMostUsedBlocks, showInserterHelpPanel]);
24013
+ const patternsTab = (0,external_wp_element_namespaceObject.useMemo)(() => (0,external_wp_element_namespaceObject.createElement)(block_patterns_tab, {
24014
+ rootClientId: destinationRootClientId,
24015
+ onInsert: onInsertPattern,
24016
+ onClickCategory: onClickPatternCategory,
24017
+ selectedCategory: selectedPatternCategory
24018
+ }), [destinationRootClientId, onInsertPattern, onClickPatternCategory, selectedPatternCategory]);
24019
+ const reusableBlocksTab = (0,external_wp_element_namespaceObject.useMemo)(() => (0,external_wp_element_namespaceObject.createElement)(reusable_blocks_tab, {
24020
+ rootClientId: destinationRootClientId,
24021
+ onInsert: onInsert,
24022
+ onHover: onHover
24023
+ }), [destinationRootClientId, onInsert, onHover]);
24024
+ const getCurrentTab = (0,external_wp_element_namespaceObject.useCallback)(tab => {
24025
+ if (tab.name === 'blocks') {
24026
+ return blocksTab;
24027
+ } else if (tab.name === 'patterns') {
24028
+ return patternsTab;
24029
+ }
24030
 
24031
+ return reusableBlocksTab;
24032
+ }, [blocksTab, patternsTab, reusableBlocksTab]);
24033
+ return (0,external_wp_element_namespaceObject.createElement)("div", {
24034
+ className: "block-editor-inserter__menu"
24035
+ }, (0,external_wp_element_namespaceObject.createElement)("div", {
24036
+ className: "block-editor-inserter__main-area"
24037
+ }, (0,external_wp_element_namespaceObject.createElement)("div", {
24038
+ className: "block-editor-inserter__content"
24039
+ }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SearchControl, {
24040
+ className: "block-editor-inserter__search",
24041
+ onChange: value => {
24042
+ if (hoveredItem) setHoveredItem(null);
24043
+ setFilterValue(value);
24044
+ },
24045
+ value: filterValue,
24046
+ label: (0,external_wp_i18n_namespaceObject.__)('Search for blocks and patterns'),
24047
+ placeholder: (0,external_wp_i18n_namespaceObject.__)('Search')
24048
+ }), !!filterValue && (0,external_wp_element_namespaceObject.createElement)(search_results, {
24049
+ filterValue: filterValue,
24050
+ onSelect: onSelect,
24051
+ onHover: onHover,
24052
+ rootClientId: rootClientId,
24053
+ clientId: clientId,
24054
+ isAppender: isAppender,
24055
+ __experimentalInsertionIndex: __experimentalInsertionIndex,
24056
+ showBlockDirectory: true,
24057
+ shouldFocusBlock: shouldFocusBlock
24058
+ }), !filterValue && (showPatterns || hasReusableBlocks) && (0,external_wp_element_namespaceObject.createElement)(tabs, {
24059
+ showPatterns: showPatterns,
24060
+ showReusableBlocks: hasReusableBlocks
24061
+ }, getCurrentTab), !filterValue && !showPatterns && !hasReusableBlocks && blocksTab)), showInserterHelpPanel && hoveredItem && (0,external_wp_element_namespaceObject.createElement)(preview_panel, {
24062
+ item: hoveredItem
24063
+ }));
24064
+ }
24065
 
24066
+ /* harmony default export */ var menu = (InserterMenu);
24067
+ //# sourceMappingURL=menu.js.map
24068
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/inserter/quick-inserter.js
24069
 
 
 
24070
 
24071
+ /**
24072
+ * External dependencies
24073
+ */
 
24074
 
24075
+ /**
24076
+ * WordPress dependencies
24077
+ */
24078
 
 
 
 
 
24079
 
24080
 
 
 
 
24081
 
 
24082
 
24083
+ /**
24084
+ * Internal dependencies
24085
+ */
 
24086
 
 
 
24087
 
 
 
24088
 
 
 
 
 
24089
 
 
 
24090
 
 
 
 
 
24091
 
24092
+ const SEARCH_THRESHOLD = 6;
24093
+ const SHOWN_BLOCK_TYPES = 6;
24094
+ const SHOWN_BLOCK_PATTERNS = 2;
24095
+ function QuickInserter({
24096
+ onSelect,
24097
+ rootClientId,
24098
+ clientId,
24099
+ isAppender
24100
+ }) {
24101
+ const [filterValue, setFilterValue] = (0,external_wp_element_namespaceObject.useState)('');
24102
+ const [destinationRootClientId, onInsertBlocks] = use_insertion_point({
24103
+ onSelect,
24104
+ rootClientId,
24105
+ clientId,
24106
+ isAppender
24107
+ });
24108
+ const [blockTypes] = use_block_types_state(destinationRootClientId, onInsertBlocks);
24109
+ const [patterns] = use_patterns_state(onInsertBlocks, destinationRootClientId);
24110
+ const showPatterns = patterns.length && !!filterValue;
24111
+ const showSearch = showPatterns && patterns.length > SEARCH_THRESHOLD || blockTypes.length > SEARCH_THRESHOLD;
24112
+ const {
24113
+ setInserterIsOpened,
24114
+ insertionIndex
24115
+ } = (0,external_wp_data_namespaceObject.useSelect)(select => {
24116
+ const {
24117
+ getSettings,
24118
+ getBlockIndex,
24119
+ getBlockCount
24120
+ } = select(store);
24121
+ const index = getBlockIndex(clientId, rootClientId);
24122
+ return {
24123
+ setInserterIsOpened: getSettings().__experimentalSetIsInserterOpened,
24124
+ insertionIndex: index === -1 ? getBlockCount() : index
24125
  };
24126
+ }, [clientId, rootClientId]);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24127
  (0,external_wp_element_namespaceObject.useEffect)(() => {
24128
+ if (setInserterIsOpened) {
24129
+ setInserterIsOpened(false);
24130
  }
24131
+ }, [setInserterIsOpened]); // When clicking Browse All select the appropriate block so as
24132
+ // the insertion point can work as expected
24133
 
24134
+ const onBrowseAll = () => {
24135
+ setInserterIsOpened({
24136
+ rootClientId,
24137
+ insertionIndex
24138
+ });
24139
+ };
24140
 
24141
+ return (0,external_wp_element_namespaceObject.createElement)("div", {
24142
+ className: classnames_default()('block-editor-inserter__quick-inserter', {
24143
+ 'has-search': showSearch,
24144
+ 'has-expand': setInserterIsOpened
24145
+ })
24146
+ }, showSearch && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SearchControl, {
24147
+ className: "block-editor-inserter__search",
24148
+ value: filterValue,
24149
+ onChange: value => {
24150
+ setFilterValue(value);
24151
+ },
24152
+ label: (0,external_wp_i18n_namespaceObject.__)('Search for blocks and patterns'),
24153
+ placeholder: (0,external_wp_i18n_namespaceObject.__)('Search')
24154
+ }), (0,external_wp_element_namespaceObject.createElement)("div", {
24155
+ className: "block-editor-inserter__quick-inserter-results"
24156
+ }, (0,external_wp_element_namespaceObject.createElement)(search_results, {
24157
+ filterValue: filterValue,
24158
+ onSelect: onSelect,
24159
+ rootClientId: rootClientId,
24160
+ clientId: clientId,
24161
+ isAppender: isAppender,
24162
+ maxBlockPatterns: showPatterns ? SHOWN_BLOCK_PATTERNS : 0,
24163
+ maxBlockTypes: SHOWN_BLOCK_TYPES,
24164
+ isDraggable: false
24165
+ })), setInserterIsOpened && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
24166
+ className: "block-editor-inserter__quick-inserter-expand",
24167
+ onClick: onBrowseAll,
24168
+ "aria-label": (0,external_wp_i18n_namespaceObject.__)('Browse all. This will open the main inserter panel in the editor toolbar.')
24169
+ }, (0,external_wp_i18n_namespaceObject.__)('Browse all')));
24170
+ }
24171
+ //# sourceMappingURL=quick-inserter.js.map
24172
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/inserter/index.js
24173
 
 
24174
 
 
 
24175
 
 
 
 
 
 
 
 
 
 
24176
  /**
24177
+ * External dependencies
24178
  */
24179
 
24180
 
 
 
 
 
24181
  /**
24182
+ * WordPress dependencies
 
 
 
 
24183
  */
24184
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24185
 
 
 
 
 
 
24186
 
 
 
 
 
24187
 
24188
 
 
 
 
24189
 
24190
 
24191
 
24198
 
24199
 
24200
 
24201
+ const defaultRenderToggle = ({
24202
+ onToggle,
24203
+ disabled,
24204
+ isOpen,
24205
+ blockTitle,
24206
+ hasSingleBlockType,
24207
+ toggleProps = {}
24208
  }) => {
24209
+ let label;
24210
+
24211
+ if (hasSingleBlockType) {
24212
+ label = (0,external_wp_i18n_namespaceObject.sprintf)( // translators: %s: the name of the block when there is only one
24213
+ (0,external_wp_i18n_namespaceObject._x)('Add %s', 'directly add the only allowed block'), blockTitle);
24214
+ } else {
24215
+ label = (0,external_wp_i18n_namespaceObject._x)('Add block', 'Generic label for block inserter button');
24216
+ }
24217
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24218
  const {
24219
+ onClick,
24220
+ ...rest
24221
+ } = toggleProps; // Handle both onClick functions from the toggle and the parent component
24222
 
24223
+ function handleClick(event) {
24224
+ if (onToggle) {
24225
+ onToggle(event);
24226
+ }
 
 
 
24227
 
24228
+ if (onClick) {
24229
+ onClick(event);
24230
+ }
 
24231
  }
24232
 
24233
+ return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, _extends({
24234
+ icon: library_plus,
24235
+ label: label,
24236
+ tooltipPosition: "bottom",
24237
+ onClick: handleClick,
24238
+ className: "block-editor-inserter__toggle",
24239
+ "aria-haspopup": !hasSingleBlockType ? 'true' : false,
24240
+ "aria-expanded": !hasSingleBlockType ? isOpen : false,
24241
+ disabled: disabled
24242
+ }, rest));
24243
+ };
 
 
24244
 
24245
+ class Inserter extends external_wp_element_namespaceObject.Component {
24246
+ constructor() {
24247
+ super(...arguments);
24248
+ this.onToggle = this.onToggle.bind(this);
24249
+ this.renderToggle = this.renderToggle.bind(this);
24250
+ this.renderContent = this.renderContent.bind(this);
24251
+ }
 
 
24252
 
24253
+ onToggle(isOpen) {
24254
+ const {
24255
+ onToggle
24256
+ } = this.props; // Surface toggle callback to parent component
24257
+
24258
+ if (onToggle) {
24259
+ onToggle(isOpen);
24260
+ }
24261
+ }
24262
+ /**
24263
+ * Render callback to display Dropdown toggle element.
24264
+ *
24265
+ * @param {Object} options
24266
+ * @param {Function} options.onToggle Callback to invoke when toggle is
24267
+ * pressed.
24268
+ * @param {boolean} options.isOpen Whether dropdown is currently open.
24269
+ *
24270
+ * @return {WPElement} Dropdown toggle element.
24271
+ */
24272
+
24273
+
24274
+ renderToggle({
24275
+ onToggle,
24276
+ isOpen
24277
+ }) {
24278
+ const {
24279
+ disabled,
24280
+ blockTitle,
24281
+ hasSingleBlockType,
24282
+ toggleProps,
24283
+ hasItems,
24284
+ renderToggle = defaultRenderToggle
24285
+ } = this.props;
24286
+ return renderToggle({
24287
+ onToggle,
24288
+ isOpen,
24289
+ disabled: disabled || !hasItems,
24290
+ blockTitle,
24291
+ hasSingleBlockType,
24292
+ toggleProps
24293
  });
24294
+ }
24295
+ /**
24296
+ * Render callback to display Dropdown content element.
24297
+ *
24298
+ * @param {Object} options
24299
+ * @param {Function} options.onClose Callback to invoke when dropdown is
24300
+ * closed.
24301
+ *
24302
+ * @return {WPElement} Dropdown content element.
24303
+ */
24304
 
 
 
 
24305
 
24306
+ renderContent({
24307
+ onClose
24308
+ }) {
24309
+ const {
24310
+ rootClientId,
24311
+ clientId,
24312
+ isAppender,
24313
+ showInserterHelpPanel,
24314
+ // This prop is experimental to give some time for the quick inserter to mature
24315
+ // Feel free to make them stable after a few releases.
24316
+ __experimentalIsQuick: isQuick
24317
+ } = this.props;
24318
 
24319
+ if (isQuick) {
24320
+ return (0,external_wp_element_namespaceObject.createElement)(QuickInserter, {
24321
+ onSelect: () => {
24322
+ onClose();
24323
+ },
24324
+ rootClientId: rootClientId,
24325
+ clientId: clientId,
24326
+ isAppender: isAppender
24327
+ });
24328
+ }
24329
 
24330
+ return (0,external_wp_element_namespaceObject.createElement)(menu, {
24331
+ onSelect: () => {
24332
+ onClose();
24333
+ },
24334
+ rootClientId: rootClientId,
24335
+ clientId: clientId,
24336
+ isAppender: isAppender,
24337
+ showInserterHelpPanel: showInserterHelpPanel
24338
+ });
24339
+ }
24340
 
24341
+ render() {
24342
+ const {
24343
+ position,
24344
+ hasSingleBlockType,
24345
+ insertOnlyAllowedBlock,
24346
+ __experimentalIsQuick: isQuick,
24347
+ onSelectOrClose
24348
+ } = this.props;
24349
 
24350
+ if (hasSingleBlockType) {
24351
+ return this.renderToggle({
24352
+ onToggle: insertOnlyAllowedBlock
24353
+ });
24354
+ }
24355
 
24356
+ return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Dropdown, {
24357
+ className: "block-editor-inserter",
24358
+ contentClassName: classnames_default()('block-editor-inserter__popover', {
24359
+ 'is-quick': isQuick
24360
+ }),
24361
+ position: position,
24362
+ onToggle: this.onToggle,
24363
+ expandOnMobile: true,
24364
+ headerTitle: (0,external_wp_i18n_namespaceObject.__)('Add a block'),
24365
+ renderToggle: this.renderToggle,
24366
+ renderContent: this.renderContent,
24367
+ onClose: onSelectOrClose
24368
+ });
24369
+ }
24370
 
24371
+ }
24372
 
24373
+ /* harmony default export */ var inserter = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)((select, {
24374
+ clientId,
24375
+ rootClientId
24376
+ }) => {
24377
+ const {
24378
+ getBlockRootClientId,
24379
+ hasInserterItems,
24380
+ __experimentalGetAllowedBlocks
24381
+ } = select(store);
24382
+ const {
24383
+ getBlockVariations
24384
+ } = select(external_wp_blocks_namespaceObject.store);
24385
+ rootClientId = rootClientId || getBlockRootClientId(clientId) || undefined;
24386
 
24387
+ const allowedBlocks = __experimentalGetAllowedBlocks(rootClientId);
24388
 
24389
+ const hasSingleBlockType = (0,external_lodash_namespaceObject.size)(allowedBlocks) === 1 && (0,external_lodash_namespaceObject.size)(getBlockVariations(allowedBlocks[0].name, 'inserter')) === 0;
24390
+ let allowedBlockType = false;
24391
 
24392
+ if (hasSingleBlockType) {
24393
+ allowedBlockType = allowedBlocks[0];
24394
+ }
24395
 
24396
+ return {
24397
+ hasItems: hasInserterItems(rootClientId),
24398
+ hasSingleBlockType,
24399
+ blockTitle: allowedBlockType ? allowedBlockType.title : '',
24400
+ allowedBlockType,
24401
+ rootClientId
24402
+ };
24403
+ }), (0,external_wp_data_namespaceObject.withDispatch)((dispatch, ownProps, {
24404
+ select
24405
+ }) => {
24406
+ return {
24407
+ insertOnlyAllowedBlock() {
24408
+ const {
24409
+ rootClientId,
24410
+ clientId,
24411
+ isAppender,
24412
+ hasSingleBlockType,
24413
+ allowedBlockType,
24414
+ onSelectOrClose
24415
+ } = ownProps;
24416
 
24417
+ if (!hasSingleBlockType) {
24418
+ return;
24419
+ }
24420
 
24421
+ function getInsertionIndex() {
24422
+ const {
24423
+ getBlockIndex,
24424
+ getBlockSelectionEnd,
24425
+ getBlockOrder,
24426
+ getBlockRootClientId
24427
+ } = select(store); // If the clientId is defined, we insert at the position of the block.
24428
 
24429
+ if (clientId) {
24430
+ return getBlockIndex(clientId, rootClientId);
24431
+ } // If there a selected block, we insert after the selected block.
24432
 
24433
 
24434
+ const end = getBlockSelectionEnd();
24435
 
24436
+ if (!isAppender && end && getBlockRootClientId(end) === rootClientId) {
24437
+ return getBlockIndex(end, rootClientId) + 1;
24438
+ } // Otherwise, we insert at the end of the current rootClientId
24439
 
24440
 
24441
+ return getBlockOrder(rootClientId).length;
24442
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24443
 
24444
+ const {
24445
+ insertBlock
24446
+ } = dispatch(store);
24447
+ const blockToInsert = (0,external_wp_blocks_namespaceObject.createBlock)(allowedBlockType.name);
24448
+ insertBlock(blockToInsert, getInsertionIndex(), rootClientId);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24449
 
24450
+ if (onSelectOrClose) {
24451
+ onSelectOrClose();
24452
+ }
 
 
 
 
 
 
 
 
 
 
24453
 
24454
+ const message = (0,external_wp_i18n_namespaceObject.sprintf)( // translators: %s: the name of the block that has been added
24455
+ (0,external_wp_i18n_namespaceObject.__)('%s block added'), allowedBlockType.title);
24456
+ (0,external_wp_a11y_namespaceObject.speak)(message);
 
24457
  }
24458
 
24459
+ };
24460
+ }), // The global inserter should always be visible, we are using ( ! isAppender && ! rootClientId && ! clientId ) as
24461
+ // a way to detect the global Inserter.
24462
+ (0,external_wp_compose_namespaceObject.ifCondition)(({
24463
+ hasItems,
24464
+ isAppender,
24465
+ rootClientId,
24466
+ clientId
24467
+ }) => hasItems || !isAppender && !rootClientId && !clientId)])(Inserter));
24468
+ //# sourceMappingURL=index.js.map
24469
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/default-block-appender/index.js
24470
 
 
 
24471
 
24472
+ /**
24473
+ * External dependencies
24474
+ */
 
 
 
24475
 
24476
+ /**
24477
+ * WordPress dependencies
24478
+ */
24479
 
 
 
24480
 
 
24481
 
 
 
 
 
24482
 
 
 
 
 
 
24483
 
 
 
 
24484
 
24485
+ /**
24486
+ * Internal dependencies
24487
+ */
 
24488
 
 
 
 
 
 
 
24489
 
 
 
24490
 
24491
+ /**
24492
+ * Zero width non-breaking space, used as padding for the paragraph when it is
24493
+ * empty.
24494
+ */
 
 
 
24495
 
24496
+ const ZWNBSP = '\ufeff';
24497
+ function DefaultBlockAppender({
24498
+ isLocked,
24499
+ isVisible,
24500
+ onAppend,
24501
+ showPrompt,
24502
+ placeholder,
24503
+ rootClientId
24504
+ }) {
24505
+ if (isLocked || !isVisible) {
24506
+ return null;
24507
  }
24508
 
24509
+ const value = (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(placeholder) || (0,external_wp_i18n_namespaceObject.__)('Type / to choose a block');
 
 
 
 
24510
 
24511
  return (0,external_wp_element_namespaceObject.createElement)("div", {
24512
+ "data-root-client-id": rootClientId || '',
24513
+ className: classnames_default()('block-editor-default-block-appender', {
24514
+ 'has-visible-prompt': showPrompt
24515
+ })
24516
+ }, (0,external_wp_element_namespaceObject.createElement)("p", {
24517
+ tabIndex: "0" // Only necessary for `useCanvasClickRedirect` to consider it
24518
+ // as a target. Ideally it should consider any tabbable target,
24519
+ // but the inserter is rendered in place while it should be
24520
+ // rendered in a popover, just like it does for an empty
24521
+ // paragraph block.
 
 
 
 
 
24522
  ,
24523
+ contentEditable: true,
24524
+ suppressContentEditableWarning: true // We want this element to be styled as a paragraph by themes.
24525
+ // eslint-disable-next-line jsx-a11y/no-noninteractive-element-to-interactive-role
24526
+ ,
24527
+ role: "button",
24528
+ "aria-label": (0,external_wp_i18n_namespaceObject.__)('Add block') // The wp-block className is important for editor styles.
24529
+ ,
24530
+ className: "wp-block block-editor-default-block-appender__content",
24531
+ onFocus: onAppend
24532
+ }, showPrompt ? value : ZWNBSP), (0,external_wp_element_namespaceObject.createElement)(inserter, {
24533
+ rootClientId: rootClientId,
24534
+ position: "bottom right",
24535
+ isAppender: true,
24536
+ __experimentalIsQuick: true
24537
+ }));
24538
  }
24539
+ /* harmony default export */ var default_block_appender = ((0,external_wp_compose_namespaceObject.compose)((0,external_wp_data_namespaceObject.withSelect)((select, ownProps) => {
24540
+ const {
24541
+ getBlockCount,
24542
+ getBlockName,
24543
+ isBlockValid,
24544
+ getSettings,
24545
+ getTemplateLock
24546
+ } = select(store);
24547
+ const isEmpty = !getBlockCount(ownProps.rootClientId);
24548
+ const isLastBlockDefault = getBlockName(ownProps.lastBlockClientId) === (0,external_wp_blocks_namespaceObject.getDefaultBlockName)();
24549
+ const isLastBlockValid = isBlockValid(ownProps.lastBlockClientId);
24550
+ const {
24551
+ bodyPlaceholder
24552
+ } = getSettings();
24553
+ return {
24554
+ isVisible: isEmpty || !isLastBlockDefault || !isLastBlockValid,
24555
+ showPrompt: isEmpty,
24556
+ isLocked: !!getTemplateLock(ownProps.rootClientId),
24557
+ placeholder: bodyPlaceholder
24558
+ };
24559
+ }), (0,external_wp_data_namespaceObject.withDispatch)((dispatch, ownProps) => {
24560
+ const {
24561
+ insertDefaultBlock,
24562
+ startTyping
24563
+ } = dispatch(store);
24564
+ return {
24565
+ onAppend() {
24566
+ const {
24567
+ rootClientId
24568
+ } = ownProps;
24569
+ insertDefaultBlock(undefined, rootClientId);
24570
+ startTyping();
24571
+ }
24572
 
24573
+ };
24574
+ }))(DefaultBlockAppender));
24575
+ //# sourceMappingURL=index.js.map
24576
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/button-block-appender/index.js
24577
 
24578
 
24579
+ /**
24580
+ * External dependencies
24581
+ */
24582
 
24583
  /**
24584
  * WordPress dependencies
24589
 
24590
 
24591
 
24592
+ /**
24593
+ * Internal dependencies
24594
+ */
 
 
 
 
 
 
 
 
 
 
 
 
24595
 
 
 
 
 
24596
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24597
 
24598
+ function ButtonBlockAppender({
24599
+ rootClientId,
24600
+ className,
24601
+ onFocus,
24602
+ tabIndex
24603
+ }, ref) {
24604
+ return (0,external_wp_element_namespaceObject.createElement)(inserter, {
24605
+ position: "bottom center",
24606
+ rootClientId: rootClientId,
24607
+ __experimentalIsQuick: true,
24608
+ renderToggle: ({
24609
+ onToggle,
24610
+ disabled,
24611
+ isOpen,
24612
+ blockTitle,
24613
+ hasSingleBlockType
24614
+ }) => {
24615
+ let label;
24616
 
24617
+ if (hasSingleBlockType) {
24618
+ label = (0,external_wp_i18n_namespaceObject.sprintf)( // translators: %s: the name of the block when there is only one
24619
+ (0,external_wp_i18n_namespaceObject._x)('Add %s', 'directly add the only allowed block'), blockTitle);
24620
+ } else {
24621
+ label = (0,external_wp_i18n_namespaceObject._x)('Add block', 'Generic label for block inserter button');
24622
+ }
 
24623
 
24624
+ const isToggleButton = !hasSingleBlockType;
24625
+ let inserterButton = (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
24626
+ ref: ref,
24627
+ onFocus: onFocus,
24628
+ tabIndex: tabIndex,
24629
+ className: classnames_default()(className, 'block-editor-button-block-appender'),
24630
+ onClick: onToggle,
24631
+ "aria-haspopup": isToggleButton ? 'true' : undefined,
24632
+ "aria-expanded": isToggleButton ? isOpen : undefined,
24633
+ disabled: disabled,
24634
+ label: label
24635
+ }, !hasSingleBlockType && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, {
24636
+ as: "span"
24637
+ }, label), (0,external_wp_element_namespaceObject.createElement)(icon, {
24638
+ icon: library_plus
24639
+ }));
24640
 
24641
+ if (isToggleButton || hasSingleBlockType) {
24642
+ inserterButton = (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Tooltip, {
24643
+ text: label
24644
+ }, inserterButton);
24645
+ }
 
 
24646
 
24647
+ return inserterButton;
24648
+ },
24649
+ isAppender: true
24650
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24651
  }
24652
+ /**
24653
+ * Use `ButtonBlockAppender` instead.
24654
+ *
24655
+ * @deprecated
24656
+ */
24657
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24658
 
24659
+ const ButtonBlockerAppender = (0,external_wp_element_namespaceObject.forwardRef)((props, ref) => {
24660
+ external_wp_deprecated_default()(`wp.blockEditor.ButtonBlockerAppender`, {
24661
+ alternative: 'wp.blockEditor.ButtonBlockAppender'
24662
+ });
24663
+ return ButtonBlockAppender(props, ref);
24664
+ });
24665
+ /**
24666
+ * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/button-block-appender/README.md
24667
+ */
24668
 
24669
+ /* harmony default export */ var button_block_appender = ((0,external_wp_element_namespaceObject.forwardRef)(ButtonBlockAppender));
24670
  //# sourceMappingURL=index.js.map
24671
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-list-appender/index.js
 
24672
 
24673
 
24674
  /**
24682
 
24683
 
24684
 
 
 
 
 
24685
  /**
24686
  * Internal dependencies
24687
  */
24690
 
24691
 
24692
 
24693
+ function BlockListAppender({
24694
+ blockClientIds,
 
 
 
 
24695
  rootClientId,
24696
+ canInsertDefaultBlock,
24697
+ isLocked,
24698
+ renderAppender: CustomAppender,
24699
+ className,
24700
+ selectedBlockClientId,
24701
+ tagName: TagName = 'div'
24702
+ }) {
24703
+ if (isLocked || CustomAppender === false) {
 
 
24704
  return null;
24705
  }
24706
 
24707
+ let appender;
 
 
 
24708
 
24709
+ if (CustomAppender) {
24710
+ // Prefer custom render prop if provided.
24711
+ appender = (0,external_wp_element_namespaceObject.createElement)(CustomAppender, null);
24712
+ } else {
24713
+ const isDocumentAppender = !rootClientId;
24714
+ const isParentSelected = selectedBlockClientId === rootClientId;
24715
+ const isAnotherDefaultAppenderAlreadyDisplayed = selectedBlockClientId && !blockClientIds.includes(selectedBlockClientId);
24716
 
24717
+ if (!isDocumentAppender && !isParentSelected && (!selectedBlockClientId || isAnotherDefaultAppenderAlreadyDisplayed)) {
24718
+ return null;
24719
+ }
24720
+
24721
+ if (canInsertDefaultBlock) {
24722
+ // Render the default block appender when renderAppender has not been
24723
+ // provided and the context supports use of the default appender.
24724
+ appender = (0,external_wp_element_namespaceObject.createElement)(default_block_appender, {
24725
+ rootClientId: rootClientId,
24726
+ lastBlockClientId: (0,external_lodash_namespaceObject.last)(blockClientIds)
24727
+ });
24728
+ } else {
24729
+ // Fallback in the case no renderAppender has been provided and the
24730
+ // default block can't be inserted.
24731
+ appender = (0,external_wp_element_namespaceObject.createElement)(button_block_appender, {
24732
+ rootClientId: rootClientId,
24733
+ className: "block-list-appender__toggle"
24734
+ });
24735
+ }
24736
+ }
24737
+
24738
+ return (0,external_wp_element_namespaceObject.createElement)(TagName // A `tabIndex` is used on the wrapping `div` element in order to
24739
+ // force a focus event to occur when an appender `button` element
24740
+ // is clicked. In some browsers (Firefox, Safari), button clicks do
24741
+ // not emit a focus event, which could cause this event to propagate
24742
+ // unexpectedly. The `tabIndex` ensures that the interaction is
24743
+ // captured as a focus, without also adding an extra tab stop.
24744
+ //
24745
+ // See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus
24746
+ , {
24747
+ tabIndex: -1,
24748
+ className: classnames_default()('block-list-appender wp-block', className)
24749
+ }, appender);
24750
  }
24751
 
24752
+ /* harmony default export */ var block_list_appender = ((0,external_wp_data_namespaceObject.withSelect)((select, {
24753
+ rootClientId
24754
  }) => {
 
 
24755
  const {
 
 
 
 
24756
  getBlockOrder,
24757
+ canInsertBlockType,
24758
+ getTemplateLock,
24759
+ getSelectedBlockClientId
24760
  } = select(store);
 
 
 
 
 
 
 
 
 
24761
  return {
24762
+ isLocked: !!getTemplateLock(rootClientId),
24763
+ blockClientIds: getBlockOrder(rootClientId),
24764
+ canInsertDefaultBlock: canInsertBlockType((0,external_wp_blocks_namespaceObject.getDefaultBlockName)(), rootClientId),
24765
+ selectedBlockClientId: getSelectedBlockClientId()
 
 
 
24766
  };
24767
+ })(BlockListAppender));
24768
  //# sourceMappingURL=index.js.map
24769
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-tools/use-popover-scroll.js
 
 
 
 
24770
  /**
24771
  * WordPress dependencies
24772
  */
24773
 
 
 
 
 
 
 
24774
  /**
24775
+ * Allow scrolling "through" popovers over the canvas. This is only called for
24776
+ * as long as the pointer is over a popover. Do not use React events because it
24777
+ * will bubble through portals.
24778
  *
24779
+ * @param {Object} scrollableRef
 
 
 
 
24780
  */
24781
 
24782
+ function usePopoverScroll(scrollableRef) {
24783
+ return (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
24784
+ if (!scrollableRef) {
24785
+ return;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24786
  }
24787
 
24788
+ function onWheel(event) {
24789
+ const {
24790
+ deltaX,
24791
+ deltaY
24792
+ } = event;
24793
+ scrollableRef.current.scrollBy(deltaX, deltaY);
24794
+ } // Tell the browser that we do not call event.preventDefault
24795
+ // See https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#improving_scrolling_performance_with_passive_listeners
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24796
 
 
 
 
 
 
 
24797
 
24798
+ const options = {
24799
+ passive: true
 
 
 
24800
  };
24801
+ node.addEventListener('wheel', onWheel, options);
 
 
 
 
 
 
 
 
 
 
 
24802
  return () => {
24803
+ node.removeEventListener('wheel', onWheel, options);
 
 
 
24804
  };
24805
+ }, [scrollableRef]);
 
 
 
 
 
 
 
24806
  }
24807
+ //# sourceMappingURL=use-popover-scroll.js.map
24808
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-tools/insertion-point.js
24809
 
24810
 
24811
+ /**
24812
+ * External dependencies
24813
+ */
24814
 
24815
  /**
24816
  * WordPress dependencies
24828
 
24829
 
24830
 
24831
+ const InsertionPointOpenRef = (0,external_wp_element_namespaceObject.createContext)();
 
 
 
 
 
24832
 
24833
+ function InsertionPointPopover({
24834
+ __unstablePopoverSlot,
24835
+ __unstableContentRef
24836
+ }) {
24837
  const {
24838
+ selectBlock
 
24839
  } = (0,external_wp_data_namespaceObject.useDispatch)(store);
24840
+ const openRef = (0,external_wp_element_namespaceObject.useContext)(InsertionPointOpenRef);
24841
+ const ref = (0,external_wp_element_namespaceObject.useRef)();
24842
  const {
24843
+ orientation,
24844
+ previousClientId,
24845
+ nextClientId,
24846
+ rootClientId,
24847
+ isInserterShown
24848
  } = (0,external_wp_data_namespaceObject.useSelect)(select => {
24849
+ var _getBlockListSettings;
24850
+
24851
  const {
24852
+ getBlockOrder,
24853
+ getBlockListSettings,
24854
+ getBlockInsertionPoint,
24855
+ isBlockBeingDragged,
24856
+ getPreviousBlockClientId,
24857
+ getNextBlockClientId
24858
  } = select(store);
24859
+ const insertionPoint = getBlockInsertionPoint();
24860
+ const order = getBlockOrder(insertionPoint.rootClientId);
 
 
 
 
 
24861
 
24862
+ if (!order.length) {
24863
+ return {};
24864
+ }
24865
+
24866
+ let _previousClientId = order[insertionPoint.index - 1];
24867
+ let _nextClientId = order[insertionPoint.index];
24868
+
24869
+ while (isBlockBeingDragged(_previousClientId)) {
24870
+ _previousClientId = getPreviousBlockClientId(_previousClientId);
24871
+ }
24872
+
24873
+ while (isBlockBeingDragged(_nextClientId)) {
24874
+ _nextClientId = getNextBlockClientId(_nextClientId);
24875
+ }
24876
 
 
24877
  return {
24878
+ previousClientId: _previousClientId,
24879
+ nextClientId: _nextClientId,
24880
+ orientation: ((_getBlockListSettings = getBlockListSettings(insertionPoint.rootClientId)) === null || _getBlockListSettings === void 0 ? void 0 : _getBlockListSettings.orientation) || 'vertical',
24881
+ rootClientId: insertionPoint.rootClientId,
24882
+ isInserterShown: insertionPoint === null || insertionPoint === void 0 ? void 0 : insertionPoint.__unstableWithInserter
24883
  };
24884
  }, []);
24885
+ const previousElement = useBlockElement(previousClientId);
24886
+ const nextElement = useBlockElement(nextClientId);
24887
+ const style = (0,external_wp_element_namespaceObject.useMemo)(() => {
24888
+ if (!previousElement && !nextElement) {
24889
+ return {};
24890
+ }
 
 
24891
 
24892
+ const previousRect = previousElement ? previousElement.getBoundingClientRect() : null;
24893
+ const nextRect = nextElement ? nextElement.getBoundingClientRect() : null;
 
 
24894
 
24895
+ if (orientation === 'vertical') {
24896
+ return {
24897
+ width: previousElement ? previousElement.offsetWidth : nextElement.offsetWidth,
24898
+ height: nextRect && previousRect ? nextRect.top - previousRect.bottom : 0
24899
+ };
24900
  }
24901
 
24902
+ let width = 0;
24903
 
24904
+ if (previousRect && nextRect) {
24905
+ width = (0,external_wp_i18n_namespaceObject.isRTL)() ? previousRect.left - nextRect.right : nextRect.left - previousRect.right;
24906
+ }
24907
 
24908
+ return {
24909
+ width,
24910
+ height: previousElement ? previousElement.offsetHeight : nextElement.offsetHeight
24911
+ };
24912
+ }, [previousElement, nextElement]);
24913
+ const getAnchorRect = (0,external_wp_element_namespaceObject.useCallback)(() => {
24914
+ if (!previousElement && !nextElement) {
24915
+ return {};
24916
+ }
 
 
 
 
 
 
 
 
 
24917
 
24918
+ const {
24919
+ ownerDocument
24920
+ } = previousElement || nextElement;
24921
+ const previousRect = previousElement ? previousElement.getBoundingClientRect() : null;
24922
+ const nextRect = nextElement ? nextElement.getBoundingClientRect() : null;
24923
 
24924
+ if (orientation === 'vertical') {
24925
+ if ((0,external_wp_i18n_namespaceObject.isRTL)()) {
24926
+ return {
24927
+ top: previousRect ? previousRect.bottom : nextRect.top,
24928
+ left: previousRect ? previousRect.right : nextRect.right,
24929
+ right: previousRect ? previousRect.left : nextRect.left,
24930
+ bottom: nextRect ? nextRect.top : previousRect.bottom,
24931
+ ownerDocument
24932
+ };
24933
+ }
24934
 
24935
+ return {
24936
+ top: previousRect ? previousRect.bottom : nextRect.top,
24937
+ left: previousRect ? previousRect.left : nextRect.left,
24938
+ right: previousRect ? previousRect.right : nextRect.right,
24939
+ bottom: nextRect ? nextRect.top : previousRect.bottom,
24940
+ ownerDocument
24941
+ };
24942
+ }
 
24943
 
24944
+ if ((0,external_wp_i18n_namespaceObject.isRTL)()) {
24945
+ return {
24946
+ top: previousRect ? previousRect.top : nextRect.top,
24947
+ left: previousRect ? previousRect.left : nextRect.right,
24948
+ right: nextRect ? nextRect.right : previousRect.left,
24949
+ bottom: previousRect ? previousRect.bottom : nextRect.bottom,
24950
+ ownerDocument
24951
+ };
24952
+ }
24953
 
24954
+ return {
24955
+ top: previousRect ? previousRect.top : nextRect.top,
24956
+ left: previousRect ? previousRect.right : nextRect.left,
24957
+ right: nextRect ? nextRect.left : previousRect.right,
24958
+ bottom: previousRect ? previousRect.bottom : nextRect.bottom,
24959
+ ownerDocument
24960
+ };
24961
+ }, [previousElement, nextElement]);
24962
+ const popoverScrollRef = usePopoverScroll(__unstableContentRef);
24963
+ const className = classnames_default()('block-editor-block-list__insertion-point', 'is-' + orientation);
24964
 
24965
+ function onClick(event) {
24966
+ if (event.target === ref.current && nextClientId) {
24967
+ selectBlock(nextClientId, -1);
24968
+ }
24969
+ }
24970
 
24971
+ function onFocus(event) {
24972
+ // Only handle click on the wrapper specifically, and not an event
24973
+ // bubbled from the inserter itself.
24974
+ if (event.target !== ref.current) {
24975
+ openRef.current = true;
24976
+ }
24977
+ } // Only show the in-between inserter between blocks, so when there's a
24978
+ // previous and a next element.
24979
 
24980
 
24981
+ const showInsertionPointInserter = previousElement && nextElement && isInserterShown;
24982
+ /* eslint-disable jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */
24983
+ // While ideally it would be enough to capture the
24984
+ // bubbling focus event from the Inserter, due to the
24985
+ // characteristics of click focusing of `button`s in
24986
+ // Firefox and Safari, it is not reliable.
24987
+ //
24988
+ // See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus
24989
+
24990
+ return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Popover, {
24991
+ ref: popoverScrollRef,
24992
+ noArrow: true,
24993
+ animate: false,
24994
+ getAnchorRect: getAnchorRect,
24995
+ focusOnMount: false,
24996
+ className: "block-editor-block-list__insertion-point-popover" // Render in the old slot if needed for backward compatibility,
24997
+ // otherwise render in place (not in the the default popover slot).
24998
+ ,
24999
+ __unstableSlotName: __unstablePopoverSlot || null
25000
  }, (0,external_wp_element_namespaceObject.createElement)("div", {
25001
+ ref: ref,
25002
+ tabIndex: -1,
25003
+ onClick: onClick,
25004
+ onFocus: onFocus,
25005
+ className: classnames_default()(className, {
25006
+ 'is-with-inserter': showInsertionPointInserter
25007
+ }),
25008
+ style: style
25009
  }, (0,external_wp_element_namespaceObject.createElement)("div", {
25010
+ className: "block-editor-block-list__insertion-point-indicator"
25011
+ }), showInsertionPointInserter && (0,external_wp_element_namespaceObject.createElement)("div", {
25012
+ className: classnames_default()('block-editor-block-list__insertion-point-inserter')
25013
+ }, (0,external_wp_element_namespaceObject.createElement)(inserter, {
25014
+ position: "bottom center",
25015
+ clientId: nextClientId,
25016
+ rootClientId: rootClientId,
25017
+ __experimentalIsQuick: true,
25018
+ onToggle: isOpen => {
25019
+ openRef.current = isOpen;
25020
+ },
25021
+ onSelectOrClose: () => {
25022
+ openRef.current = false;
25023
+ }
25024
+ }))));
25025
+ /* eslint-enable jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */
25026
  }
 
 
 
25027
 
25028
+ function InsertionPoint({
25029
+ children,
25030
+ __unstablePopoverSlot,
25031
+ __unstableContentRef
25032
+ }) {
25033
+ const isVisible = (0,external_wp_data_namespaceObject.useSelect)(select => {
25034
+ return select(store).isBlockInsertionPointVisible();
25035
+ }, []);
25036
+ return (0,external_wp_element_namespaceObject.createElement)(InsertionPointOpenRef.Provider, {
25037
+ value: (0,external_wp_element_namespaceObject.useRef)(false)
25038
+ }, isVisible && (0,external_wp_element_namespaceObject.createElement)(InsertionPointPopover, {
25039
+ __unstablePopoverSlot: __unstablePopoverSlot,
25040
+ __unstableContentRef: __unstableContentRef
25041
+ }), children);
25042
+ }
25043
+ //# sourceMappingURL=insertion-point.js.map
25044
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-list/use-in-between-inserter.js
25045
  /**
25046
  * WordPress dependencies
25047
  */
25048
 
25049
 
25050
 
 
25051
  /**
25052
  * Internal dependencies
25053
  */
25054
 
25055
 
25056
 
25057
+ function useInBetweenInserter() {
25058
+ const openRef = (0,external_wp_element_namespaceObject.useContext)(InsertionPointOpenRef);
25059
+ const hasReducedUI = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).getSettings().hasReducedUI, []);
25060
+ const {
25061
+ getBlockListSettings,
25062
+ getBlockRootClientId,
25063
+ getBlockIndex,
25064
+ isBlockInsertionPointVisible,
25065
+ isMultiSelecting,
25066
+ getSelectedBlockClientIds,
25067
+ getTemplateLock
25068
+ } = (0,external_wp_data_namespaceObject.useSelect)(store);
25069
+ const {
25070
+ showInsertionPoint,
25071
+ hideInsertionPoint
25072
+ } = (0,external_wp_data_namespaceObject.useDispatch)(store);
25073
+ return (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
25074
+ if (hasReducedUI) {
25075
+ return;
25076
+ }
25077
 
25078
+ function onMouseMove(event) {
25079
+ var _getBlockListSettings, _element$parentElemen;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25080
 
25081
+ if (openRef.current) {
25082
+ return;
25083
+ }
 
 
 
25084
 
25085
+ if (isMultiSelecting()) {
25086
+ return;
25087
+ }
25088
 
25089
+ if (!event.target.classList.contains('block-editor-block-list__layout')) {
25090
+ if (isBlockInsertionPointVisible()) {
25091
+ hideInsertionPoint();
25092
+ }
25093
 
25094
+ return;
25095
+ }
 
 
 
 
 
 
25096
 
25097
+ let rootClientId;
 
 
 
 
25098
 
25099
+ if (!event.target.classList.contains('is-root-container')) {
25100
+ const blockElement = !!event.target.getAttribute('data-block') ? event.target : event.target.closest('[data-block]');
25101
+ rootClientId = blockElement.getAttribute('data-block');
25102
+ } // Don't set the insertion point if the template is locked.
25103
 
 
 
 
 
25104
 
25105
+ if (getTemplateLock(rootClientId)) {
25106
+ return;
25107
+ }
 
 
 
 
 
 
 
 
25108
 
25109
+ const orientation = ((_getBlockListSettings = getBlockListSettings(rootClientId)) === null || _getBlockListSettings === void 0 ? void 0 : _getBlockListSettings.orientation) || 'vertical';
25110
+ const rect = event.target.getBoundingClientRect();
25111
+ const offsetTop = event.clientY - rect.top;
25112
+ const offsetLeft = event.clientX - rect.left;
25113
+ const children = Array.from(event.target.children);
25114
+ let element = children.find(blockEl => {
25115
+ return blockEl.classList.contains('wp-block') && orientation === 'vertical' && blockEl.offsetTop > offsetTop || blockEl.classList.contains('wp-block') && orientation === 'horizontal' && blockEl.offsetLeft > offsetLeft;
25116
+ });
25117
 
25118
+ if (!element) {
25119
+ return;
25120
+ } // The block may be in an alignment wrapper, so check the first direct
25121
+ // child if the element has no ID.
25122
 
 
 
 
 
 
25123
 
25124
+ if (!element.id) {
25125
+ element = element.firstElementChild;
25126
 
25127
+ if (!element) {
25128
+ return;
25129
+ }
25130
+ } // Don't show the insertion point if a parent block has an "overlay"
25131
+ // See https://github.com/WordPress/gutenberg/pull/34012#pullrequestreview-727762337
25132
 
25133
 
25134
+ const parentOverlay = (_element$parentElemen = element.parentElement) === null || _element$parentElemen === void 0 ? void 0 : _element$parentElemen.closest('.block-editor-block-content-overlay.overlay-active');
 
 
25135
 
25136
+ if (parentOverlay) {
25137
+ return;
25138
+ }
25139
 
25140
+ const clientId = element.id.slice('block-'.length);
25141
 
25142
+ if (!clientId) {
25143
+ return;
25144
+ } // Don't show the inserter when hovering above (conflicts with
25145
+ // block toolbar) or inside selected block(s).
25146
 
25147
 
25148
+ if (getSelectedBlockClientIds().includes(clientId)) {
25149
+ return;
25150
+ }
25151
 
25152
+ const elementRect = element.getBoundingClientRect();
 
 
25153
 
25154
+ if (orientation === 'horizontal' && (event.clientY > elementRect.bottom || event.clientY < elementRect.top) || orientation === 'vertical' && (event.clientX > elementRect.right || event.clientX < elementRect.left)) {
25155
+ if (isBlockInsertionPointVisible()) {
25156
+ hideInsertionPoint();
25157
+ }
25158
 
25159
+ return;
25160
+ }
25161
 
25162
+ const index = getBlockIndex(clientId, rootClientId); // Don't show the in-between inserter before the first block in
25163
+ // the list (preserves the original behaviour).
25164
 
25165
+ if (index === 0) {
25166
+ if (isBlockInsertionPointVisible()) {
25167
+ hideInsertionPoint();
25168
+ }
25169
 
25170
+ return;
25171
+ }
 
 
25172
 
25173
+ showInsertionPoint(rootClientId, index, {
25174
+ __unstableWithInserter: true
 
 
25175
  });
25176
  }
25177
 
25178
+ node.addEventListener('mousemove', onMouseMove);
25179
+ return () => {
25180
+ node.removeEventListener('mousemove', onMouseMove);
25181
+ };
25182
+ }, [openRef, getBlockListSettings, getBlockRootClientId, getBlockIndex, isBlockInsertionPointVisible, isMultiSelecting, showInsertionPoint, hideInsertionPoint, getSelectedBlockClientIds]);
25183
  }
25184
+ //# sourceMappingURL=use-in-between-inserter.js.map
25185
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/utils/pre-parse-patterns.js
25186
+ /**
25187
+ * WordPress dependencies
25188
+ */
25189
 
 
 
 
 
 
 
 
 
 
 
 
25190
 
25191
+ /**
25192
+ * Internal dependencies
25193
+ */
25194
 
25195
+
25196
+
25197
+ const requestIdleCallback = (() => {
25198
+ if (typeof window === 'undefined') {
25199
+ return callback => {
25200
+ setTimeout(() => callback(Date.now()), 0);
 
 
 
25201
  };
25202
+ }
25203
 
25204
+ return window.requestIdleCallback || window.requestAnimationFrame;
25205
+ })();
 
 
 
 
 
 
 
 
25206
 
25207
+ const cancelIdleCallback = (() => {
25208
+ if (typeof window === 'undefined') {
25209
+ return clearTimeout;
25210
  }
25211
 
25212
+ return window.cancelIdleCallback || window.cancelAnimationFrame;
25213
+ })();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25214
 
25215
+ function usePreParsePatterns() {
25216
+ const patterns = (0,external_wp_data_namespaceObject.useSelect)(_select => _select(store).getSettings().__experimentalBlockPatterns, []);
25217
+ (0,external_wp_element_namespaceObject.useEffect)(() => {
25218
+ if (!(patterns !== null && patterns !== void 0 && patterns.length)) {
25219
+ return;
25220
+ }
25221
+
25222
+ let handle;
25223
+ let index = -1;
25224
+
25225
+ const callback = () => {
25226
+ index++;
25227
+
25228
+ if (index >= patterns.length) {
25229
+ return;
 
 
 
 
 
 
 
 
 
 
 
 
25230
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25231
 
25232
+ (0,external_wp_data_namespaceObject.select)(store).__experimentalGetParsedPattern(patterns[index].name);
 
 
25233
 
25234
+ handle = requestIdleCallback(callback);
25235
+ };
25236
 
25237
+ handle = requestIdleCallback(callback);
25238
+ return () => cancelIdleCallback(handle);
25239
+ }, [patterns]);
25240
+ return null;
25241
+ }
25242
+ //# sourceMappingURL=pre-parse-patterns.js.map
25243
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/use-block-display-information/index.js
25244
  /**
25245
  * WordPress dependencies
25246
  */
25247
 
25248
 
 
 
 
25249
  /**
25250
  * Internal dependencies
25251
  */
25252
 
25253
 
25254
+ /** @typedef {import('@wordpress/blocks').WPIcon} WPIcon */
25255
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25256
  /**
25257
+ * Contains basic block's information for display reasons.
25258
+ *
25259
+ * @typedef {Object} WPBlockDisplayInformation
25260
+ *
25261
+ * @property {string} title Human-readable block type label.
25262
+ * @property {WPIcon} icon Block type icon.
25263
+ * @property {string} description A detailed block type description.
25264
  */
25265
 
25266
  /**
25267
+ * Hook used to try to find a matching block variation and return
25268
+ * the appropriate information for display reasons. In order to
25269
+ * to try to find a match we need to things:
25270
+ * 1. Block's client id to extract it's current attributes.
25271
+ * 2. A block variation should have set `isActive` prop to a proper function.
25272
  *
25273
+ * If for any reason a block variaton match cannot be found,
25274
+ * the returned information come from the Block Type.
25275
+ * If no blockType is found with the provided clientId, returns null.
25276
  *
25277
+ * @param {string} clientId Block's client id.
25278
+ * @return {?WPBlockDisplayInformation} Block's display information, or `null` when the block or its type not found.
25279
  */
25280
 
25281
+ function useBlockDisplayInformation(clientId) {
25282
+ return (0,external_wp_data_namespaceObject.useSelect)(select => {
25283
+ if (!clientId) return null;
25284
+ const {
25285
+ getBlockName,
25286
+ getBlockAttributes
25287
+ } = select(store);
25288
+ const {
25289
+ getBlockType,
25290
+ getActiveBlockVariation
25291
+ } = select(external_wp_blocks_namespaceObject.store);
25292
+ const blockName = getBlockName(clientId);
25293
+ const blockType = getBlockType(blockName);
25294
+ if (!blockType) return null;
25295
+ const attributes = getBlockAttributes(clientId);
25296
+ const match = getActiveBlockVariation(blockName, attributes);
25297
+ const blockTypeInfo = {
25298
+ title: blockType.title,
25299
+ icon: blockType.icon,
25300
+ description: blockType.description,
25301
+ anchor: attributes === null || attributes === void 0 ? void 0 : attributes.anchor
25302
+ };
25303
+ if (!match) return blockTypeInfo;
25304
+ return {
25305
+ title: match.title || blockType.title,
25306
+ icon: match.icon || blockType.icon,
25307
+ description: match.description || blockType.description
25308
+ };
25309
+ }, [clientId]);
25310
+ }
25311
+ //# sourceMappingURL=index.js.map
25312
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-title/index.js
25313
+ /**
25314
+ * External dependencies
25315
  */
25316
 
 
 
 
 
 
 
 
 
 
 
25317
  /**
25318
  * WordPress dependencies
25319
  */
25320
 
25321
 
25322
+
25323
  /**
25324
  * Internal dependencies
25325
  */
25326
 
25327
 
 
 
 
 
 
 
 
 
 
25328
 
 
 
 
 
 
 
 
25329
  /**
25330
+ * Renders the block's configured title as a string, or empty if the title
25331
+ * cannot be determined.
 
25332
  *
25333
+ * @example
25334
+ *
25335
+ * ```jsx
25336
+ * <BlockTitle clientId="afd1cb17-2c08-4e7a-91be-007ba7ddc3a1" />
25337
+ * ```
25338
+ *
25339
+ * @param {Object} props
25340
+ * @param {string} props.clientId Client ID of block.
25341
+ *
25342
+ * @return {?string} Block title.
25343
  */
25344
 
25345
+ function BlockTitle({
25346
+ clientId
25347
+ }) {
25348
+ const {
25349
+ attributes,
25350
+ name,
25351
+ reusableBlockTitle
25352
+ } = (0,external_wp_data_namespaceObject.useSelect)(select => {
25353
+ if (!clientId) {
25354
+ return {};
25355
+ }
 
 
 
 
 
 
 
 
 
 
25356
 
25357
+ const {
25358
+ getBlockName,
25359
+ getBlockAttributes,
25360
+ __experimentalGetReusableBlockTitle
25361
+ } = select(store);
25362
+ const blockName = getBlockName(clientId);
25363
 
25364
+ if (!blockName) {
25365
+ return {};
25366
+ }
25367
 
25368
+ const isReusable = (0,external_wp_blocks_namespaceObject.isReusableBlock)((0,external_wp_blocks_namespaceObject.getBlockType)(blockName));
25369
+ return {
25370
+ attributes: getBlockAttributes(clientId),
25371
+ name: blockName,
25372
+ reusableBlockTitle: isReusable && __experimentalGetReusableBlockTitle(getBlockAttributes(clientId).ref)
25373
+ };
25374
+ }, [clientId]);
25375
+ const blockInformation = useBlockDisplayInformation(clientId);
25376
+ if (!name || !blockInformation) return null;
25377
+ const blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(name);
25378
+ const label = reusableBlockTitle || (0,external_wp_blocks_namespaceObject.__experimentalGetBlockLabel)(blockType, attributes); // Label will fallback to the title if no label is defined for the current
25379
+ // label context. If the label is defined we prioritize it over possible
25380
+ // possible block variation title match.
25381
 
25382
+ if (label !== blockType.title) {
25383
+ return (0,external_lodash_namespaceObject.truncate)(label, {
25384
+ length: 35
25385
+ });
25386
  }
25387
 
25388
+ return blockInformation.title;
25389
+ }
25390
+ //# sourceMappingURL=index.js.map
25391
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-draggable/use-scroll-when-dragging.js
25392
  /**
25393
+ * WordPress dependencies
25394
  */
25395
 
25396
+
25397
+ const SCROLL_INACTIVE_DISTANCE_PX = 50;
25398
+ const SCROLL_INTERVAL_MS = 25;
25399
+ const PIXELS_PER_SECOND_PER_PERCENTAGE = 1000;
25400
+ const VELOCITY_MULTIPLIER = PIXELS_PER_SECOND_PER_PERCENTAGE * (SCROLL_INTERVAL_MS / 1000);
25401
  /**
25402
+ * React hook that scrolls the scroll container when a block is being dragged.
 
 
 
 
 
25403
  *
25404
+ * @return {Function[]} `startScrolling`, `scrollOnDragOver`, `stopScrolling`
25405
+ * functions to be called in `onDragStart`, `onDragOver`
25406
+ * and `onDragEnd` events respectively.
25407
  */
 
25408
 
25409
+ function useScrollWhenDragging() {
25410
+ const dragStartY = (0,external_wp_element_namespaceObject.useRef)(null);
25411
+ const velocityY = (0,external_wp_element_namespaceObject.useRef)(null);
25412
+ const scrollParentY = (0,external_wp_element_namespaceObject.useRef)(null);
25413
+ const scrollEditorInterval = (0,external_wp_element_namespaceObject.useRef)(null); // Clear interval when unmounting.
25414
 
25415
+ (0,external_wp_element_namespaceObject.useEffect)(() => () => {
25416
+ if (scrollEditorInterval.current) {
25417
+ clearInterval(scrollEditorInterval.current);
25418
+ scrollEditorInterval.current = null;
25419
  }
25420
+ }, []);
25421
+ const startScrolling = (0,external_wp_element_namespaceObject.useCallback)(event => {
25422
+ dragStartY.current = event.clientY; // Find nearest parent(s) to scroll.
25423
 
25424
+ scrollParentY.current = (0,external_wp_dom_namespaceObject.getScrollContainer)(event.target);
25425
+ scrollEditorInterval.current = setInterval(() => {
25426
+ if (scrollParentY.current && velocityY.current) {
25427
+ const newTop = scrollParentY.current.scrollTop + velocityY.current; // Setting `behavior: 'smooth'` as a scroll property seems to hurt performance.
25428
+ // Better to use a small scroll interval.
25429
 
25430
+ scrollParentY.current.scroll({
25431
+ top: newTop
25432
+ });
25433
+ }
25434
+ }, SCROLL_INTERVAL_MS);
25435
+ }, []);
25436
+ const scrollOnDragOver = (0,external_wp_element_namespaceObject.useCallback)(event => {
25437
+ if (!scrollParentY.current) {
25438
+ return;
25439
+ }
25440
+
25441
+ const scrollParentHeight = scrollParentY.current.offsetHeight;
25442
+ const offsetDragStartPosition = dragStartY.current - scrollParentY.current.offsetTop;
25443
+ const offsetDragPosition = event.clientY - scrollParentY.current.offsetTop;
25444
+
25445
+ if (event.clientY > offsetDragStartPosition) {
25446
+ // User is dragging downwards.
25447
+ const moveableDistance = Math.max(scrollParentHeight - offsetDragStartPosition - SCROLL_INACTIVE_DISTANCE_PX, 0);
25448
+ const dragDistance = Math.max(offsetDragPosition - offsetDragStartPosition - SCROLL_INACTIVE_DISTANCE_PX, 0);
25449
+ const distancePercentage = dragDistance / moveableDistance;
25450
+ velocityY.current = VELOCITY_MULTIPLIER * distancePercentage;
25451
+ } else if (event.clientY < offsetDragStartPosition) {
25452
+ // User is dragging upwards.
25453
+ const moveableDistance = Math.max(offsetDragStartPosition - SCROLL_INACTIVE_DISTANCE_PX, 0);
25454
+ const dragDistance = Math.max(offsetDragStartPosition - offsetDragPosition - SCROLL_INACTIVE_DISTANCE_PX, 0);
25455
+ const distancePercentage = dragDistance / moveableDistance;
25456
+ velocityY.current = -VELOCITY_MULTIPLIER * distancePercentage;
25457
+ } else {
25458
+ velocityY.current = 0;
25459
+ }
25460
+ }, []);
25461
+
25462
+ const stopScrolling = () => {
25463
+ dragStartY.current = null;
25464
+ scrollParentY.current = null;
25465
+
25466
+ if (scrollEditorInterval.current) {
25467
+ clearInterval(scrollEditorInterval.current);
25468
+ scrollEditorInterval.current = null;
25469
+ }
25470
+ };
25471
 
25472
+ return [startScrolling, scrollOnDragOver, stopScrolling];
25473
+ }
25474
+ //# sourceMappingURL=use-scroll-when-dragging.js.map
25475
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-draggable/index.js
25476
 
25477
 
25478
  /**
25482
 
25483
 
25484
 
 
25485
  /**
25486
  * Internal dependencies
25487
  */
25489
 
25490
 
25491
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25492
 
25493
+ const BlockDraggable = ({
25494
+ children,
25495
+ clientIds,
25496
+ cloneClassname,
25497
+ onDragStart,
25498
+ onDragEnd
25499
+ }) => {
25500
+ const {
25501
+ srcRootClientId,
25502
+ isDraggable,
25503
+ icon
25504
+ } = (0,external_wp_data_namespaceObject.useSelect)(select => {
25505
+ var _getBlockType;
 
 
 
 
 
 
 
25506
 
25507
+ const {
25508
+ getBlockRootClientId,
25509
+ getTemplateLock,
25510
+ getBlockName
25511
+ } = select(store);
25512
+ const rootClientId = getBlockRootClientId(clientIds[0]);
25513
+ const templateLock = rootClientId ? getTemplateLock(rootClientId) : null;
25514
+ const blockName = getBlockName(clientIds[0]);
25515
+ return {
25516
+ srcRootClientId: rootClientId,
25517
+ isDraggable: 'all' !== templateLock,
25518
+ icon: (_getBlockType = (0,external_wp_blocks_namespaceObject.getBlockType)(blockName)) === null || _getBlockType === void 0 ? void 0 : _getBlockType.icon
25519
+ };
25520
+ }, [clientIds]);
25521
+ const isDragging = (0,external_wp_element_namespaceObject.useRef)(false);
25522
+ const [startScrolling, scrollOnDragOver, stopScrolling] = useScrollWhenDragging();
25523
+ const {
25524
+ startDraggingBlocks,
25525
+ stopDraggingBlocks
25526
+ } = (0,external_wp_data_namespaceObject.useDispatch)(store); // Stop dragging blocks if the block draggable is unmounted
25527
 
25528
+ (0,external_wp_element_namespaceObject.useEffect)(() => {
25529
+ return () => {
25530
+ if (isDragging.current) {
25531
+ stopDraggingBlocks();
25532
+ }
25533
+ };
25534
+ }, []);
25535
+
25536
+ if (!isDraggable) {
25537
+ return children({
25538
+ isDraggable: false
25539
+ });
25540
+ }
25541
+
25542
+ const transferData = {
25543
+ type: 'block',
25544
+ srcClientIds: clientIds,
25545
+ srcRootClientId
25546
+ };
25547
+ return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Draggable, {
25548
+ cloneClassname: cloneClassname,
25549
+ __experimentalTransferDataType: "wp-blocks",
25550
+ transferData: transferData,
25551
+ onDragStart: event => {
25552
+ startDraggingBlocks(clientIds);
25553
+ isDragging.current = true;
25554
+ startScrolling(event);
25555
+
25556
+ if (onDragStart) {
25557
+ onDragStart();
25558
+ }
25559
+ },
25560
+ onDragOver: scrollOnDragOver,
25561
+ onDragEnd: () => {
25562
+ stopDraggingBlocks();
25563
+ isDragging.current = false;
25564
+ stopScrolling();
25565
+
25566
+ if (onDragEnd) {
25567
+ onDragEnd();
25568
+ }
25569
+ },
25570
+ __experimentalDragComponent: (0,external_wp_element_namespaceObject.createElement)(BlockDraggableChip, {
25571
+ count: clientIds.length,
25572
+ icon: icon
25573
+ })
25574
+ }, ({
25575
+ onDraggableStart,
25576
+ onDraggableEnd
25577
+ }) => {
25578
+ return children({
25579
+ draggable: true,
25580
+ onDragStart: onDraggableStart,
25581
+ onDragEnd: onDraggableEnd
25582
+ });
25583
+ });
25584
+ };
25585
+
25586
+ /* harmony default export */ var block_draggable = (BlockDraggable);
25587
+ //# sourceMappingURL=index.js.map
25588
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-tools/block-selection-button.js
25589
 
 
 
 
25590
 
25591
 
25592
  /**
25602
 
25603
 
25604
 
25605
+
25606
+
25607
+
25608
+
25609
  /**
25610
  * Internal dependencies
25611
  */
25615
 
25616
 
25617
 
25618
+ /**
25619
+ * Block selection button component, displaying the label of the block. If the block
25620
+ * descends from a root block, a button is displayed enabling the user to select
25621
+ * the root block.
25622
+ *
25623
+ * @param {string} props Component props.
25624
+ * @param {string} props.clientId Client ID of block.
25625
+ *
25626
+ * @return {WPComponent} The component to be rendered.
25627
+ */
25628
 
25629
+ function BlockSelectionButton({
25630
+ clientId,
25631
+ rootClientId,
25632
+ blockElement
25633
+ }) {
25634
+ const blockInformation = useBlockDisplayInformation(clientId);
25635
+ const selected = (0,external_wp_data_namespaceObject.useSelect)(select => {
25636
+ var _getBlockListSettings;
25637
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25638
  const {
25639
+ __unstableGetBlockWithoutInnerBlocks,
25640
+ getBlockIndex,
25641
+ hasBlockMovingClientId,
25642
+ getBlockListSettings
25643
  } = select(store);
25644
+ const index = getBlockIndex(clientId, rootClientId);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25645
 
25646
+ const {
25647
+ name,
25648
+ attributes
25649
+ } = __unstableGetBlockWithoutInnerBlocks(clientId);
25650
 
25651
+ const blockMovingMode = hasBlockMovingClientId();
25652
  return {
25653
+ index,
25654
+ name,
25655
+ attributes,
25656
+ blockMovingMode,
25657
+ orientation: (_getBlockListSettings = getBlockListSettings(rootClientId)) === null || _getBlockListSettings === void 0 ? void 0 : _getBlockListSettings.orientation
25658
+ };
25659
+ }, [clientId, rootClientId]);
25660
+ const {
25661
+ index,
25662
+ name,
25663
+ attributes,
25664
+ blockMovingMode,
25665
+ orientation
25666
+ } = selected;
25667
+ const {
25668
+ setNavigationMode,
25669
+ removeBlock
25670
+ } = (0,external_wp_data_namespaceObject.useDispatch)(store);
25671
+ const ref = (0,external_wp_element_namespaceObject.useRef)();
25672
+ const blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(name);
25673
+ const label = (0,external_wp_blocks_namespaceObject.__experimentalGetAccessibleBlockLabel)(blockType, attributes, index + 1, orientation); // Focus the breadcrumb in navigation mode.
25674
 
25675
+ (0,external_wp_element_namespaceObject.useEffect)(() => {
25676
+ ref.current.focus();
25677
+ (0,external_wp_a11y_namespaceObject.speak)(label);
25678
+ }, [label]);
25679
+ const {
25680
+ hasBlockMovingClientId,
25681
+ getBlockIndex,
25682
+ getBlockRootClientId,
25683
+ getClientIdsOfDescendants,
25684
+ getSelectedBlockClientId,
25685
+ getMultiSelectedBlocksEndClientId,
25686
+ getPreviousBlockClientId,
25687
+ getNextBlockClientId
25688
+ } = (0,external_wp_data_namespaceObject.useSelect)(store);
25689
+ const {
25690
+ selectBlock,
25691
+ clearSelectedBlock,
25692
+ setBlockMovingClientId,
25693
+ moveBlockToPosition
25694
+ } = (0,external_wp_data_namespaceObject.useDispatch)(store);
25695
 
25696
+ function onKeyDown(event) {
25697
+ const {
25698
+ keyCode
25699
+ } = event;
25700
+ const isUp = keyCode === external_wp_keycodes_namespaceObject.UP;
25701
+ const isDown = keyCode === external_wp_keycodes_namespaceObject.DOWN;
25702
+ const isLeft = keyCode === external_wp_keycodes_namespaceObject.LEFT;
25703
+ const isRight = keyCode === external_wp_keycodes_namespaceObject.RIGHT;
25704
+ const isTab = keyCode === external_wp_keycodes_namespaceObject.TAB;
25705
+ const isEscape = keyCode === external_wp_keycodes_namespaceObject.ESCAPE;
25706
+ const isEnter = keyCode === external_wp_keycodes_namespaceObject.ENTER;
25707
+ const isSpace = keyCode === external_wp_keycodes_namespaceObject.SPACE;
25708
+ const isShift = event.shiftKey;
25709
 
25710
+ if (keyCode === external_wp_keycodes_namespaceObject.BACKSPACE || keyCode === external_wp_keycodes_namespaceObject.DELETE) {
25711
+ removeBlock(clientId);
25712
+ event.preventDefault();
25713
+ return;
25714
+ }
25715
 
25716
+ const selectedBlockClientId = getSelectedBlockClientId();
25717
+ const selectionEndClientId = getMultiSelectedBlocksEndClientId();
25718
+ const selectionBeforeEndClientId = getPreviousBlockClientId(selectionEndClientId || selectedBlockClientId);
25719
+ const selectionAfterEndClientId = getNextBlockClientId(selectionEndClientId || selectedBlockClientId);
25720
+ const navigateUp = isTab && isShift || isUp;
25721
+ const navigateDown = isTab && !isShift || isDown; // Move out of current nesting level (no effect if at root level).
25722
 
25723
+ const navigateOut = isLeft; // Move into next nesting level (no effect if the current block has no innerBlocks).
 
 
 
 
 
 
 
 
 
 
25724
 
25725
+ const navigateIn = isRight;
25726
+ let focusedBlockUid;
25727
+
25728
+ if (navigateUp) {
25729
+ focusedBlockUid = selectionBeforeEndClientId;
25730
+ } else if (navigateDown) {
25731
+ focusedBlockUid = selectionAfterEndClientId;
25732
+ } else if (navigateOut) {
25733
+ var _getBlockRootClientId;
25734
+
25735
+ focusedBlockUid = (_getBlockRootClientId = getBlockRootClientId(selectedBlockClientId)) !== null && _getBlockRootClientId !== void 0 ? _getBlockRootClientId : selectedBlockClientId;
25736
+ } else if (navigateIn) {
25737
+ var _getClientIdsOfDescen;
25738
+
25739
+ focusedBlockUid = (_getClientIdsOfDescen = getClientIdsOfDescendants([selectedBlockClientId])[0]) !== null && _getClientIdsOfDescen !== void 0 ? _getClientIdsOfDescen : selectedBlockClientId;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25740
  }
25741
+
25742
+ const startingBlockClientId = hasBlockMovingClientId();
25743
+
25744
+ if (isEscape && startingBlockClientId && !event.defaultPrevented) {
25745
+ setBlockMovingClientId(null);
25746
+ event.preventDefault();
 
25747
  }
 
 
 
 
 
 
 
 
 
25748
 
25749
+ if ((isEnter || isSpace) && startingBlockClientId) {
25750
+ const sourceRoot = getBlockRootClientId(startingBlockClientId);
25751
+ const destRoot = getBlockRootClientId(selectedBlockClientId);
25752
+ const sourceBlockIndex = getBlockIndex(startingBlockClientId, sourceRoot);
25753
+ let destinationBlockIndex = getBlockIndex(selectedBlockClientId, destRoot);
25754
 
25755
+ if (sourceBlockIndex < destinationBlockIndex && sourceRoot === destRoot) {
25756
+ destinationBlockIndex -= 1;
25757
+ }
 
 
 
 
 
 
 
 
 
 
25758
 
25759
+ moveBlockToPosition(startingBlockClientId, sourceRoot, destRoot, destinationBlockIndex);
25760
+ selectBlock(startingBlockClientId);
25761
+ setBlockMovingClientId(null);
25762
+ }
25763
 
25764
+ if (navigateDown || navigateUp || navigateOut || navigateIn) {
25765
+ if (focusedBlockUid) {
25766
+ event.preventDefault();
25767
+ selectBlock(focusedBlockUid);
25768
+ } else if (isTab && selectedBlockClientId) {
25769
+ let nextTabbable;
 
25770
 
25771
+ if (navigateDown) {
25772
+ nextTabbable = external_wp_dom_namespaceObject.focus.tabbable.findNext(blockElement);
25773
+
25774
+ if (!nextTabbable) {
25775
+ nextTabbable = blockElement.ownerDocument.defaultView.frameElement;
25776
+ nextTabbable = external_wp_dom_namespaceObject.focus.tabbable.findNext(nextTabbable);
25777
+ }
25778
+ } else {
25779
+ nextTabbable = external_wp_dom_namespaceObject.focus.tabbable.findPrevious(blockElement);
25780
+ }
25781
+
25782
+ if (nextTabbable) {
25783
+ event.preventDefault();
25784
+ nextTabbable.focus();
25785
+ clearSelectedBlock();
25786
+ }
25787
+ }
25788
  }
25789
  }
25790
 
25791
+ const classNames = classnames_default()('block-editor-block-list__block-selection-button', {
25792
+ 'is-block-moving-mode': !!blockMovingMode
25793
+ });
 
25794
 
25795
+ const dragHandleLabel = (0,external_wp_i18n_namespaceObject.__)('Drag');
 
 
 
25796
 
25797
+ return (0,external_wp_element_namespaceObject.createElement)("div", {
25798
+ className: classNames
25799
+ }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Flex, {
25800
+ justify: "center",
25801
+ className: "block-editor-block-list__block-selection-button__content"
25802
+ }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_element_namespaceObject.createElement)(BlockIcon, {
25803
+ icon: blockInformation === null || blockInformation === void 0 ? void 0 : blockInformation.icon,
25804
+ showColors: true
25805
+ })), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_element_namespaceObject.createElement)(block_draggable, {
25806
+ clientIds: [clientId]
25807
+ }, draggableProps => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, _extends({
25808
+ icon: drag_handle,
25809
+ className: "block-selection-button_drag-handle",
25810
+ "aria-hidden": "true",
25811
+ label: dragHandleLabel // Should not be able to tab to drag handle as this
25812
+ // button can only be used with a pointer device.
25813
+ ,
25814
+ tabIndex: "-1"
25815
+ }, draggableProps)))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
25816
+ ref: ref,
25817
+ onClick: () => setNavigationMode(false),
25818
+ onKeyDown: onKeyDown,
25819
+ label: label,
25820
+ className: "block-selection-button_select-button"
25821
+ }, (0,external_wp_element_namespaceObject.createElement)(BlockTitle, {
25822
+ clientId: clientId
25823
+ })))));
25824
  }
25825
+
25826
+ /* harmony default export */ var block_selection_button = (BlockSelectionButton);
25827
+ //# sourceMappingURL=block-selection-button.js.map
25828
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/navigable-toolbar/index.js
25829
+
25830
 
25831
 
25832
  /**
25838
 
25839
 
25840
 
25841
+ function hasOnlyToolbarItem(elements) {
25842
+ const dataProp = 'toolbarItem';
25843
+ return !elements.some(element => !(dataProp in element.dataset));
25844
+ }
25845
 
25846
+ function getAllToolbarItemsIn(container) {
25847
+ return Array.from(container.querySelectorAll('[data-toolbar-item]'));
25848
+ }
 
 
25849
 
25850
+ function hasFocusWithin(container) {
25851
+ return container.contains(container.ownerDocument.activeElement);
25852
+ }
 
 
 
 
 
 
 
 
 
25853
 
25854
+ function focusFirstTabbableIn(container) {
25855
+ const [firstTabbable] = external_wp_dom_namespaceObject.focus.tabbable.find(container);
 
 
 
 
 
 
 
 
 
 
 
25856
 
25857
+ if (firstTabbable) {
25858
+ firstTabbable.focus();
25859
+ }
 
25860
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25861
 
25862
+ function useIsAccessibleToolbar(ref) {
25863
+ /*
25864
+ * By default, we'll assume the starting accessible state of the Toolbar
25865
+ * is true, as it seems to be the most common case.
25866
+ *
25867
+ * Transitioning from an (initial) false to true state causes the
25868
+ * <Toolbar /> component to mount twice, which is causing undesired
25869
+ * side-effects. These side-effects appear to only affect certain
25870
+ * E2E tests.
25871
+ *
25872
+ * This was initial discovered in this pull-request:
25873
+ * https://github.com/WordPress/gutenberg/pull/23425
25874
+ */
25875
+ const initialAccessibleToolbarState = true; // By default, it's gonna render NavigableMenu. If all the tabbable elements
25876
+ // inside the toolbar are ToolbarItem components (or derived components like
25877
+ // ToolbarButton), then we can wrap them with the accessible Toolbar
25878
+ // component.
25879
 
25880
+ const [isAccessibleToolbar, setIsAccessibleToolbar] = (0,external_wp_element_namespaceObject.useState)(initialAccessibleToolbarState);
25881
+ const determineIsAccessibleToolbar = (0,external_wp_element_namespaceObject.useCallback)(() => {
25882
+ const tabbables = external_wp_dom_namespaceObject.focus.tabbable.find(ref.current);
25883
+ const onlyToolbarItem = hasOnlyToolbarItem(tabbables);
25884
 
25885
+ if (!onlyToolbarItem) {
25886
+ external_wp_deprecated_default()('Using custom components as toolbar controls', {
25887
+ since: '5.6',
25888
+ alternative: 'ToolbarItem, ToolbarButton or ToolbarDropdownMenu components',
25889
+ link: 'https://developer.wordpress.org/block-editor/components/toolbar-button/#inside-blockcontrols'
25890
+ });
25891
+ }
 
25892
 
25893
+ setIsAccessibleToolbar(onlyToolbarItem);
25894
+ }, []);
25895
+ (0,external_wp_element_namespaceObject.useLayoutEffect)(() => {
25896
+ // Toolbar buttons may be rendered asynchronously, so we use
25897
+ // MutationObserver to check if the toolbar subtree has been modified
25898
+ const observer = new window.MutationObserver(determineIsAccessibleToolbar);
25899
+ observer.observe(ref.current, {
25900
+ childList: true,
25901
+ subtree: true
25902
+ });
25903
+ return () => observer.disconnect();
25904
+ }, [isAccessibleToolbar]);
25905
+ return isAccessibleToolbar;
25906
+ }
25907
 
25908
+ function useToolbarFocus(ref, focusOnMount, isAccessibleToolbar, defaultIndex, onIndexChange) {
25909
+ // Make sure we don't use modified versions of this prop
25910
+ const [initialFocusOnMount] = (0,external_wp_element_namespaceObject.useState)(focusOnMount);
25911
+ const [initialIndex] = (0,external_wp_element_namespaceObject.useState)(defaultIndex);
25912
+ const focusToolbar = (0,external_wp_element_namespaceObject.useCallback)(() => {
25913
+ focusFirstTabbableIn(ref.current);
25914
+ }, []); // Focus on toolbar when pressing alt+F10 when the toolbar is visible
25915
 
25916
+ (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/block-editor/focus-toolbar', focusToolbar, {
25917
+ bindGlobal: true,
25918
+ eventName: 'keydown'
25919
+ });
25920
+ (0,external_wp_element_namespaceObject.useEffect)(() => {
25921
+ if (initialFocusOnMount) {
25922
+ focusToolbar();
25923
+ }
25924
+ }, [isAccessibleToolbar, initialFocusOnMount, focusToolbar]);
25925
+ (0,external_wp_element_namespaceObject.useEffect)(() => {
25926
+ // If initialIndex is passed, we focus on that toolbar item when the
25927
+ // toolbar gets mounted and initial focus is not forced.
25928
+ // We have to wait for the next browser paint because block controls aren't
25929
+ // rendered right away when the toolbar gets mounted.
25930
+ let raf = 0;
25931
 
25932
+ if (initialIndex && !initialFocusOnMount) {
25933
+ raf = window.requestAnimationFrame(() => {
25934
+ const items = getAllToolbarItemsIn(ref.current);
25935
+ const index = initialIndex || 0;
25936
 
25937
+ if (items[index] && hasFocusWithin(ref.current)) {
25938
+ items[index].focus();
 
25939
  }
25940
+ });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25941
  }
25942
 
 
 
 
25943
  return () => {
25944
+ window.cancelAnimationFrame(raf);
25945
+ if (!onIndexChange || !ref.current) return; // When the toolbar element is unmounted and onIndexChange is passed, we
25946
+ // pass the focused toolbar item index so it can be hydrated later.
25947
+
25948
+ const items = getAllToolbarItemsIn(ref.current);
25949
+ const index = items.findIndex(item => item.tabIndex === 0);
25950
+ onIndexChange(index);
25951
  };
25952
+ }, [initialIndex, initialFocusOnMount]);
25953
  }
25954
 
25955
+ function NavigableToolbar({
25956
+ children,
25957
+ focusOnMount,
25958
+ __experimentalInitialIndex: initialIndex,
25959
+ __experimentalOnIndexChange: onIndexChange,
25960
+ ...props
25961
  }) {
25962
+ const ref = (0,external_wp_element_namespaceObject.useRef)();
25963
+ const isAccessibleToolbar = useIsAccessibleToolbar(ref);
25964
+ useToolbarFocus(ref, focusOnMount, isAccessibleToolbar, initialIndex, onIndexChange);
25965
+
25966
+ if (isAccessibleToolbar) {
25967
+ return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Toolbar, _extends({
25968
+ label: props['aria-label'],
25969
+ ref: ref
25970
+ }, props), children);
25971
+ }
25972
+
25973
+ return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.NavigableMenu, _extends({
25974
+ orientation: "horizontal",
25975
+ role: "toolbar",
25976
+ ref: ref
25977
+ }, props), children);
25978
  }
25979
 
25980
+ /* harmony default export */ var navigable_toolbar = (NavigableToolbar);
25981
  //# sourceMappingURL=index.js.map
25982
+ ;// CONCATENATED MODULE: ./packages/icons/build-module/library/chevron-right.js
25983
+
 
 
25984
 
25985
  /**
25986
  * WordPress dependencies
25987
  */
25988
 
25989
+ const chevronRight = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
25990
+ xmlns: "http://www.w3.org/2000/svg",
25991
+ viewBox: "0 0 24 24"
25992
+ }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
25993
+ d: "M10.6 6L9.4 7l4.6 5-4.6 5 1.2 1 5.4-6z"
25994
+ }));
25995
+ /* harmony default export */ var chevron_right = (chevronRight);
25996
+ //# sourceMappingURL=chevron-right.js.map
25997
+ ;// CONCATENATED MODULE: ./packages/icons/build-module/library/chevron-left.js
25998
 
25999
 
26000
  /**
26001
+ * WordPress dependencies
26002
  */
26003
 
26004
+ const chevronLeft = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
26005
+ xmlns: "http://www.w3.org/2000/svg",
26006
+ viewBox: "0 0 24 24"
26007
+ }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
26008
+ d: "M14.6 7l-1.2-1L8 12l5.4 6 1.2-1-4.6-5z"
26009
+ }));
26010
+ /* harmony default export */ var chevron_left = (chevronLeft);
26011
+ //# sourceMappingURL=chevron-left.js.map
26012
+ ;// CONCATENATED MODULE: ./packages/icons/build-module/library/chevron-up.js
26013
 
26014
 
26015
+ /**
26016
+ * WordPress dependencies
26017
+ */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26018
 
26019
+ const chevronUp = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
26020
+ viewBox: "0 0 24 24",
26021
+ xmlns: "http://www.w3.org/2000/svg"
26022
+ }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
26023
+ d: "M6.5 12.4L12 8l5.5 4.4-.9 1.2L12 10l-4.5 3.6-1-1.2z"
26024
+ }));
26025
+ /* harmony default export */ var chevron_up = (chevronUp);
26026
+ //# sourceMappingURL=chevron-up.js.map
26027
+ ;// CONCATENATED MODULE: ./packages/icons/build-module/library/chevron-down.js
26028
 
 
 
 
26029
 
26030
+ /**
26031
+ * WordPress dependencies
26032
+ */
 
 
26033
 
26034
+ const chevronDown = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
26035
+ viewBox: "0 0 24 24",
26036
+ xmlns: "http://www.w3.org/2000/svg"
26037
+ }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
26038
+ d: "M17.5 11.6L12 16l-5.5-4.4.9-1.2L12 14l4.5-3.6 1 1.2z"
26039
+ }));
26040
+ /* harmony default export */ var chevron_down = (chevronDown);
26041
+ //# sourceMappingURL=chevron-down.js.map
26042
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-mover/mover-description.js
26043
+ /**
26044
+ * WordPress dependencies
26045
+ */
26046
 
26047
+ /**
26048
+ * Return a label for the block movement controls depending on block position.
26049
+ *
26050
+ * @param {number} selectedCount Number of blocks selected.
26051
+ * @param {string} type Block type - in the case of a single block, should
26052
+ * define its 'type'. I.e. 'Text', 'Heading', 'Image' etc.
26053
+ * @param {number} firstIndex The index (position - 1) of the first block selected.
26054
+ * @param {boolean} isFirst This is the first block.
26055
+ * @param {boolean} isLast This is the last block.
26056
+ * @param {number} dir Direction of movement (> 0 is considered to be going
26057
+ * down, < 0 is up).
26058
+ * @param {string} orientation The orientation of the block movers, vertical or
26059
+ * horizontal.
26060
+ *
26061
+ * @return {string} Label for the block movement controls.
26062
+ */
26063
 
26064
+ function getBlockMoverDescription(selectedCount, type, firstIndex, isFirst, isLast, dir, orientation) {
26065
+ const position = firstIndex + 1;
26066
 
26067
+ const getMovementDirection = moveDirection => {
26068
+ if (moveDirection === 'up') {
26069
+ if (orientation === 'horizontal') {
26070
+ return (0,external_wp_i18n_namespaceObject.isRTL)() ? 'right' : 'left';
26071
  }
26072
 
26073
+ return 'up';
26074
+ } else if (moveDirection === 'down') {
26075
+ if (orientation === 'horizontal') {
26076
+ return (0,external_wp_i18n_namespaceObject.isRTL)() ? 'left' : 'right';
 
 
26077
  }
26078
 
26079
+ return 'down';
26080
+ }
26081
 
26082
+ return null;
26083
+ };
 
26084
 
26085
+ if (selectedCount > 1) {
26086
+ return getMultiBlockMoverDescription(selectedCount, firstIndex, isFirst, isLast, dir);
26087
+ }
26088
 
26089
+ if (isFirst && isLast) {
26090
+ return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: %s: Type of block (i.e. Text, Image etc)
26091
+ (0,external_wp_i18n_namespaceObject.__)('Block %s is the only block, and cannot be moved'), type);
26092
+ }
26093
 
26094
+ if (dir > 0 && !isLast) {
26095
+ // moving down
26096
+ const movementDirection = getMovementDirection('down');
26097
 
26098
+ if (movementDirection === 'down') {
26099
+ return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: 1: Type of block (i.e. Text, Image etc), 2: Position of selected block, 3: New position
26100
+ (0,external_wp_i18n_namespaceObject.__)('Move %1$s block from position %2$d down to position %3$d'), type, position, position + 1);
26101
  }
26102
 
26103
+ if (movementDirection === 'left') {
26104
+ return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: 1: Type of block (i.e. Text, Image etc), 2: Position of selected block, 3: New position
26105
+ (0,external_wp_i18n_namespaceObject.__)('Move %1$s block from position %2$d left to position %3$d'), type, position, position + 1);
26106
+ }
 
 
 
 
 
26107
 
26108
+ if (movementDirection === 'right') {
26109
+ return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: 1: Type of block (i.e. Text, Image etc), 2: Position of selected block, 3: New position
26110
+ (0,external_wp_i18n_namespaceObject.__)('Move %1$s block from position %2$d right to position %3$d'), type, position, position + 1);
26111
+ }
26112
+ }
26113
 
26114
+ if (dir > 0 && isLast) {
26115
+ // moving down, and is the last item
26116
+ const movementDirection = getMovementDirection('down');
26117
 
26118
+ if (movementDirection === 'down') {
26119
+ return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: 1: Type of block (i.e. Text, Image etc)
26120
+ (0,external_wp_i18n_namespaceObject.__)('Block %1$s is at the end of the content and can’t be moved down'), type);
26121
+ }
26122
 
26123
+ if (movementDirection === 'left') {
26124
+ return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: 1: Type of block (i.e. Text, Image etc)
26125
+ (0,external_wp_i18n_namespaceObject.__)('Block %1$s is at the end of the content and can’t be moved left'), type);
26126
+ }
26127
 
26128
+ if (movementDirection === 'right') {
26129
+ return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: 1: Type of block (i.e. Text, Image etc)
26130
+ (0,external_wp_i18n_namespaceObject.__)('Block %1$s is at the end of the content and can’t be moved right'), type);
26131
+ }
26132
+ }
26133
 
26134
+ if (dir < 0 && !isFirst) {
26135
+ // moving up
26136
+ const movementDirection = getMovementDirection('up');
26137
 
26138
+ if (movementDirection === 'up') {
26139
+ return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: 1: Type of block (i.e. Text, Image etc), 2: Position of selected block, 3: New position
26140
+ (0,external_wp_i18n_namespaceObject.__)('Move %1$s block from position %2$d up to position %3$d'), type, position, position - 1);
26141
+ }
26142
 
26143
+ if (movementDirection === 'left') {
26144
+ return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: 1: Type of block (i.e. Text, Image etc), 2: Position of selected block, 3: New position
26145
+ (0,external_wp_i18n_namespaceObject.__)('Move %1$s block from position %2$d left to position %3$d'), type, position, position - 1);
26146
+ }
26147
 
26148
+ if (movementDirection === 'right') {
26149
+ return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: 1: Type of block (i.e. Text, Image etc), 2: Position of selected block, 3: New position
26150
+ (0,external_wp_i18n_namespaceObject.__)('Move %1$s block from position %2$d right to position %3$d'), type, position, position - 1);
26151
+ }
 
 
 
 
 
26152
  }
26153
 
26154
+ if (dir < 0 && isFirst) {
26155
+ // moving up, and is the first item
26156
+ const movementDirection = getMovementDirection('up');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26157
 
26158
+ if (movementDirection === 'up') {
26159
+ return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: 1: Type of block (i.e. Text, Image etc)
26160
+ (0,external_wp_i18n_namespaceObject.__)('Block %1$s is at the beginning of the content and can’t be moved up'), type);
26161
+ }
26162
 
26163
+ if (movementDirection === 'left') {
26164
+ return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: 1: Type of block (i.e. Text, Image etc)
26165
+ (0,external_wp_i18n_namespaceObject.__)('Block %1$s is at the beginning of the content and can’t be moved left'), type);
26166
+ }
26167
 
26168
+ if (movementDirection === 'right') {
26169
+ return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: 1: Type of block (i.e. Text, Image etc)
26170
+ (0,external_wp_i18n_namespaceObject.__)('Block %1$s is at the beginning of the content and can’t be moved right'), type);
26171
+ }
26172
+ }
26173
+ }
26174
  /**
26175
+ * Return a label for the block movement controls depending on block position.
26176
+ *
26177
+ * @param {number} selectedCount Number of blocks selected.
26178
+ * @param {number} firstIndex The index (position - 1) of the first block selected.
26179
+ * @param {boolean} isFirst This is the first block.
26180
+ * @param {boolean} isLast This is the last block.
26181
+ * @param {number} dir Direction of movement (> 0 is considered to be going
26182
+ * down, < 0 is up).
26183
+ *
26184
+ * @return {string} Label for the block movement controls.
26185
  */
26186
 
26187
+ function getMultiBlockMoverDescription(selectedCount, firstIndex, isFirst, isLast, dir) {
26188
+ const position = firstIndex + 1;
26189
 
26190
+ if (dir < 0 && isFirst) {
26191
+ return (0,external_wp_i18n_namespaceObject.__)('Blocks cannot be moved up as they are already at the top');
 
 
 
 
 
26192
  }
26193
 
26194
+ if (dir > 0 && isLast) {
26195
+ return (0,external_wp_i18n_namespaceObject.__)('Blocks cannot be moved down as they are already at the bottom');
26196
+ }
26197
 
26198
+ if (dir < 0 && !isFirst) {
26199
+ return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: 1: Number of selected blocks, 2: Position of selected blocks
26200
+ (0,external_wp_i18n_namespaceObject._n)('Move %1$d block from position %2$d up by one place', 'Move %1$d blocks from position %2$d up by one place', selectedCount), selectedCount, position);
26201
+ }
26202
+
26203
+ if (dir > 0 && !isLast) {
26204
+ return (0,external_wp_i18n_namespaceObject.sprintf)( // translators: 1: Number of selected blocks, 2: Position of selected blocks
26205
+ (0,external_wp_i18n_namespaceObject._n)('Move %1$d block from position %2$d down by one place', 'Move %1$d blocks from position %2$d down by one place', selectedCount), selectedCount, position);
26206
+ }
26207
  }
26208
+ //# sourceMappingURL=mover-description.js.map
26209
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-mover/button.js
 
 
 
26210
 
26211
 
26212
 
26213
  /**
26214
+ * External dependencies
26215
  */
26216
 
26217
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26218
  /**
26219
  * WordPress dependencies
26220
  */
26221
 
 
 
 
 
 
 
 
 
26222
 
26223
 
 
 
 
26224
 
26225
 
26226
 
26232
 
26233
 
26234
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26235
 
26236
+ const getArrowIcon = (direction, orientation) => {
26237
+ if (direction === 'up') {
26238
+ if (orientation === 'horizontal') {
26239
+ return (0,external_wp_i18n_namespaceObject.isRTL)() ? chevron_right : chevron_left;
26240
  }
 
 
 
 
26241
 
26242
+ return chevron_up;
26243
+ } else if (direction === 'down') {
26244
+ if (orientation === 'horizontal') {
26245
+ return (0,external_wp_i18n_namespaceObject.isRTL)() ? chevron_left : chevron_right;
26246
  }
26247
 
26248
+ return chevron_down;
 
 
 
 
26249
  }
26250
 
26251
+ return null;
26252
+ };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26253
 
26254
+ const getMovementDirectionLabel = (moveDirection, orientation) => {
26255
+ if (moveDirection === 'up') {
26256
+ if (orientation === 'horizontal') {
26257
+ return (0,external_wp_i18n_namespaceObject.isRTL)() ? (0,external_wp_i18n_namespaceObject.__)('Move right') : (0,external_wp_i18n_namespaceObject.__)('Move left');
26258
+ }
26259
 
26260
+ return (0,external_wp_i18n_namespaceObject.__)('Move up');
26261
+ } else if (moveDirection === 'down') {
26262
+ if (orientation === 'horizontal') {
26263
+ return (0,external_wp_i18n_namespaceObject.isRTL)() ? (0,external_wp_i18n_namespaceObject.__)('Move left') : (0,external_wp_i18n_namespaceObject.__)('Move right');
26264
+ }
26265
 
26266
+ return (0,external_wp_i18n_namespaceObject.__)('Move down');
26267
+ }
 
 
 
 
 
 
 
 
26268
 
26269
+ return null;
26270
+ };
 
 
 
 
 
26271
 
26272
+ const BlockMoverButton = (0,external_wp_element_namespaceObject.forwardRef)(({
26273
+ clientIds,
26274
+ direction,
26275
+ orientation: moverOrientation,
26276
+ ...props
26277
+ }, ref) => {
26278
+ const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(BlockMoverButton);
26279
+ const blocksCount = (0,external_lodash_namespaceObject.castArray)(clientIds).length;
26280
  const {
26281
+ blockType,
26282
+ isDisabled,
26283
+ rootClientId,
26284
+ isFirst,
26285
+ isLast,
26286
+ firstIndex,
26287
+ orientation = 'vertical'
26288
  } = (0,external_wp_data_namespaceObject.useSelect)(select => {
 
 
26289
  const {
26290
+ getBlockIndex,
26291
  getBlockRootClientId,
26292
+ getBlockOrder,
26293
+ getBlock,
26294
+ getBlockListSettings
26295
  } = select(store);
26296
+ const normalizedClientIds = (0,external_lodash_namespaceObject.castArray)(clientIds);
26297
+ const firstClientId = (0,external_lodash_namespaceObject.first)(normalizedClientIds);
26298
+ const blockRootClientId = getBlockRootClientId(firstClientId);
26299
+ const firstBlockIndex = getBlockIndex(firstClientId, blockRootClientId);
26300
+ const lastBlockIndex = getBlockIndex((0,external_lodash_namespaceObject.last)(normalizedClientIds), blockRootClientId);
26301
+ const blockOrder = getBlockOrder(blockRootClientId);
26302
+ const block = getBlock(firstClientId);
26303
+ const isFirstBlock = firstBlockIndex === 0;
26304
+ const isLastBlock = lastBlockIndex === blockOrder.length - 1;
26305
  const {
26306
+ orientation: blockListOrientation
26307
+ } = getBlockListSettings(blockRootClientId) || {};
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26308
  return {
26309
+ blockType: block ? (0,external_wp_blocks_namespaceObject.getBlockType)(block.name) : null,
26310
+ isDisabled: direction === 'up' ? isFirstBlock : isLastBlock,
26311
+ rootClientId: blockRootClientId,
26312
+ firstIndex: firstBlockIndex,
26313
+ isFirst: isFirstBlock,
26314
+ isLast: isLastBlock,
26315
+ orientation: moverOrientation || blockListOrientation
26316
  };
26317
+ }, [clientIds, direction]);
26318
+ const {
26319
+ moveBlocksDown,
26320
+ moveBlocksUp
26321
+ } = (0,external_wp_data_namespaceObject.useDispatch)(store);
26322
+ const moverFunction = direction === 'up' ? moveBlocksUp : moveBlocksDown;
26323
+
26324
+ const onClick = event => {
26325
+ moverFunction(clientIds, rootClientId);
26326
+
26327
+ if (props.onClick) {
26328
+ props.onClick(event);
26329
+ }
26330
  };
26331
+
26332
+ const descriptionId = `block-editor-block-mover-button__description-${instanceId}`;
26333
+ return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, _extends({
26334
+ ref: ref,
26335
+ className: classnames_default()('block-editor-block-mover-button', `is-${direction}-button`),
26336
+ icon: getArrowIcon(direction, orientation),
26337
+ label: getMovementDirectionLabel(direction, orientation),
26338
+ "aria-describedby": descriptionId
26339
+ }, props, {
26340
+ onClick: isDisabled ? null : onClick,
26341
+ "aria-disabled": isDisabled
26342
+ })), (0,external_wp_element_namespaceObject.createElement)("span", {
26343
+ id: descriptionId,
26344
+ className: "block-editor-block-mover-button__description"
26345
+ }, getBlockMoverDescription(blocksCount, blockType && blockType.title, firstIndex, isFirst, isLast, direction === 'up' ? -1 : 1, orientation)));
26346
+ });
26347
+ const BlockMoverUpButton = (0,external_wp_element_namespaceObject.forwardRef)((props, ref) => {
26348
+ return (0,external_wp_element_namespaceObject.createElement)(BlockMoverButton, _extends({
26349
+ direction: "up",
26350
+ ref: ref
26351
+ }, props));
26352
+ });
26353
+ const BlockMoverDownButton = (0,external_wp_element_namespaceObject.forwardRef)((props, ref) => {
26354
+ return (0,external_wp_element_namespaceObject.createElement)(BlockMoverButton, _extends({
26355
+ direction: "down",
26356
+ ref: ref
26357
+ }, props));
26358
+ });
26359
+ //# sourceMappingURL=button.js.map
26360
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-mover/index.js
26361
 
26362
 
26363
 
26365
  * External dependencies
26366
  */
26367
 
26368
+
26369
  /**
26370
  * WordPress dependencies
26371
  */
26372
 
26373
 
26374
 
26375
+
26376
+
26377
+
26378
+
26379
  /**
26380
  * Internal dependencies
26381
  */
26382
 
26383
 
26384
 
 
 
 
 
26385
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26386
 
26387
+ function BlockMover({
26388
+ isFirst,
26389
+ isLast,
26390
+ clientIds,
26391
+ isLocked,
26392
+ isHidden,
26393
+ rootClientId,
26394
+ orientation,
26395
+ hideDragHandle
26396
+ }) {
26397
+ const [isFocused, setIsFocused] = (0,external_wp_element_namespaceObject.useState)(false);
 
 
 
 
 
 
 
 
 
 
 
 
 
26398
 
26399
+ const onFocus = () => setIsFocused(true);
26400
 
26401
+ const onBlur = () => setIsFocused(false);
 
 
 
 
 
26402
 
26403
+ if (isLocked || isFirst && isLast && !rootClientId) {
26404
+ return null;
26405
+ }
26406
+
26407
+ const dragHandleLabel = (0,external_wp_i18n_namespaceObject.__)('Drag'); // We emulate a disabled state because forcefully applying the `disabled`
26408
+ // attribute on the buttons while it has focus causes the screen to change
26409
+ // to an unfocused state (body as active element) without firing blur on,
26410
+ // the rendering parent, leaving it unable to react to focus out.
26411
 
26412
 
26413
+ return (0,external_wp_element_namespaceObject.createElement)("div", {
26414
+ className: classnames_default()('block-editor-block-mover', {
26415
+ 'is-visible': isFocused || !isHidden,
26416
+ 'is-horizontal': orientation === 'horizontal'
26417
+ })
26418
+ }, !hideDragHandle && (0,external_wp_element_namespaceObject.createElement)(block_draggable, {
26419
+ clientIds: clientIds,
26420
+ cloneClassname: "block-editor-block-mover__drag-clone"
26421
+ }, draggableProps => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, _extends({
26422
+ icon: drag_handle,
26423
+ className: "block-editor-block-mover__drag-handle",
26424
+ "aria-hidden": "true",
26425
+ label: dragHandleLabel // Should not be able to tab to drag handle as this
26426
+ // button can only be used with a pointer device.
26427
+ ,
26428
+ tabIndex: "-1"
26429
+ }, draggableProps))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarGroup, {
26430
+ className: "block-editor-block-mover__move-button-container"
26431
+ }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarItem, {
26432
+ onFocus: onFocus,
26433
+ onBlur: onBlur
26434
+ }, itemProps => (0,external_wp_element_namespaceObject.createElement)(BlockMoverUpButton, _extends({
26435
+ clientIds: clientIds
26436
+ }, itemProps))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarItem, {
26437
+ onFocus: onFocus,
26438
+ onBlur: onBlur
26439
+ }, itemProps => (0,external_wp_element_namespaceObject.createElement)(BlockMoverDownButton, _extends({
26440
+ clientIds: clientIds
26441
+ }, itemProps)))));
26442
+ }
26443
+
26444
+ /* harmony default export */ var block_mover = ((0,external_wp_data_namespaceObject.withSelect)((select, {
26445
+ clientIds
26446
+ }) => {
26447
+ var _getBlockListSettings;
26448
 
26449
+ const {
26450
+ getBlock,
26451
+ getBlockIndex,
26452
+ getBlockListSettings,
26453
+ getTemplateLock,
26454
+ getBlockOrder,
26455
+ getBlockRootClientId
26456
+ } = select(store);
26457
+ const normalizedClientIds = (0,external_lodash_namespaceObject.castArray)(clientIds);
26458
+ const firstClientId = (0,external_lodash_namespaceObject.first)(normalizedClientIds);
26459
+ const block = getBlock(firstClientId);
26460
+ const rootClientId = getBlockRootClientId((0,external_lodash_namespaceObject.first)(normalizedClientIds));
26461
+ const firstIndex = getBlockIndex(firstClientId, rootClientId);
26462
+ const lastIndex = getBlockIndex((0,external_lodash_namespaceObject.last)(normalizedClientIds), rootClientId);
26463
+ const blockOrder = getBlockOrder(rootClientId);
26464
+ const isFirst = firstIndex === 0;
26465
+ const isLast = lastIndex === blockOrder.length - 1;
26466
+ return {
26467
+ blockType: block ? (0,external_wp_blocks_namespaceObject.getBlockType)(block.name) : null,
26468
+ isLocked: getTemplateLock(rootClientId) === 'all',
26469
+ rootClientId,
26470
+ firstIndex,
26471
+ isFirst,
26472
+ isLast,
26473
+ orientation: (_getBlockListSettings = getBlockListSettings(rootClientId)) === null || _getBlockListSettings === void 0 ? void 0 : _getBlockListSettings.orientation
26474
+ };
26475
+ })(BlockMover));
26476
+ //# sourceMappingURL=index.js.map
26477
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-toolbar/utils.js
26478
  /**
26479
  * External dependencies
26480
  */
26484
  */
26485
 
26486
 
26487
+ const {
26488
+ clearTimeout: utils_clearTimeout,
26489
+ setTimeout: utils_setTimeout
26490
+ } = window;
26491
+ const DEBOUNCE_TIMEOUT = 200;
26492
+ /**
26493
+ * Hook that creates a showMover state, as well as debounced show/hide callbacks.
26494
+ *
26495
+ * @param {Object} props Component props.
26496
+ * @param {Object} props.ref Element reference.
26497
+ * @param {boolean} props.isFocused Whether the component has current focus.
26498
+ * @param {number} [props.debounceTimeout=250] Debounce timeout in milliseconds.
26499
+ * @param {Function} [props.onChange=noop] Callback function.
26500
+ */
26501
 
26502
+ function useDebouncedShowMovers({
26503
+ ref,
26504
+ isFocused,
26505
+ debounceTimeout = DEBOUNCE_TIMEOUT,
26506
+ onChange = external_lodash_namespaceObject.noop
26507
+ }) {
26508
+ const [showMovers, setShowMovers] = (0,external_wp_element_namespaceObject.useState)(false);
26509
+ const timeoutRef = (0,external_wp_element_namespaceObject.useRef)();
26510
 
26511
+ const handleOnChange = nextIsFocused => {
26512
+ if (ref !== null && ref !== void 0 && ref.current) {
26513
+ setShowMovers(nextIsFocused);
26514
+ }
26515
 
26516
+ onChange(nextIsFocused);
26517
+ };
26518
 
26519
+ const getIsHovered = () => {
26520
+ return (ref === null || ref === void 0 ? void 0 : ref.current) && ref.current.matches(':hover');
26521
+ };
26522
 
26523
+ const shouldHideMovers = () => {
26524
+ const isHovered = getIsHovered();
26525
+ return !isFocused && !isHovered;
26526
+ };
26527
 
26528
+ const clearTimeoutRef = () => {
26529
+ const timeout = timeoutRef.current;
26530
 
26531
+ if (timeout && utils_clearTimeout) {
26532
+ utils_clearTimeout(timeout);
26533
+ }
26534
+ };
 
26535
 
26536
+ const debouncedShowMovers = event => {
26537
+ if (event) {
26538
+ event.stopPropagation();
26539
+ }
26540
 
26541
+ clearTimeoutRef();
26542
 
26543
+ if (!showMovers) {
26544
+ handleOnChange(true);
26545
+ }
26546
+ };
26547
 
26548
+ const debouncedHideMovers = event => {
26549
+ if (event) {
26550
+ event.stopPropagation();
26551
+ }
26552
 
26553
+ clearTimeoutRef();
26554
+ timeoutRef.current = utils_setTimeout(() => {
26555
+ if (shouldHideMovers()) {
26556
+ handleOnChange(false);
26557
+ }
26558
+ }, debounceTimeout);
26559
+ };
26560
 
26561
+ (0,external_wp_element_namespaceObject.useEffect)(() => () => clearTimeoutRef(), []);
26562
+ return {
26563
+ showMovers,
26564
+ debouncedShowMovers,
26565
+ debouncedHideMovers
26566
+ };
 
 
26567
  }
26568
+ /**
26569
+ * Hook that provides a showMovers state and gesture events for DOM elements
26570
+ * that interact with the showMovers state.
26571
+ *
26572
+ * @param {Object} props Component props.
26573
+ * @param {Object} props.ref Element reference.
26574
+ * @param {number} [props.debounceTimeout=250] Debounce timeout in milliseconds.
26575
+ * @param {Function} [props.onChange=noop] Callback function.
26576
+ */
26577
 
26578
+ function useShowMoversGestures({
26579
+ ref,
26580
+ debounceTimeout = DEBOUNCE_TIMEOUT,
26581
+ onChange = external_lodash_namespaceObject.noop
 
26582
  }) {
26583
+ const [isFocused, setIsFocused] = (0,external_wp_element_namespaceObject.useState)(false);
26584
+ const {
26585
+ showMovers,
26586
+ debouncedShowMovers,
26587
+ debouncedHideMovers
26588
+ } = useDebouncedShowMovers({
26589
+ ref,
26590
+ debounceTimeout,
26591
+ isFocused,
26592
+ onChange
26593
+ });
26594
+ const registerRef = (0,external_wp_element_namespaceObject.useRef)(false);
 
 
 
 
 
26595
 
26596
+ const isFocusedWithin = () => {
26597
+ return (ref === null || ref === void 0 ? void 0 : ref.current) && ref.current.contains(ref.current.ownerDocument.activeElement);
26598
+ };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26599
 
26600
+ (0,external_wp_element_namespaceObject.useEffect)(() => {
26601
+ const node = ref.current;
26602
 
26603
+ const handleOnFocus = () => {
26604
+ if (isFocusedWithin()) {
26605
+ setIsFocused(true);
26606
+ debouncedShowMovers();
26607
+ }
26608
+ };
26609
 
26610
+ const handleOnBlur = () => {
26611
+ if (!isFocusedWithin()) {
26612
+ setIsFocused(false);
26613
+ debouncedHideMovers();
26614
+ }
26615
+ };
26616
+ /**
26617
+ * Events are added via DOM events (vs. React synthetic events),
26618
+ * as the child React components swallow mouse events.
26619
+ */
26620
 
 
 
 
26621
 
26622
+ if (node && !registerRef.current) {
26623
+ node.addEventListener('focus', handleOnFocus, true);
26624
+ node.addEventListener('blur', handleOnBlur, true);
26625
+ registerRef.current = true;
26626
+ }
26627
 
26628
+ return () => {
26629
+ if (node) {
26630
+ node.removeEventListener('focus', handleOnFocus);
26631
+ node.removeEventListener('blur', handleOnBlur);
26632
+ }
26633
+ };
26634
+ }, [ref, registerRef, setIsFocused, debouncedShowMovers, debouncedHideMovers]);
26635
+ return {
26636
+ showMovers,
26637
+ gestures: {
26638
+ onMouseMove: debouncedShowMovers,
26639
+ onMouseLeave: debouncedHideMovers
26640
+ }
26641
+ };
26642
  }
26643
+ //# sourceMappingURL=utils.js.map
26644
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-parent-selector/index.js
 
 
26645
 
26646
 
 
 
 
26647
 
26648
  /**
26649
  * WordPress dependencies
26653
 
26654
 
26655
 
 
26656
  /**
26657
  * Internal dependencies
26658
  */
26661
 
26662
 
26663
 
26664
+ /**
26665
+ * Block parent selector component, displaying the hierarchy of the
26666
+ * current block selection as a single icon to "go up" a level.
26667
+ *
26668
+ * @return {WPComponent} Parent block selector.
26669
+ */
26670
 
26671
+ function BlockParentSelector() {
 
 
 
 
26672
  const {
26673
+ selectBlock,
26674
+ toggleBlockHighlight
26675
+ } = (0,external_wp_data_namespaceObject.useDispatch)(store);
26676
+ const {
26677
+ firstParentClientId,
26678
+ shouldHide,
26679
+ hasReducedUI
26680
  } = (0,external_wp_data_namespaceObject.useSelect)(select => {
26681
  const {
26682
  getBlockName,
26683
+ getBlockParents,
26684
+ getSelectedBlockClientId,
 
 
26685
  getSettings
26686
  } = select(store);
26687
+ const {
26688
+ hasBlockSupport
26689
+ } = select(external_wp_blocks_namespaceObject.store);
26690
+ const selectedBlockClientId = getSelectedBlockClientId();
26691
+ const parents = getBlockParents(selectedBlockClientId);
26692
+ const _firstParentClientId = parents[parents.length - 1];
26693
+ const parentBlockName = getBlockName(_firstParentClientId);
26694
+
26695
+ const _parentBlockType = (0,external_wp_blocks_namespaceObject.getBlockType)(parentBlockName);
26696
+
26697
  const settings = getSettings();
26698
  return {
26699
+ firstParentClientId: _firstParentClientId,
26700
+ shouldHide: !hasBlockSupport(_parentBlockType, '__experimentalParentSelector', true),
26701
+ hasReducedUI: settings.hasReducedUI
 
 
 
 
 
26702
  };
26703
+ }, []);
26704
+ const blockInformation = useBlockDisplayInformation(firstParentClientId); // Allows highlighting the parent block outline when focusing or hovering
26705
+ // the parent block selector within the child.
26706
 
 
 
 
26707
  const nodeRef = (0,external_wp_element_namespaceObject.useRef)();
26708
  const {
 
26709
  gestures: showMoversGestures
26710
  } = useShowMoversGestures({
26711
  ref: nodeRef,
26715
  return;
26716
  }
26717
 
26718
+ toggleBlockHighlight(firstParentClientId, isFocused);
 
 
 
 
 
 
 
 
 
 
26719
  }
 
26720
 
26721
+ });
26722
 
26723
+ if (shouldHide || firstParentClientId === undefined) {
26724
  return null;
26725
  }
26726
 
26727
+ return (0,external_wp_element_namespaceObject.createElement)("div", _extends({
26728
+ className: "block-editor-block-parent-selector",
26729
+ key: firstParentClientId,
 
 
 
 
 
26730
  ref: nodeRef
26731
+ }, showMoversGestures), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, {
26732
+ className: "block-editor-block-parent-selector__button",
26733
+ onClick: () => selectBlock(firstParentClientId),
26734
+ label: (0,external_wp_i18n_namespaceObject.sprintf)(
26735
+ /* translators: %s: Name of the block's parent. */
26736
+ (0,external_wp_i18n_namespaceObject.__)('Select %s'), blockInformation.title),
26737
+ showTooltip: true,
26738
+ icon: (0,external_wp_element_namespaceObject.createElement)(BlockIcon, {
26739
+ icon: blockInformation.icon
26740
+ })
 
 
 
 
 
 
 
 
 
 
26741
  }));
26742
  }
26743
  //# sourceMappingURL=index.js.map
26744
+ ;// CONCATENATED MODULE: ./packages/icons/build-module/library/stack.js
26745
+
26746
+
26747
+ /**
26748
+ * WordPress dependencies
26749
+ */
26750
+
26751
+ const stack = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
26752
+ xmlns: "http://www.w3.org/2000/svg",
26753
+ viewBox: "0 0 24 24"
26754
+ }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
26755
+ d: "M20.2 8v11c0 .7-.6 1.2-1.2 1.2H6v1.5h13c1.5 0 2.7-1.2 2.7-2.8V8zM18 16.4V4.6c0-.9-.7-1.6-1.6-1.6H4.6C3.7 3 3 3.7 3 4.6v11.8c0 .9.7 1.6 1.6 1.6h11.8c.9 0 1.6-.7 1.6-1.6zm-13.5 0V4.6c0-.1.1-.1.1-.1h11.8c.1 0 .1.1.1.1v11.8c0 .1-.1.1-.1.1H4.6l-.1-.1z"
26756
+ }));
26757
+ /* harmony default export */ var library_stack = (stack);
26758
+ //# sourceMappingURL=stack.js.map
26759
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-switcher/preview-block-popover.js
26760
+
26761
 
26762
+ /**
26763
+ * WordPress dependencies
26764
+ */
26765
 
26766
 
26767
  /**
26768
+ * Internal dependencies
26769
  */
26770
 
26771
+
26772
+ function PreviewBlockPopover({
26773
+ blocks
26774
+ }) {
26775
+ return (0,external_wp_element_namespaceObject.createElement)("div", {
26776
+ className: "block-editor-block-switcher__popover__preview__parent"
26777
+ }, (0,external_wp_element_namespaceObject.createElement)("div", {
26778
+ className: "block-editor-block-switcher__popover__preview__container"
26779
+ }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Popover, {
26780
+ className: "block-editor-block-switcher__preview__popover",
26781
+ position: "bottom right",
26782
+ focusOnMount: false
26783
+ }, (0,external_wp_element_namespaceObject.createElement)("div", {
26784
+ className: "block-editor-block-switcher__preview"
26785
+ }, (0,external_wp_element_namespaceObject.createElement)("div", {
26786
+ className: "block-editor-block-switcher__preview-title"
26787
+ }, (0,external_wp_i18n_namespaceObject.__)('Preview')), (0,external_wp_element_namespaceObject.createElement)(block_preview, {
26788
+ viewportWidth: 500,
26789
+ blocks: blocks
26790
+ })))));
26791
+ }
26792
+ //# sourceMappingURL=preview-block-popover.js.map
26793
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-switcher/block-transformations-menu.js
26794
+
26795
+
26796
  /**
26797
  * WordPress dependencies
26798
  */
26807
 
26808
 
26809
 
26810
+ const BlockTransformationsMenu = ({
26811
+ className,
26812
+ possibleBlockTransformations,
26813
+ onSelect,
26814
+ blocks
26815
+ }) => {
26816
+ const [hoveredTransformItemName, setHoveredTransformItemName] = (0,external_wp_element_namespaceObject.useState)();
26817
+ return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, {
26818
+ label: (0,external_wp_i18n_namespaceObject.__)('Transform to'),
26819
+ className: className
26820
+ }, hoveredTransformItemName && (0,external_wp_element_namespaceObject.createElement)(PreviewBlockPopover, {
26821
+ blocks: (0,external_wp_blocks_namespaceObject.switchToBlockType)(blocks, hoveredTransformItemName)
26822
+ }), possibleBlockTransformations.map(item => {
 
 
 
26823
  const {
26824
+ name,
26825
+ icon,
26826
+ title,
26827
+ isDisabled
26828
+ } = item;
26829
+ return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
26830
+ key: name,
26831
+ className: (0,external_wp_blocks_namespaceObject.getBlockMenuDefaultClassName)(name),
26832
+ onClick: event => {
26833
+ event.preventDefault();
26834
+ onSelect(name);
26835
+ },
26836
+ disabled: isDisabled,
26837
+ onMouseLeave: () => setHoveredTransformItemName(null),
26838
+ onMouseEnter: () => setHoveredTransformItemName(name)
26839
+ }, (0,external_wp_element_namespaceObject.createElement)(BlockIcon, {
26840
+ icon: icon,
26841
+ showColors: true
26842
+ }), title);
26843
+ }));
26844
+ };
26845
 
26846
+ /* harmony default export */ var block_transformations_menu = (BlockTransformationsMenu);
26847
+ //# sourceMappingURL=block-transformations-menu.js.map
26848
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-styles/utils.js
26849
+ /**
26850
+ * External dependencies
26851
+ */
26852
+
26853
+ /**
26854
+ * WordPress dependencies
26855
+ */
26856
+
26857
+
26858
+ /**
26859
+ * Returns the active style from the given className.
26860
+ *
26861
+ * @param {Array} styles Block style variations.
26862
+ * @param {string} className Class name
26863
+ *
26864
+ * @return {Object?} The active style.
26865
+ */
26866
+
26867
+ function getActiveStyle(styles, className) {
26868
+ for (const style of new (external_wp_tokenList_default())(className).values()) {
26869
+ if (style.indexOf('is-style-') === -1) {
26870
+ continue;
26871
  }
 
26872
 
26873
+ const potentialStyleName = style.substring(9);
26874
+ const activeStyle = (0,external_lodash_namespaceObject.find)(styles, {
26875
+ name: potentialStyleName
26876
+ });
26877
 
26878
+ if (activeStyle) {
26879
+ return activeStyle;
26880
+ }
26881
+ }
26882
+
26883
+ return (0,external_lodash_namespaceObject.find)(styles, 'isDefault');
 
 
 
 
 
 
 
26884
  }
26885
+ /**
26886
+ * Replaces the active style in the block's className.
26887
+ *
26888
+ * @param {string} className Class name.
26889
+ * @param {Object?} activeStyle The replaced style.
26890
+ * @param {Object} newStyle The replacing style.
26891
+ *
26892
+ * @return {string} The updated className.
26893
+ */
26894
 
26895
+ function replaceActiveStyle(className, activeStyle, newStyle) {
26896
+ const list = new (external_wp_tokenList_default())(className);
26897
+
26898
+ if (activeStyle) {
26899
+ list.remove('is-style-' + activeStyle.name);
26900
+ }
26901
+
26902
+ list.add('is-style-' + newStyle.name);
26903
+ return list.value;
26904
+ }
26905
+ //# sourceMappingURL=utils.js.map
26906
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-styles/index.js
26907
 
26908
 
26909
  /**
26920
 
26921
 
26922
 
 
 
26923
  /**
26924
  * Internal dependencies
26925
  */
26927
 
26928
 
26929
 
26930
+ const EMPTY_OBJECT = {};
26931
 
26932
+ function useGenericPreviewBlock(block, type) {
26933
+ return (0,external_wp_element_namespaceObject.useMemo)(() => {
26934
+ const example = type === null || type === void 0 ? void 0 : type.example;
26935
+ const blockName = type === null || type === void 0 ? void 0 : type.name;
26936
 
26937
+ if (example && blockName) {
26938
+ return (0,external_wp_blocks_namespaceObject.getBlockFromExample)(blockName, {
26939
+ attributes: example.attributes,
26940
+ innerBlocks: example.innerBlocks
26941
+ });
26942
+ }
26943
 
26944
+ if (block) {
26945
+ return (0,external_wp_blocks_namespaceObject.cloneBlock)(block);
26946
+ }
26947
+ }, [type !== null && type !== void 0 && type.example ? block === null || block === void 0 ? void 0 : block.name : block, type]);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26948
  }
26949
 
26950
+ function BlockStyles({
26951
  clientId,
26952
+ onSwitch = external_lodash_namespaceObject.noop,
26953
+ onHoverClassName = external_lodash_namespaceObject.noop,
26954
+ itemRole
 
 
 
26955
  }) {
26956
+ const selector = select => {
 
 
 
 
 
 
 
 
 
26957
  const {
26958
+ getBlock
 
 
26959
  } = select(store);
26960
+ const block = getBlock(clientId);
26961
 
26962
+ if (!block) {
26963
+ return EMPTY_OBJECT;
26964
  }
26965
 
26966
+ const blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(block.name);
26967
+ const {
26968
+ getBlockStyles
26969
+ } = select(external_wp_blocks_namespaceObject.store);
26970
+ return {
26971
+ block,
26972
+ type: blockType,
26973
+ styles: getBlockStyles(block.name),
26974
+ className: block.attributes.className || ''
26975
+ };
26976
+ };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26977
 
26978
+ const {
26979
+ styles,
26980
+ block,
26981
+ type,
26982
+ className
26983
+ } = (0,external_wp_data_namespaceObject.useSelect)(selector, [clientId]);
26984
+ const {
26985
+ updateBlockAttributes
26986
+ } = (0,external_wp_data_namespaceObject.useDispatch)(store);
26987
+ const genericPreviewBlock = useGenericPreviewBlock(block, type);
26988
 
26989
+ if (!styles || styles.length === 0) {
26990
  return null;
26991
  }
26992
 
26993
+ const renderedStyles = (0,external_lodash_namespaceObject.find)(styles, 'isDefault') ? styles : [{
26994
+ name: 'default',
26995
+ label: (0,external_wp_i18n_namespaceObject._x)('Default', 'block style'),
26996
+ isDefault: true
26997
+ }, ...styles];
26998
+ const activeStyle = getActiveStyle(renderedStyles, className);
26999
+ return (0,external_wp_element_namespaceObject.createElement)("div", {
27000
+ className: "block-editor-block-styles"
27001
+ }, renderedStyles.map(style => {
27002
+ var _type$example$viewpor, _type$example;
27003
 
27004
+ const styleClassName = replaceActiveStyle(className, activeStyle, style);
27005
+ return (0,external_wp_element_namespaceObject.createElement)(BlockStyleItem, {
27006
+ genericPreviewBlock: genericPreviewBlock,
27007
+ viewportWidth: (_type$example$viewpor = (_type$example = type.example) === null || _type$example === void 0 ? void 0 : _type$example.viewportWidth) !== null && _type$example$viewpor !== void 0 ? _type$example$viewpor : 500,
27008
+ className: className,
27009
+ isActive: activeStyle === style,
27010
+ key: style.name,
27011
+ onSelect: () => {
27012
+ updateBlockAttributes(clientId, {
27013
+ className: styleClassName
27014
+ });
27015
+ onHoverClassName(null);
27016
+ onSwitch();
27017
+ },
27018
+ onBlur: () => onHoverClassName(null),
27019
+ onHover: () => onHoverClassName(styleClassName),
27020
+ style: style,
27021
+ styleClassName: styleClassName,
27022
+ itemRole: itemRole
27023
+ });
27024
+ }));
27025
+ }
27026
 
27027
+ function BlockStyleItem({
27028
+ genericPreviewBlock,
27029
+ viewportWidth,
27030
+ style,
27031
+ isActive,
27032
+ onBlur,
27033
+ onHover,
27034
+ onSelect,
27035
+ styleClassName,
27036
+ itemRole
27037
+ }) {
27038
+ const previewBlocks = (0,external_wp_element_namespaceObject.useMemo)(() => {
27039
+ return { ...genericPreviewBlock,
27040
+ attributes: { ...genericPreviewBlock.attributes,
27041
+ className: styleClassName
27042
+ }
27043
+ };
27044
+ }, [genericPreviewBlock, styleClassName]);
27045
+ return (0,external_wp_element_namespaceObject.createElement)("div", {
27046
+ key: style.name,
27047
+ className: classnames_default()('block-editor-block-styles__item', {
27048
+ 'is-active': isActive
27049
+ }),
27050
+ onClick: () => onSelect(),
27051
+ onKeyDown: event => {
27052
+ if (external_wp_keycodes_namespaceObject.ENTER === event.keyCode || external_wp_keycodes_namespaceObject.SPACE === event.keyCode) {
27053
+ event.preventDefault();
27054
+ onSelect();
27055
+ }
27056
+ },
27057
+ onMouseEnter: onHover,
27058
+ onMouseLeave: onBlur,
27059
+ role: itemRole || 'button',
27060
+ tabIndex: "0",
27061
+ "aria-label": style.label || style.name
27062
+ }, (0,external_wp_element_namespaceObject.createElement)("div", {
27063
+ className: "block-editor-block-styles__item-preview"
27064
+ }, (0,external_wp_element_namespaceObject.createElement)(block_preview, {
27065
+ viewportWidth: viewportWidth,
27066
+ blocks: previewBlocks
27067
+ })), (0,external_wp_element_namespaceObject.createElement)("div", {
27068
+ className: "block-editor-block-styles__item-label"
27069
+ }, style.label || style.name));
27070
+ }
27071
 
27072
+ /* harmony default export */ var block_styles = (BlockStyles);
27073
+ //# sourceMappingURL=index.js.map
27074
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-switcher/block-styles-menu.js
27075
 
 
 
 
 
 
 
27076
 
27077
+ /**
27078
+ * WordPress dependencies
27079
+ */
 
 
27080
 
 
 
 
27081
 
 
 
 
 
 
 
27082
 
27083
 
27084
+
27085
+ /**
27086
+ * Internal dependencies
27087
+ */
27088
+
27089
+
27090
+
27091
+ function BlockStylesMenu({
27092
+ hoveredBlock,
27093
+ onSwitch
27094
+ }) {
27095
+ const {
27096
+ name,
27097
+ clientId
27098
+ } = hoveredBlock;
27099
+ const [hoveredClassName, setHoveredClassName] = (0,external_wp_element_namespaceObject.useState)();
27100
+ const blockType = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_blocks_namespaceObject.store).getBlockType(name), [name]);
27101
+ return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, {
27102
+ label: (0,external_wp_i18n_namespaceObject.__)('Styles'),
27103
+ className: "block-editor-block-switcher__styles__menugroup"
27104
+ }, hoveredClassName && (0,external_wp_element_namespaceObject.createElement)(PreviewBlockPopover, {
27105
+ blocks: blockType.example ? (0,external_wp_blocks_namespaceObject.getBlockFromExample)(blockType.name, {
27106
+ attributes: { ...blockType.example.attributes,
27107
+ className: hoveredClassName
27108
+ },
27109
+ innerBlocks: blockType.example.innerBlocks
27110
+ }) : (0,external_wp_blocks_namespaceObject.cloneBlock)(hoveredBlock, {
27111
+ className: hoveredClassName
 
 
 
 
 
 
 
 
 
 
 
27112
  })
27113
+ }), (0,external_wp_element_namespaceObject.createElement)(block_styles, {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27114
  clientId: clientId,
27115
+ onSwitch: onSwitch,
27116
+ onHoverClassName: setHoveredClassName,
27117
+ itemRole: "menuitem"
27118
+ }));
27119
  }
27120
+ //# sourceMappingURL=block-styles-menu.js.map
27121
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-switcher/utils.js
27122
+ /**
27123
+ * WordPress dependencies
27124
+ */
27125
 
27126
+ /**
27127
+ * Try to find a matching block by a block's name in a provided
27128
+ * block. We recurse through InnerBlocks and return the reference
27129
+ * of the matched block (it could be an InnerBlock).
27130
+ * If no match is found return nothing.
27131
+ *
27132
+ * @param {WPBlock} block The block to try to find a match.
27133
+ * @param {string} selectedBlockName The block's name to use for matching condition.
27134
+ * @param {Set} consumedBlocks A set holding the previously matched/consumed blocks.
27135
+ *
27136
+ * @return {WPBlock?} The matched block if found or nothing(`undefined`).
27137
+ */
27138
+
27139
+ const getMatchingBlockByName = (block, selectedBlockName, consumedBlocks = new Set()) => {
27140
  const {
27141
+ clientId,
27142
+ name,
27143
+ innerBlocks = []
27144
+ } = block; // Check if block has been consumed already.
 
 
 
 
27145
 
27146
+ if (consumedBlocks.has(clientId)) return;
27147
+ if (name === selectedBlockName) return block; // Try to find a matching block from InnerBlocks recursively.
27148
+
27149
+ for (const innerBlock of innerBlocks) {
27150
+ const match = getMatchingBlockByName(innerBlock, selectedBlockName, consumedBlocks);
27151
+ if (match) return match;
27152
  }
27153
+ };
27154
+ /**
27155
+ * Find and return the block attributes to retain through
27156
+ * the transformation, based on Block Type's `role:content`
27157
+ * attributes. If no `role:content` attributes exist,
27158
+ * return selected block's attributes.
27159
+ *
27160
+ * @param {string} name Block type's namespaced name.
27161
+ * @param {Object} attributes Selected block's attributes.
27162
+ * @return {Object} The block's attributes to retain.
27163
+ */
27164
 
27165
+ const getRetainedBlockAttributes = (name, attributes) => {
27166
+ const contentAttributes = (0,external_wp_blocks_namespaceObject.__experimentalGetBlockAttributesNamesByRole)(name, 'content');
27167
+ if (!(contentAttributes !== null && contentAttributes !== void 0 && contentAttributes.length)) return attributes;
27168
+ return contentAttributes.reduce((_accumulator, attribute) => {
27169
+ if (attributes[attribute]) _accumulator[attribute] = attributes[attribute];
27170
+ return _accumulator;
27171
+ }, {});
27172
+ };
27173
+ //# sourceMappingURL=utils.js.map
27174
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-switcher/use-transformed-patterns.js
27175
+ /**
27176
+ * WordPress dependencies
27177
+ */
27178
 
 
27179
 
27180
+ /**
27181
+ * Internal dependencies
27182
+ */
27183
 
 
 
27184
 
27185
+ /**
27186
+ * Mutate the matched block's attributes by getting
27187
+ * which block type's attributes to retain and prioritize
27188
+ * them in the merging of the attributes.
27189
+ *
27190
+ * @param {WPBlock} match The matched block.
27191
+ * @param {WPBlock} selectedBlock The selected block.
27192
+ * @return {void}
27193
+ */
27194
+
27195
+ const transformMatchingBlock = (match, selectedBlock) => {
27196
+ // Get the block attributes to retain through the transformation.
27197
+ const retainedBlockAttributes = getRetainedBlockAttributes(selectedBlock.name, selectedBlock.attributes);
27198
+ match.attributes = { ...match.attributes,
27199
+ ...retainedBlockAttributes
27200
  };
27201
+ };
27202
+ /**
27203
+ * By providing the selected blocks and pattern's blocks
27204
+ * find the matching blocks, transform them and return them.
27205
+ * If not all selected blocks are matched, return nothing.
27206
+ *
27207
+ * @param {WPBlock[]} selectedBlocks The selected blocks.
27208
+ * @param {WPBlock[]} patternBlocks The pattern's blocks.
27209
+ * @return {WPBlock[]|void} The transformed pattern's blocks or undefined if not all selected blocks have been matched.
27210
+ */
27211
 
27212
+ const getPatternTransformedBlocks = (selectedBlocks, patternBlocks) => {
27213
+ // Clone Pattern's blocks to produce new clientIds and be able to mutate the matches.
27214
+ const _patternBlocks = patternBlocks.map(block => (0,external_wp_blocks_namespaceObject.cloneBlock)(block));
27215
+ /**
27216
+ * Keep track of the consumed pattern blocks.
27217
+ * This is needed because we loop the selected blocks
27218
+ * and for example we may have selected two paragraphs and
27219
+ * the pattern's blocks could have more `paragraphs`.
27220
+ */
27221
 
 
 
 
27222
 
27223
+ const consumedBlocks = new Set();
 
 
 
 
 
 
 
27224
 
27225
+ for (const selectedBlock of selectedBlocks) {
27226
+ let isMatch = false;
 
27227
 
27228
+ for (const patternBlock of _patternBlocks) {
27229
+ const match = getMatchingBlockByName(patternBlock, selectedBlock.name, consumedBlocks);
27230
+ if (!match) continue;
27231
+ isMatch = true;
27232
+ consumedBlocks.add(match.clientId); // We update (mutate) the matching pattern block.
 
 
 
 
 
 
 
27233
 
27234
+ transformMatchingBlock(match, selectedBlock); // No need to loop through other pattern's blocks.
27235
 
27236
+ break;
27237
+ } // Bail eary if a selected block has not been matched.
 
27238
 
27239
 
27240
+ if (!isMatch) return;
27241
+ }
27242
 
27243
+ return _patternBlocks;
27244
+ };
27245
  /**
27246
+ * @typedef {WPBlockPattern & {transformedBlocks: WPBlock[]}} TransformedBlockPattern
27247
  */
27248
 
27249
+ /**
27250
+ * Custom hook that accepts patterns from state and the selected
27251
+ * blocks and tries to match these with the pattern's blocks.
27252
+ * If all selected blocks are matched with a Pattern's block,
27253
+ * we transform them by retaining block's attributes with `role:content`.
27254
+ * The transformed pattern's blocks are set to a new pattern
27255
+ * property `transformedBlocks`.
27256
+ *
27257
+ * @param {WPBlockPattern[]} patterns Patterns from state.
27258
+ * @param {WPBlock[]} selectedBlocks The currently selected blocks.
27259
+ * @return {TransformedBlockPattern[]} Returns the eligible matched patterns with all the selected blocks.
27260
+ */
27261
+ // TODO tests
27262
 
27263
+ const useTransformedPatterns = (patterns, selectedBlocks) => {
27264
+ return (0,external_wp_element_namespaceObject.useMemo)(() => patterns.reduce((accumulator, _pattern) => {
27265
+ const transformedBlocks = getPatternTransformedBlocks(selectedBlocks, _pattern.blocks);
27266
 
27267
+ if (transformedBlocks) {
27268
+ accumulator.push({ ..._pattern,
27269
+ transformedBlocks
27270
+ });
27271
+ }
27272
 
27273
+ return accumulator;
27274
+ }, []), [patterns, selectedBlocks]);
27275
+ };
27276
 
27277
+ /* harmony default export */ var use_transformed_patterns = (useTransformedPatterns);
27278
+ //# sourceMappingURL=use-transformed-patterns.js.map
27279
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-switcher/pattern-transformations-menu.js
 
 
 
 
 
 
 
 
27280
 
27281
 
27282
 
27285
  */
27286
 
27287
 
27288
+
 
 
27289
 
27290
 
27291
  /**
27292
+ * Internal dependencies
 
 
 
 
27293
  */
27294
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27295
 
27296
 
 
 
 
27297
 
27298
+ function PatternTransformationsMenu({
27299
+ blocks,
27300
+ patterns: statePatterns,
27301
+ onSelect
27302
+ }) {
27303
+ const [showTransforms, setShowTransforms] = (0,external_wp_element_namespaceObject.useState)(false);
27304
+ const patterns = use_transformed_patterns(statePatterns, blocks);
27305
+ if (!patterns.length) return null;
27306
+ return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, {
27307
+ className: "block-editor-block-switcher__pattern__transforms__menugroup"
27308
+ }, showTransforms && (0,external_wp_element_namespaceObject.createElement)(PreviewPatternsPopover, {
27309
+ patterns: patterns,
27310
+ onSelect: onSelect
27311
+ }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
27312
+ onClick: event => {
27313
+ event.preventDefault();
27314
+ setShowTransforms(!showTransforms);
27315
+ },
27316
+ icon: chevron_right
27317
+ }, (0,external_wp_i18n_namespaceObject.__)('Patterns')));
27318
+ }
27319
 
27320
+ function PreviewPatternsPopover({
27321
+ patterns,
27322
+ onSelect
27323
+ }) {
27324
+ return (0,external_wp_element_namespaceObject.createElement)("div", {
27325
+ className: "block-editor-block-switcher__popover__preview__parent"
27326
+ }, (0,external_wp_element_namespaceObject.createElement)("div", {
27327
+ className: "block-editor-block-switcher__popover__preview__container"
27328
+ }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Popover, {
27329
+ className: "block-editor-block-switcher__preview__popover",
27330
+ position: "bottom right"
27331
+ }, (0,external_wp_element_namespaceObject.createElement)("div", {
27332
+ className: "block-editor-block-switcher__preview"
27333
+ }, (0,external_wp_element_namespaceObject.createElement)("div", {
27334
+ className: "block-editor-block-switcher__preview-title"
27335
+ }, (0,external_wp_i18n_namespaceObject.__)('Preview')), (0,external_wp_element_namespaceObject.createElement)(BlockPatternsList, {
27336
+ patterns: patterns,
27337
+ onSelect: onSelect
27338
+ })))));
27339
  }
27340
+
27341
+ function BlockPatternsList({
27342
+ patterns,
27343
+ onSelect
27344
+ }) {
27345
+ const composite = (0,external_wp_components_namespaceObject.__unstableUseCompositeState)();
27346
+ return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableComposite, _extends({}, composite, {
27347
+ role: "listbox",
27348
+ className: "block-editor-block-switcher__preview-patterns-container",
27349
+ "aria-label": (0,external_wp_i18n_namespaceObject.__)('Patterns list')
27350
+ }), patterns.map(pattern => (0,external_wp_element_namespaceObject.createElement)(pattern_transformations_menu_BlockPattern, {
27351
+ key: pattern.name,
27352
+ pattern: pattern,
27353
+ onSelect: onSelect,
27354
+ composite: composite
27355
+ })));
27356
  }
27357
+
27358
+ function pattern_transformations_menu_BlockPattern({
27359
+ pattern,
27360
+ onSelect,
27361
+ composite
27362
+ }) {
27363
+ // TODO check pattern/preview width...
27364
+ const baseClassName = 'block-editor-block-switcher__preview-patterns-container';
27365
+ const descriptionId = (0,external_wp_compose_namespaceObject.useInstanceId)(pattern_transformations_menu_BlockPattern, `${baseClassName}-list__item-description`);
27366
+ return (0,external_wp_element_namespaceObject.createElement)("div", {
27367
+ className: `${baseClassName}-list__list-item`,
27368
+ "aria-label": pattern.title,
27369
+ "aria-describedby": pattern.description ? descriptionId : undefined
27370
+ }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableCompositeItem, _extends({
27371
+ role: "option",
27372
+ as: "div"
27373
+ }, composite, {
27374
+ className: `${baseClassName}-list__item`,
27375
+ onClick: () => onSelect(pattern.transformedBlocks)
27376
+ }), (0,external_wp_element_namespaceObject.createElement)(block_preview, {
27377
+ blocks: pattern.transformedBlocks,
27378
+ viewportWidth: pattern.viewportWidth || 500
27379
+ }), (0,external_wp_element_namespaceObject.createElement)("div", {
27380
+ className: `${baseClassName}-list__item-title`
27381
+ }, pattern.title)), !!pattern.description && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, {
27382
+ id: descriptionId
27383
+ }, pattern.description));
27384
+ }
27385
+
27386
+ /* harmony default export */ var pattern_transformations_menu = (PatternTransformationsMenu);
27387
+ //# sourceMappingURL=pattern-transformations-menu.js.map
27388
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-switcher/index.js
27389
 
27390
 
27391
  /**
27399
 
27400
 
27401
 
27402
+
27403
+
27404
  /**
27405
  * Internal dependencies
27406
  */
27412
 
27413
 
27414
 
27415
+ const BlockSwitcherDropdownMenu = ({
27416
+ clientIds,
27417
+ blocks
27418
+ }) => {
 
 
 
 
 
 
27419
  const {
27420
+ replaceBlocks
27421
+ } = (0,external_wp_data_namespaceObject.useDispatch)(store);
27422
+ const blockInformation = useBlockDisplayInformation(blocks[0].clientId);
27423
+ const {
27424
+ possibleBlockTransformations,
27425
+ hasBlockStyles,
27426
+ icon,
27427
+ blockTitle,
27428
+ patterns
27429
  } = (0,external_wp_data_namespaceObject.useSelect)(select => {
27430
  const {
27431
+ getBlockRootClientId,
27432
+ getBlockTransformItems,
27433
+ __experimentalGetPatternTransformItems
27434
  } = select(store);
27435
  const {
27436
+ getBlockStyles,
27437
+ getBlockType
27438
+ } = select(external_wp_blocks_namespaceObject.store);
27439
+ const rootClientId = getBlockRootClientId((0,external_lodash_namespaceObject.castArray)(clientIds)[0]);
27440
+ const [{
27441
+ name: firstBlockName
27442
+ }] = blocks;
 
 
 
 
 
 
 
 
 
 
 
27443
 
27444
+ const _isSingleBlockSelected = blocks.length === 1;
 
 
 
 
 
 
 
 
27445
 
27446
+ const styles = _isSingleBlockSelected && getBlockStyles(firstBlockName);
 
 
 
 
 
 
 
 
 
 
 
27447
 
27448
+ let _icon;
 
 
27449
 
27450
+ if (_isSingleBlockSelected) {
27451
+ _icon = blockInformation === null || blockInformation === void 0 ? void 0 : blockInformation.icon; // Take into account active block variations.
27452
+ } else {
27453
+ var _getBlockType;
27454
 
27455
+ const isSelectionOfSameType = (0,external_lodash_namespaceObject.uniq)(blocks.map(({
27456
+ name
27457
+ }) => name)).length === 1; // When selection consists of blocks of multiple types, display an
27458
+ // appropriate icon to communicate the non-uniformity.
27459
+
27460
+ _icon = isSelectionOfSameType ? (_getBlockType = getBlockType(firstBlockName)) === null || _getBlockType === void 0 ? void 0 : _getBlockType.icon : library_stack;
27461
+ }
27462
 
 
 
 
 
 
 
 
 
 
 
 
 
27463
  return {
27464
+ possibleBlockTransformations: getBlockTransformItems(blocks, rootClientId),
27465
+ hasBlockStyles: !!(styles !== null && styles !== void 0 && styles.length),
27466
+ icon: _icon,
27467
+ blockTitle: getBlockType(firstBlockName).title,
27468
+ patterns: __experimentalGetPatternTransformItems(blocks, rootClientId)
27469
  };
27470
+ }, [clientIds, blocks, blockInformation === null || blockInformation === void 0 ? void 0 : blockInformation.icon]);
27471
+ const isReusable = blocks.length === 1 && (0,external_wp_blocks_namespaceObject.isReusableBlock)(blocks[0]);
27472
+ const isTemplate = blocks.length === 1 && (0,external_wp_blocks_namespaceObject.isTemplatePart)(blocks[0]); // Simple block tranformation based on the `Block Transforms` API.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27473
 
27474
+ const onBlockTransform = name => replaceBlocks(clientIds, (0,external_wp_blocks_namespaceObject.switchToBlockType)(blocks, name)); // Pattern transformation through the `Patterns` API.
 
 
 
 
 
 
 
 
 
 
 
27475
 
27476
 
27477
+ const onPatternTransform = transformedBlocks => replaceBlocks(clientIds, transformedBlocks);
 
 
27478
 
27479
+ const hasPossibleBlockTransformations = !!possibleBlockTransformations.length;
27480
+ const hasPatternTransformation = !!(patterns !== null && patterns !== void 0 && patterns.length);
27481
 
27482
+ if (!hasBlockStyles && !hasPossibleBlockTransformations) {
27483
+ return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarGroup, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, {
27484
+ disabled: true,
27485
+ className: "block-editor-block-switcher__no-switcher-icon",
27486
+ title: blockTitle,
27487
+ icon: (0,external_wp_element_namespaceObject.createElement)(BlockIcon, {
27488
+ icon: icon,
27489
+ showColors: true
27490
+ })
27491
+ }));
27492
+ }
27493
+
27494
+ const blockSwitcherLabel = blockTitle;
27495
+ const blockSwitcherDescription = 1 === blocks.length ? (0,external_wp_i18n_namespaceObject.sprintf)(
27496
+ /* translators: %s: block title. */
27497
+ (0,external_wp_i18n_namespaceObject.__)('%s: Change block type or style'), blockTitle) : (0,external_wp_i18n_namespaceObject.sprintf)(
27498
+ /* translators: %d: number of blocks. */
27499
+ (0,external_wp_i18n_namespaceObject._n)('Change type of %d block', 'Change type of %d blocks', blocks.length), blocks.length);
27500
+ const showDropDown = hasBlockStyles || hasPossibleBlockTransformations || hasPatternTransformation;
27501
+ return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarGroup, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarItem, null, toggleProps => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.DropdownMenu, {
27502
+ className: "block-editor-block-switcher",
27503
+ label: blockSwitcherLabel,
27504
+ popoverProps: {
27505
+ position: 'bottom right',
27506
+ isAlternate: true,
27507
+ className: 'block-editor-block-switcher__popover'
27508
+ },
27509
+ icon: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(BlockIcon, {
27510
+ icon: icon,
27511
+ className: "block-editor-block-switcher__toggle",
27512
+ showColors: true
27513
+ }), (isReusable || isTemplate) && (0,external_wp_element_namespaceObject.createElement)("span", {
27514
+ className: "block-editor-block-switcher__toggle-text"
27515
+ }, (0,external_wp_element_namespaceObject.createElement)(BlockTitle, {
27516
+ clientId: clientIds
27517
+ }))),
27518
+ toggleProps: {
27519
+ describedBy: blockSwitcherDescription,
27520
+ ...toggleProps
27521
+ },
27522
+ menuProps: {
27523
+ orientation: 'both'
27524
  }
27525
+ }, ({
27526
+ onClose
27527
+ }) => showDropDown && (0,external_wp_element_namespaceObject.createElement)("div", {
27528
+ className: "block-editor-block-switcher__container"
27529
+ }, hasPatternTransformation && (0,external_wp_element_namespaceObject.createElement)(pattern_transformations_menu, {
27530
+ blocks: blocks,
27531
+ patterns: patterns,
27532
+ onSelect: transformedBlocks => {
27533
+ onPatternTransform(transformedBlocks);
27534
+ onClose();
27535
+ }
27536
+ }), hasPossibleBlockTransformations && (0,external_wp_element_namespaceObject.createElement)(block_transformations_menu, {
27537
+ className: "block-editor-block-switcher__transforms__menugroup",
27538
+ possibleBlockTransformations: possibleBlockTransformations,
27539
+ blocks: blocks,
27540
+ onSelect: name => {
27541
+ onBlockTransform(name);
27542
+ onClose();
27543
+ }
27544
+ }), hasBlockStyles && (0,external_wp_element_namespaceObject.createElement)(BlockStylesMenu, {
27545
+ hoveredBlock: blocks[0],
27546
+ onSwitch: onClose
27547
+ })))));
27548
+ };
27549
+ const BlockSwitcher = ({
27550
+ clientIds
27551
+ }) => {
27552
+ const blocks = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).getBlocksByClientId(clientIds), [clientIds]);
27553
+
27554
+ if (!blocks.length || blocks.some(block => !block)) {
27555
+ return null;
27556
+ }
27557
+
27558
+ return (0,external_wp_element_namespaceObject.createElement)(BlockSwitcherDropdownMenu, {
27559
+ clientIds: clientIds,
27560
+ blocks: blocks
27561
+ });
27562
+ };
27563
+ /* harmony default export */ var block_switcher = (BlockSwitcher);
27564
+ //# sourceMappingURL=index.js.map
27565
+ ;// CONCATENATED MODULE: ./packages/icons/build-module/library/more-vertical.js
27566
+
27567
+
27568
  /**
27569
+ * WordPress dependencies
27570
  */
27571
 
27572
+ const moreVertical = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
27573
+ xmlns: "http://www.w3.org/2000/svg",
27574
+ viewBox: "0 0 24 24"
27575
+ }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
27576
+ d: "M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z"
27577
+ }));
27578
+ /* harmony default export */ var more_vertical = (moreVertical);
27579
+ //# sourceMappingURL=more-vertical.js.map
27580
+ ;// CONCATENATED MODULE: external ["wp","blob"]
27581
+ var external_wp_blob_namespaceObject = window["wp"]["blob"];
27582
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/utils/get-paste-event-data.js
27583
  /**
27584
  * WordPress dependencies
27585
  */
27586
 
27587
 
27588
+ function getPasteEventData({
27589
+ clipboardData
27590
+ }) {
27591
+ let plainText = '';
27592
+ let html = ''; // IE11 only supports `Text` as an argument for `getData` and will
27593
+ // otherwise throw an invalid argument error, so we try the standard
27594
+ // arguments first, then fallback to `Text` if they fail.
27595
+
27596
+ try {
27597
+ plainText = clipboardData.getData('text/plain');
27598
+ html = clipboardData.getData('text/html');
27599
+ } catch (error1) {
27600
+ try {
27601
+ html = clipboardData.getData('Text');
27602
+ } catch (error2) {
27603
+ // Some browsers like UC Browser paste plain text by default and
27604
+ // don't support clipboardData at all, so allow default
27605
+ // behaviour.
27606
+ return;
27607
+ }
27608
+ }
27609
 
27610
+ const files = (0,external_wp_dom_namespaceObject.getFilesFromDataTransfer)(clipboardData).filter(({
27611
+ type
27612
+ }) => /^image\/(?:jpe?g|png|gif)$/.test(type)); // Only process files if no HTML is present.
27613
+ // A pasted file may have the URL as plain text.
27614
 
27615
+ if (files.length && !html) {
27616
+ html = files.map(file => `<img src="${(0,external_wp_blob_namespaceObject.createBlobURL)(file)}">`).join('');
27617
+ plainText = '';
27618
+ }
27619
 
27620
+ return {
27621
+ html,
27622
+ plainText
27623
+ };
27624
+ }
27625
+ //# sourceMappingURL=get-paste-event-data.js.map
27626
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/copy-handler/index.js
27627
 
27628
 
27629
  /**
27630
+ * WordPress dependencies
27631
  */
27632
 
27633
 
27636
 
27637
 
27638
 
27639
+ /**
27640
+ * Internal dependencies
27641
+ */
27642
 
27643
 
27644
 
27645
+ function useNotifyCopy() {
27646
+ const {
27647
+ getBlockName
27648
+ } = (0,external_wp_data_namespaceObject.useSelect)(store);
27649
+ const {
27650
+ getBlockType
27651
+ } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_blocks_namespaceObject.store);
27652
+ const {
27653
+ createSuccessNotice
27654
+ } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
27655
+ return (0,external_wp_element_namespaceObject.useCallback)((eventType, selectedBlockClientIds) => {
27656
+ let notice = '';
27657
 
27658
+ if (selectedBlockClientIds.length === 1) {
27659
+ const clientId = selectedBlockClientIds[0];
27660
+ const {
27661
+ title
27662
+ } = getBlockType(getBlockName(clientId));
27663
+ notice = eventType === 'copy' ? (0,external_wp_i18n_namespaceObject.sprintf)( // Translators: Name of the block being copied, e.g. "Paragraph".
27664
+ (0,external_wp_i18n_namespaceObject.__)('Copied "%s" to clipboard.'), title) : (0,external_wp_i18n_namespaceObject.sprintf)( // Translators: Name of the block being cut, e.g. "Paragraph".
27665
+ (0,external_wp_i18n_namespaceObject.__)('Moved "%s" to clipboard.'), title);
27666
+ } else {
27667
+ notice = eventType === 'copy' ? (0,external_wp_i18n_namespaceObject.sprintf)( // Translators: %d: Number of blocks being copied.
27668
+ (0,external_wp_i18n_namespaceObject._n)('Copied %d block to clipboard.', 'Copied %d blocks to clipboard.', selectedBlockClientIds.length), selectedBlockClientIds.length) : (0,external_wp_i18n_namespaceObject.sprintf)( // Translators: %d: Number of blocks being cut.
27669
+ (0,external_wp_i18n_namespaceObject._n)('Moved %d block to clipboard.', 'Moved %d blocks to clipboard.', selectedBlockClientIds.length), selectedBlockClientIds.length);
27670
+ }
27671
 
27672
+ createSuccessNotice(notice, {
27673
+ type: 'snackbar'
27674
+ });
27675
+ }, []);
27676
+ }
27677
+ function useClipboardHandler() {
27678
+ const {
27679
+ getBlocksByClientId,
27680
+ getSelectedBlockClientIds,
27681
+ hasMultiSelection,
27682
+ getSettings
27683
+ } = (0,external_wp_data_namespaceObject.useSelect)(store);
27684
+ const {
27685
+ flashBlock,
27686
+ removeBlocks,
27687
+ replaceBlocks
27688
+ } = (0,external_wp_data_namespaceObject.useDispatch)(store);
27689
+ const notifyCopy = useNotifyCopy();
27690
+ return (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
27691
+ function handler(event) {
27692
+ const selectedBlockClientIds = getSelectedBlockClientIds();
27693
 
27694
+ if (selectedBlockClientIds.length === 0) {
27695
+ return;
27696
+ } // Always handle multiple selected blocks.
27697
 
27698
 
27699
+ if (!hasMultiSelection()) {
27700
+ const {
27701
+ target
27702
+ } = event;
27703
+ const {
27704
+ ownerDocument
27705
+ } = target; // If copying, only consider actual text selection as selection.
27706
+ // Otherwise, any focus on an input field is considered.
27707
 
27708
+ const hasSelection = event.type === 'copy' || event.type === 'cut' ? (0,external_wp_dom_namespaceObject.documentHasUncollapsedSelection)(ownerDocument) : (0,external_wp_dom_namespaceObject.documentHasSelection)(ownerDocument); // Let native copy behaviour take over in input fields.
27709
 
27710
+ if (hasSelection) {
27711
+ return;
27712
+ }
27713
+ }
27714
 
27715
+ if (!node.contains(event.target.ownerDocument.activeElement)) {
27716
+ return;
27717
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27718
 
27719
+ event.preventDefault();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27720
 
27721
+ if (event.type === 'copy' || event.type === 'cut') {
27722
+ if (selectedBlockClientIds.length === 1) {
27723
+ flashBlock(selectedBlockClientIds[0]);
27724
+ }
 
 
 
 
 
 
27725
 
27726
+ notifyCopy(event.type, selectedBlockClientIds);
27727
+ const blocks = getBlocksByClientId(selectedBlockClientIds);
27728
+ const serialized = (0,external_wp_blocks_namespaceObject.serialize)(blocks);
27729
+ event.clipboardData.setData('text/plain', serialized);
27730
+ event.clipboardData.setData('text/html', serialized);
27731
+ }
27732
 
27733
+ if (event.type === 'cut') {
27734
+ removeBlocks(selectedBlockClientIds);
27735
+ } else if (event.type === 'paste') {
27736
+ const {
27737
+ __experimentalCanUserUseUnfilteredHTML: canUserUseUnfilteredHTML
27738
+ } = getSettings();
27739
+ const {
27740
+ plainText,
27741
+ html
27742
+ } = getPasteEventData(event);
27743
+ const blocks = (0,external_wp_blocks_namespaceObject.pasteHandler)({
27744
+ HTML: html,
27745
+ plainText,
27746
+ mode: 'BLOCKS',
27747
+ canUserUseUnfilteredHTML
27748
+ });
27749
+ replaceBlocks(selectedBlockClientIds, blocks, blocks.length - 1, -1);
27750
+ }
27751
  }
 
 
 
 
 
 
 
27752
 
27753
+ node.ownerDocument.addEventListener('copy', handler);
27754
+ node.ownerDocument.addEventListener('cut', handler);
27755
+ node.ownerDocument.addEventListener('paste', handler);
27756
+ return () => {
27757
+ node.ownerDocument.removeEventListener('copy', handler);
27758
+ node.ownerDocument.removeEventListener('cut', handler);
27759
+ node.ownerDocument.removeEventListener('paste', handler);
27760
+ };
27761
+ }, []);
27762
+ }
27763
 
27764
+ function CopyHandler({
27765
+ children
27766
+ }) {
27767
+ return (0,external_wp_element_namespaceObject.createElement)("div", {
27768
+ ref: useClipboardHandler()
27769
+ }, children);
27770
+ }
27771
 
27772
+ /* harmony default export */ var copy_handler = (CopyHandler);
27773
+ //# sourceMappingURL=index.js.map
27774
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-actions/index.js
27775
  /**
27776
  * External dependencies
27777
  */
27778
 
 
27779
  /**
27780
  * WordPress dependencies
27781
  */
27782
 
27783
 
27784
 
 
 
 
 
27785
  /**
27786
  * Internal dependencies
27787
  */
27788
 
27789
 
27790
 
27791
+ function BlockActions({
27792
+ clientIds,
27793
+ children,
27794
+ __experimentalUpdateSelection: updateSelection
27795
+ }) {
27796
+ const {
27797
+ canInsertBlockType,
27798
+ getBlockRootClientId,
27799
+ getBlocksByClientId,
27800
+ getTemplateLock
27801
+ } = (0,external_wp_data_namespaceObject.useSelect)(select => select(store), []);
27802
+ const {
27803
+ getDefaultBlockName,
27804
+ getGroupingBlockName
27805
+ } = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_blocks_namespaceObject.store), []);
27806
+ const blocks = getBlocksByClientId(clientIds);
27807
+ const rootClientId = getBlockRootClientId(clientIds[0]);
27808
+ const canDuplicate = (0,external_lodash_namespaceObject.every)(blocks, block => {
27809
+ return !!block && (0,external_wp_blocks_namespaceObject.hasBlockSupport)(block.name, 'multiple', true) && canInsertBlockType(block.name, rootClientId);
27810
+ });
27811
+ const canInsertDefaultBlock = canInsertBlockType(getDefaultBlockName(), rootClientId);
27812
+ const {
27813
+ removeBlocks,
27814
+ replaceBlocks,
27815
+ duplicateBlocks,
27816
+ insertAfterBlock,
27817
+ insertBeforeBlock,
27818
+ flashBlock,
27819
+ setBlockMovingClientId,
27820
+ setNavigationMode,
27821
+ selectBlock
27822
+ } = (0,external_wp_data_namespaceObject.useDispatch)(store);
27823
+ const notifyCopy = useNotifyCopy();
27824
+ return children({
27825
+ canDuplicate,
27826
+ canInsertDefaultBlock,
27827
+ isLocked: !!getTemplateLock(rootClientId),
27828
+ rootClientId,
27829
+ blocks,
27830
 
27831
+ onDuplicate() {
27832
+ return duplicateBlocks(clientIds, updateSelection);
27833
+ },
27834
 
27835
+ onRemove() {
27836
+ return removeBlocks(clientIds, updateSelection);
27837
+ },
27838
 
27839
+ onInsertBefore() {
27840
+ insertBeforeBlock((0,external_lodash_namespaceObject.first)((0,external_lodash_namespaceObject.castArray)(clientIds)));
27841
+ },
27842
 
27843
+ onInsertAfter() {
27844
+ insertAfterBlock((0,external_lodash_namespaceObject.last)((0,external_lodash_namespaceObject.castArray)(clientIds)));
27845
+ },
27846
 
27847
+ onMoveTo() {
27848
+ setNavigationMode(true);
27849
+ selectBlock(clientIds[0]);
27850
+ setBlockMovingClientId(clientIds[0]);
27851
+ },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27852
 
27853
+ onGroup() {
27854
+ if (!blocks.length) {
27855
+ return;
 
 
 
 
 
 
 
 
 
 
27856
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27857
 
27858
+ const groupingBlockName = getGroupingBlockName(); // Activate the `transform` on `core/group` which does the conversion
 
 
 
 
 
 
 
 
 
 
27859
 
27860
+ const newBlocks = (0,external_wp_blocks_namespaceObject.switchToBlockType)(blocks, groupingBlockName);
27861
 
27862
+ if (!newBlocks) {
27863
+ return;
27864
+ }
 
 
27865
 
27866
+ replaceBlocks(clientIds, newBlocks);
27867
+ },
 
 
 
 
27868
 
27869
+ onUngroup() {
27870
+ if (!blocks.length) {
27871
+ return;
27872
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27873
 
27874
+ const innerBlocks = blocks[0].innerBlocks;
 
 
 
 
 
 
 
 
 
 
 
27875
 
27876
+ if (!innerBlocks.length) {
27877
+ return;
27878
+ }
 
 
 
27879
 
27880
+ replaceBlocks(clientIds, innerBlocks);
 
 
 
 
 
 
 
 
 
27881
  },
27882
 
27883
+ onCopy() {
27884
+ const selectedBlockClientIds = blocks.map(({
27885
  clientId
27886
+ }) => clientId);
 
 
 
 
 
 
 
 
 
 
 
 
 
27887
 
27888
+ if (blocks.length === 1) {
27889
+ flashBlock(selectedBlockClientIds[0]);
 
27890
  }
 
27891
 
27892
+ notifyCopy('copy', selectedBlockClientIds);
27893
+ }
 
 
27894
 
27895
+ });
27896
+ }
27897
+ //# sourceMappingURL=index.js.map
27898
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-settings-menu/block-mode-toggle.js
27899
 
 
 
 
27900
 
 
 
 
 
 
 
 
 
 
 
27901
  /**
27902
  * External dependencies
27903
  */
27907
  */
27908
 
27909
 
 
 
 
 
 
 
 
 
 
 
 
 
27910
 
27911
+
 
 
27912
 
27913
 
27914
  /**
27915
+ * Internal dependencies
27916
  */
27917
 
27918
+
27919
+ function BlockModeToggle({
27920
+ blockType,
27921
+ mode,
27922
+ onToggleMode,
27923
+ small = false,
27924
+ isCodeEditingEnabled = true
27925
  }) {
27926
+ if (!(0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockType, 'html', true) || !isCodeEditingEnabled) {
27927
+ return null;
27928
+ }
27929
+
27930
+ const label = mode === 'visual' ? (0,external_wp_i18n_namespaceObject.__)('Edit as HTML') : (0,external_wp_i18n_namespaceObject.__)('Edit visually');
27931
+ return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
27932
+ onClick: onToggleMode
27933
+ }, !small && label);
 
 
 
 
 
 
 
 
 
 
 
27934
  }
27935
+ /* harmony default export */ var block_mode_toggle = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)((select, {
27936
+ clientId
27937
+ }) => {
27938
+ const {
27939
+ getBlock,
27940
+ getBlockMode,
27941
+ getSettings
27942
+ } = select(store);
27943
+ const block = getBlock(clientId);
27944
+ const isCodeEditingEnabled = getSettings().codeEditingEnabled;
27945
+ return {
27946
+ mode: getBlockMode(clientId),
27947
+ blockType: block ? (0,external_wp_blocks_namespaceObject.getBlockType)(block.name) : null,
27948
+ isCodeEditingEnabled
27949
+ };
27950
+ }), (0,external_wp_data_namespaceObject.withDispatch)((dispatch, {
27951
+ onToggle = external_lodash_namespaceObject.noop,
27952
+ clientId
27953
+ }) => ({
27954
+ onToggleMode() {
27955
+ dispatch(store).toggleBlockMode(clientId);
27956
+ onToggle();
27957
+ }
27958
 
27959
+ }))])(BlockModeToggle));
27960
+ //# sourceMappingURL=block-mode-toggle.js.map
27961
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-settings-menu/block-convert-button.js
27962
 
 
 
 
27963
 
27964
  /**
27965
  * WordPress dependencies
27966
  */
27967
 
27968
 
27969
+ function BlockConvertButton({
27970
+ shouldRender,
27971
+ onClick,
27972
+ small
27973
+ }) {
27974
+ if (!shouldRender) {
27975
+ return null;
27976
+ }
27977
 
27978
+ const label = (0,external_wp_i18n_namespaceObject.__)('Convert to Blocks');
27979
 
27980
+ return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
27981
+ onClick: onClick
27982
+ }, !small && label);
27983
+ }
27984
+ //# sourceMappingURL=block-convert-button.js.map
27985
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-settings-menu/block-html-convert-button.js
27986
  /**
27987
+ * WordPress dependencies
27988
  */
27989
 
27990
 
27991
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27992
  /**
27993
+ * Internal dependencies
27994
  */
27995
 
27996
+
27997
+
27998
+ /* harmony default export */ var block_html_convert_button = ((0,external_wp_compose_namespaceObject.compose)((0,external_wp_data_namespaceObject.withSelect)((select, {
27999
+ clientId
28000
+ }) => {
28001
+ const block = select(store).getBlock(clientId);
28002
+ return {
28003
+ block,
28004
+ shouldRender: block && block.name === 'core/html'
28005
+ };
28006
+ }), (0,external_wp_data_namespaceObject.withDispatch)((dispatch, {
28007
+ block
28008
+ }) => ({
28009
+ onClick: () => dispatch(store).replaceBlocks(block.clientId, (0,external_wp_blocks_namespaceObject.rawHandler)({
28010
+ HTML: (0,external_wp_blocks_namespaceObject.getBlockContent)(block)
28011
+ }))
28012
+ })))(BlockConvertButton));
28013
+ //# sourceMappingURL=block-html-convert-button.js.map
28014
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-settings-menu/block-settings-menu-first-item.js
28015
  /**
28016
  * WordPress dependencies
28017
  */
28018
 
28019
+ const {
28020
+ Fill: __unstableBlockSettingsMenuFirstItem,
28021
+ Slot: block_settings_menu_first_item_Slot
28022
+ } = (0,external_wp_components_namespaceObject.createSlotFill)('__unstableBlockSettingsMenuFirstItem');
28023
+ __unstableBlockSettingsMenuFirstItem.Slot = block_settings_menu_first_item_Slot;
28024
+ /* harmony default export */ var block_settings_menu_first_item = (__unstableBlockSettingsMenuFirstItem);
28025
+ //# sourceMappingURL=block-settings-menu-first-item.js.map
28026
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/convert-to-group-buttons/index.js
28027
 
28028
 
28029
+ /**
28030
+ * WordPress dependencies
28031
+ */
28032
 
28033
 
28034
 
28040
 
28041
 
28042
 
28043
+ function ConvertToGroupButton({
28044
+ clientIds,
28045
+ isGroupable,
28046
+ isUngroupable,
28047
+ blocksSelection,
28048
+ groupingBlockName,
28049
+ onClose = () => {}
28050
+ }) {
28051
+ const {
28052
+ replaceBlocks
28053
+ } = (0,external_wp_data_namespaceObject.useDispatch)(store);
28054
 
28055
+ const onConvertToGroup = () => {
28056
+ // Activate the `transform` on the Grouping Block which does the conversion
28057
+ const newBlocks = (0,external_wp_blocks_namespaceObject.switchToBlockType)(blocksSelection, groupingBlockName);
28058
 
28059
+ if (newBlocks) {
28060
+ replaceBlocks(clientIds, newBlocks);
28061
+ }
28062
+ };
28063
 
28064
+ const onConvertFromGroup = () => {
28065
+ const innerBlocks = blocksSelection[0].innerBlocks;
28066
 
28067
+ if (!innerBlocks.length) {
28068
+ return;
28069
+ }
28070
 
28071
+ replaceBlocks(clientIds, innerBlocks);
28072
+ };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28073
 
28074
+ if (!isGroupable && !isUngroupable) {
28075
+ return null;
28076
+ }
28077
 
28078
+ return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, isGroupable && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
28079
+ onClick: () => {
28080
+ onConvertToGroup();
28081
+ onClose();
28082
+ }
28083
+ }, (0,external_wp_i18n_namespaceObject._x)('Group', 'verb')), isUngroupable && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
28084
+ onClick: () => {
28085
+ onConvertFromGroup();
28086
+ onClose();
28087
+ }
28088
+ }, (0,external_wp_i18n_namespaceObject._x)('Ungroup', 'Ungrouping blocks from within a Group block back into individual blocks within the Editor ')));
28089
+ }
28090
 
 
 
 
28091
 
28092
+ //# sourceMappingURL=index.js.map
28093
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.js
28094
  /**
28095
  * WordPress dependencies
28096
  */
28097
 
28098
 
 
28099
  /**
28100
  * Internal dependencies
28101
  */
28102
 
28103
 
28104
+ /**
28105
+ * Contains the properties `ConvertToGroupButton` component needs.
28106
+ *
28107
+ * @typedef {Object} ConvertToGroupButtonProps
28108
+ * @property {string[]} clientIds An array of the selected client ids.
28109
+ * @property {boolean} isGroupable Indicates if the selected blocks can be grouped.
28110
+ * @property {boolean} isUngroupable Indicates if the selected blocks can be ungrouped.
28111
+ * @property {WPBlock[]} blocksSelection An array of the selected blocks.
28112
+ * @property {string} groupingBlockName The name of block used for handling grouping interactions.
28113
+ */
28114
 
28115
+ /**
28116
+ * Returns the properties `ConvertToGroupButton` component needs to work properly.
28117
+ * It is used in `BlockSettingsMenuControls` to know if `ConvertToGroupButton`
28118
+ * should be rendered, to avoid ending up with an empty MenuGroup.
28119
+ *
28120
+ * @return {ConvertToGroupButtonProps} Returns the properties needed by `ConvertToGroupButton`.
28121
+ */
28122
 
28123
+ function useConvertToGroupButtonProps() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28124
  const {
28125
+ clientIds,
28126
+ isGroupable,
28127
+ isUngroupable,
28128
+ blocksSelection,
28129
+ groupingBlockName
28130
  } = (0,external_wp_data_namespaceObject.useSelect)(select => {
28131
+ var _blocksSelection$;
28132
+
28133
  const {
28134
  getBlockRootClientId,
28135
+ getBlocksByClientId,
28136
+ canInsertBlockType,
28137
+ getSelectedBlockClientIds
28138
  } = select(store);
28139
+ const {
28140
+ getGroupingBlockName
28141
+ } = select(external_wp_blocks_namespaceObject.store);
28142
+
28143
+ const _clientIds = getSelectedBlockClientIds();
28144
+
28145
+ const _groupingBlockName = getGroupingBlockName();
28146
+
28147
+ const rootClientId = !!(_clientIds !== null && _clientIds !== void 0 && _clientIds.length) ? getBlockRootClientId(_clientIds[0]) : undefined;
28148
+ const groupingBlockAvailable = canInsertBlockType(_groupingBlockName, rootClientId);
28149
+
28150
+ const _blocksSelection = getBlocksByClientId(_clientIds);
28151
+
28152
+ const isSingleGroupingBlock = _blocksSelection.length === 1 && ((_blocksSelection$ = _blocksSelection[0]) === null || _blocksSelection$ === void 0 ? void 0 : _blocksSelection$.name) === _groupingBlockName; // Do we have
28153
+ // 1. Grouping block available to be inserted?
28154
+ // 2. One or more blocks selected
28155
+ // (we allow single Blocks to become groups unless
28156
+ // they are a soltiary group block themselves)
28157
+
28158
+ const _isGroupable = groupingBlockAvailable && _blocksSelection.length && !isSingleGroupingBlock; // Do we have a single Group Block selected and does that group have inner blocks?
28159
+
28160
+
28161
+ const _isUngroupable = isSingleGroupingBlock && !!_blocksSelection[0].innerBlocks.length;
28162
+
28163
  return {
28164
+ clientIds: _clientIds,
28165
+ isGroupable: _isGroupable,
28166
+ isUngroupable: _isUngroupable,
28167
+ blocksSelection: _blocksSelection,
28168
+ groupingBlockName: _groupingBlockName
28169
  };
28170
+ }, []);
28171
+ return {
28172
+ clientIds,
28173
+ isGroupable,
28174
+ isUngroupable,
28175
+ blocksSelection,
28176
+ groupingBlockName
28177
+ };
28178
+ }
28179
+ //# sourceMappingURL=use-convert-to-group-button-props.js.map
28180
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-settings-menu-controls/index.js
28181
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28182
 
28183
 
28184
  /**
28191
 
28192
 
28193
 
 
 
 
28194
  /**
28195
  * Internal dependencies
28196
  */
28197
 
28198
 
28199
 
28200
+ const {
28201
+ Fill,
28202
+ Slot: block_settings_menu_controls_Slot
28203
+ } = (0,external_wp_components_namespaceObject.createSlotFill)('BlockSettingsMenuControls');
28204
 
28205
+ const BlockSettingsMenuControlsSlot = ({
28206
+ fillProps,
28207
+ clientIds = null
28208
+ }) => {
28209
+ const selectedBlocks = (0,external_wp_data_namespaceObject.useSelect)(select => {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28210
  const {
28211
+ getBlocksByClientId,
28212
+ getSelectedBlockClientIds
 
28213
  } = select(store);
28214
+ const ids = clientIds !== null ? clientIds : getSelectedBlockClientIds();
28215
+ return (0,external_lodash_namespaceObject.map)((0,external_lodash_namespaceObject.compact)(getBlocksByClientId(ids)), block => block.name);
28216
+ }, [clientIds]); // Check if current selection of blocks is Groupable or Ungroupable
28217
+ // and pass this props down to ConvertToGroupButton.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28218
 
28219
+ const convertToGroupButtonProps = useConvertToGroupButtonProps();
28220
+ const {
28221
+ isGroupable,
28222
+ isUngroupable
28223
+ } = convertToGroupButtonProps;
28224
+ const showConvertToGroupButton = isGroupable || isUngroupable;
28225
+ return (0,external_wp_element_namespaceObject.createElement)(block_settings_menu_controls_Slot, {
28226
+ fillProps: { ...fillProps,
28227
+ selectedBlocks
28228
  }
28229
+ }, fills => {
28230
+ if ((fills === null || fills === void 0 ? void 0 : fills.length) > 0 || showConvertToGroupButton) {
28231
+ return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, null, fills, (0,external_wp_element_namespaceObject.createElement)(ConvertToGroupButton, _extends({}, convertToGroupButtonProps, {
28232
+ onClose: fillProps === null || fillProps === void 0 ? void 0 : fillProps.onClose
28233
+ })));
 
28234
  }
28235
+ });
28236
+ };
28237
+ /**
28238
+ * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-settings-menu-controls/README.md
28239
+ *
28240
+ * @param {Object} props Fill props.
28241
+ * @return {WPElement} Element.
28242
+ */
28243
 
 
 
 
 
28244
 
28245
+ function BlockSettingsMenuControls({ ...props
28246
+ }) {
28247
+ return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalStyleProvider, {
28248
+ document: document
28249
+ }, (0,external_wp_element_namespaceObject.createElement)(Fill, props));
28250
+ }
28251
 
28252
+ BlockSettingsMenuControls.Slot = BlockSettingsMenuControlsSlot;
28253
+ /* harmony default export */ var block_settings_menu_controls = (BlockSettingsMenuControls);
28254
+ //# sourceMappingURL=index.js.map
28255
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-settings-menu/block-settings-dropdown.js
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28256
 
 
 
 
 
 
 
 
28257
 
28258
 
28259
  /**
28268
 
28269
 
28270
 
 
 
 
 
 
28271
 
28272
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28273
 
28274
 
28275
  /**
28276
+ * Internal dependencies
28277
  */
28278
 
 
 
 
28279
 
28280
 
 
 
 
28281
 
28282
 
28283
 
28284
 
28285
+ const block_settings_dropdown_POPOVER_PROPS = {
28286
+ className: 'block-editor-block-settings-menu__popover',
28287
+ position: 'bottom right',
28288
+ isAlternate: true
28289
+ };
28290
 
28291
+ function CopyMenuItem({
28292
+ blocks,
28293
+ onCopy
28294
+ }) {
28295
+ const ref = (0,external_wp_compose_namespaceObject.useCopyToClipboard)(() => (0,external_wp_blocks_namespaceObject.serialize)(blocks), onCopy);
28296
+ return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
28297
+ ref: ref
28298
+ }, (0,external_wp_i18n_namespaceObject.__)('Copy'));
28299
+ }
 
 
 
 
 
 
 
 
 
 
28300
 
28301
+ function BlockSettingsDropdown({
28302
+ clientIds,
28303
+ __experimentalSelectBlock,
28304
+ children,
28305
+ ...props
28306
+ }) {
28307
+ const blockClientIds = (0,external_lodash_namespaceObject.castArray)(clientIds);
28308
+ const count = blockClientIds.length;
28309
+ const firstBlockClientId = blockClientIds[0];
28310
+ const onlyBlock = (0,external_wp_data_namespaceObject.useSelect)(select => 1 === select(store).getBlockCount(), []);
28311
+ const shortcuts = (0,external_wp_data_namespaceObject.useSelect)(select => {
28312
+ const {
28313
+ getShortcutRepresentation
28314
+ } = select(external_wp_keyboardShortcuts_namespaceObject.store);
28315
+ return {
28316
+ duplicate: getShortcutRepresentation('core/block-editor/duplicate'),
28317
+ remove: getShortcutRepresentation('core/block-editor/remove'),
28318
+ insertAfter: getShortcutRepresentation('core/block-editor/insert-after'),
28319
+ insertBefore: getShortcutRepresentation('core/block-editor/insert-before')
28320
+ };
28321
+ }, []);
28322
+ const updateSelection = (0,external_wp_element_namespaceObject.useCallback)(__experimentalSelectBlock ? async clientIdsPromise => {
28323
+ const ids = await clientIdsPromise;
28324
 
28325
+ if (ids && ids[0]) {
28326
+ __experimentalSelectBlock(ids[0]);
28327
+ }
28328
+ } : external_lodash_namespaceObject.noop, [__experimentalSelectBlock]);
28329
+ const removeBlockLabel = count === 1 ? (0,external_wp_i18n_namespaceObject.__)('Remove block') : (0,external_wp_i18n_namespaceObject.__)('Remove blocks');
28330
+ return (0,external_wp_element_namespaceObject.createElement)(BlockActions, {
28331
+ clientIds: clientIds,
28332
+ __experimentalUpdateSelection: !__experimentalSelectBlock
28333
+ }, ({
28334
+ canDuplicate,
28335
+ canInsertDefaultBlock,
28336
+ isLocked,
28337
+ onDuplicate,
28338
+ onInsertAfter,
28339
+ onInsertBefore,
28340
+ onRemove,
28341
+ onCopy,
28342
+ onMoveTo,
28343
+ blocks
28344
+ }) => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.DropdownMenu, _extends({
28345
+ icon: more_vertical,
28346
+ label: (0,external_wp_i18n_namespaceObject.__)('Options'),
28347
+ className: "block-editor-block-settings-menu",
28348
+ popoverProps: block_settings_dropdown_POPOVER_PROPS,
28349
+ noIcons: true
28350
+ }, props), ({
28351
+ onClose
28352
+ }) => (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, null, (0,external_wp_element_namespaceObject.createElement)(block_settings_menu_first_item.Slot, {
28353
+ fillProps: {
28354
+ onClose
28355
+ }
28356
+ }), count === 1 && (0,external_wp_element_namespaceObject.createElement)(block_html_convert_button, {
28357
+ clientId: firstBlockClientId
28358
+ }), (0,external_wp_element_namespaceObject.createElement)(CopyMenuItem, {
28359
+ blocks: blocks,
28360
+ onCopy: onCopy
28361
+ }), canDuplicate && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
28362
+ onClick: (0,external_lodash_namespaceObject.flow)(onClose, onDuplicate, updateSelection),
28363
+ shortcut: shortcuts.duplicate
28364
+ }, (0,external_wp_i18n_namespaceObject.__)('Duplicate')), canInsertDefaultBlock && (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
28365
+ onClick: (0,external_lodash_namespaceObject.flow)(onClose, onInsertBefore),
28366
+ shortcut: shortcuts.insertBefore
28367
+ }, (0,external_wp_i18n_namespaceObject.__)('Insert before')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
28368
+ onClick: (0,external_lodash_namespaceObject.flow)(onClose, onInsertAfter),
28369
+ shortcut: shortcuts.insertAfter
28370
+ }, (0,external_wp_i18n_namespaceObject.__)('Insert after'))), !isLocked && !onlyBlock && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
28371
+ onClick: (0,external_lodash_namespaceObject.flow)(onClose, onMoveTo)
28372
+ }, (0,external_wp_i18n_namespaceObject.__)('Move to')), count === 1 && (0,external_wp_element_namespaceObject.createElement)(block_mode_toggle, {
28373
+ clientId: firstBlockClientId,
28374
+ onToggle: onClose
28375
+ })), (0,external_wp_element_namespaceObject.createElement)(block_settings_menu_controls.Slot, {
28376
+ fillProps: {
28377
+ onClose
28378
+ },
28379
+ clientIds: clientIds
28380
+ }), typeof children === 'function' ? children({
28381
+ onClose
28382
+ }) : external_wp_element_namespaceObject.Children.map(child => (0,external_wp_element_namespaceObject.cloneElement)(child, {
28383
+ onClose
28384
+ })), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, null, !isLocked && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
28385
+ onClick: (0,external_lodash_namespaceObject.flow)(onClose, onRemove, updateSelection),
28386
+ shortcut: shortcuts.remove
28387
+ }, removeBlockLabel)))));
28388
+ }
28389
+ /* harmony default export */ var block_settings_dropdown = (BlockSettingsDropdown);
28390
+ //# sourceMappingURL=block-settings-dropdown.js.map
28391
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-settings-menu/index.js
28392
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28393
 
 
 
 
 
28394
 
28395
+ /**
28396
+ * WordPress dependencies
28397
+ */
 
28398
 
28399
+ /**
28400
+ * Internal dependencies
28401
+ */
28402
 
 
 
 
 
 
 
28403
 
28404
+ function BlockSettingsMenu({
28405
+ clientIds,
28406
+ ...props
28407
+ }) {
28408
+ return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarGroup, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarItem, null, toggleProps => (0,external_wp_element_namespaceObject.createElement)(block_settings_dropdown, _extends({
28409
+ clientIds: clientIds,
28410
+ toggleProps: toggleProps
28411
+ }, props))));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28412
  }
28413
+ /* harmony default export */ var block_settings_menu = (BlockSettingsMenu);
28414
+ //# sourceMappingURL=index.js.map
28415
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-toolbar/index.js
28416
+
 
28417
 
28418
 
28419
+ /**
28420
+ * External dependencies
28421
+ */
28422
+
28423
  /**
28424
  * WordPress dependencies
28425
  */
28426
 
28427
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28428
 
28429
 
 
 
 
28430
 
28431
 
28432
+ /**
28433
+ * Internal dependencies
28434
+ */
28435
 
 
 
 
 
28436
 
 
 
 
 
 
 
 
28437
 
28438
 
 
 
 
 
 
 
 
 
 
28439
 
28440
+
28441
+
28442
+
28443
+ function BlockToolbar({
28444
+ hideDragHandle
28445
+ }) {
28446
+ const {
28447
+ blockClientIds,
28448
+ blockClientId,
28449
+ blockType,
28450
+ hasFixedToolbar,
28451
+ hasReducedUI,
28452
+ isValid,
28453
+ isVisual
28454
+ } = (0,external_wp_data_namespaceObject.useSelect)(select => {
28455
+ const {
28456
+ getBlockName,
28457
+ getBlockMode,
28458
+ getSelectedBlockClientIds,
28459
+ isBlockValid,
28460
+ getBlockRootClientId,
28461
+ getSettings
28462
+ } = select(store);
28463
+ const selectedBlockClientIds = getSelectedBlockClientIds();
28464
+ const selectedBlockClientId = selectedBlockClientIds[0];
28465
+ const blockRootClientId = getBlockRootClientId(selectedBlockClientId);
28466
+ const settings = getSettings();
28467
  return {
28468
+ blockClientIds: selectedBlockClientIds,
28469
+ blockClientId: selectedBlockClientId,
28470
+ blockType: selectedBlockClientId && (0,external_wp_blocks_namespaceObject.getBlockType)(getBlockName(selectedBlockClientId)),
28471
+ hasFixedToolbar: settings.hasFixedToolbar,
28472
+ hasReducedUI: settings.hasReducedUI,
28473
+ rootClientId: blockRootClientId,
28474
+ isValid: selectedBlockClientIds.every(id => isBlockValid(id)),
28475
+ isVisual: selectedBlockClientIds.every(id => getBlockMode(id) === 'visual')
28476
  };
28477
+ }, []); // Handles highlighting the current block outline on hover or focus of the
28478
+ // block type toolbar area.
 
 
 
28479
 
28480
+ const {
28481
+ toggleBlockHighlight
28482
+ } = (0,external_wp_data_namespaceObject.useDispatch)(store);
28483
+ const nodeRef = (0,external_wp_element_namespaceObject.useRef)();
28484
+ const {
28485
+ showMovers,
28486
+ gestures: showMoversGestures
28487
+ } = useShowMoversGestures({
28488
+ ref: nodeRef,
 
28489
 
28490
+ onChange(isFocused) {
28491
+ if (isFocused && hasReducedUI) {
28492
+ return;
28493
+ }
28494
+
28495
+ toggleBlockHighlight(blockClientId, isFocused);
28496
  }
28497
 
28498
+ }); // Account for the cases where the block toolbar is rendered within the
28499
+ // header area and not contextually to the block.
28500
+
28501
+ const displayHeaderToolbar = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<') || hasFixedToolbar;
28502
+
28503
+ if (blockType) {
28504
+ if (!(0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockType, '__experimentalToolbar', true)) {
28505
+ return null;
28506
  }
28507
+ }
28508
 
28509
+ const shouldShowMovers = displayHeaderToolbar || showMovers;
 
28510
 
28511
+ if (blockClientIds.length === 0) {
28512
  return null;
28513
  }
28514
 
28515
+ const shouldShowVisualToolbar = isValid && isVisual;
28516
+ const isMultiToolbar = blockClientIds.length > 1;
28517
+ const classes = classnames_default()('block-editor-block-toolbar', shouldShowMovers && 'is-showing-movers');
28518
+ return (0,external_wp_element_namespaceObject.createElement)("div", {
28519
+ className: classes
28520
+ }, !isMultiToolbar && !displayHeaderToolbar && (0,external_wp_element_namespaceObject.createElement)(BlockParentSelector, {
28521
+ clientIds: blockClientIds
28522
+ }), (0,external_wp_element_namespaceObject.createElement)("div", _extends({
28523
+ ref: nodeRef
28524
+ }, showMoversGestures), (shouldShowVisualToolbar || isMultiToolbar) && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarGroup, {
28525
+ className: "block-editor-block-toolbar__block-controls"
28526
+ }, (0,external_wp_element_namespaceObject.createElement)(block_switcher, {
28527
+ clientIds: blockClientIds
28528
+ }), (0,external_wp_element_namespaceObject.createElement)(block_mover, {
28529
+ clientIds: blockClientIds,
28530
+ hideDragHandle: hideDragHandle || hasReducedUI
28531
+ }))), shouldShowVisualToolbar && (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(block_controls.Slot, {
28532
+ group: "parent",
28533
+ className: "block-editor-block-toolbar__slot"
28534
+ }), (0,external_wp_element_namespaceObject.createElement)(block_controls.Slot, {
28535
+ group: "block",
28536
+ className: "block-editor-block-toolbar__slot"
28537
+ }), (0,external_wp_element_namespaceObject.createElement)(block_controls.Slot, {
28538
+ className: "block-editor-block-toolbar__slot"
28539
+ }), (0,external_wp_element_namespaceObject.createElement)(block_controls.Slot, {
28540
+ group: "inline",
28541
+ className: "block-editor-block-toolbar__slot"
28542
+ }), (0,external_wp_element_namespaceObject.createElement)(block_controls.Slot, {
28543
+ group: "other",
28544
+ className: "block-editor-block-toolbar__slot"
28545
+ })), (0,external_wp_element_namespaceObject.createElement)(block_settings_menu, {
28546
+ clientIds: blockClientIds
28547
  }));
28548
  }
28549
+ //# sourceMappingURL=index.js.map
28550
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-tools/block-contextual-toolbar.js
28551
+
28552
+
28553
+
28554
  /**
28555
+ * External dependencies
28556
  */
28557
 
28558
  /**
28559
+ * WordPress dependencies
28560
  */
28561
 
28562
 
28563
 
28564
 
28565
+ /**
28566
+ * Internal dependencies
28567
+ */
 
 
28568
 
 
 
 
28569
 
 
 
28570
 
 
 
 
 
 
 
28571
 
 
 
 
28572
 
28573
+ function BlockContextualToolbar({
28574
+ focusOnMount,
28575
+ isFixed,
28576
+ ...props
28577
+ }) {
28578
+ const {
28579
+ blockType,
28580
+ hasParents,
28581
+ showParentSelector
28582
+ } = (0,external_wp_data_namespaceObject.useSelect)(select => {
28583
+ const {
28584
+ getBlockName,
28585
+ getBlockParents,
28586
+ getSelectedBlockClientIds
28587
+ } = select(store);
28588
+ const {
28589
+ getBlockType
28590
+ } = select(external_wp_blocks_namespaceObject.store);
28591
+ const selectedBlockClientIds = getSelectedBlockClientIds();
28592
+ const selectedBlockClientId = selectedBlockClientIds[0];
28593
+ const parents = getBlockParents(selectedBlockClientId);
28594
+ const firstParentClientId = parents[parents.length - 1];
28595
+ const parentBlockName = getBlockName(firstParentClientId);
28596
+ const parentBlockType = getBlockType(parentBlockName);
28597
+ return {
28598
+ blockType: selectedBlockClientId && getBlockType(getBlockName(selectedBlockClientId)),
28599
+ hasParents: parents.length,
28600
+ showParentSelector: (0,external_wp_blocks_namespaceObject.hasBlockSupport)(parentBlockType, '__experimentalParentSelector', true) && selectedBlockClientIds.length <= 1
28601
+ };
28602
+ }, []);
28603
 
28604
+ if (blockType) {
28605
+ if (!(0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockType, '__experimentalToolbar', true)) {
28606
+ return null;
28607
+ }
28608
+ } // Shifts the toolbar to make room for the parent block selector.
28609
 
 
28610
 
28611
+ const classes = classnames_default()('block-editor-block-contextual-toolbar', {
28612
+ 'has-parent': hasParents && showParentSelector,
28613
+ 'is-fixed': isFixed
28614
+ });
28615
+ return (0,external_wp_element_namespaceObject.createElement)(navigable_toolbar, _extends({
28616
+ focusOnMount: focusOnMount,
28617
+ className: classes
28618
+ /* translators: accessibility text for the block toolbar */
28619
+ ,
28620
+ "aria-label": (0,external_wp_i18n_namespaceObject.__)('Block tools')
28621
+ }, props), (0,external_wp_element_namespaceObject.createElement)(BlockToolbar, {
28622
+ hideDragHandle: isFixed
28623
+ }));
28624
+ }
28625
 
28626
+ /* harmony default export */ var block_contextual_toolbar = (BlockContextualToolbar);
28627
+ //# sourceMappingURL=block-contextual-toolbar.js.map
28628
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-tools/block-popover.js
28629
 
 
 
 
28630
 
28631
+ /**
28632
+ * External dependencies
28633
+ */
28634
+
28635
 
 
 
 
 
 
 
 
 
 
 
28636
  /**
28637
  * WordPress dependencies
28638
  */
28639
 
28640
 
28641
 
28642
+
28643
+
28644
+
28645
+
28646
+
28647
  /**
28648
  * Internal dependencies
28649
  */
28651
 
28652
 
28653
 
 
28654
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28655
 
 
 
 
 
 
 
 
 
 
 
28656
 
 
 
 
 
 
 
 
 
28657
 
28658
+ function block_popover_selector(select) {
28659
+ const {
28660
+ isNavigationMode,
28661
+ isMultiSelecting,
28662
+ hasMultiSelection,
28663
+ isTyping,
28664
+ isCaretWithinFormattedText,
28665
+ getSettings,
28666
+ getLastMultiSelectedBlockClientId
28667
+ } = select(store);
28668
+ return {
28669
+ isNavigationMode: isNavigationMode(),
28670
+ isMultiSelecting: isMultiSelecting(),
28671
+ isTyping: isTyping(),
28672
+ isCaretWithinFormattedText: isCaretWithinFormattedText(),
28673
+ hasMultiSelection: hasMultiSelection(),
28674
+ hasFixedToolbar: getSettings().hasFixedToolbar,
28675
+ lastClientId: getLastMultiSelectedBlockClientId()
28676
+ };
28677
  }
 
 
 
 
 
 
 
 
 
 
28678
 
28679
+ function BlockPopover({
28680
+ clientId,
28681
+ rootClientId,
28682
+ isValid,
28683
+ isEmptyDefaultBlock,
28684
+ capturingClientId,
28685
+ __unstablePopoverSlot,
28686
+ __unstableContentRef
28687
+ }) {
28688
+ const {
28689
+ isNavigationMode,
28690
+ isMultiSelecting,
28691
+ isTyping,
28692
+ isCaretWithinFormattedText,
28693
+ hasMultiSelection,
28694
+ hasFixedToolbar,
28695
+ lastClientId
28696
+ } = (0,external_wp_data_namespaceObject.useSelect)(block_popover_selector, []);
28697
+ const isInsertionPointVisible = (0,external_wp_data_namespaceObject.useSelect)(select => {
28698
+ const {
28699
+ isBlockInsertionPointVisible,
28700
+ getBlockInsertionPoint,
28701
+ getBlockOrder
28702
+ } = select(store);
28703
 
28704
+ if (!isBlockInsertionPointVisible()) {
28705
+ return false;
28706
+ }
 
 
28707
 
28708
+ const insertionPoint = getBlockInsertionPoint();
28709
+ const order = getBlockOrder(insertionPoint.rootClientId);
28710
+ return order[insertionPoint.index] === clientId;
28711
+ }, [clientId]);
28712
+ const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium');
28713
+ const [isToolbarForced, setIsToolbarForced] = (0,external_wp_element_namespaceObject.useState)(false);
28714
+ const [isInserterShown, setIsInserterShown] = (0,external_wp_element_namespaceObject.useState)(false);
28715
+ const {
28716
+ stopTyping
28717
+ } = (0,external_wp_data_namespaceObject.useDispatch)(store); // Controls when the side inserter on empty lines should
28718
+ // be shown, including writing and selection modes.
28719
 
28720
+ const showEmptyBlockSideInserter = !isTyping && !isNavigationMode && isEmptyDefaultBlock && isValid;
28721
+ const shouldShowBreadcrumb = isNavigationMode;
28722
+ const shouldShowContextualToolbar = !isNavigationMode && !hasFixedToolbar && isLargeViewport && !showEmptyBlockSideInserter && !isMultiSelecting && (!isTyping || isCaretWithinFormattedText);
28723
+ const canFocusHiddenToolbar = !isNavigationMode && !shouldShowContextualToolbar && !hasFixedToolbar && !isEmptyDefaultBlock;
28724
+ (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/block-editor/focus-toolbar', (0,external_wp_element_namespaceObject.useCallback)(() => {
28725
+ setIsToolbarForced(true);
28726
+ stopTyping(true);
28727
+ }, []), {
28728
+ bindGlobal: true,
28729
+ eventName: 'keydown',
28730
+ isDisabled: !canFocusHiddenToolbar
28731
+ });
28732
+ (0,external_wp_element_namespaceObject.useEffect)(() => {
28733
+ if (!shouldShowContextualToolbar) {
28734
+ setIsToolbarForced(false);
28735
+ }
28736
+ }, [shouldShowContextualToolbar]); // Stores the active toolbar item index so the block toolbar can return focus
28737
+ // to it when re-mounting.
28738
 
28739
+ const initialToolbarItemIndexRef = (0,external_wp_element_namespaceObject.useRef)();
28740
+ const selectedElement = useBlockElement(clientId);
28741
+ const lastSelectedElement = useBlockElement(lastClientId);
28742
+ const capturingElement = useBlockElement(capturingClientId);
28743
+ const popoverScrollRef = usePopoverScroll(__unstableContentRef);
28744
 
28745
+ if (!shouldShowBreadcrumb && !shouldShowContextualToolbar && !isToolbarForced && !showEmptyBlockSideInserter) {
28746
+ return null;
28747
+ }
 
28748
 
28749
+ let node = selectedElement;
 
 
28750
 
28751
+ if (!node) {
28752
+ return null;
28753
+ }
 
 
 
28754
 
28755
+ if (capturingClientId) {
28756
+ node = capturingElement;
28757
+ }
 
 
 
 
 
 
 
 
 
 
 
28758
 
28759
+ let anchorRef = node;
28760
 
28761
+ if (hasMultiSelection) {
28762
+ // Wait to render the popover until the bottom reference is available
28763
+ // as well.
28764
+ if (!lastSelectedElement) {
28765
+ return null;
28766
  }
28767
+
28768
+ anchorRef = {
28769
+ top: node,
28770
+ bottom: lastSelectedElement
28771
+ };
28772
  }
28773
 
28774
+ function onFocus() {
28775
+ setIsInserterShown(true);
28776
  }
28777
 
28778
+ function onBlur() {
28779
+ setIsInserterShown(false);
28780
+ } // Position above the anchor, pop out towards the right, and position in the
28781
+ // left corner. For the side inserter, pop out towards the left, and
28782
+ // position in the right corner.
28783
+ // To do: refactor `Popover` to make this prop clearer.
28784
 
 
 
 
 
 
 
 
 
28785
 
28786
+ const popoverPosition = showEmptyBlockSideInserter ? 'top left right' : 'top right left';
28787
+ const {
28788
+ ownerDocument
28789
+ } = node;
28790
+ const stickyBoundaryElement = showEmptyBlockSideInserter ? undefined : // The sticky boundary element should be the boundary at which the
28791
+ // the block toolbar becomes sticky when the block scolls out of view.
28792
+ // In case of an iframe, this should be the iframe boundary, otherwise
28793
+ // the scroll container.
28794
+ ownerDocument.defaultView.frameElement || (0,external_wp_dom_namespaceObject.getScrollContainer)(node) || ownerDocument.body;
28795
+ return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Popover, {
28796
+ ref: popoverScrollRef,
28797
+ noArrow: true,
28798
+ animate: false,
28799
+ position: popoverPosition,
28800
+ focusOnMount: false,
28801
+ anchorRef: anchorRef,
28802
+ className: classnames_default()('block-editor-block-list__block-popover', {
28803
+ 'is-insertion-point-visible': isInsertionPointVisible
28804
+ }),
28805
+ __unstableStickyBoundaryElement: stickyBoundaryElement // Render in the old slot if needed for backward compatibility,
28806
+ // otherwise render in place (not in the the default popover slot).
28807
+ ,
28808
+ __unstableSlotName: __unstablePopoverSlot || null,
28809
+ __unstableBoundaryParent: true // Observe movement for block animations (especially horizontal).
28810
+ ,
28811
+ __unstableObserveElement: node,
28812
+ shouldAnchorIncludePadding: true
28813
+ }, (shouldShowContextualToolbar || isToolbarForced) && (0,external_wp_element_namespaceObject.createElement)("div", {
28814
+ onFocus: onFocus,
28815
+ onBlur: onBlur // While ideally it would be enough to capture the
28816
+ // bubbling focus event from the Inserter, due to the
28817
+ // characteristics of click focusing of `button`s in
28818
+ // Firefox and Safari, it is not reliable.
28819
+ //
28820
+ // See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus
28821
+ ,
28822
+ tabIndex: -1,
28823
+ className: classnames_default()('block-editor-block-list__block-popover-inserter', {
28824
+ 'is-visible': isInserterShown
28825
+ })
28826
+ }, (0,external_wp_element_namespaceObject.createElement)(inserter, {
28827
+ clientId: clientId,
28828
+ rootClientId: rootClientId,
28829
+ __experimentalIsQuick: true
28830
+ })), (shouldShowContextualToolbar || isToolbarForced) && (0,external_wp_element_namespaceObject.createElement)(block_contextual_toolbar // If the toolbar is being shown because of being forced
28831
+ // it should focus the toolbar right after the mount.
28832
+ , {
28833
+ focusOnMount: isToolbarForced,
28834
+ __experimentalInitialIndex: initialToolbarItemIndexRef.current,
28835
+ __experimentalOnIndexChange: index => {
28836
+ initialToolbarItemIndexRef.current = index;
28837
+ } // Resets the index whenever the active block changes so
28838
+ // this is not persisted. See https://github.com/WordPress/gutenberg/pull/25760#issuecomment-717906169
28839
+ ,
28840
+ key: clientId
28841
+ }), shouldShowBreadcrumb && (0,external_wp_element_namespaceObject.createElement)(block_selection_button, {
28842
+ clientId: clientId,
28843
+ rootClientId: rootClientId,
28844
+ blockElement: node
28845
+ }), showEmptyBlockSideInserter && (0,external_wp_element_namespaceObject.createElement)("div", {
28846
+ className: "block-editor-block-list__empty-block-inserter"
28847
+ }, (0,external_wp_element_namespaceObject.createElement)(inserter, {
28848
+ position: "bottom right",
28849
+ rootClientId: rootClientId,
28850
+ clientId: clientId,
28851
+ __experimentalIsQuick: true
28852
+ })));
28853
+ }
28854
+
28855
+ function wrapperSelector(select) {
28856
+ const {
28857
+ getSelectedBlockClientId,
28858
+ getFirstMultiSelectedBlockClientId,
28859
+ getBlockRootClientId,
28860
+ __unstableGetBlockWithoutInnerBlocks,
28861
+ getBlockParents,
28862
+ __experimentalGetBlockListSettingsForBlocks
28863
+ } = select(store);
28864
+ const clientId = getSelectedBlockClientId() || getFirstMultiSelectedBlockClientId();
28865
 
28866
+ if (!clientId) {
28867
  return;
28868
  }
28869
 
28870
+ const {
28871
+ name,
28872
+ attributes = {},
28873
+ isValid
28874
+ } = __unstableGetBlockWithoutInnerBlocks(clientId) || {};
28875
+ const blockParentsClientIds = getBlockParents(clientId); // Get Block List Settings for all ancestors of the current Block clientId
28876
+
28877
+ const parentBlockListSettings = __experimentalGetBlockListSettingsForBlocks(blockParentsClientIds); // Get the clientId of the topmost parent with the capture toolbars setting.
28878
+
28879
+
28880
+ const capturingClientId = (0,external_lodash_namespaceObject.find)(blockParentsClientIds, parentClientId => {
28881
+ var _parentBlockListSetti;
28882
+
28883
+ return (_parentBlockListSetti = parentBlockListSettings[parentClientId]) === null || _parentBlockListSetti === void 0 ? void 0 : _parentBlockListSetti.__experimentalCaptureToolbars;
28884
+ });
28885
  return {
28886
+ clientId,
28887
+ rootClientId: getBlockRootClientId(clientId),
28888
+ name,
28889
+ isValid,
28890
+ isEmptyDefaultBlock: name && (0,external_wp_blocks_namespaceObject.isUnmodifiedDefaultBlock)({
28891
+ name,
28892
+ attributes
28893
+ }),
28894
+ capturingClientId
28895
  };
28896
  }
28897
+
28898
+ function WrappedBlockPopover({
28899
+ __unstablePopoverSlot,
28900
+ __unstableContentRef
28901
+ }) {
28902
+ const selected = (0,external_wp_data_namespaceObject.useSelect)(wrapperSelector, []);
28903
+
28904
+ if (!selected) {
28905
+ return null;
28906
+ }
28907
+
28908
+ const {
28909
+ clientId,
28910
+ rootClientId,
28911
+ name,
28912
+ isValid,
28913
+ isEmptyDefaultBlock,
28914
+ capturingClientId
28915
+ } = selected;
28916
+
28917
+ if (!name) {
28918
+ return null;
28919
+ }
28920
+
28921
+ return (0,external_wp_element_namespaceObject.createElement)(BlockPopover, {
28922
+ clientId: clientId,
28923
+ rootClientId: rootClientId,
28924
+ isValid: isValid,
28925
+ isEmptyDefaultBlock: isEmptyDefaultBlock,
28926
+ capturingClientId: capturingClientId,
28927
+ __unstablePopoverSlot: __unstablePopoverSlot,
28928
+ __unstableContentRef: __unstableContentRef
28929
+ });
28930
+ }
28931
+ //# sourceMappingURL=block-popover.js.map
28932
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-tools/back-compat.js
28933
+
28934
+
28935
  /**
28936
+ * WordPress dependencies
 
 
28937
  */
28938
 
28939
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28940
 
28941
+ /**
28942
+ * Internal dependencies
28943
+ */
 
 
 
28944
 
 
 
 
 
 
 
28945
 
 
 
 
 
28946
 
28947
+ function BlockToolsBackCompat({
28948
+ children
28949
+ }) {
28950
+ const openRef = (0,external_wp_element_namespaceObject.useContext)(InsertionPointOpenRef);
28951
+ const isDisabled = (0,external_wp_element_namespaceObject.useContext)(external_wp_components_namespaceObject.Disabled.Context); // If context is set, `BlockTools` is a parent component.
28952
+
28953
+ if (openRef || isDisabled) {
28954
+ return children;
28955
+ }
28956
+
28957
+ external_wp_deprecated_default()('wp.components.Popover.Slot name="block-toolbar"', {
28958
+ alternative: 'wp.blockEditor.BlockTools'
28959
  });
28960
+ return (0,external_wp_element_namespaceObject.createElement)(InsertionPoint, {
28961
+ __unstablePopoverSlot: "block-toolbar"
28962
+ }, (0,external_wp_element_namespaceObject.createElement)(WrappedBlockPopover, {
28963
+ __unstablePopoverSlot: "block-toolbar"
28964
+ }), children);
28965
  }
28966
+ //# sourceMappingURL=back-compat.js.map
28967
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/inner-blocks/with-client-id.js
28968
 
28969
 
28970
 
28972
  * WordPress dependencies
28973
  */
28974
 
28975
+ /**
28976
+ * Internal dependencies
28977
+ */
28978
 
28979
 
28980
+ const withClientId = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(WrappedComponent => props => {
28981
+ const {
28982
+ clientId
28983
+ } = useBlockEditContext();
28984
+ return (0,external_wp_element_namespaceObject.createElement)(WrappedComponent, _extends({}, props, {
28985
+ clientId: clientId
28986
+ }));
28987
+ }, 'withClientId');
28988
+ /* harmony default export */ var with_client_id = (withClientId);
28989
+ //# sourceMappingURL=with-client-id.js.map
28990
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/inner-blocks/button-block-appender.js
28991
 
28992
 
28993
  /**
28995
  */
28996
 
28997
 
28998
+ const button_block_appender_ButtonBlockAppender = ({
28999
+ clientId,
29000
+ showSeparator,
29001
+ isFloating,
29002
+ onAddBlock
29003
+ }) => {
29004
+ return (0,external_wp_element_namespaceObject.createElement)(button_block_appender, {
29005
+ rootClientId: clientId,
29006
+ showSeparator: showSeparator,
29007
+ isFloating: isFloating,
29008
+ onAddBlock: onAddBlock
29009
+ });
29010
+ };
29011
+ /* harmony default export */ var inner_blocks_button_block_appender = (with_client_id(button_block_appender_ButtonBlockAppender));
29012
+ //# sourceMappingURL=button-block-appender.js.map
29013
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/inner-blocks/default-block-appender.js
29014
 
29015
 
29016
+ /**
29017
+ * External dependencies
29018
+ */
29019
 
29020
+ /**
29021
+ * WordPress dependencies
29022
+ */
29023
 
29024
 
29025
 
29026
+ /**
29027
+ * Internal dependencies
29028
+ */
29029
 
 
 
 
 
 
 
 
 
29030
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29031
 
29032
 
29033
+ const default_block_appender_DefaultBlockAppender = ({
29034
+ clientId,
29035
+ lastBlockClientId
29036
+ }) => {
29037
+ return (0,external_wp_element_namespaceObject.createElement)(default_block_appender, {
29038
+ rootClientId: clientId,
29039
+ lastBlockClientId: lastBlockClientId
29040
+ });
29041
+ };
29042
+ /* harmony default export */ var inner_blocks_default_block_appender = ((0,external_wp_compose_namespaceObject.compose)([with_client_id, (0,external_wp_data_namespaceObject.withSelect)((select, {
29043
+ clientId
29044
+ }) => {
 
 
 
 
 
 
 
 
29045
  const {
29046
+ getBlockOrder
29047
+ } = select(store);
29048
+ const blockClientIds = getBlockOrder(clientId);
29049
+ return {
29050
+ lastBlockClientId: (0,external_lodash_namespaceObject.last)(blockClientIds)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29051
  };
29052
+ })])(default_block_appender_DefaultBlockAppender));
29053
+ //# sourceMappingURL=default-block-appender.js.map
29054
+ ;// CONCATENATED MODULE: external ["wp","isShallowEqual"]
29055
+ var external_wp_isShallowEqual_namespaceObject = window["wp"]["isShallowEqual"];
29056
+ var external_wp_isShallowEqual_default = /*#__PURE__*/__webpack_require__.n(external_wp_isShallowEqual_namespaceObject);
29057
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/inner-blocks/use-nested-settings-update.js
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29058
  /**
29059
  * WordPress dependencies
29060
  */
29061
 
29062
 
29063
 
 
 
29064
  /**
29065
  * Internal dependencies
29066
  */
29067
 
29068
 
29069
 
29070
+ /**
29071
+ * This hook is a side effect which updates the block-editor store when changes
29072
+ * happen to inner block settings. The given props are transformed into a
29073
+ * settings object, and if that is different from the current settings object in
29074
+ * the block-editor store, then the store is updated with the new settings which
29075
+ * came from props.
29076
+ *
29077
+ * @param {string} clientId The client ID of the block to update.
29078
+ * @param {string[]} allowedBlocks An array of block names which are permitted
29079
+ * in inner blocks.
29080
+ * @param {string} [templateLock] The template lock specified for the inner
29081
+ * blocks component. (e.g. "all")
29082
+ * @param {boolean} captureToolbars Whether or children toolbars should be shown
29083
+ * in the inner blocks component rather than on
29084
+ * the child block.
29085
+ * @param {string} orientation The direction in which the block
29086
+ * should face.
29087
+ * @param {Object} layout The layout object for the block container.
29088
+ */
29089
 
29090
+ function useNestedSettingsUpdate(clientId, allowedBlocks, templateLock, captureToolbars, orientation, layout) {
29091
+ const {
29092
+ updateBlockListSettings
29093
+ } = (0,external_wp_data_namespaceObject.useDispatch)(store);
29094
+ const {
29095
+ blockListSettings,
29096
+ parentLock
29097
+ } = (0,external_wp_data_namespaceObject.useSelect)(select => {
29098
+ const rootClientId = select(store).getBlockRootClientId(clientId);
29099
+ return {
29100
+ blockListSettings: select(store).getBlockListSettings(clientId),
29101
+ parentLock: select(store).getTemplateLock(rootClientId)
29102
+ };
29103
+ }, [clientId]); // Memoize as inner blocks implementors often pass a new array on every
29104
+ // render.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29105
 
29106
+ const _allowedBlocks = (0,external_wp_element_namespaceObject.useMemo)(() => allowedBlocks, allowedBlocks);
 
 
29107
 
29108
+ (0,external_wp_element_namespaceObject.useLayoutEffect)(() => {
29109
+ const newSettings = {
29110
+ allowedBlocks: _allowedBlocks,
29111
+ templateLock: templateLock === undefined ? parentLock : templateLock
29112
+ }; // These values are not defined for RN, so only include them if they
29113
+ // are defined.
29114
 
29115
+ if (captureToolbars !== undefined) {
29116
+ newSettings.__experimentalCaptureToolbars = captureToolbars;
29117
+ } // Orientation depends on layout,
29118
+ // ideally the separate orientation prop should be deprecated.
29119
 
 
 
 
 
 
 
 
 
 
29120
 
29121
+ if (orientation !== undefined) {
29122
+ newSettings.orientation = orientation;
29123
+ } else {
29124
+ const layoutType = getLayoutType(layout === null || layout === void 0 ? void 0 : layout.type);
29125
+ newSettings.orientation = layoutType.getOrientation(layout);
29126
+ }
29127
 
29128
+ if (!external_wp_isShallowEqual_default()(blockListSettings, newSettings)) {
29129
+ updateBlockListSettings(clientId, newSettings);
29130
+ }
29131
+ }, [clientId, blockListSettings, _allowedBlocks, templateLock, parentLock, captureToolbars, orientation, updateBlockListSettings, layout]);
29132
+ }
29133
+ //# sourceMappingURL=use-nested-settings-update.js.map
29134
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/inner-blocks/use-inner-block-template-sync.js
29135
  /**
29136
  * External dependencies
29137
  */
29143
 
29144
 
29145
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29146
  /**
29147
+ * Internal dependencies
29148
  */
29149
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29150
 
29151
  /**
29152
+ * This hook makes sure that a block's inner blocks stay in sync with the given
29153
+ * block "template". The template is a block hierarchy to which inner blocks must
29154
+ * conform. If the blocks get "out of sync" with the template and the template
29155
+ * is meant to be locked (e.g. templateLock = "all"), then we replace the inner
29156
+ * blocks with the correct value after synchronizing it with the template.
29157
+ *
29158
+ * @param {string} clientId The block client ID.
29159
+ * @param {Object} template The template to match.
29160
+ * @param {string} templateLock The template lock state for the inner blocks. For
29161
+ * example, if the template lock is set to "all",
29162
+ * then the inner blocks will stay in sync with the
29163
+ * template. If not defined or set to false, then
29164
+ * the inner blocks will not be synchronized with
29165
+ * the given template.
29166
+ * @param {boolean} templateInsertUpdatesSelection Whether or not to update the
29167
+ * block-editor selection state when inner blocks
29168
+ * are replaced after template synchronization.
29169
  */
29170
 
29171
+ function useInnerBlockTemplateSync(clientId, template, templateLock, templateInsertUpdatesSelection) {
29172
+ const {
29173
+ getSelectedBlocksInitialCaretPosition
29174
+ } = (0,external_wp_data_namespaceObject.useSelect)(store);
29175
+ const {
29176
+ replaceInnerBlocks
29177
+ } = (0,external_wp_data_namespaceObject.useDispatch)(store);
29178
+ const innerBlocks = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).getBlocks(clientId), [clientId]); // Maintain a reference to the previous value so we can do a deep equality check.
29179
+
29180
+ const existingTemplate = (0,external_wp_element_namespaceObject.useRef)(null);
29181
+ (0,external_wp_element_namespaceObject.useLayoutEffect)(() => {
29182
+ // Only synchronize innerBlocks with template if innerBlocks are empty or
29183
+ // a locking all exists directly on the block.
29184
+ if (innerBlocks.length === 0 || templateLock === 'all') {
29185
+ const hasTemplateChanged = !(0,external_lodash_namespaceObject.isEqual)(template, existingTemplate.current);
29186
 
29187
+ if (hasTemplateChanged) {
29188
+ existingTemplate.current = template;
29189
+ const nextBlocks = (0,external_wp_blocks_namespaceObject.synchronizeBlocksWithTemplate)(innerBlocks, template);
29190
 
29191
+ if (!(0,external_lodash_namespaceObject.isEqual)(nextBlocks, innerBlocks)) {
29192
+ replaceInnerBlocks(clientId, nextBlocks, innerBlocks.length === 0 && templateInsertUpdatesSelection && nextBlocks.length !== 0, // This ensures the "initialPosition" doesn't change when applying the template
29193
+ // If we're supposed to focus the block, we'll focus the first inner block
29194
+ // otherwise, we won't apply any auto-focus.
29195
+ // This ensures for instance that the focus stays in the inserter when inserting the "buttons" block.
29196
+ getSelectedBlocksInitialCaretPosition());
29197
+ }
29198
+ }
29199
+ }
29200
+ }, [innerBlocks, template, templateLock, clientId]);
29201
+ }
29202
+ //# sourceMappingURL=use-inner-block-template-sync.js.map
29203
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/inner-blocks/get-block-context.js
29204
  /**
29205
+ * External dependencies
29206
  */
29207
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29208
  /**
29209
+ * Block context cache, implemented as a WeakMap mapping block types to a
29210
+ * WeakMap mapping attributes object to context value.
29211
+ *
29212
+ * @type {WeakMap<string,WeakMap<string,*>>}
29213
  */
29214
 
29215
+ const BLOCK_CONTEXT_CACHE = new WeakMap();
29216
  /**
29217
+ * Returns a cached context object value for a given set of attributes for the
29218
+ * block type.
29219
+ *
29220
+ * @param {Record<string,*>} attributes Block attributes object.
29221
+ * @param {WPBlockType} blockType Block type settings.
29222
+ *
29223
+ * @return {Record<string,*>} Context value.
29224
  */
29225
 
29226
+ function getBlockContext(attributes, blockType) {
29227
+ if (!BLOCK_CONTEXT_CACHE.has(blockType)) {
29228
+ BLOCK_CONTEXT_CACHE.set(blockType, new WeakMap());
29229
+ }
29230
 
29231
+ const blockTypeCache = BLOCK_CONTEXT_CACHE.get(blockType);
29232
 
29233
+ if (!blockTypeCache.has(attributes)) {
29234
+ const context = (0,external_lodash_namespaceObject.mapValues)(blockType.providesContext, attributeName => attributes[attributeName]);
29235
+ blockTypeCache.set(attributes, context);
29236
+ }
 
 
 
 
 
 
 
 
29237
 
29238
+ return blockTypeCache.get(attributes);
 
29239
  }
29240
+ //# sourceMappingURL=get-block-context.js.map
29241
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/use-on-block-drop/index.js
 
 
 
 
 
29242
  /**
29243
  * WordPress dependencies
29244
  */
29245
 
29246
 
29247
 
 
 
 
29248
  /**
29249
  * Internal dependencies
29250
  */
29251
 
29252
 
29253
+ /** @typedef {import('@wordpress/element').WPSyntheticEvent} WPSyntheticEvent */
29254
 
29255
+ /**
29256
+ * Retrieve the data for a block drop event.
29257
+ *
29258
+ * @param {WPSyntheticEvent} event The drop event.
29259
+ *
29260
+ * @return {Object} An object with block drag and drop data.
29261
+ */
29262
 
29263
+ function parseDropEvent(event) {
29264
+ let result = {
29265
+ srcRootClientId: null,
29266
+ srcClientIds: null,
29267
+ srcIndex: null,
29268
+ type: null,
29269
+ blocks: null
29270
+ };
29271
 
29272
+ if (!event.dataTransfer) {
29273
+ return result;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29274
  }
29275
 
29276
+ try {
29277
+ result = Object.assign(result, JSON.parse(event.dataTransfer.getData('wp-blocks')));
29278
+ } catch (err) {
29279
+ return result;
29280
+ }
 
 
 
 
 
 
29281
 
29282
+ return result;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29283
  }
29284
+ /**
29285
+ * A function that returns an event handler function for block drop events.
29286
+ *
29287
+ * @param {string} targetRootClientId The root client id where the block(s) will be inserted.
29288
+ * @param {number} targetBlockIndex The index where the block(s) will be inserted.
29289
+ * @param {Function} getBlockIndex A function that gets the index of a block.
29290
+ * @param {Function} getClientIdsOfDescendants A function that gets the client ids of descendant blocks.
29291
+ * @param {Function} moveBlocksToPosition A function that moves blocks.
29292
+ * @param {Function} insertBlocks A function that inserts blocks.
29293
+ * @param {Function} clearSelectedBlock A function that clears block selection.
29294
+ * @return {Function} The event handler for a block drop event.
29295
+ */
29296
 
29297
+ function onBlockDrop(targetRootClientId, targetBlockIndex, getBlockIndex, getClientIdsOfDescendants, moveBlocksToPosition, insertBlocks, clearSelectedBlock) {
29298
+ return event => {
29299
+ const {
29300
+ srcRootClientId: sourceRootClientId,
29301
+ srcClientIds: sourceClientIds,
29302
+ type: dropType,
29303
+ blocks
29304
+ } = parseDropEvent(event); // If the user is inserting a block
 
 
 
 
 
 
 
 
 
 
 
 
 
29305
 
29306
+ if (dropType === 'inserter') {
29307
+ clearSelectedBlock();
29308
+ insertBlocks(blocks, targetBlockIndex, targetRootClientId, true, null);
29309
+ } // If the user is moving a block
 
 
 
 
 
 
 
 
 
 
29310
 
 
 
 
29311
 
29312
+ if (dropType === 'block') {
29313
+ const sourceBlockIndex = getBlockIndex(sourceClientIds[0], sourceRootClientId); // If the user is dropping to the same position, return early.
 
 
29314
 
29315
+ if (sourceRootClientId === targetRootClientId && sourceBlockIndex === targetBlockIndex) {
29316
+ return;
29317
+ } // If the user is attempting to drop a block within its own
29318
+ // nested blocks, return early as this would create infinite
29319
+ // recursion.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29320
 
 
 
 
 
 
 
29321
 
29322
+ if (sourceClientIds.includes(targetRootClientId) || getClientIdsOfDescendants(sourceClientIds).some(id => id === targetRootClientId)) {
29323
+ return;
29324
+ }
29325
+
29326
+ const isAtSameLevel = sourceRootClientId === targetRootClientId;
29327
+ const draggedBlockCount = sourceClientIds.length; // If the block is kept at the same level and moved downwards,
29328
+ // subtract to take into account that the blocks being dragged
29329
+ // were removed from the block list above the insertion point.
29330
 
29331
+ const insertIndex = isAtSameLevel && sourceBlockIndex < targetBlockIndex ? targetBlockIndex - draggedBlockCount : targetBlockIndex;
29332
+ moveBlocksToPosition(sourceClientIds, sourceRootClientId, targetRootClientId, insertIndex);
29333
+ }
29334
+ };
29335
+ }
29336
  /**
29337
+ * A function that returns an event handler function for block-related file drop events.
 
 
29338
  *
29339
+ * @param {string} targetRootClientId The root client id where the block(s) will be inserted.
29340
+ * @param {number} targetBlockIndex The index where the block(s) will be inserted.
29341
+ * @param {boolean} hasUploadPermissions Whether the user has upload permissions.
29342
+ * @param {Function} updateBlockAttributes A function that updates a block's attributes.
29343
+ * @param {Function} canInsertBlockType A function that returns checks whether a block type can be inserted.
29344
+ * @param {Function} insertBlocks A function that inserts blocks.
29345
  *
29346
+ * @return {Function} The event handler for a block-related file drop event.
 
 
29347
  */
29348
 
29349
+ function onFilesDrop(targetRootClientId, targetBlockIndex, hasUploadPermissions, updateBlockAttributes, canInsertBlockType, insertBlocks) {
29350
+ return files => {
29351
+ if (!hasUploadPermissions) {
29352
+ return;
29353
+ }
 
 
 
 
 
 
 
 
29354
 
29355
+ const transformation = (0,external_wp_blocks_namespaceObject.findTransform)((0,external_wp_blocks_namespaceObject.getBlockTransforms)('from'), transform => transform.type === 'files' && canInsertBlockType(transform.blockName, targetRootClientId) && transform.isMatch(files));
29356
 
29357
+ if (transformation) {
29358
+ const blocks = transformation.transform(files, updateBlockAttributes);
29359
+ insertBlocks(blocks, targetBlockIndex, targetRootClientId);
29360
+ }
29361
+ };
29362
+ }
29363
  /**
29364
+ * A function that returns an event handler function for block-related HTML drop events.
29365
+ *
29366
+ * @param {string} targetRootClientId The root client id where the block(s) will be inserted.
29367
+ * @param {number} targetBlockIndex The index where the block(s) will be inserted.
29368
+ * @param {Function} insertBlocks A function that inserts blocks.
29369
+ *
29370
+ * @return {Function} The event handler for a block-related HTML drop event.
29371
  */
29372
 
29373
+ function onHTMLDrop(targetRootClientId, targetBlockIndex, insertBlocks) {
29374
+ return HTML => {
29375
+ const blocks = (0,external_wp_blocks_namespaceObject.pasteHandler)({
29376
+ HTML,
29377
+ mode: 'BLOCKS'
29378
+ });
29379
 
29380
+ if (blocks.length) {
29381
+ insertBlocks(blocks, targetBlockIndex, targetRootClientId);
29382
+ }
29383
+ };
29384
+ }
29385
  /**
29386
+ * A React hook for handling block drop events.
29387
+ *
29388
+ * @param {string} targetRootClientId The root client id where the block(s) will be inserted.
29389
+ * @param {number} targetBlockIndex The index where the block(s) will be inserted.
29390
+ *
29391
+ * @return {Object} An object that contains the event handlers `onDrop`, `onFilesDrop` and `onHTMLDrop`.
29392
  */
29393
 
29394
+ function useOnBlockDrop(targetRootClientId, targetBlockIndex) {
29395
+ const hasUploadPermissions = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).getSettings().mediaUpload, []);
 
 
 
 
 
29396
  const {
29397
+ canInsertBlockType,
29398
+ getBlockIndex,
29399
+ getClientIdsOfDescendants
29400
+ } = (0,external_wp_data_namespaceObject.useSelect)(store);
29401
  const {
29402
+ insertBlocks,
29403
+ moveBlocksToPosition,
29404
+ updateBlockAttributes,
29405
+ clearSelectedBlock
29406
+ } = (0,external_wp_data_namespaceObject.useDispatch)(store);
 
 
 
 
 
 
 
 
 
 
 
 
 
29407
 
29408
+ const _onDrop = onBlockDrop(targetRootClientId, targetBlockIndex, getBlockIndex, getClientIdsOfDescendants, moveBlocksToPosition, insertBlocks, clearSelectedBlock);
 
 
 
 
 
 
 
 
 
 
 
29409
 
29410
+ const _onFilesDrop = onFilesDrop(targetRootClientId, targetBlockIndex, hasUploadPermissions, updateBlockAttributes, canInsertBlockType, insertBlocks);
 
 
 
 
 
29411
 
29412
+ const _onHTMLDrop = onHTMLDrop(targetRootClientId, targetBlockIndex, insertBlocks);
29413
+
29414
+ return event => {
29415
+ const files = (0,external_wp_dom_namespaceObject.getFilesFromDataTransfer)(event.dataTransfer);
29416
+ const html = event.dataTransfer.getData('text/html');
29417
+
29418
+ if (files.length) {
29419
+ _onFilesDrop(files);
29420
+ } else if (html) {
29421
+ _onHTMLDrop(html);
29422
+ } else {
29423
+ _onDrop(event);
29424
  }
29425
+ };
 
 
 
 
 
 
29426
  }
 
 
29427
  //# sourceMappingURL=index.js.map
29428
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/utils/math.js
29429
+ /**
29430
+ * A string representing the name of an edge.
29431
+ *
29432
+ * @typedef {'top'|'right'|'bottom'|'left'} WPEdgeName
29433
+ */
29434
 
29435
  /**
29436
+ * @typedef {Object} WPPoint
29437
+ * @property {number} x The horizontal position.
29438
+ * @property {number} y The vertical position.
29439
  */
29440
 
29441
+ /**
29442
+ * Given a point, a DOMRect and the name of an edge, returns the distance to
29443
+ * that edge of the rect.
29444
+ *
29445
+ * This function works for edges that are horizontal or vertical (e.g. not
29446
+ * rotated), the following terms are used so that the function works in both
29447
+ * orientations:
29448
+ *
29449
+ * - Forward, meaning the axis running horizontally when an edge is vertical
29450
+ * and vertically when an edge is horizontal.
29451
+ * - Lateral, meaning the axis running vertically when an edge is vertical
29452
+ * and horizontally when an edge is horizontal.
29453
+ *
29454
+ * @param {WPPoint} point The point to measure distance from.
29455
+ * @param {DOMRect} rect A DOM Rect containing edge positions.
29456
+ * @param {WPEdgeName} edge The edge to measure to.
29457
+ */
29458
+ function getDistanceFromPointToEdge(point, rect, edge) {
29459
+ const isHorizontal = edge === 'top' || edge === 'bottom';
29460
+ const {
29461
+ x,
29462
+ y
29463
+ } = point;
29464
+ const pointLateralPosition = isHorizontal ? x : y;
29465
+ const pointForwardPosition = isHorizontal ? y : x;
29466
+ const edgeStart = isHorizontal ? rect.left : rect.top;
29467
+ const edgeEnd = isHorizontal ? rect.right : rect.bottom;
29468
+ const edgeForwardPosition = rect[edge]; // Measure the straight line distance to the edge of the rect, when the
29469
+ // point is adjacent to the edge.
29470
+ // Else, if the point is positioned diagonally to the edge of the rect,
29471
+ // measure diagonally to the nearest corner that the edge meets.
29472
 
29473
+ let edgeLateralPosition;
29474
 
29475
+ if (pointLateralPosition >= edgeStart && pointLateralPosition <= edgeEnd) {
29476
+ edgeLateralPosition = pointLateralPosition;
29477
+ } else if (pointLateralPosition < edgeEnd) {
29478
+ edgeLateralPosition = edgeStart;
29479
+ } else {
29480
+ edgeLateralPosition = edgeEnd;
29481
+ }
29482
 
29483
+ return Math.sqrt((pointLateralPosition - edgeLateralPosition) ** 2 + (pointForwardPosition - edgeForwardPosition) ** 2);
29484
+ }
29485
  /**
29486
+ * Given a point, a DOMRect and a list of allowed edges returns the name of and
29487
+ * distance to the nearest edge.
29488
+ *
29489
+ * @param {WPPoint} point The point to measure distance from.
29490
+ * @param {DOMRect} rect A DOM Rect containing edge positions.
29491
+ * @param {WPEdgeName[]} allowedEdges A list of the edges included in the
29492
+ * calculation. Defaults to all edges.
29493
+ *
29494
+ * @return {[number, string]} An array where the first value is the distance
29495
+ * and a second is the edge name.
29496
  */
29497
 
29498
+ function getDistanceToNearestEdge(point, rect, allowedEdges = ['top', 'bottom', 'left', 'right']) {
29499
+ let candidateDistance;
29500
+ let candidateEdge;
29501
+ allowedEdges.forEach(edge => {
29502
+ const distance = getDistanceFromPointToEdge(point, rect, edge);
29503
 
29504
+ if (candidateDistance === undefined || distance < candidateDistance) {
29505
+ candidateDistance = distance;
29506
+ candidateEdge = edge;
29507
+ }
29508
+ });
29509
+ return [candidateDistance, candidateEdge];
29510
+ }
29511
+ //# sourceMappingURL=math.js.map
29512
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/use-block-drop-zone/index.js
29513
  /**
29514
+ * WordPress dependencies
29515
  */
29516
 
29517
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29518
 
 
 
 
 
 
 
 
 
 
 
29519
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29520
  /**
29521
+ * Internal dependencies
29522
  */
29523
 
29524
 
 
 
 
29525
 
29526
 
29527
+ /** @typedef {import('../../utils/math').WPPoint} WPPoint */
29528
 
29529
  /**
29530
+ * The orientation of a block list.
29531
+ *
29532
+ * @typedef {'horizontal'|'vertical'|undefined} WPBlockListOrientation
29533
  */
29534
 
29535
+ /**
29536
+ * Given a list of block DOM elements finds the index that a block should be dropped
29537
+ * at.
29538
+ *
29539
+ * @param {Element[]} elements Array of DOM elements that represent each block in a block list.
29540
+ * @param {WPPoint} position The position of the item being dragged.
29541
+ * @param {WPBlockListOrientation} orientation The orientation of a block list.
29542
+ *
29543
+ * @return {number|undefined} The block index that's closest to the drag position.
29544
+ */
 
 
29545
 
29546
+ function getNearestBlockIndex(elements, position, orientation) {
29547
+ const allowedEdges = orientation === 'horizontal' ? ['left', 'right'] : ['top', 'bottom'];
29548
+ const isRightToLeft = (0,external_wp_i18n_namespaceObject.isRTL)();
29549
+ let candidateIndex;
29550
+ let candidateDistance;
29551
+ elements.forEach((element, index) => {
29552
+ const rect = element.getBoundingClientRect();
29553
+ const [distance, edge] = getDistanceToNearestEdge(position, rect, allowedEdges);
29554
 
29555
+ if (candidateDistance === undefined || distance < candidateDistance) {
29556
+ // If the user is dropping to the trailing edge of the block
29557
+ // add 1 to the index to represent dragging after.
29558
+ // Take RTL languages into account where the left edge is
29559
+ // the trailing edge.
29560
+ const isTrailingEdge = edge === 'bottom' || !isRightToLeft && edge === 'right' || isRightToLeft && edge === 'left';
29561
+ const offset = isTrailingEdge ? 1 : 0; // Update the currently known best candidate.
29562
 
29563
+ candidateDistance = distance;
29564
+ candidateIndex = index + offset;
29565
+ }
29566
+ });
29567
+ return candidateIndex;
29568
+ }
29569
  /**
29570
+ * @typedef {Object} WPBlockDropZoneConfig
29571
+ * @property {string} rootClientId The root client id for the block list.
29572
  */
29573
 
29574
  /**
29575
+ * A React hook that can be used to make a block list handle drag and drop.
29576
+ *
29577
+ * @param {WPBlockDropZoneConfig} dropZoneConfig configuration data for the drop zone.
29578
  */
29579
 
29580
+ function useBlockDropZone({
29581
+ // An undefined value represents a top-level block. Default to an empty
29582
+ // string for this so that `targetRootClientId` can be easily compared to
29583
+ // values returned by the `getRootBlockClientId` selector, which also uses
29584
+ // an empty string to represent top-level blocks.
29585
+ rootClientId: targetRootClientId = ''
29586
+ } = {}) {
29587
+ const [targetBlockIndex, setTargetBlockIndex] = (0,external_wp_element_namespaceObject.useState)(null);
29588
+ const isLockedAll = (0,external_wp_data_namespaceObject.useSelect)(select => {
29589
+ const {
29590
+ getTemplateLock
29591
+ } = select(store);
29592
+ return getTemplateLock(targetRootClientId) === 'all';
29593
+ }, [targetRootClientId]);
29594
+ const {
29595
+ getBlockListSettings
29596
+ } = (0,external_wp_data_namespaceObject.useSelect)(store);
29597
+ const {
29598
+ showInsertionPoint,
29599
+ hideInsertionPoint
29600
+ } = (0,external_wp_data_namespaceObject.useDispatch)(store);
29601
+ const onBlockDrop = useOnBlockDrop(targetRootClientId, targetBlockIndex);
29602
+ const throttled = (0,external_wp_compose_namespaceObject.useThrottle)((0,external_wp_element_namespaceObject.useCallback)((event, currentTarget) => {
29603
+ var _getBlockListSettings;
29604
 
29605
+ const blockElements = Array.from(currentTarget.children).filter( // Ensure the element is a block. It should have the `wp-block` class.
29606
+ element => element.classList.contains('wp-block'));
29607
+ const targetIndex = getNearestBlockIndex(blockElements, {
29608
+ x: event.clientX,
29609
+ y: event.clientY
29610
+ }, (_getBlockListSettings = getBlockListSettings(targetRootClientId)) === null || _getBlockListSettings === void 0 ? void 0 : _getBlockListSettings.orientation);
29611
+ setTargetBlockIndex(targetIndex === undefined ? 0 : targetIndex);
29612
 
29613
+ if (targetIndex !== null) {
29614
+ showInsertionPoint(targetRootClientId, targetIndex);
29615
+ }
29616
+ }, []), 200);
29617
+ return (0,external_wp_compose_namespaceObject.__experimentalUseDropZone)({
29618
+ isDisabled: isLockedAll,
29619
+ onDrop: onBlockDrop,
29620
 
29621
+ onDragOver(event) {
29622
+ // `currentTarget` is only available while the event is being
29623
+ // handled, so get it now and pass it to the thottled function.
29624
+ // https://developer.mozilla.org/en-US/docs/Web/API/Event/currentTarget
29625
+ throttled(event, event.currentTarget);
29626
+ },
 
 
 
 
 
 
 
 
 
 
 
 
 
29627
 
29628
+ onDragLeave() {
29629
+ throttled.cancel();
29630
+ hideInsertionPoint();
29631
+ setTargetBlockIndex(null);
29632
+ },
29633
 
29634
+ onDragEnd() {
29635
+ throttled.cancel();
29636
+ hideInsertionPoint();
29637
+ setTargetBlockIndex(null);
29638
+ }
29639
 
29640
+ });
29641
+ }
29642
  //# sourceMappingURL=index.js.map
29643
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/inner-blocks/index.js
29644
 
29645
 
29646
 
29647
  /**
29648
+ * External dependencies
29649
  */
29650
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29651
  /**
29652
  * WordPress dependencies
29653
  */
29654
 
 
 
29655
 
 
 
 
 
29656
 
 
 
 
 
29657
 
 
 
 
 
29658
 
29659
+ /**
29660
+ * Internal dependencies
29661
+ */
29662
+
29663
+
29664
+
29665
 
 
 
 
 
29666
 
 
 
 
 
 
 
 
 
29667
 
 
 
 
 
 
 
 
 
 
29668
 
29669
 
 
 
 
29670
 
 
 
 
29671
 
29672
 
29673
 
29674
  /**
29675
+ * InnerBlocks is a component which allows a single block to have multiple blocks
29676
+ * as children. The UncontrolledInnerBlocks component is used whenever the inner
29677
+ * blocks are not controlled by another entity. In other words, it is normally
29678
+ * used for inner blocks in the post editor
29679
+ *
29680
+ * @param {Object} props The component props.
29681
  */
29682
 
29683
+ function UncontrolledInnerBlocks(props) {
 
 
 
 
 
 
 
 
 
 
 
 
29684
  const {
29685
+ clientId,
29686
+ allowedBlocks,
29687
+ template,
29688
+ templateLock,
29689
+ wrapperRef,
29690
+ templateInsertUpdatesSelection,
29691
+ __experimentalCaptureToolbars: captureToolbars,
29692
+ __experimentalAppenderTagName,
29693
+ renderAppender,
29694
+ orientation,
29695
+ placeholder,
29696
+ __experimentalLayout
29697
+ } = props;
29698
+ useNestedSettingsUpdate(clientId, allowedBlocks, templateLock, captureToolbars, orientation, __experimentalLayout);
29699
+ useInnerBlockTemplateSync(clientId, template, templateLock, templateInsertUpdatesSelection);
29700
+ const context = (0,external_wp_data_namespaceObject.useSelect)(select => {
29701
+ const block = select(store).getBlock(clientId);
29702
+ const blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(block.name);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29703
 
29704
+ if (!blockType || !blockType.providesContext) {
29705
+ return;
29706
+ }
29707
 
29708
+ return getBlockContext(block.attributes, blockType);
29709
+ }, [clientId]); // This component needs to always be synchronous as it's the one changing
29710
+ // the async mode depending on the block selection.
29711
 
29712
+ return (0,external_wp_element_namespaceObject.createElement)(BlockContextProvider, {
29713
+ value: context
29714
+ }, (0,external_wp_element_namespaceObject.createElement)(BlockListItems, {
29715
+ rootClientId: clientId,
29716
+ renderAppender: renderAppender,
29717
+ __experimentalAppenderTagName: __experimentalAppenderTagName,
29718
+ __experimentalLayout: __experimentalLayout,
29719
+ wrapperRef: wrapperRef,
29720
+ placeholder: placeholder
29721
+ }));
29722
+ }
29723
  /**
29724
+ * The controlled inner blocks component wraps the uncontrolled inner blocks
29725
+ * component with the blockSync hook. This keeps the innerBlocks of the block in
29726
+ * the block-editor store in sync with the blocks of the controlling entity. An
29727
+ * example of an inner block controller is a template part block, which provides
29728
+ * its own blocks from the template part entity data source.
29729
+ *
29730
+ * @param {Object} props The component props.
29731
  */
29732
 
29733
+
29734
+ function ControlledInnerBlocks(props) {
29735
+ useBlockSync(props);
29736
+ return (0,external_wp_element_namespaceObject.createElement)(UncontrolledInnerBlocks, props);
29737
+ }
29738
+
29739
+ const ForwardedInnerBlocks = (0,external_wp_element_namespaceObject.forwardRef)((props, ref) => {
29740
+ const innerBlocksProps = useInnerBlocksProps({
29741
+ ref
29742
+ }, props);
29743
+ return (0,external_wp_element_namespaceObject.createElement)("div", {
29744
+ className: "block-editor-inner-blocks"
29745
+ }, (0,external_wp_element_namespaceObject.createElement)("div", innerBlocksProps));
29746
+ });
29747
  /**
29748
+ * This hook is used to lightly mark an element as an inner blocks wrapper
29749
+ * element. Call this hook and pass the returned props to the element to mark as
29750
+ * an inner blocks wrapper, automatically rendering inner blocks as children. If
29751
+ * you define a ref for the element, it is important to pass the ref to this
29752
+ * hook, which the hook in turn will pass to the component through the props it
29753
+ * returns. Optionally, you can also pass any other props through this hook, and
29754
+ * they will be merged and returned.
29755
+ *
29756
+ * @param {Object} props Optional. Props to pass to the element. Must contain
29757
+ * the ref if one is defined.
29758
+ * @param {Object} options Optional. Inner blocks options.
29759
+ *
29760
+ * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/inner-blocks/README.md
29761
  */
29762
 
29763
+ function useInnerBlocksProps(props = {}, options = {}) {
 
29764
  const {
29765
  clientId
29766
  } = useBlockEditContext();
29767
+ const isSmallScreen = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<');
29768
+ const {
29769
+ __experimentalCaptureToolbars,
29770
+ hasOverlay
29771
+ } = (0,external_wp_data_namespaceObject.useSelect)(select => {
29772
+ if (!clientId) {
29773
+ return {};
29774
+ }
29775
 
29776
+ const {
29777
+ getBlockName,
29778
+ isBlockSelected,
29779
+ hasSelectedInnerBlock,
29780
+ isNavigationMode
29781
+ } = select(store);
29782
+ const blockName = getBlockName(clientId);
29783
+ const enableClickThrough = isNavigationMode() || isSmallScreen;
29784
+ return {
29785
+ __experimentalCaptureToolbars: select(external_wp_blocks_namespaceObject.store).hasBlockSupport(blockName, '__experimentalExposeControlsToChildren', false),
29786
+ hasOverlay: blockName !== 'core/template' && !isBlockSelected(clientId) && !hasSelectedInnerBlock(clientId, true) && enableClickThrough
29787
+ };
29788
+ }, [clientId, isSmallScreen]);
29789
+ const ref = (0,external_wp_compose_namespaceObject.useMergeRefs)([props.ref, useBlockDropZone({
29790
+ rootClientId: clientId
29791
+ })]);
29792
+ const innerBlocksProps = {
29793
+ __experimentalCaptureToolbars,
29794
+ ...options
29795
+ };
29796
+ const InnerBlocks = innerBlocksProps.value && innerBlocksProps.onChange ? ControlledInnerBlocks : UncontrolledInnerBlocks;
29797
+ return { ...props,
29798
+ ref,
29799
+ className: classnames_default()(props.className, 'block-editor-block-list__layout', {
29800
+ 'has-overlay': hasOverlay
29801
+ }),
29802
+ children: clientId ? (0,external_wp_element_namespaceObject.createElement)(InnerBlocks, _extends({}, innerBlocksProps, {
29803
+ clientId: clientId
29804
+ })) : (0,external_wp_element_namespaceObject.createElement)(BlockListItems, options)
29805
+ };
29806
+ } // Expose default appender placeholders as components.
29807
 
29808
+ ForwardedInnerBlocks.DefaultBlockAppender = inner_blocks_default_block_appender;
29809
+ ForwardedInnerBlocks.ButtonBlockAppender = inner_blocks_button_block_appender;
29810
+ ForwardedInnerBlocks.Content = (0,external_wp_blocks_namespaceObject.withBlockContentContext)(({
29811
+ BlockContent
29812
+ }) => (0,external_wp_element_namespaceObject.createElement)(BlockContent, null));
29813
  /**
29814
+ * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/inner-blocks/README.md
29815
  */
29816
 
29817
+ /* harmony default export */ var inner_blocks = (ForwardedInnerBlocks);
29818
+ //# sourceMappingURL=index.js.map
29819
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-list/index.js
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29820
 
29821
 
29822
  /**
29829
 
29830
 
29831
 
29832
+
29833
  /**
29834
  * Internal dependencies
29835
  */
29837
 
29838
 
29839
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29840
 
29841
 
29842
 
 
 
 
29843
 
29844
 
29845
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29846
 
29847
+ const elementContext = (0,external_wp_element_namespaceObject.createContext)();
29848
+ const IntersectionObserver = (0,external_wp_element_namespaceObject.createContext)();
29849
+
29850
+ function Root({
29851
+ className,
29852
+ ...settings
29853
+ }) {
29854
+ const [element, setElement] = (0,external_wp_element_namespaceObject.useState)();
29855
+ const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium');
29856
  const {
29857
+ isOutlineMode,
29858
+ isFocusMode,
29859
+ isNavigationMode
29860
  } = (0,external_wp_data_namespaceObject.useSelect)(select => {
29861
+ const {
29862
+ getSettings,
29863
+ isNavigationMode: _isNavigationMode
29864
+ } = select(store);
29865
+ const {
29866
+ outlineMode,
29867
+ focusMode
29868
+ } = getSettings();
29869
  return {
29870
+ isOutlineMode: outlineMode,
29871
+ isFocusMode: focusMode,
29872
+ isNavigationMode: _isNavigationMode()
29873
  };
29874
+ }, []);
29875
+ const innerBlocksProps = useInnerBlocksProps({
29876
+ ref: (0,external_wp_compose_namespaceObject.useMergeRefs)([useBlockSelectionClearer(), useInBetweenInserter(), setElement]),
29877
+ className: classnames_default()('is-root-container', className, {
29878
+ 'is-outline-mode': isOutlineMode,
29879
+ 'is-focus-mode': isFocusMode && isLargeViewport,
29880
+ 'is-navigate-mode': isNavigationMode
29881
+ })
29882
+ }, settings);
29883
+ return (0,external_wp_element_namespaceObject.createElement)(elementContext.Provider, {
29884
+ value: element
29885
+ }, (0,external_wp_element_namespaceObject.createElement)("div", innerBlocksProps));
29886
+ }
29887
 
29888
+ function BlockList(settings) {
29889
+ usePreParsePatterns();
29890
+ return (0,external_wp_element_namespaceObject.createElement)(BlockToolsBackCompat, null, (0,external_wp_element_namespaceObject.createElement)(Provider, {
29891
+ value: DEFAULT_BLOCK_EDIT_CONTEXT
29892
+ }, (0,external_wp_element_namespaceObject.createElement)(Root, settings)));
29893
+ }
29894
+ BlockList.__unstableElementContext = elementContext;
29895
 
29896
+ function Items({
29897
+ placeholder,
29898
+ rootClientId,
29899
+ renderAppender,
29900
+ __experimentalAppenderTagName,
29901
+ __experimentalLayout: layout = defaultLayout
29902
+ }) {
29903
+ const [intersectingBlocks, setIntersectingBlocks] = (0,external_wp_element_namespaceObject.useState)(new Set());
29904
+ const intersectionObserver = (0,external_wp_element_namespaceObject.useMemo)(() => {
29905
+ const {
29906
+ IntersectionObserver: Observer
29907
+ } = window;
29908
 
29909
+ if (!Observer) {
29910
+ return;
29911
+ }
 
29912
 
29913
+ return new Observer(entries => {
29914
+ setIntersectingBlocks(oldIntersectingBlocks => {
29915
+ const newIntersectingBlocks = new Set(oldIntersectingBlocks);
29916
 
29917
+ for (const entry of entries) {
29918
+ const clientId = entry.target.getAttribute('data-block');
29919
+ const action = entry.isIntersecting ? 'add' : 'delete';
29920
+ newIntersectingBlocks[action](clientId);
29921
+ }
 
29922
 
29923
+ return newIntersectingBlocks;
29924
+ });
29925
+ });
29926
+ }, [setIntersectingBlocks]);
29927
+ const {
29928
+ order,
29929
+ selectedBlocks
29930
+ } = (0,external_wp_data_namespaceObject.useSelect)(select => {
29931
+ const {
29932
+ getBlockOrder,
29933
+ getSelectedBlockClientIds
29934
+ } = select(store);
29935
+ return {
29936
+ order: getBlockOrder(rootClientId),
29937
+ selectedBlocks: getSelectedBlockClientIds()
29938
+ };
29939
+ }, [rootClientId]);
29940
+ return (0,external_wp_element_namespaceObject.createElement)(LayoutProvider, {
29941
+ value: layout
29942
+ }, (0,external_wp_element_namespaceObject.createElement)(IntersectionObserver.Provider, {
29943
+ value: intersectionObserver
29944
+ }, order.map(clientId => (0,external_wp_element_namespaceObject.createElement)(external_wp_data_namespaceObject.AsyncModeProvider, {
29945
+ key: clientId,
29946
+ value: // Only provide data asynchronously if the block is
29947
+ // not visible and not selected.
29948
+ !intersectingBlocks.has(clientId) && !selectedBlocks.includes(clientId)
29949
+ }, (0,external_wp_element_namespaceObject.createElement)(block, {
29950
+ rootClientId: rootClientId,
29951
+ clientId: clientId
29952
+ })))), order.length < 1 && placeholder, (0,external_wp_element_namespaceObject.createElement)(block_list_appender, {
29953
+ tagName: __experimentalAppenderTagName,
29954
+ rootClientId: rootClientId,
29955
+ renderAppender: renderAppender
29956
+ }));
29957
  }
29958
+
29959
+ function BlockListItems(props) {
29960
+ // This component needs to always be synchronous as it's the one changing
29961
+ // the async mode depending on the block selection.
29962
+ return (0,external_wp_element_namespaceObject.createElement)(external_wp_data_namespaceObject.AsyncModeProvider, {
29963
+ value: false
29964
+ }, (0,external_wp_element_namespaceObject.createElement)(Items, props));
29965
+ }
29966
+ //# sourceMappingURL=index.js.map
29967
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/hooks/duotone.js
29968
+
29969
+
29970
+
29971
  /**
29972
  * External dependencies
29973
  */
29974
 
29975
+
29976
  /**
29977
  * WordPress dependencies
29978
  */
29980
 
29981
 
29982
 
29983
+
29984
+
29985
  /**
29986
  * Internal dependencies
29987
  */
29988
 
29989
 
29990
+
29991
+ const duotone_EMPTY_ARRAY = [];
29992
  /**
29993
+ * Convert a list of colors to an object of R, G, and B values.
 
 
 
 
29994
  *
29995
+ * @param {string[]} colors Array of RBG color strings.
29996
+ *
29997
+ * @return {Object} R, G, and B values.
 
 
 
 
 
 
 
 
29998
  */
29999
 
30000
+ function getValuesFromColors(colors = []) {
30001
+ const values = {
30002
+ r: [],
30003
+ g: [],
30004
+ b: []
30005
+ };
30006
+ colors.forEach(color => {
30007
+ // Access values directly to skip extra rounding that tinycolor.toRgb() does.
30008
+ const tcolor = tinycolor_default()(color);
30009
+ values.r.push(tcolor._r / 255);
30010
+ values.g.push(tcolor._g / 255);
30011
+ values.b.push(tcolor._b / 255);
30012
+ });
30013
+ return values;
30014
+ }
30015
+ /**
30016
+ * Values for the SVG `feComponentTransfer`.
30017
+ *
30018
+ * @typedef Values {Object}
30019
+ * @property {number[]} r Red values.
30020
+ * @property {number[]} g Green values.
30021
+ * @property {number[]} b Blue values.
30022
+ */
30023
 
30024
+ /**
30025
+ * SVG and stylesheet needed for rendering the duotone filter.
30026
+ *
30027
+ * @param {Object} props Duotone props.
30028
+ * @param {string} props.selector Selector to apply the filter to.
30029
+ * @param {string} props.id Unique id for this duotone filter.
30030
+ * @param {Values} props.values R, G, and B values to filter with.
30031
+ *
30032
+ * @return {WPElement} Duotone element.
30033
+ */
30034
 
30035
+ function DuotoneFilter({
30036
+ selector,
30037
+ id,
30038
+ values
30039
+ }) {
30040
+ const stylesheet = `
30041
+ ${selector} {
30042
+ filter: url( #${id} );
30043
+ }
30044
+ `;
30045
+ return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SVG, {
30046
+ xmlnsXlink: "http://www.w3.org/1999/xlink",
30047
+ viewBox: "0 0 0 0",
30048
+ width: "0",
30049
+ height: "0",
30050
+ focusable: "false",
30051
+ role: "none",
30052
+ style: {
30053
+ visibility: 'hidden',
30054
+ position: 'absolute',
30055
+ left: '-9999px',
30056
+ overflow: 'hidden'
30057
+ }
30058
+ }, (0,external_wp_element_namespaceObject.createElement)("defs", null, (0,external_wp_element_namespaceObject.createElement)("filter", {
30059
+ id: id
30060
+ }, (0,external_wp_element_namespaceObject.createElement)("feColorMatrix", {
30061
+ type: "matrix" // Use perceptual brightness to convert to grayscale.
30062
+ // prettier-ignore
30063
+ ,
30064
+ values: ".299 .587 .114 0 0 .299 .587 .114 0 0 .299 .587 .114 0 0 0 0 0 1 0"
30065
+ }), (0,external_wp_element_namespaceObject.createElement)("feComponentTransfer", {
30066
+ // Use sRGB instead of linearRGB to be consistent with how CSS gradients work.
30067
+ colorInterpolationFilters: "sRGB"
30068
+ }, (0,external_wp_element_namespaceObject.createElement)("feFuncR", {
30069
+ type: "table",
30070
+ tableValues: values.r.join(' ')
30071
+ }), (0,external_wp_element_namespaceObject.createElement)("feFuncG", {
30072
+ type: "table",
30073
+ tableValues: values.g.join(' ')
30074
+ }), (0,external_wp_element_namespaceObject.createElement)("feFuncB", {
30075
+ type: "table",
30076
+ tableValues: values.b.join(' ')
30077
+ }))))), (0,external_wp_element_namespaceObject.createElement)("style", {
30078
+ dangerouslySetInnerHTML: {
30079
+ __html: stylesheet
30080
+ }
30081
+ }));
30082
+ }
30083
 
30084
+ function DuotonePanel({
30085
+ attributes,
30086
+ setAttributes
30087
+ }) {
30088
+ var _style$color;
30089
+
30090
+ const style = attributes === null || attributes === void 0 ? void 0 : attributes.style;
30091
+ const duotone = style === null || style === void 0 ? void 0 : (_style$color = style.color) === null || _style$color === void 0 ? void 0 : _style$color.duotone;
30092
+ const duotonePalette = useSetting('color.duotone') || duotone_EMPTY_ARRAY;
30093
+ const colorPalette = useSetting('color.palette') || duotone_EMPTY_ARRAY;
30094
+ const disableCustomColors = !useSetting('color.custom');
30095
+ const disableCustomDuotone = !useSetting('color.customDuotone') || (colorPalette === null || colorPalette === void 0 ? void 0 : colorPalette.length) === 0 && disableCustomColors;
30096
+
30097
+ if ((duotonePalette === null || duotonePalette === void 0 ? void 0 : duotonePalette.length) === 0 && disableCustomDuotone) {
30098
+ return null;
30099
+ }
30100
+
30101
+ return (0,external_wp_element_namespaceObject.createElement)(block_controls, {
30102
+ group: "block",
30103
+ __experimentalExposeToChildren: true
30104
+ }, (0,external_wp_element_namespaceObject.createElement)(duotone_control, {
30105
+ duotonePalette: duotonePalette,
30106
+ colorPalette: colorPalette,
30107
+ disableCustomDuotone: disableCustomDuotone,
30108
+ disableCustomColors: disableCustomColors,
30109
+ value: duotone,
30110
+ onChange: newDuotone => {
30111
+ const newStyle = { ...style,
30112
+ color: { ...(style === null || style === void 0 ? void 0 : style.color),
30113
+ duotone: newDuotone
30114
  }
30115
+ };
30116
+ setAttributes({
30117
+ style: newStyle
30118
+ });
30119
  }
30120
+ }));
30121
  }
 
 
30122
  /**
30123
+ * Filters registered block settings, extending attributes to include
30124
+ * the `duotone` attribute.
30125
+ *
30126
+ * @param {Object} settings Original block settings.
30127
+ *
30128
+ * @return {Object} Filtered block settings.
30129
  */
30130
 
30131
+
30132
+ function addDuotoneAttributes(settings) {
30133
+ if (!(0,external_wp_blocks_namespaceObject.hasBlockSupport)(settings, 'color.__experimentalDuotone')) {
30134
+ return settings;
30135
+ } // Allow blocks to specify their own attribute definition with default
30136
+ // values if needed.
30137
+
30138
+
30139
+ if (!settings.attributes.style) {
30140
+ Object.assign(settings.attributes, {
30141
+ style: {
30142
+ type: 'object'
30143
+ }
30144
+ });
30145
+ }
30146
+
30147
+ return settings;
30148
+ }
30149
  /**
30150
+ * Override the default edit UI to include toolbar controls for duotone if the
30151
+ * block supports duotone.
30152
  *
30153
+ * @param {Function} BlockEdit Original component.
30154
+ *
30155
+ * @return {Function} Wrapped component.
30156
  */
30157
 
30158
+
30159
+ const withDuotoneControls = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockEdit => props => {
30160
+ const hasDuotoneSupport = (0,external_wp_blocks_namespaceObject.hasBlockSupport)(props.name, 'color.__experimentalDuotone');
30161
+ return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(BlockEdit, props), hasDuotoneSupport && (0,external_wp_element_namespaceObject.createElement)(DuotonePanel, props));
30162
+ }, 'withDuotoneControls');
30163
  /**
30164
+ * Override the default block element to include duotone styles.
 
30165
  *
30166
+ * @param {Function} BlockListBlock Original component.
 
30167
  *
30168
+ * @return {Function} Wrapped component.
30169
  */
30170
 
30171
+ const withDuotoneStyles = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockListBlock => props => {
30172
+ var _props$attributes, _props$attributes$sty, _props$attributes$sty2;
 
 
30173
 
30174
+ const duotoneSupport = (0,external_wp_blocks_namespaceObject.getBlockSupport)(props.name, 'color.__experimentalDuotone');
30175
+ const values = props === null || props === void 0 ? void 0 : (_props$attributes = props.attributes) === null || _props$attributes === void 0 ? void 0 : (_props$attributes$sty = _props$attributes.style) === null || _props$attributes$sty === void 0 ? void 0 : (_props$attributes$sty2 = _props$attributes$sty.color) === null || _props$attributes$sty2 === void 0 ? void 0 : _props$attributes$sty2.duotone;
30176
 
30177
+ if (!duotoneSupport || !values) {
30178
+ return (0,external_wp_element_namespaceObject.createElement)(BlockListBlock, props);
 
30179
  }
30180
 
30181
+ const id = `wp-duotone-filter-${(0,external_wp_compose_namespaceObject.useInstanceId)(BlockListBlock)}`;
30182
+ const selectors = duotoneSupport.split(',');
30183
+ const selectorsScoped = selectors.map(selector => `.${id} ${selector.trim()}`);
30184
+ const selectorsGroup = selectorsScoped.join(', ');
30185
+ const className = classnames_default()(props === null || props === void 0 ? void 0 : props.className, id);
30186
+ const element = (0,external_wp_element_namespaceObject.useContext)(BlockList.__unstableElementContext);
30187
+ return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, element && (0,external_wp_element_namespaceObject.createPortal)((0,external_wp_element_namespaceObject.createElement)(DuotoneFilter, {
30188
+ selector: selectorsGroup,
30189
+ id: id,
30190
+ values: getValuesFromColors(values)
30191
+ }), element), (0,external_wp_element_namespaceObject.createElement)(BlockListBlock, _extends({}, props, {
30192
+ className: className
30193
+ })));
30194
+ }, 'withDuotoneStyles');
30195
+ (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'core/editor/duotone/add-attributes', addDuotoneAttributes);
30196
+ (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockEdit', 'core/editor/duotone/with-editor-controls', withDuotoneControls);
30197
+ (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockListBlock', 'core/editor/duotone/with-styles', withDuotoneStyles);
30198
+ //# sourceMappingURL=duotone.js.map
30199
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/hooks/layout.js
30200
 
30201
 
30202
 
30204
  * External dependencies
30205
  */
30206
 
30207
+
30208
  /**
30209
  * WordPress dependencies
30210
  */
30213
 
30214
 
30215
 
30216
+
30217
+
30218
+
30219
  /**
30220
  * Internal dependencies
30221
  */
30226
 
30227
 
30228
 
30229
+ const layoutBlockSupportKey = '__experimentalLayout';
30230
 
30231
+ function LayoutPanel({
30232
+ setAttributes,
30233
+ attributes,
30234
+ name: blockName
30235
+ }) {
30236
+ const {
30237
+ layout
30238
+ } = attributes;
30239
+ const defaultThemeLayout = useSetting('layout');
30240
+ const themeSupportsLayout = (0,external_wp_data_namespaceObject.useSelect)(select => {
30241
+ const {
30242
+ getSettings
30243
+ } = select(store);
30244
+ return getSettings().supportsLayout;
30245
+ }, []);
30246
 
30247
+ if (!themeSupportsLayout) {
30248
+ return null;
30249
+ }
30250
 
30251
+ const {
30252
+ allowSwitching: canBlockSwitchLayout,
30253
+ allowEditing = true,
30254
+ allowInheriting = true,
30255
+ default: defaultBlockLayout
30256
+ } = (0,external_wp_blocks_namespaceObject.getBlockSupport)(blockName, layoutBlockSupportKey) || {};
30257
 
30258
+ if (!allowEditing) {
30259
+ return null;
30260
+ }
30261
 
30262
+ const usedLayout = layout ? layout : defaultBlockLayout || {};
 
 
 
 
 
 
 
 
 
30263
  const {
30264
+ inherit = false,
30265
+ type = 'default'
30266
+ } = usedLayout;
30267
+ const layoutType = getLayoutType(type);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30268
 
30269
+ const onChangeType = newType => setAttributes({
30270
+ layout: {
30271
+ type: newType
30272
  }
30273
+ });
30274
 
30275
+ const onChangeLayout = newLayout => setAttributes({
30276
+ layout: newLayout
30277
+ });
30278
 
30279
+ return (0,external_wp_element_namespaceObject.createElement)(inspector_controls, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelBody, {
30280
+ title: (0,external_wp_i18n_namespaceObject.__)('Layout')
30281
+ }, allowInheriting && !!defaultThemeLayout && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToggleControl, {
30282
+ label: (0,external_wp_i18n_namespaceObject.__)('Inherit default layout'),
30283
+ checked: !!inherit,
30284
+ onChange: () => setAttributes({
30285
+ layout: {
30286
+ inherit: !inherit
30287
+ }
30288
+ })
30289
+ }), !inherit && canBlockSwitchLayout && (0,external_wp_element_namespaceObject.createElement)(LayoutTypeSwitcher, {
30290
+ type: type,
30291
+ onChange: onChangeType
30292
+ }), !inherit && layoutType && (0,external_wp_element_namespaceObject.createElement)(layoutType.edit, {
30293
+ layout: usedLayout,
30294
+ onChange: onChangeLayout
30295
+ })));
30296
+ }
30297
+
30298
+ function LayoutTypeSwitcher({
30299
+ type,
30300
+ onChange
30301
+ }) {
30302
+ return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ButtonGroup, null, getLayoutTypes().map(({
30303
+ name,
30304
+ label
30305
+ }) => {
30306
+ return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
30307
+ key: name,
30308
+ isPressed: type === name,
30309
+ onClick: () => onChange(name)
30310
+ }, label);
30311
  }));
30312
  }
30313
  /**
30314
+ * Filters registered block settings, extending attributes to include `layout`.
 
 
 
 
30315
  *
30316
+ * @param {Object} settings Original block settings.
30317
+ *
30318
+ * @return {Object} Filtered block settings.
30319
  */
30320
 
30321
 
30322
+ function layout_addAttribute(settings) {
30323
+ if ((0,external_lodash_namespaceObject.has)(settings.attributes, ['layout', 'type'])) {
30324
+ return settings;
30325
+ }
30326
+
30327
+ if ((0,external_wp_blocks_namespaceObject.hasBlockSupport)(settings, layoutBlockSupportKey)) {
30328
+ settings.attributes = { ...settings.attributes,
30329
+ layout: {
30330
+ type: 'object'
30331
+ }
30332
+ };
30333
+ }
30334
+
30335
+ return settings;
30336
  }
30337
+ /**
30338
+ * Override the default edit UI to include layout controls
30339
+ *
30340
+ * @param {Function} BlockEdit Original component.
30341
+ *
30342
+ * @return {Function} Wrapped component.
30343
+ */
30344
 
30345
+ const withInspectorControls = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockEdit => props => {
30346
+ const {
30347
+ name: blockName
30348
+ } = props;
30349
+ const supportLayout = (0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockName, layoutBlockSupportKey);
30350
+ return [supportLayout && (0,external_wp_element_namespaceObject.createElement)(LayoutPanel, _extends({
30351
+ key: "layout"
30352
+ }, props)), (0,external_wp_element_namespaceObject.createElement)(BlockEdit, _extends({
30353
+ key: "edit"
30354
+ }, props))];
30355
+ }, 'withInspectorControls');
30356
  /**
30357
+ * Override the default block element to add the layout styles.
 
 
 
 
 
 
30358
  *
30359
+ * @param {Function} BlockListBlock Original component.
 
 
30360
  *
30361
+ * @return {Function} Wrapped component.
30362
  */
30363
 
30364
+ const withLayoutStyles = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockListBlock => props => {
30365
  const {
30366
+ name,
30367
+ attributes
30368
+ } = props;
30369
+ const shouldRenderLayoutStyles = (0,external_wp_blocks_namespaceObject.hasBlockSupport)(name, layoutBlockSupportKey);
30370
+ const id = (0,external_wp_compose_namespaceObject.useInstanceId)(BlockListBlock);
30371
+ const defaultThemeLayout = useSetting('layout') || {};
30372
+ const element = (0,external_wp_element_namespaceObject.useContext)(BlockList.__unstableElementContext);
30373
+ const {
30374
+ layout
30375
+ } = attributes;
30376
+ const {
30377
+ default: defaultBlockLayout
30378
+ } = (0,external_wp_blocks_namespaceObject.getBlockSupport)(name, layoutBlockSupportKey) || {};
30379
+ const usedLayout = layout !== null && layout !== void 0 && layout.inherit ? defaultThemeLayout : layout || defaultBlockLayout || {};
30380
+ const className = classnames_default()(props === null || props === void 0 ? void 0 : props.className, {
30381
+ [`wp-container-${id}`]: shouldRenderLayoutStyles
30382
+ });
30383
+ return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, shouldRenderLayoutStyles && element && (0,external_wp_element_namespaceObject.createPortal)((0,external_wp_element_namespaceObject.createElement)(LayoutStyle, {
30384
+ selector: `.wp-container-${id}`,
30385
+ layout: usedLayout
30386
+ }), element), (0,external_wp_element_namespaceObject.createElement)(BlockListBlock, _extends({}, props, {
30387
+ className: className
30388
+ })));
30389
+ });
30390
+ (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'core/layout/addAttribute', layout_addAttribute);
30391
+ (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockListBlock', 'core/editor/layout/with-layout-styles', withLayoutStyles);
30392
+ (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockEdit', 'core/editor/layout/with-inspector-controls', withInspectorControls);
30393
+ //# sourceMappingURL=layout.js.map
30394
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/hooks/use-border-props.js
30395
+ /**
30396
+ * External dependencies
30397
+ */
30398
 
 
 
 
 
 
30399
  /**
30400
+ * Internal dependencies
30401
  */
30402
 
 
 
 
30403
 
30404
 
30405
+ // This utility is intended to assist where the serialization of the border
30406
+ // block support is being skipped for a block but the border related CSS classes
30407
+ // & styles still need to be generated so they can be applied to inner elements.
30408
+
30409
+ const use_border_props_EMPTY_ARRAY = [];
30410
  /**
30411
+ * Provides the CSS class names and inline styles for a block's border support
30412
+ * attributes.
30413
+ *
30414
+ * @param {Object} attributes Block attributes.
30415
+ * @param {string} attributes.borderColor Selected named border color.
30416
+ * @param {Object} attributes.style Block's styles attribute.
30417
+ *
30418
+ * @return {Object} Border block support derived CSS classes & styles.
30419
  */
30420
 
30421
+ function getBorderClassesAndStyles({
30422
+ borderColor,
30423
+ style
30424
+ }) {
30425
+ var _style$border;
 
 
 
 
 
30426
 
30427
+ const borderStyles = (style === null || style === void 0 ? void 0 : style.border) || {};
30428
+ const borderClass = getColorClassName('border-color', borderColor);
30429
+ const className = classnames_default()({
30430
+ [borderClass]: !!borderClass,
30431
+ 'has-border-color': borderColor || (style === null || style === void 0 ? void 0 : (_style$border = style.border) === null || _style$border === void 0 ? void 0 : _style$border.color)
30432
+ });
30433
+ return {
30434
+ className: className || undefined,
30435
+ style: getInlineStyles({
30436
+ border: borderStyles
30437
+ })
30438
+ };
30439
+ }
30440
  /**
30441
+ * Derives the border related props for a block from its border block support
30442
+ * attributes.
30443
+ *
30444
+ * Inline styles are forced for named colors to ensure these selections are
30445
+ * reflected when themes do not load their color stylesheets in the editor.
30446
+ *
30447
+ * @param {Object} attributes Block attributes.
30448
+ *
30449
+ * @return {Object} ClassName & style props from border block support.
30450
  */
30451
 
30452
+ function useBorderProps(attributes) {
30453
+ const colors = useSetting('color.palette') || use_border_props_EMPTY_ARRAY;
30454
+ const borderProps = getBorderClassesAndStyles(attributes); // Force inline style to apply border color when themes do not load their
30455
+ // color stylesheets in the editor.
 
 
 
 
 
30456
 
30457
+ if (attributes.borderColor) {
30458
+ const borderColorObject = getColorObjectByAttributeValues(colors, attributes.borderColor);
30459
+ borderProps.style.borderColor = borderColorObject.color;
30460
+ }
30461
 
30462
+ return borderProps;
30463
+ }
30464
+ //# sourceMappingURL=use-border-props.js.map
30465
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/hooks/use-color-props.js
30466
  /**
30467
+ * External dependencies
30468
  */
30469
 
 
 
 
 
 
 
 
 
 
 
 
30470
  /**
30471
+ * Internal dependencies
30472
  */
30473
 
 
 
 
 
 
 
 
 
 
30474
 
30475
 
30476
 
30477
+ // The code in this file has largely been lifted from the color block support
30478
+ // hook.
30479
+ //
30480
+ // This utility is intended to assist where the serialization of the colors
30481
+ // block support is being skipped for a block but the color related CSS classes
30482
+ // & styles still need to be generated so they can be applied to inner elements.
30483
+
30484
+ const use_color_props_EMPTY_ARRAY = [];
30485
  /**
30486
+ * Provides the CSS class names and inline styles for a block's color support
30487
+ * attributes.
30488
+ *
30489
+ * @param {Object} attributes Block attributes.
30490
+ *
30491
+ * @return {Object} Color block support derived CSS classes & styles.
30492
  */
30493
 
30494
+ function getColorClassesAndStyles(attributes) {
30495
+ var _style$color, _style$color2, _style$color3, _style$color4, _style$elements, _style$elements$link;
30496
 
30497
+ const {
30498
+ backgroundColor,
30499
+ textColor,
30500
+ gradient,
30501
+ style
30502
+ } = attributes; // Collect color CSS classes.
30503
 
30504
+ const backgroundClass = getColorClassName('background-color', backgroundColor);
30505
+ const textClass = getColorClassName('color', textColor);
 
 
 
 
30506
 
30507
+ const gradientClass = __experimentalGetGradientClass(gradient);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30508
 
30509
+ const hasGradient = gradientClass || (style === null || style === void 0 ? void 0 : (_style$color = style.color) === null || _style$color === void 0 ? void 0 : _style$color.gradient); // Determine color CSS class name list.
30510
+
30511
+ const className = classnames_default()(textClass, gradientClass, {
30512
+ // Don't apply the background class if there's a gradient.
30513
+ [backgroundClass]: !hasGradient && !!backgroundClass,
30514
+ 'has-text-color': textColor || (style === null || style === void 0 ? void 0 : (_style$color2 = style.color) === null || _style$color2 === void 0 ? void 0 : _style$color2.text),
30515
+ 'has-background': backgroundColor || (style === null || style === void 0 ? void 0 : (_style$color3 = style.color) === null || _style$color3 === void 0 ? void 0 : _style$color3.background) || gradient || (style === null || style === void 0 ? void 0 : (_style$color4 = style.color) === null || _style$color4 === void 0 ? void 0 : _style$color4.gradient),
30516
+ 'has-link-color': style === null || style === void 0 ? void 0 : (_style$elements = style.elements) === null || _style$elements === void 0 ? void 0 : (_style$elements$link = _style$elements.link) === null || _style$elements$link === void 0 ? void 0 : _style$elements$link.color
30517
+ }); // Collect inline styles for colors.
30518
+
30519
+ const colorStyles = (style === null || style === void 0 ? void 0 : style.color) || {};
30520
+ const styleProp = getInlineStyles({
30521
+ color: colorStyles
30522
+ });
30523
+ return {
30524
+ className: className || undefined,
30525
+ style: styleProp
30526
+ };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30527
  }
30528
+ /**
30529
+ * Determines the color related props for a block derived from its color block
30530
+ * support attributes.
30531
+ *
30532
+ * Inline styles are forced for named colors to ensure these selections are
30533
+ * reflected when themes do not load their color stylesheets in the editor.
30534
+ *
30535
+ * @param {Object} attributes Block attributes.
30536
+ *
30537
+ * @return {Object} ClassName & style props from colors block support.
30538
+ */
30539
 
30540
+ function useColorProps(attributes) {
30541
+ const {
30542
+ backgroundColor,
30543
+ textColor,
30544
+ gradient
30545
+ } = attributes;
30546
+ const colors = useSetting('color.palette') || use_color_props_EMPTY_ARRAY;
30547
+ const gradients = useSetting('color.gradients') || use_color_props_EMPTY_ARRAY;
30548
+ const colorProps = getColorClassesAndStyles(attributes); // Force inline styles to apply colors when themes do not load their color
30549
+ // stylesheets in the editor.
30550
+
30551
+ if (backgroundColor) {
30552
+ const backgroundColorObject = getColorObjectByAttributeValues(colors, backgroundColor);
30553
+ colorProps.style.backgroundColor = backgroundColorObject.color;
30554
+ }
30555
 
30556
+ if (gradient) {
30557
+ colorProps.style.background = getGradientValueBySlug(gradients, gradient);
30558
+ }
30559
 
30560
+ if (textColor) {
30561
+ const textColorObject = getColorObjectByAttributeValues(colors, textColor);
30562
+ colorProps.style.color = textColorObject.color;
30563
+ }
30564
 
30565
+ return colorProps;
30566
+ }
30567
+ //# sourceMappingURL=use-color-props.js.map
30568
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/hooks/use-spacing-props.js
30569
  /**
30570
  * Internal dependencies
30571
  */
30572
+ // This utility is intended to assist where the serialization of the spacing
30573
+ // block support is being skipped for a block but the spacing related CSS
30574
+ // styles still need to be generated so they can be applied to inner elements.
30575
 
30576
+ /**
30577
+ * Provides the CSS class names and inline styles for a block's spacing support
30578
+ * attributes.
30579
+ *
30580
+ * @param {Object} attributes Block attributes.
30581
+ *
30582
+ * @return {Object} Spacing block support derived CSS classes & styles.
30583
+ */
 
 
 
 
30584
 
30585
+ function getSpacingClassesAndStyles(attributes) {
30586
+ const {
30587
+ style
30588
+ } = attributes; // Collect inline styles for spacing.
30589
 
30590
+ const spacingStyles = (style === null || style === void 0 ? void 0 : style.spacing) || {};
30591
+ const styleProp = getInlineStyles({
30592
+ spacing: spacingStyles
30593
+ });
30594
+ return {
30595
+ style: styleProp
30596
+ };
30597
+ }
30598
+ //# sourceMappingURL=use-spacing-props.js.map
30599
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/hooks/index.js
30600
  /**
30601
+ * Internal dependencies
30602
  */
30603
 
 
 
 
 
 
 
 
 
 
30604
 
30605
 
 
 
 
30606
 
 
 
 
30607
 
30608
 
30609
 
30610
 
 
 
 
 
 
 
 
 
30611
 
 
 
 
 
 
30612
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30613
 
30614
+
30615
+
30616
+
30617
+ //# sourceMappingURL=index.js.map
30618
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/colors/with-colors.js
30619
 
30620
 
30621
 
30623
  * External dependencies
30624
  */
30625
 
 
 
30626
  /**
30627
  * WordPress dependencies
30628
  */
30629
 
30630
 
30631
 
 
 
 
 
 
30632
  /**
30633
  * Internal dependencies
30634
  */
30635
 
30636
 
30637
 
30638
+ const DEFAULT_COLORS = [];
30639
+ /**
30640
+ * Higher order component factory for injecting the `colorsArray` argument as
30641
+ * the colors prop in the `withCustomColors` HOC.
30642
+ *
30643
+ * @param {Array} colorsArray An array of color objects.
30644
+ *
30645
+ * @return {Function} The higher order component.
30646
+ */
 
 
 
 
 
 
 
 
 
 
 
 
 
30647
 
30648
+ const withCustomColorPalette = colorsArray => (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(WrappedComponent => props => (0,external_wp_element_namespaceObject.createElement)(WrappedComponent, _extends({}, props, {
30649
+ colors: colorsArray
30650
+ })), 'withCustomColorPalette');
30651
+ /**
30652
+ * Higher order component factory for injecting the editor colors as the
30653
+ * `colors` prop in the `withColors` HOC.
30654
+ *
30655
+ * @return {Function} The higher order component.
30656
+ */
30657
 
 
 
 
 
 
 
 
 
 
30658
 
30659
+ const withEditorColorPalette = () => (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(WrappedComponent => props => {
30660
+ const colors = useSetting('color.palette') || DEFAULT_COLORS;
30661
+ return (0,external_wp_element_namespaceObject.createElement)(WrappedComponent, _extends({}, props, {
30662
+ colors: colors
30663
+ }));
30664
+ }, 'withEditorColorPalette');
30665
+ /**
30666
+ * Helper function used with `createHigherOrderComponent` to create
30667
+ * higher order components for managing color logic.
30668
+ *
30669
+ * @param {Array} colorTypes An array of color types (e.g. 'backgroundColor, borderColor).
30670
+ * @param {Function} withColorPalette A HOC for injecting the 'colors' prop into the WrappedComponent.
30671
+ *
30672
+ * @return {WPComponent} The component that can be used as a HOC.
30673
+ */
30674
 
 
 
 
 
30675
 
30676
+ function createColorHOC(colorTypes, withColorPalette) {
30677
+ const colorMap = (0,external_lodash_namespaceObject.reduce)(colorTypes, (colorObject, colorType) => {
30678
+ return { ...colorObject,
30679
+ ...((0,external_lodash_namespaceObject.isString)(colorType) ? {
30680
+ [colorType]: (0,external_lodash_namespaceObject.kebabCase)(colorType)
30681
+ } : colorType)
30682
+ };
30683
+ }, {});
30684
+ return (0,external_wp_compose_namespaceObject.compose)([withColorPalette, WrappedComponent => {
30685
+ return class extends external_wp_element_namespaceObject.Component {
30686
+ constructor(props) {
30687
+ super(props);
30688
+ this.setters = this.createSetters();
30689
+ this.colorUtils = {
30690
+ getMostReadableColor: this.getMostReadableColor.bind(this)
30691
+ };
30692
+ this.state = {};
30693
+ }
30694
 
30695
+ getMostReadableColor(colorValue) {
30696
+ const {
30697
+ colors
30698
+ } = this.props;
30699
+ return getMostReadableColor(colors, colorValue);
30700
+ }
30701
 
30702
+ createSetters() {
30703
+ return (0,external_lodash_namespaceObject.reduce)(colorMap, (settersAccumulator, colorContext, colorAttributeName) => {
30704
+ const upperFirstColorAttributeName = (0,external_lodash_namespaceObject.upperFirst)(colorAttributeName);
30705
+ const customColorAttributeName = `custom${upperFirstColorAttributeName}`;
30706
+ settersAccumulator[`set${upperFirstColorAttributeName}`] = this.createSetColor(colorAttributeName, customColorAttributeName);
30707
+ return settersAccumulator;
30708
+ }, {});
30709
+ }
30710
 
30711
+ createSetColor(colorAttributeName, customColorAttributeName) {
30712
+ return colorValue => {
30713
+ const colorObject = getColorObjectByColorValue(this.props.colors, colorValue);
30714
+ this.props.setAttributes({
30715
+ [colorAttributeName]: colorObject && colorObject.slug ? colorObject.slug : undefined,
30716
+ [customColorAttributeName]: colorObject && colorObject.slug ? undefined : colorValue
30717
+ });
30718
+ };
30719
+ }
30720
 
30721
+ static getDerivedStateFromProps({
30722
+ attributes,
30723
+ colors
30724
+ }, previousState) {
30725
+ return (0,external_lodash_namespaceObject.reduce)(colorMap, (newState, colorContext, colorAttributeName) => {
30726
+ const colorObject = getColorObjectByAttributeValues(colors, attributes[colorAttributeName], attributes[`custom${(0,external_lodash_namespaceObject.upperFirst)(colorAttributeName)}`]);
30727
+ const previousColorObject = previousState[colorAttributeName];
30728
+ const previousColor = previousColorObject === null || previousColorObject === void 0 ? void 0 : previousColorObject.color;
30729
+ /**
30730
+ * The "and previousColorObject" condition checks that a previous color object was already computed.
30731
+ * At the start previousColorObject and colorValue are both equal to undefined
30732
+ * bus as previousColorObject does not exist we should compute the object.
30733
+ */
30734
 
30735
+ if (previousColor === colorObject.color && previousColorObject) {
30736
+ newState[colorAttributeName] = previousColorObject;
30737
+ } else {
30738
+ newState[colorAttributeName] = { ...colorObject,
30739
+ class: getColorClassName(colorContext, colorObject.slug)
30740
+ };
30741
+ }
30742
 
30743
+ return newState;
30744
+ }, {});
30745
+ }
30746
 
30747
+ render() {
30748
+ return (0,external_wp_element_namespaceObject.createElement)(WrappedComponent, _extends({}, this.props, {
30749
+ colors: undefined
30750
+ }, this.state, this.setters, {
30751
+ colorUtils: this.colorUtils
30752
+ }));
30753
+ }
30754
 
30755
+ };
30756
+ }]);
30757
+ }
30758
+ /**
30759
+ * A higher-order component factory for creating a 'withCustomColors' HOC, which handles color logic
30760
+ * for class generation color value, retrieval and color attribute setting.
30761
+ *
30762
+ * Use this higher-order component to work with a custom set of colors.
30763
+ *
30764
+ * @example
30765
+ *
30766
+ * ```jsx
30767
+ * const CUSTOM_COLORS = [ { name: 'Red', slug: 'red', color: '#ff0000' }, { name: 'Blue', slug: 'blue', color: '#0000ff' } ];
30768
+ * const withCustomColors = createCustomColorsHOC( CUSTOM_COLORS );
30769
+ * // ...
30770
+ * export default compose(
30771
+ * withCustomColors( 'backgroundColor', 'borderColor' ),
30772
+ * MyColorfulComponent,
30773
+ * );
30774
+ * ```
30775
+ *
30776
+ * @param {Array} colorsArray The array of color objects (name, slug, color, etc... ).
30777
+ *
30778
+ * @return {Function} Higher-order component.
30779
+ */
30780
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30781
 
30782
+ function createCustomColorsHOC(colorsArray) {
30783
+ return (...colorTypes) => {
30784
+ const withColorPalette = withCustomColorPalette(colorsArray);
30785
+ return (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(createColorHOC(colorTypes, withColorPalette), 'withCustomColors');
30786
+ };
30787
+ }
30788
+ /**
30789
+ * A higher-order component, which handles color logic for class generation color value, retrieval and color attribute setting.
30790
+ *
30791
+ * For use with the default editor/theme color palette.
30792
+ *
30793
+ * @example
30794
+ *
30795
+ * ```jsx
30796
+ * export default compose(
30797
+ * withColors( 'backgroundColor', { textColor: 'color' } ),
30798
+ * MyColorfulComponent,
30799
+ * );
30800
+ * ```
30801
+ *
30802
+ * @param {...(Object|string)} colorTypes The arguments can be strings or objects. If the argument is an object,
30803
+ * it should contain the color attribute name as key and the color context as value.
30804
+ * If the argument is a string the value should be the color attribute name,
30805
+ * the color context is computed by applying a kebab case transform to the value.
30806
+ * Color context represents the context/place where the color is going to be used.
30807
+ * The class name of the color is generated using 'has' followed by the color name
30808
+ * and ending with the color context all in kebab case e.g: has-green-background-color.
30809
+ *
30810
+ * @return {Function} Higher-order component.
30811
+ */
30812
 
30813
+ function withColors(...colorTypes) {
30814
+ const withColorPalette = withEditorColorPalette();
30815
+ return (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(createColorHOC(colorTypes, withColorPalette), 'withColors');
30816
+ }
30817
+ //# sourceMappingURL=with-colors.js.map
30818
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/colors/index.js
 
30819
 
 
 
 
 
 
 
 
 
 
 
30820
 
30821
+ //# sourceMappingURL=index.js.map
30822
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/gradients/index.js
30823
 
30824
+ //# sourceMappingURL=index.js.map
30825
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/font-sizes/with-font-sizes.js
 
30826
 
 
 
 
 
30827
 
 
 
 
 
 
 
 
 
 
30828
 
30829
+ /**
30830
+ * External dependencies
30831
+ */
 
 
30832
 
30833
+ /**
30834
+ * WordPress dependencies
30835
+ */
 
 
 
 
 
30836
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30837
 
 
 
30838
 
30839
+ /**
30840
+ * Internal dependencies
30841
+ */
 
30842
 
 
 
 
 
30843
 
 
 
30844
 
30845
+ const DEFAULT_FONT_SIZES = [];
30846
+ /**
30847
+ * Higher-order component, which handles font size logic for class generation,
30848
+ * font size value retrieval, and font size change handling.
30849
+ *
30850
+ * @param {...(Object|string)} fontSizeNames The arguments should all be strings.
30851
+ * Each string contains the font size
30852
+ * attribute name e.g: 'fontSize'.
30853
+ *
30854
+ * @return {Function} Higher-order component.
30855
+ */
30856
 
30857
+ /* harmony default export */ var with_font_sizes = ((...fontSizeNames) => {
30858
+ /*
30859
+ * Computes an object whose key is the font size attribute name as passed in the array,
30860
+ * and the value is the custom font size attribute name.
30861
+ * Custom font size is automatically compted by appending custom followed by the font size attribute name in with the first letter capitalized.
30862
+ */
30863
+ const fontSizeAttributeNames = (0,external_lodash_namespaceObject.reduce)(fontSizeNames, (fontSizeAttributeNamesAccumulator, fontSizeAttributeName) => {
30864
+ fontSizeAttributeNamesAccumulator[fontSizeAttributeName] = `custom${(0,external_lodash_namespaceObject.upperFirst)(fontSizeAttributeName)}`;
30865
+ return fontSizeAttributeNamesAccumulator;
30866
+ }, {});
30867
+ return (0,external_wp_compose_namespaceObject.createHigherOrderComponent)((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_compose_namespaceObject.createHigherOrderComponent)(WrappedComponent => props => {
30868
+ const fontSizes = useSetting('typography.fontSizes') || DEFAULT_FONT_SIZES;
30869
+ return (0,external_wp_element_namespaceObject.createElement)(WrappedComponent, _extends({}, props, {
30870
+ fontSizes: fontSizes
30871
+ }));
30872
+ }, 'withFontSizes'), WrappedComponent => {
30873
+ return class extends external_wp_element_namespaceObject.Component {
30874
+ constructor(props) {
30875
+ super(props);
30876
+ this.setters = this.createSetters();
30877
+ this.state = {};
30878
+ }
30879
 
30880
+ createSetters() {
30881
+ return (0,external_lodash_namespaceObject.reduce)(fontSizeAttributeNames, (settersAccumulator, customFontSizeAttributeName, fontSizeAttributeName) => {
30882
+ const upperFirstFontSizeAttributeName = (0,external_lodash_namespaceObject.upperFirst)(fontSizeAttributeName);
30883
+ settersAccumulator[`set${upperFirstFontSizeAttributeName}`] = this.createSetFontSize(fontSizeAttributeName, customFontSizeAttributeName);
30884
+ return settersAccumulator;
30885
+ }, {});
30886
  }
30887
 
30888
+ createSetFontSize(fontSizeAttributeName, customFontSizeAttributeName) {
30889
+ return fontSizeValue => {
30890
+ const fontSizeObject = (0,external_lodash_namespaceObject.find)(this.props.fontSizes, {
30891
+ size: Number(fontSizeValue)
30892
+ });
30893
+ this.props.setAttributes({
30894
+ [fontSizeAttributeName]: fontSizeObject && fontSizeObject.slug ? fontSizeObject.slug : undefined,
30895
+ [customFontSizeAttributeName]: fontSizeObject && fontSizeObject.slug ? undefined : fontSizeValue
30896
+ });
30897
+ };
30898
+ }
30899
 
30900
+ static getDerivedStateFromProps({
30901
+ attributes,
30902
+ fontSizes
30903
+ }, previousState) {
30904
+ const didAttributesChange = (customFontSizeAttributeName, fontSizeAttributeName) => {
30905
+ if (previousState[fontSizeAttributeName]) {
30906
+ // if new font size is name compare with the previous slug
30907
+ if (attributes[fontSizeAttributeName]) {
30908
+ return attributes[fontSizeAttributeName] !== previousState[fontSizeAttributeName].slug;
30909
+ } // if font size is not named, update when the font size value changes.
30910
 
 
 
 
 
 
 
 
 
 
 
30911
 
30912
+ return previousState[fontSizeAttributeName].size !== attributes[customFontSizeAttributeName];
30913
+ } // in this case we need to build the font size object
 
 
 
 
 
 
 
30914
 
 
 
 
 
30915
 
30916
+ return true;
30917
+ };
30918
 
30919
+ if (!(0,external_lodash_namespaceObject.some)(fontSizeAttributeNames, didAttributesChange)) {
30920
+ return null;
30921
  }
30922
 
30923
+ const newState = (0,external_lodash_namespaceObject.reduce)((0,external_lodash_namespaceObject.pickBy)(fontSizeAttributeNames, didAttributesChange), (newStateAccumulator, customFontSizeAttributeName, fontSizeAttributeName) => {
30924
+ const fontSizeAttributeValue = attributes[fontSizeAttributeName];
30925
+ const fontSizeObject = getFontSize(fontSizes, fontSizeAttributeValue, attributes[customFontSizeAttributeName]);
30926
+ newStateAccumulator[fontSizeAttributeName] = { ...fontSizeObject,
30927
+ class: getFontSizeClass(fontSizeAttributeValue)
30928
+ };
30929
+ return newStateAccumulator;
30930
+ }, {});
30931
+ return { ...previousState,
30932
+ ...newState
30933
+ };
30934
+ }
30935
 
30936
+ render() {
30937
+ return (0,external_wp_element_namespaceObject.createElement)(WrappedComponent, _extends({}, this.props, {
30938
+ fontSizes: undefined
30939
+ }, this.state, this.setters));
30940
+ }
 
30941
 
30942
+ };
30943
+ }]), 'withFontSizes');
30944
+ });
30945
+ //# sourceMappingURL=with-font-sizes.js.map
30946
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/font-sizes/index.js
30947
 
 
 
 
 
 
 
 
30948
 
 
 
30949
 
30950
+ //# sourceMappingURL=index.js.map
30951
+ ;// CONCATENATED MODULE: ./packages/icons/build-module/library/align-left.js
30952
 
 
 
 
 
 
 
 
 
 
 
30953
 
30954
+ /**
30955
+ * WordPress dependencies
30956
+ */
30957
 
30958
+ const alignLeft = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
30959
+ xmlns: "http://www.w3.org/2000/svg",
30960
+ viewBox: "0 0 24 24"
30961
+ }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
30962
+ d: "M4 19.8h8.9v-1.5H4v1.5zm8.9-15.6H4v1.5h8.9V4.2zm-8.9 7v1.5h16v-1.5H4z"
30963
+ }));
30964
+ /* harmony default export */ var align_left = (alignLeft);
30965
+ //# sourceMappingURL=align-left.js.map
30966
+ ;// CONCATENATED MODULE: ./packages/icons/build-module/library/align-center.js
30967
 
30968
+
30969
+ /**
30970
+ * WordPress dependencies
30971
+ */
30972
+
30973
+ const alignCenter = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
30974
+ xmlns: "http://www.w3.org/2000/svg",
30975
+ viewBox: "0 0 24 24"
30976
+ }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
30977
+ d: "M16.4 4.2H7.6v1.5h8.9V4.2zM4 11.2v1.5h16v-1.5H4zm3.6 8.6h8.9v-1.5H7.6v1.5z"
30978
+ }));
30979
+ /* harmony default export */ var align_center = (alignCenter);
30980
+ //# sourceMappingURL=align-center.js.map
30981
+ ;// CONCATENATED MODULE: ./packages/icons/build-module/library/align-right.js
30982
+
30983
+
30984
+ /**
30985
+ * WordPress dependencies
30986
+ */
30987
+
30988
+ const alignRight = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
30989
+ xmlns: "http://www.w3.org/2000/svg",
30990
+ viewBox: "0 0 24 24"
30991
+ }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
30992
+ d: "M11.1 19.8H20v-1.5h-8.9v1.5zm0-15.6v1.5H20V4.2h-8.9zM4 12.8h16v-1.5H4v1.5z"
30993
+ }));
30994
+ /* harmony default export */ var align_right = (alignRight);
30995
+ //# sourceMappingURL=align-right.js.map
30996
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/alignment-control/ui.js
30997
+
30998
+
30999
+
31000
+ /**
31001
+ * External dependencies
31002
+ */
31003
+
31004
+ /**
31005
+ * WordPress dependencies
31006
+ */
31007
+
31008
+
31009
+
31010
+
31011
+ const DEFAULT_ALIGNMENT_CONTROLS = [{
31012
+ icon: align_left,
31013
+ title: (0,external_wp_i18n_namespaceObject.__)('Align text left'),
31014
+ align: 'left'
31015
+ }, {
31016
+ icon: align_center,
31017
+ title: (0,external_wp_i18n_namespaceObject.__)('Align text center'),
31018
+ align: 'center'
31019
+ }, {
31020
+ icon: align_right,
31021
+ title: (0,external_wp_i18n_namespaceObject.__)('Align text right'),
31022
+ align: 'right'
31023
+ }];
31024
+ const ui_POPOVER_PROPS = {
31025
+ position: 'bottom right',
31026
+ isAlternate: true
31027
+ };
31028
+
31029
+ function AlignmentUI({
31030
+ value,
31031
+ onChange,
31032
+ alignmentControls = DEFAULT_ALIGNMENT_CONTROLS,
31033
+ label = (0,external_wp_i18n_namespaceObject.__)('Align'),
31034
+ describedBy = (0,external_wp_i18n_namespaceObject.__)('Change text alignment'),
31035
+ isCollapsed = true,
31036
+ isToolbar
31037
+ }) {
31038
+ function applyOrUnset(align) {
31039
+ return () => onChange(value === align ? undefined : align);
31040
  }
31041
 
31042
+ const activeAlignment = (0,external_lodash_namespaceObject.find)(alignmentControls, control => control.align === value);
31043
+
31044
+ function setIcon() {
31045
+ if (activeAlignment) return activeAlignment.icon;
31046
+ return (0,external_wp_i18n_namespaceObject.isRTL)() ? align_right : align_left;
31047
  }
31048
 
31049
+ const UIComponent = isToolbar ? external_wp_components_namespaceObject.ToolbarGroup : external_wp_components_namespaceObject.ToolbarDropdownMenu;
31050
+ const extraProps = isToolbar ? {
31051
+ isCollapsed
31052
+ } : {};
31053
+ return (0,external_wp_element_namespaceObject.createElement)(UIComponent, _extends({
31054
+ icon: setIcon(),
31055
+ label: label,
31056
+ toggleProps: {
31057
+ describedBy
31058
+ },
31059
+ popoverProps: ui_POPOVER_PROPS,
31060
+ controls: alignmentControls.map(control => {
31061
+ const {
31062
+ align
31063
+ } = control;
31064
+ const isActive = value === align;
31065
+ return { ...control,
31066
+ isActive,
31067
+ role: isCollapsed ? 'menuitemradio' : undefined,
31068
+ onClick: applyOrUnset(align)
31069
+ };
31070
+ })
31071
+ }, extraProps));
31072
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31073
 
31074
+ /* harmony default export */ var alignment_control_ui = (AlignmentUI);
31075
+ //# sourceMappingURL=ui.js.map
31076
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/alignment-control/index.js
31077
 
 
 
31078
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31079
 
31080
+ /**
31081
+ * Internal dependencies
31082
+ */
31083
+
31084
+ function AlignmentControl(props) {
31085
+ return (0,external_wp_element_namespaceObject.createElement)(alignment_control_ui, _extends({}, props, {
31086
+ isToolbar: false
31087
+ }));
31088
+ }
31089
+ function AlignmentToolbar(props) {
31090
+ return (0,external_wp_element_namespaceObject.createElement)(alignment_control_ui, _extends({}, props, {
31091
+ isToolbar: true
31092
+ }));
31093
+ }
31094
+ //# sourceMappingURL=index.js.map
31095
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/autocompleters/block.js
31096
+
31097
+
31098
+ /**
31099
+ * External dependencies
31100
+ */
31101
+
31102
+ /**
31103
+ * WordPress dependencies
31104
+ */
31105
+
31106
+
31107
+
31108
+
31109
+ /**
31110
+ * Internal dependencies
31111
+ */
31112
+
31113
+
31114
+
31115
+
31116
+
31117
+ const block_SHOWN_BLOCK_TYPES = 9;
31118
+ /** @typedef {import('@wordpress/components').WPCompleter} WPCompleter */
31119
+
31120
+ /**
31121
+ * Creates a blocks repeater for replacing the current block with a selected block type.
31122
+ *
31123
+ * @return {WPCompleter} A blocks completer.
31124
+ */
31125
+
31126
+ function createBlockCompleter() {
31127
+ return {
31128
+ name: 'blocks',
31129
+ className: 'block-editor-autocompleters__block',
31130
+ triggerPrefix: '/',
31131
+
31132
+ useItems(filterValue) {
31133
+ const {
31134
+ rootClientId,
31135
+ selectedBlockName
31136
+ } = (0,external_wp_data_namespaceObject.useSelect)(select => {
31137
+ const {
31138
+ getSelectedBlockClientId,
31139
+ getBlockName,
31140
+ getBlockInsertionPoint
31141
+ } = select(store);
31142
+ const selectedBlockClientId = getSelectedBlockClientId();
31143
+ return {
31144
+ selectedBlockName: selectedBlockClientId ? getBlockName(selectedBlockClientId) : null,
31145
+ rootClientId: getBlockInsertionPoint().rootClientId
31146
+ };
31147
+ }, []);
31148
+ const [items, categories, collections] = use_block_types_state(rootClientId, external_lodash_namespaceObject.noop);
31149
+ const filteredItems = (0,external_wp_element_namespaceObject.useMemo)(() => {
31150
+ const initialFilteredItems = !!filterValue.trim() ? searchBlockItems(items, categories, collections, filterValue) : (0,external_lodash_namespaceObject.orderBy)(items, ['frecency'], ['desc']);
31151
+ return initialFilteredItems.filter(item => item.name !== selectedBlockName).slice(0, block_SHOWN_BLOCK_TYPES);
31152
+ }, [filterValue, selectedBlockName, items, categories, collections]);
31153
+ const options = (0,external_wp_element_namespaceObject.useMemo)(() => filteredItems.map(blockItem => {
31154
+ const {
31155
+ title,
31156
+ icon,
31157
+ isDisabled
31158
+ } = blockItem;
31159
+ return {
31160
+ key: `block-${blockItem.id}`,
31161
+ value: blockItem,
31162
+ label: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(BlockIcon, {
31163
+ key: "icon",
31164
+ icon: icon,
31165
+ showColors: true
31166
+ }), title),
31167
+ isDisabled
31168
+ };
31169
+ }), [filteredItems]);
31170
+ return [options];
31171
+ },
31172
+
31173
+ allowContext(before, after) {
31174
+ return !(/\S/.test(before) || /\S/.test(after));
31175
+ },
31176
+
31177
+ getOptionCompletion(inserterItem) {
31178
+ const {
31179
+ name,
31180
+ initialAttributes,
31181
+ innerBlocks
31182
+ } = inserterItem;
31183
+ return {
31184
+ action: 'replace',
31185
+ value: (0,external_wp_blocks_namespaceObject.createBlock)(name, initialAttributes, (0,external_wp_blocks_namespaceObject.createBlocksFromInnerBlocksTemplate)(innerBlocks))
31186
  };
 
 
 
 
 
 
 
 
 
 
 
 
31187
  }
31188
 
31189
+ };
31190
+ }
31191
+ /**
31192
+ * Creates a blocks repeater for replacing the current block with a selected block type.
31193
+ *
31194
+ * @return {WPCompleter} A blocks completer.
31195
+ */
31196
+
31197
+
31198
+ /* harmony default export */ var autocompleters_block = (createBlockCompleter());
31199
+ //# sourceMappingURL=block.js.map
31200
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/autocomplete/index.js
31201
+
 
 
31202
 
 
 
31203
 
 
31204
  /**
31205
+ * External dependencies
31206
  */
31207
 
31208
+ /**
31209
+ * WordPress dependencies
31210
+ */
31211
 
 
 
 
 
 
 
31212
 
 
 
 
 
 
 
 
 
 
31213
 
31214
 
31215
 
31216
  /**
31217
+ * Internal dependencies
31218
  */
31219
 
31220
 
31221
+
31222
  /**
31223
+ * Shared reference to an empty array for cases where it is important to avoid
31224
+ * returning a new array reference on every invocation.
31225
+ *
31226
+ * @type {Array}
31227
  */
31228
 
31229
+ const autocomplete_EMPTY_ARRAY = [];
31230
 
31231
+ function useCompleters({
31232
+ completers = autocomplete_EMPTY_ARRAY
31233
+ }) {
31234
+ const {
31235
+ name
31236
+ } = useBlockEditContext();
31237
+ return (0,external_wp_element_namespaceObject.useMemo)(() => {
31238
+ let filteredCompleters = completers;
31239
 
31240
+ if (name === (0,external_wp_blocks_namespaceObject.getDefaultBlockName)()) {
31241
+ filteredCompleters = filteredCompleters.concat([autocompleters_block]);
31242
+ }
31243
 
31244
+ if ((0,external_wp_hooks_namespaceObject.hasFilter)('editor.Autocomplete.completers')) {
31245
+ // Provide copies so filters may directly modify them.
31246
+ if (filteredCompleters === completers) {
31247
+ filteredCompleters = filteredCompleters.map(external_lodash_namespaceObject.clone);
31248
+ }
31249
 
31250
+ filteredCompleters = (0,external_wp_hooks_namespaceObject.applyFilters)('editor.Autocomplete.completers', filteredCompleters, name);
31251
+ }
 
 
 
 
 
 
 
 
31252
 
31253
+ return filteredCompleters;
31254
+ }, [completers, name]);
31255
+ }
31256
 
31257
+ function useBlockEditorAutocompleteProps(props) {
31258
+ return (0,external_wp_components_namespaceObject.__unstableUseAutocompleteProps)({ ...props,
31259
+ completers: useCompleters(props)
31260
+ });
31261
+ }
31262
+ /**
31263
+ * Wrap the default Autocomplete component with one that supports a filter hook
31264
+ * for customizing its list of autocompleters.
31265
+ *
31266
+ * @type {import('react').FC}
31267
+ */
31268
 
31269
+ function BlockEditorAutocomplete(props) {
31270
+ return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Autocomplete, _extends({}, props, {
31271
+ completers: useCompleters(props)
31272
+ }));
31273
+ }
31274
+ /**
31275
+ * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/autocomplete/README.md
31276
+ */
31277
+
31278
+
31279
+ /* harmony default export */ var autocomplete = (BlockEditorAutocomplete);
31280
+ //# sourceMappingURL=index.js.map
31281
+ ;// CONCATENATED MODULE: ./packages/icons/build-module/library/fullscreen.js
 
 
 
 
31282
 
31283
 
31284
  /**
31285
  * WordPress dependencies
31286
  */
31287
 
31288
+ const fullscreen = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
31289
  xmlns: "http://www.w3.org/2000/svg",
31290
+ viewBox: "0 0 24 24"
31291
  }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
31292
+ d: "M4.2 9h1.5V5.8H9V4.2H4.2V9zm14 9.2H15v1.5h4.8V15h-1.5v3.2zM15 4.2v1.5h3.2V9h1.5V4.2H15zM5.8 15H4.2v4.8H9v-1.5H5.8V15z"
31293
  }));
31294
+ /* harmony default export */ var library_fullscreen = (fullscreen);
31295
+ //# sourceMappingURL=fullscreen.js.map
31296
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-full-height-alignment-control/index.js
31297
+
31298
+
31299
+ /**
31300
+ * WordPress dependencies
31301
+ */
31302
+
31303
+
31304
+
31305
+
31306
+ function BlockFullHeightAlignmentControl({
31307
+ isActive,
31308
+ label = (0,external_wp_i18n_namespaceObject.__)('Toggle full height'),
31309
+ onToggle,
31310
+ isDisabled
31311
+ }) {
31312
+ return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, {
31313
+ isActive: isActive,
31314
+ icon: library_fullscreen,
31315
+ label: label,
31316
+ onClick: () => onToggle(!isActive),
31317
+ disabled: isDisabled
31318
+ });
31319
+ }
31320
 
31321
+ /* harmony default export */ var block_full_height_alignment_control = (BlockFullHeightAlignmentControl);
31322
+ //# sourceMappingURL=index.js.map
31323
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-alignment-matrix-control/index.js
31324
 
31325
 
31326
  /**
31335
 
31336
 
31337
 
31338
+ function BlockAlignmentMatrixControl(props) {
31339
+ const {
31340
+ label = (0,external_wp_i18n_namespaceObject.__)('Change matrix alignment'),
31341
+ onChange = external_lodash_namespaceObject.noop,
31342
+ value = 'center',
31343
+ isDisabled
31344
+ } = props;
31345
+ const icon = (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalAlignmentMatrixControl.Icon, {
31346
+ value: value
31347
+ });
31348
+ const className = 'block-editor-block-alignment-matrix-control';
31349
+ const popoverClassName = `${className}__popover`;
31350
+ const isAlternate = true;
31351
+ return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Dropdown, {
31352
+ position: "bottom right",
31353
+ className: className,
31354
+ popoverProps: {
31355
+ className: popoverClassName,
31356
+ isAlternate
31357
+ },
31358
+ renderToggle: ({
31359
+ onToggle,
31360
+ isOpen
31361
+ }) => {
31362
+ const openOnArrowDown = event => {
31363
+ if (!isOpen && event.keyCode === external_wp_keycodes_namespaceObject.DOWN) {
31364
+ event.preventDefault();
31365
+ onToggle();
31366
+ }
31367
+ };
31368
+
31369
+ return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, {
31370
+ onClick: onToggle,
31371
+ "aria-haspopup": "true",
31372
+ "aria-expanded": isOpen,
31373
+ onKeyDown: openOnArrowDown,
31374
+ label: label,
31375
+ icon: icon,
31376
+ showTooltip: true,
31377
+ disabled: isDisabled
31378
+ });
31379
+ },
31380
+ renderContent: () => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalAlignmentMatrixControl, {
31381
+ hasFocusBorder: false,
31382
+ onChange: onChange,
31383
+ value: value
31384
  })
31385
+ });
31386
+ }
31387
+
31388
+ /* harmony default export */ var block_alignment_matrix_control = (BlockAlignmentMatrixControl);
31389
+ //# sourceMappingURL=index.js.map
31390
+ ;// CONCATENATED MODULE: ./packages/icons/build-module/library/chevron-right-small.js
31391
+
31392
+
 
 
 
 
 
 
 
 
 
 
 
 
31393
  /**
31394
  * WordPress dependencies
31395
  */
 
 
 
31396
 
31397
+ const chevronRightSmall = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
31398
+ xmlns: "http://www.w3.org/2000/svg",
31399
+ viewBox: "0 0 24 24"
31400
+ }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
31401
+ d: "M10.8622 8.04053L14.2805 12.0286L10.8622 16.0167L9.72327 15.0405L12.3049 12.0286L9.72327 9.01672L10.8622 8.04053Z"
31402
+ }));
31403
+ /* harmony default export */ var chevron_right_small = (chevronRightSmall);
31404
+ //# sourceMappingURL=chevron-right-small.js.map
31405
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-breadcrumb/index.js
31406
 
31407
 
31408
  /**
31410
  */
31411
 
31412
 
31413
+
31414
+
31415
  /**
31416
+ * Internal dependencies
31417
  */
31418
 
31419
 
31420
 
31421
  /**
31422
+ * Block breadcrumb component, displaying the hierarchy of the current block selection as a breadcrumb.
31423
+ *
31424
+ * @param {Object} props Component props.
31425
+ * @param {string} props.rootLabelText Translated label for the root element of the breadcrumb trail.
31426
+ * @return {WPElement} Block Breadcrumb.
31427
  */
31428
 
31429
+ function BlockBreadcrumb({
31430
+ rootLabelText
31431
+ }) {
31432
+ const {
31433
+ selectBlock,
31434
+ clearSelectedBlock
31435
+ } = (0,external_wp_data_namespaceObject.useDispatch)(store);
31436
+ const {
31437
+ clientId,
31438
+ parents,
31439
+ hasSelection
31440
+ } = (0,external_wp_data_namespaceObject.useSelect)(select => {
31441
+ const {
31442
+ getSelectionStart,
31443
+ getSelectedBlockClientId,
31444
+ getBlockParents
31445
+ } = select(store);
31446
+ const selectedBlockClientId = getSelectedBlockClientId();
31447
+ return {
31448
+ parents: getBlockParents(selectedBlockClientId),
31449
+ clientId: selectedBlockClientId,
31450
+ hasSelection: !!getSelectionStart().clientId
31451
+ };
31452
+ }, []);
31453
 
31454
+ const rootLabel = rootLabelText || (0,external_wp_i18n_namespaceObject.__)('Document');
31455
+ /*
31456
+ * Disable reason: The `list` ARIA role is redundant but
31457
+ * Safari+VoiceOver won't announce the list otherwise.
31458
+ */
31459
 
31460
+ /* eslint-disable jsx-a11y/no-redundant-roles */
31461
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31462
 
31463
+ return (0,external_wp_element_namespaceObject.createElement)("ul", {
31464
+ className: "block-editor-block-breadcrumb",
31465
+ role: "list",
31466
+ "aria-label": (0,external_wp_i18n_namespaceObject.__)('Block breadcrumb')
31467
+ }, (0,external_wp_element_namespaceObject.createElement)("li", {
31468
+ className: !hasSelection ? 'block-editor-block-breadcrumb__current' : undefined,
31469
+ "aria-current": !hasSelection ? 'true' : undefined
31470
+ }, hasSelection && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
31471
+ className: "block-editor-block-breadcrumb__button",
31472
+ variant: "tertiary",
31473
+ onClick: clearSelectedBlock
31474
+ }, rootLabel), !hasSelection && rootLabel, !!clientId && (0,external_wp_element_namespaceObject.createElement)(icon, {
31475
+ icon: chevron_right_small,
31476
+ className: "block-editor-block-breadcrumb__separator"
31477
+ })), parents.map(parentClientId => (0,external_wp_element_namespaceObject.createElement)("li", {
31478
+ key: parentClientId
31479
+ }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
31480
+ className: "block-editor-block-breadcrumb__button",
31481
+ variant: "tertiary",
31482
+ onClick: () => selectBlock(parentClientId)
31483
+ }, (0,external_wp_element_namespaceObject.createElement)(BlockTitle, {
31484
+ clientId: parentClientId
31485
+ })), (0,external_wp_element_namespaceObject.createElement)(icon, {
31486
+ icon: chevron_right_small,
31487
+ className: "block-editor-block-breadcrumb__separator"
31488
+ }))), !!clientId && (0,external_wp_element_namespaceObject.createElement)("li", {
31489
+ className: "block-editor-block-breadcrumb__current",
31490
+ "aria-current": "true"
31491
+ }, (0,external_wp_element_namespaceObject.createElement)(BlockTitle, {
31492
+ clientId: clientId
31493
+ })))
31494
+ /* eslint-enable jsx-a11y/no-redundant-roles */
31495
+ ;
31496
+ }
31497
 
31498
+ /* harmony default export */ var block_breadcrumb = (BlockBreadcrumb);
31499
+ //# sourceMappingURL=index.js.map
31500
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/block-content-overlay/index.js
 
 
 
31501
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31502
 
31503
 
31504
+ /**
31505
+ * WordPress dependencies
31506
+ */
31507
+
31508
+
31509
+ /**
31510
+ * Internal dependencies
31511
+ */
31512
+
31513
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31514
  /**
31515
  * External dependencies
31516
  */
31517
 
 
 
 
31518
 
31519
+ function BlockContentOverlay({
31520
+ clientId,
31521
+ tagName: TagName = 'div',
31522
+ wrapperProps,
31523
+ className
31524
+ }) {
31525
+ const baseClassName = 'block-editor-block-content-overlay';
31526
+ const [isOverlayActive, setIsOverlayActive] = (0,external_wp_element_namespaceObject.useState)(true);
31527
+ const [isHovered, setIsHovered] = (0,external_wp_element_namespaceObject.useState)(false);
31528
+ const {
31529
+ isParentSelected,
31530
+ hasChildSelected,
31531
+ isDraggingBlocks,
31532
+ isParentHighlighted
31533
+ } = (0,external_wp_data_namespaceObject.useSelect)(select => {
31534
+ const {
31535
+ isBlockSelected,
31536
+ hasSelectedInnerBlock,
31537
+ isDraggingBlocks: _isDraggingBlocks,
31538
+ isBlockHighlighted
31539
+ } = select(store);
31540
+ return {
31541
+ isParentSelected: isBlockSelected(clientId),
31542
+ hasChildSelected: hasSelectedInnerBlock(clientId, true),
31543
+ isDraggingBlocks: _isDraggingBlocks(),
31544
+ isParentHighlighted: isBlockHighlighted(clientId)
31545
+ };
31546
+ }, [clientId]);
31547
+ const classes = classnames_default()(baseClassName, wrapperProps === null || wrapperProps === void 0 ? void 0 : wrapperProps.className, className, {
31548
+ 'overlay-active': isOverlayActive,
31549
+ 'parent-highlighted': isParentHighlighted,
31550
+ 'is-dragging-blocks': isDraggingBlocks
31551
+ });
31552
+ (0,external_wp_element_namespaceObject.useEffect)(() => {
31553
+ // Reenable when blocks are not in use.
31554
+ if (!isParentSelected && !hasChildSelected && !isOverlayActive) {
31555
+ setIsOverlayActive(true);
31556
+ } // Disable if parent selected by another means (such as list view).
31557
+ // We check hover to ensure the overlay click interaction is not taking place.
31558
+ // Trying to click the overlay will select the parent block via its 'focusin'
31559
+ // listener on the wrapper, so if the block is selected while hovered we will
31560
+ // let the mouseup disable the overlay instead.
31561
+
31562
+
31563
+ if (isParentSelected && !isHovered && isOverlayActive) {
31564
+ setIsOverlayActive(false);
31565
+ } // Ensure overlay is disabled if a child block is selected.
31566
+
31567
+
31568
+ if (hasChildSelected && isOverlayActive) {
31569
+ setIsOverlayActive(false);
31570
+ }
31571
+ }, [isParentSelected, hasChildSelected, isOverlayActive, isHovered]); // Disabled because the overlay div doesn't actually have a role or functionality
31572
+ // as far as the a11y is concerned. We're just catching the first click so that
31573
+ // the block can be selected without interacting with its contents.
31574
 
31575
+ /* eslint-disable jsx-a11y/no-static-element-interactions */
 
 
 
 
 
 
 
 
 
 
31576
 
31577
+ return (0,external_wp_element_namespaceObject.createElement)(TagName, _extends({}, wrapperProps, {
31578
+ className: classes,
31579
+ onMouseEnter: () => setIsHovered(true),
31580
+ onMouseLeave: () => setIsHovered(false),
31581
+ onMouseUp: isOverlayActive ? () => setIsOverlayActive(false) : undefined
31582
+ }), wrapperProps === null || wrapperProps === void 0 ? void 0 : wrapperProps.children);
31583
  }
31584
+ /* eslint-enable jsx-a11y/no-static-element-interactions */
31585
+ //# sourceMappingURL=index.js.map
31586
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/color-style-selector/index.js
31587
+
31588
+
31589
  /**
31590
  * WordPress dependencies
31591
  */
31592
 
31593
 
31594
 
31595
+
31596
+ const ColorSelectorSVGIcon = () => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SVG, {
31597
+ xmlns: "https://www.w3.org/2000/svg",
31598
+ viewBox: "0 0 20 20"
31599
+ }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Path, {
31600
+ d: "M7.434 5l3.18 9.16H8.538l-.692-2.184H4.628l-.705 2.184H2L5.18 5h2.254zm-1.13 1.904h-.115l-1.148 3.593H7.44L6.304 6.904zM14.348 7.006c1.853 0 2.9.876 2.9 2.374v4.78h-1.79v-.914h-.114c-.362.64-1.123 1.022-2.031 1.022-1.346 0-2.292-.826-2.292-2.108 0-1.27.972-2.006 2.71-2.107l1.696-.102V9.38c0-.584-.42-.914-1.18-.914-.667 0-1.112.228-1.264.647h-1.701c.12-1.295 1.307-2.107 3.066-2.107zm1.079 4.1l-1.416.09c-.793.056-1.18.342-1.18.844 0 .52.45.837 1.091.837.857 0 1.505-.545 1.505-1.256v-.515z"
31601
+ }));
31602
  /**
31603
+ * Color Selector Icon component.
31604
+ *
31605
+ * @param {Object} props Component properties.
31606
+ * @param {Object} props.style Style object.
31607
+ * @param {string} props.className Class name for component.
31608
+ *
31609
+ * @return {*} React Icon component.
31610
  */
31611
 
31612
 
31613
+ const ColorSelectorIcon = ({
31614
+ style,
31615
+ className
31616
+ }) => {
31617
+ return (0,external_wp_element_namespaceObject.createElement)("div", {
31618
+ className: "block-library-colors-selector__icon-container"
31619
+ }, (0,external_wp_element_namespaceObject.createElement)("div", {
31620
+ className: `${className} block-library-colors-selector__state-selection`,
31621
+ style: style
31622
+ }, (0,external_wp_element_namespaceObject.createElement)(ColorSelectorSVGIcon, null)));
31623
+ };
31624
  /**
31625
+ * Renders the Colors Selector Toolbar with the icon button.
31626
+ *
31627
+ * @param {Object} props Component properties.
31628
+ * @param {Object} props.TextColor Text color component that wraps icon.
31629
+ * @param {Object} props.BackgroundColor Background color component that wraps icon.
31630
+ *
31631
+ * @return {*} React toggle button component.
31632
  */
31633
 
31634
 
31635
+ const renderToggleComponent = ({
31636
+ TextColor,
31637
+ BackgroundColor
31638
+ }) => ({
31639
+ onToggle,
31640
+ isOpen
31641
+ }) => {
31642
+ const openOnArrowDown = event => {
31643
+ if (!isOpen && event.keyCode === external_wp_keycodes_namespaceObject.DOWN) {
31644
+ event.preventDefault();
31645
+ onToggle();
31646
+ }
31647
+ };
31648
 
31649
+ return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarGroup, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, {
31650
+ className: "components-toolbar__control block-library-colors-selector__toggle",
31651
+ label: (0,external_wp_i18n_namespaceObject.__)('Open Colors Selector'),
31652
+ onClick: onToggle,
31653
+ onKeyDown: openOnArrowDown,
31654
+ icon: (0,external_wp_element_namespaceObject.createElement)(BackgroundColor, null, (0,external_wp_element_namespaceObject.createElement)(TextColor, null, (0,external_wp_element_namespaceObject.createElement)(ColorSelectorIcon, null)))
31655
+ }));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31656
  };
31657
 
31658
+ const BlockColorsStyleSelector = ({
31659
+ children,
31660
+ ...other
31661
+ }) => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Dropdown, {
31662
+ position: "bottom right",
31663
+ className: "block-library-colors-selector",
31664
+ contentClassName: "block-library-colors-selector__popover",
31665
+ renderToggle: renderToggleComponent(other),
31666
+ renderContent: () => children
31667
+ });
 
 
 
 
31668
 
31669
+ /* harmony default export */ var color_style_selector = (BlockColorsStyleSelector);
31670
+ //# sourceMappingURL=index.js.map
31671
+ ;// CONCATENATED MODULE: ./packages/icons/build-module/library/list-view.js
31672
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31673
 
31674
+ /**
31675
+ * WordPress dependencies
31676
+ */
31677
 
31678
+ const listView = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
31679
+ viewBox: "0 0 24 24",
31680
+ xmlns: "http://www.w3.org/2000/svg"
31681
+ }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
31682
+ d: "M13.8 5.2H3v1.5h10.8V5.2zm-3.6 12v1.5H21v-1.5H10.2zm7.2-6H6.6v1.5h10.8v-1.5z"
31683
+ }));
31684
+ /* harmony default export */ var list_view = (listView);
31685
+ //# sourceMappingURL=list-view.js.map
31686
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/list-view/leaf.js
 
 
31687
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31688
 
31689
 
31690
  /**
31691
  * External dependencies
31692
  */
31693
 
31694
+
31695
  /**
31696
  * WordPress dependencies
31697
  */
31698
 
31699
 
 
 
31700
  /**
31701
  * Internal dependencies
31702
  */
31703
 
31704
 
31705
+ const AnimatedTreeGridRow = (0,web_cjs/* animated */.q)(external_wp_components_namespaceObject.__experimentalTreeGridRow);
31706
+ function ListViewLeaf({
31707
+ isSelected,
31708
+ position,
31709
+ level,
31710
+ rowCount,
 
 
 
 
31711
  children,
31712
+ className,
31713
+ path,
31714
+ ...props
31715
+ }) {
31716
+ const ref = use_moving_animation({
31717
+ isSelected,
31718
+ adjustScrolling: false,
31719
+ enableAnimation: true,
31720
+ triggerAnimationOnChange: path.join('_')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31721
  });
31722
+ return (0,external_wp_element_namespaceObject.createElement)(AnimatedTreeGridRow, _extends({
31723
+ ref: ref,
31724
+ className: classnames_default()('block-editor-list-view-leaf', className),
31725
+ level: level,
31726
+ positionInSet: position,
31727
+ setSize: rowCount
31728
+ }, props), children);
31729
+ }
31730
+ //# sourceMappingURL=leaf.js.map
31731
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/list-view/context.js
31732
+ /**
31733
+ * WordPress dependencies
31734
+ */
31735
 
31736
+ const ListViewContext = (0,external_wp_element_namespaceObject.createContext)({
31737
+ __experimentalFeatures: false,
31738
+ __experimentalPersistentListViewFeatures: false
31739
+ });
31740
+ const useListViewContext = () => (0,external_wp_element_namespaceObject.useContext)(ListViewContext);
31741
+ //# sourceMappingURL=context.js.map
31742
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/list-view/utils.js
31743
+ /**
31744
+ * External dependencies
31745
+ */
31746
 
31747
+ /**
31748
+ * WordPress dependencies
31749
+ */
 
31750
 
 
31751
 
31752
+ const getBlockPositionDescription = (position, siblingCount, level) => (0,external_wp_i18n_namespaceObject.sprintf)(
31753
+ /* translators: 1: The numerical position of the block. 2: The total number of blocks. 3. The level of nesting for the block. */
31754
+ (0,external_wp_i18n_namespaceObject.__)('Block %1$d of %2$d, Level %3$d'), position, siblingCount, level);
31755
+ /**
31756
+ * Returns true if the client ID occurs within the block selection or multi-selection,
31757
+ * or false otherwise.
31758
+ *
31759
+ * @param {string} clientId Block client ID.
31760
+ * @param {string|string[]} selectedBlockClientIds Selected block client ID, or an array of multi-selected blocks client IDs.
31761
+ *
31762
+ * @return {boolean} Whether the block is in multi-selection set.
31763
+ */
31764
 
31765
+ const isClientIdSelected = (clientId, selectedBlockClientIds) => (0,external_lodash_namespaceObject.isArray)(selectedBlockClientIds) && selectedBlockClientIds.length ? selectedBlockClientIds.indexOf(clientId) !== -1 : selectedBlockClientIds === clientId;
31766
+ //# sourceMappingURL=utils.js.map
31767
+ ;// CONCATENATED MODULE: ./packages/block-editor/build-module/components/list-view/expander.js
31768
 
 
 
 
 
 
 
 
31769
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31770
  /**
31771
  * WordPress dependencies
31772
  */
31773
 
31774
+ function ListViewExpander({
31775
+ onClick
31776
+ }) {
31777
+ return (// Keyboard events are handled by TreeGrid see: components/src/tree-grid/index.js
31778
+ //
31779
+ // The expander component is implemented as a pseudo element in the w3 example
31780
+ // https://www.w3.org/TR/wai-aria-practices/examples/treegrid/treegrid-1.html
31781
+ //
31782
+ // We've mimicked this by adding an icon with aria-hidden set to true to hide this from the accessibility tree.
31783
+ // For the current tree grid implementation, please do not try to make this a button.
31784
+ //
31785
+ // eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions
31786
+ (0,external_wp_element_namespaceObject.createElement)("span", {
31787
+ className: "block-editor-list-view__expander",
31788
+ onClick: event => onClick(event, {
31789
+ forceToggle: true
31790
+ }),
31791
+ "aria-hidden": "true"
31792
+ }, (0,external_wp_element_namespaceObject.createElement)(icon, {
31793
+ i