mirror of
https://github.com/WordPress/WordPress.git
synced 2024-11-10 12:50:18 +01:00
a41c798835
In addition to all the packages being updated to the latest versions, this commit also includes some mandatory changes to avoid editor breakage: - Update React to to 18.2.0. - Add the right stylesheets to support iframed block editors. Props ntsekouras, mamaduka, flixos90, desrosj, peterwilsoncc. See #57471. Built from https://develop.svn.wordpress.org/trunk@55246 git-svn-id: http://core.svn.wordpress.org/trunk@54779 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2 lines
21 KiB
JavaScript
2 lines
21 KiB
JavaScript
/*! This file is auto-generated */
|
||
!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 G}});var l={};e.r(l),e.d(l,{getDownloadableBlocks:function(){return k},getErrorNoticeForBlock:function(){return h},getErrorNotices:function(){return E},getInstalledBlockTypes:function(){return g},getNewBlockTypes:function(){return f},getUnusedBlockTypes:function(){return _},isInstalling:function(){return w},isRequestingDownloadableBlocks:function(){return b}});var n={};e.r(n),e.d(n,{addInstalledBlockType:function(){return D},clearErrorNotice:function(){return x},fetchDownloadableBlocks:function(){return S},installBlockType:function(){return C},receiveDownloadableBlocks:function(){return O},removeInstalledBlockType:function(){return R},setErrorNotice:function(){return M},setIsInstalling:function(){return P},uninstallBlockType:function(){return A}});var r={};e.r(r),e.d(r,{getDownloadableBlocks:function(){return Y}});var o=window.wp.element,a=window.wp.plugins,i=window.wp.hooks,c=window.wp.blocks,s=window.wp.data,d=window.wp.editor;var u=(0,s.combineReducers)({downloadableBlocks:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;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:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{installedBlockTypes:[],isInstalling:{}},t=arguments.length>1?arguments[1]:void 0;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:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;switch(t.type){case"SET_ERROR_NOTICE":return{...e,[t.blockId]:{message:t.message,isFatal:t.isFatal}};case"CLEAR_ERROR_NOTICE":const{[t.blockId]:l,...n}=e;return n}return e}}),m=window.wp.blockEditor;function p(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];if(!t.length)return!1;if(t.some((t=>{let{name:l}=t;return l===e.name})))return!0;for(let l=0;l<t.length;l++)if(p(e,t[l].innerBlocks))return!0;return!1}function b(e,t){var l,n;return null!==(l=null===(n=e.downloadableBlocks[t])||void 0===n?void 0:n.isRequesting)&&void 0!==l&&l}function k(e,t){var l,n;return null!==(l=null===(n=e.downloadableBlocks[t])||void 0===n?void 0:n.results)&&void 0!==l?l:[]}function g(e){return e.blockManagement.installedBlockTypes}const f=(0,s.createRegistrySelector)((e=>t=>{const l=e(m.store).getBlocks();return g(t).filter((e=>p(e,l)))})),_=(0,s.createRegistrySelector)((e=>t=>{const l=e(m.store).getBlocks();return g(t).filter((e=>!p(e,l)))}));function w(e,t){return e.blockManagement.isInstalling[t]||!1}function E(e){return e.errorNotices}function h(e,t){return e.errorNotices[t]}var y=window.wp.i18n,v=window.wp.apiFetch,B=e.n(v),I=window.wp.notices,N=window.wp.url;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()}));function L(e){if(!e)return!1;const t=e.links["wp:plugin"]||e.links.self;return!(!t||!t.length)&&t[0].href}function S(e){return{type:"FETCH_DOWNLOADABLE_BLOCKS",filterValue:e}}function O(e,t){return{type:"RECEIVE_DOWNLOADABLE_BLOCKS",downloadableBlocks:e,filterValue:t}}const C=e=>async t=>{let{registry:l,dispatch:n}=t;const{id:r,name:o}=e;let a=!1;n.clearErrorNotice(r);try{n.setIsInstalling(r,!0);const t=L(e);let i={};if(t)await B()({method:"PUT",url:t,data:{status:"active"}});else{i=(await B()({method:"POST",path:"wp/v2/plugins",data:{slug:r,status:"active"}}))._links}n.addInstalledBlockType({...e,links:{...e.links,...i}});const s=["api_version","title","category","parent","icon","description","keywords","attributes","provides_context","uses_context","supports","styles","example","variations"];await B()({path:(0,N.addQueryArgs)(`/wp/v2/block-types/${o}`,{_fields:s})}).catch((()=>{})).then((e=>{e&&(0,c.unstable__bootstrapServerSideBlockDefinitions)({[o]:Object.fromEntries(Object.entries(e).filter((e=>{let[t]=e;return s.includes(t)})))})})),await async function(){const e=await B()({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)}();if(!l.select(c.store).getBlockTypes().some((e=>e.name===o)))throw new Error((0,y.__)("Error registering block. Try reloading the page."));l.dispatch(I.store).createInfoNotice((0,y.sprintf)((0,y.__)("Block %s installed and added."),e.title),{speak:!0,type:"snackbar"}),a=!0}catch(e){let t=e.message||(0,y.__)("An error occurred."),o=e instanceof Error;const a={folder_exists:(0,y.__)("This block is already installed. Try reloading the page."),unable_to_connect_to_filesystem:(0,y.__)("Error installing block. You can reload the page and try again.")};a[e.code]&&(o=!0,t=a[e.code]),n.setErrorNotice(r,t,o),l.dispatch(I.store).createErrorNotice(t,{speak:!0,isDismissible:!0})}return n.setIsInstalling(r,!1),a},A=e=>async t=>{let{registry:l,dispatch:n}=t;try{const t=L(e);await B()({method:"PUT",url:t,data:{status:"inactive"}}),await B()({method:"DELETE",url:t}),n.removeInstalledBlockType(e)}catch(e){l.dispatch(I.store).createErrorNotice(e.message||(0,y.__)("An error occurred."))}};function D(e){return{type:"ADD_INSTALLED_BLOCK_TYPE",item:e}}function R(e){return{type:"REMOVE_INSTALLED_BLOCK_TYPE",item:e}}function P(e,t){return{type:"SET_INSTALLING_BLOCK",blockId:e,isInstalling:t}}function M(e,t){let l=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return{type:"SET_ERROR_NOTICE",blockId:e,message:t,isFatal:l}}function x(e){return{type:"CLEAR_ERROR_NOTICE",blockId:e}}var F=function(){return F=Object.assign||function(e){for(var t,l=1,n=arguments.length;l<n;l++)for(var r in t=arguments[l])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},F.apply(this,arguments)};Object.create;Object.create;function j(e){return e.toLowerCase()}var V=[/([a-z0-9])([A-Z])/g,/([A-Z])([A-Z][a-z])/g],H=/[^A-Z0-9]+/gi;function $(e,t,l){return t instanceof RegExp?e.replace(t,l):t.reduce((function(e,t){return e.replace(t,l)}),e)}function z(e,t){var l=e.charAt(0),n=e.substr(1).toLowerCase();return t>0&&l>="0"&&l<="9"?"_"+l+n:""+l.toUpperCase()+n}function K(e,t){return void 0===t&&(t={}),function(e,t){void 0===t&&(t={});for(var l=t.splitRegexp,n=void 0===l?V:l,r=t.stripRegexp,o=void 0===r?H:r,a=t.transform,i=void 0===a?j:a,c=t.delimiter,s=void 0===c?" ":c,d=$($(e,n,"$1\0$2"),o,"\0"),u=0,m=d.length;"\0"===d.charAt(u);)u++;for(;"\0"===d.charAt(m-1);)m--;return d.slice(u,m).split("\0").map(i).join(s)}(e,F({delimiter:"",transform:z},t))}function U(e,t){return 0===t?e.toLowerCase():z(e,t)}const Y=e=>async t=>{let{dispatch:l}=t;if(e)try{l(S(e));const t=await B()({path:`wp/v2/block-directory/search?term=${e}`});l(O(t.map((e=>Object.fromEntries(Object.entries(e).map((e=>{let[t,l]=e;return[(n=t,void 0===r&&(r={}),K(n,F({transform:U},r))),l];var n,r}))))),e))}catch{}},q={reducer:u,selectors:l,actions:n,resolvers:r},G=(0,s.createReduxStore)("core/block-directory",q);function W(){const{uninstallBlockType:e}=(0,s.useDispatch)(G),t=(0,s.useSelect)((e=>{const{isAutosavingPost:t,isSavingPost:l}=e(d.store);return l()&&!t()}),[]),l=(0,s.useSelect)((e=>e(G).getUnusedBlockTypes()),[]);return(0,o.useEffect)((()=>{t&&l.length&&l.forEach((t=>{e(t),(0,c.unregisterBlockType)(t.name)}))}),[t]),null}(0,s.register)(G);var Z=window.wp.compose,Q=window.wp.components,J=window.wp.coreData;function X(){return X=Object.assign?Object.assign.bind():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},X.apply(this,arguments)}var ee=window.wp.htmlEntities;var te=function(e){let{icon:t,size:l=24,...n}=e;return(0,o.cloneElement)(t,{width:l,height:l,...n})},le=window.wp.primitives;var ne=(0,o.createElement)(le.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,o.createElement)(le.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"}));var re=(0,o.createElement)(le.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,o.createElement)(le.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"}));var oe=(0,o.createElement)(le.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,o.createElement)(le.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"}));var ae=function(e){let{rating:t}=e;const l=.5*Math.round(t/.5),n=Math.floor(t),r=Math.ceil(t-n),a=5-(n+r);return(0,o.createElement)("span",{"aria-label":(0,y.sprintf)((0,y.__)("%s out of 5 stars"),l)},Array.from({length:n}).map(((e,t)=>(0,o.createElement)(te,{key:`full_stars_${t}`,className:"block-directory-block-ratings__star-full",icon:ne,size:16}))),Array.from({length:r}).map(((e,t)=>(0,o.createElement)(te,{key:`half_stars_${t}`,className:"block-directory-block-ratings__star-half-full",icon:re,size:16}))),Array.from({length:a}).map(((e,t)=>(0,o.createElement)(te,{key:`empty_stars_${t}`,className:"block-directory-block-ratings__star-empty",icon:oe,size:16}))))};var ie=e=>{let{rating:t}=e;return(0,o.createElement)("span",{className:"block-directory-block-ratings"},(0,o.createElement)(ae,{rating:t}))};var ce=function(e){let{icon:t}=e;const l="block-directory-downloadable-block-icon";return null!==t.match(/\.(jpeg|jpg|gif|png|svg)(?:\?.*)?$/)?(0,o.createElement)("img",{className:l,src:t,alt:""}):(0,o.createElement)(m.BlockIcon,{className:l,icon:t,showColors:!0})};var se=e=>{let{block:t}=e;const l=(0,s.useSelect)((e=>e(G).getErrorNoticeForBlock(t.id)),[t]);return l?(0,o.createElement)("div",{className:"block-directory-downloadable-block-notice"},(0,o.createElement)("div",{className:"block-directory-downloadable-block-notice__content"},l.message,l.isFatal?" "+(0,y.__)("Try reloading the page."):null)):null};function de(e,t){let{title:l,rating:n,ratingCount:r}=e,{hasNotice:o,isInstalled:a,isInstalling:i}=t;const c=.5*Math.round(n/.5);return!a&&o?(0,y.sprintf)("Retry installing %s.",(0,ee.decodeEntities)(l)):a?(0,y.sprintf)("Add %s.",(0,ee.decodeEntities)(l)):i?(0,y.sprintf)("Installing %s.",(0,ee.decodeEntities)(l)):r<1?(0,y.sprintf)("Install %s.",(0,ee.decodeEntities)(l)):(0,y.sprintf)((0,y._n)("Install %1$s. %2$s stars with %3$s review.","Install %1$s. %2$s stars with %3$s reviews.",r),(0,ee.decodeEntities)(l),c,r)}var ue=function(e){let{composite:t,item:l,onClick:n}=e;const{author:r,description:a,icon:i,rating:d,title:u}=l,m=!!(0,c.getBlockType)(l.name),{hasNotice:p,isInstalling:b,isInstallable:k}=(0,s.useSelect)((e=>{const{getErrorNoticeForBlock:t,isInstalling:n}=e(G),r=t(l.id),o=r&&r.isFatal;return{hasNotice:!!r,isInstalling:n(l.id),isInstallable:!o}}),[l]);let g="";return m?g=(0,y.__)("Installed!"):b&&(g=(0,y.__)("Installing…")),(0,o.createElement)(Q.__unstableCompositeItem,X({__experimentalIsFocusable:!0,role:"option",as:Q.Button},t,{className:"block-directory-downloadable-block-list-item",onClick:e=>{e.preventDefault(),n()},isBusy:b,disabled:b||!k,label:de(l,{hasNotice:p,isInstalled:m,isInstalling:b}),showTooltip:!0,tooltipPosition:"top center"}),(0,o.createElement)("div",{className:"block-directory-downloadable-block-list-item__icon"},(0,o.createElement)(ce,{icon:i,title:u}),b?(0,o.createElement)("span",{className:"block-directory-downloadable-block-list-item__spinner"},(0,o.createElement)(Q.Spinner,null)):(0,o.createElement)(ie,{rating:d})),(0,o.createElement)("span",{className:"block-directory-downloadable-block-list-item__details"},(0,o.createElement)("span",{className:"block-directory-downloadable-block-list-item__title"},(0,o.createInterpolateElement)((0,y.sprintf)((0,y.__)("%1$s <span>by %2$s</span>"),(0,ee.decodeEntities)(u),r),{span:(0,o.createElement)("span",{className:"block-directory-downloadable-block-list-item__author"})})),p?(0,o.createElement)(se,{block:l}):(0,o.createElement)(o.Fragment,null,(0,o.createElement)("span",{className:"block-directory-downloadable-block-list-item__desc"},g||(0,ee.decodeEntities)(a)),k&&!(m||b)&&(0,o.createElement)(Q.VisuallyHidden,null,(0,y.__)("Install block")))))};const me=()=>{};var pe=function(e){let{items:t,onHover:l=me,onSelect:n}=e;const r=(0,Q.__unstableUseCompositeState)(),{installBlockType:a}=(0,s.useDispatch)(G);return t.length?(0,o.createElement)(Q.__unstableComposite,X({},r,{role:"listbox",className:"block-directory-downloadable-blocks-list","aria-label":(0,y.__)("Blocks available for install")}),t.map((e=>(0,o.createElement)(ue,{key:e.id,composite:r,onClick:()=>{(0,c.getBlockType)(e.name)?n(e):a(e).then((t=>{t&&n(e)})),l(null)},onHover:l,item:e})))):null},be=window.wp.a11y;var ke=function(e){let{children:t,downloadableItems:l,hasLocalBlocks:n}=e;const r=l.length;return(0,o.useEffect)((()=>{(0,be.speak)((0,y.sprintf)((0,y._n)("%d additional block is available to install.","%d additional blocks are available to install.",r),r))}),[r]),(0,o.createElement)(o.Fragment,null,!n&&(0,o.createElement)("p",{className:"block-directory-downloadable-blocks-panel__no-local"},(0,y.__)("No results available from your installed blocks.")),(0,o.createElement)("div",{className:"block-editor-inserter__quick-inserter-separator"}),(0,o.createElement)("div",{className:"block-directory-downloadable-blocks-panel"},(0,o.createElement)("div",{className:"block-directory-downloadable-blocks-panel__header"},(0,o.createElement)("h2",{className:"block-directory-downloadable-blocks-panel__title"},(0,y.__)("Available to install")),(0,o.createElement)("p",{className:"block-directory-downloadable-blocks-panel__description"},(0,y.__)("Select a block to install and add it to your post."))),t))};var ge=(0,o.createElement)(le.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,o.createElement)(le.Path,{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"}));var fe=function(){return(0,o.createElement)(o.Fragment,null,(0,o.createElement)("div",{className:"block-editor-inserter__no-results"},(0,o.createElement)(te,{className:"block-editor-inserter__no-results-icon",icon:ge}),(0,o.createElement)("p",null,(0,y.__)("No results found."))),(0,o.createElement)("div",{className:"block-editor-inserter__tips"},(0,o.createElement)(Q.Tip,null,(0,y.__)("Interested in creating your own block?"),(0,o.createElement)("br",null),(0,o.createElement)(Q.ExternalLink,{href:"https://developer.wordpress.org/block-editor/"},(0,y.__)("Get started here"),"."))))};var _e=(0,Z.compose)([(0,s.withSelect)(((e,t)=>{let{filterValue:l,rootClientId:n=null}=t;const{getDownloadableBlocks:r,isRequestingDownloadableBlocks:o}=e(G),{canInsertBlockType:a}=e(m.store),i=e(J.store).canUser("read","block-directory/search");return{downloadableItems:i?r(l).filter((e=>a(e,n,!0))):[],hasPermission:i,isLoading:o(l)}}))])((function(e){let{downloadableItems:t,onSelect:l,onHover:n,hasLocalBlocks:r,hasPermission:a,isLoading:i,isTyping:c}=e;return void 0===a||i||c?(0,o.createElement)(o.Fragment,null,a&&!r&&(0,o.createElement)(o.Fragment,null,(0,o.createElement)("p",{className:"block-directory-downloadable-blocks-panel__no-local"},(0,y.__)("No results available from your installed blocks.")),(0,o.createElement)("div",{className:"block-editor-inserter__quick-inserter-separator"})),(0,o.createElement)("div",{className:"block-directory-downloadable-blocks-panel has-blocks-loading"},(0,o.createElement)(Q.Spinner,null))):!1===a?r?null:(0,o.createElement)(fe,null):t.length?(0,o.createElement)(ke,{downloadableItems:t,hasLocalBlocks:r},(0,o.createElement)(pe,{items:t,onSelect:l,onHover:n})):!r&&(0,o.createElement)(fe,null)}));var we,Ee,he,ye=function(){const[e,t]=(0,o.useState)(""),l=(0,Z.debounce)(t,400);return(0,o.createElement)(m.__unstableInserterMenuExtension,null,(t=>{let{onSelect:n,onHover:r,filterValue:a,hasItems:i,rootClientId:c}=t;return e!==a&&l(a),e?(0,o.createElement)(_e,{onSelect:n,onHover:r,rootClientId:c,filterValue:e,hasLocalBlocks:i,isTyping:a!==e}):null}))};function ve(e){let{items:t}=e;return t.length?(0,o.createElement)("ul",{className:"block-directory-compact-list"},t.map((e=>{let{icon:t,id:l,title:n,author:r}=e;return(0,o.createElement)("li",{key:l,className:"block-directory-compact-list__item"},(0,o.createElement)(ce,{icon:t,title:n}),(0,o.createElement)("div",{className:"block-directory-compact-list__item-details"},(0,o.createElement)("div",{className:"block-directory-compact-list__item-title"},n),(0,o.createElement)("div",{className:"block-directory-compact-list__item-author"},(0,y.sprintf)((0,y.__)("By %s"),r))))}))):null}const{PluginPrePublishPanel:Be}=null!==(we=null===(Ee=window)||void 0===Ee||null===(he=Ee.wp)||void 0===he?void 0:he.editPost)&&void 0!==we?we:{};function Ie(){const e=(0,s.useSelect)((e=>e(G).getNewBlockTypes()),[]);return e.length?(0,o.createElement)(Be,{icon:ge,title:(0,y.sprintf)((0,y._n)("Added: %d block","Added: %d blocks",e.length),e.length),initialOpen:!0},(0,o.createElement)("p",{className:"installed-blocks-pre-publish-panel__copy"},(0,y._n)("The following block has been added to your site.","The following blocks have been added to your site.",e.length)),(0,o.createElement)(ve,{items:e})):null}function Ne(e){let{attributes:t,block:l,clientId:n}=e;const r=(0,s.useSelect)((e=>e(G).isInstalling(l.id)),[l.id]),{installBlockType:a}=(0,s.useDispatch)(G),{replaceBlock:i}=(0,s.useDispatch)(m.store);return(0,o.createElement)(Q.Button,{onClick:()=>a(l).then((e=>{if(e){const e=(0,c.getBlockType)(l.name),[r]=(0,c.parse)(t.originalContent);r&&e&&i(n,(0,c.createBlock)(e.name,r.attributes,r.innerBlocks))}})),disabled:r,isBusy:r,variant:"primary"},(0,y.sprintf)((0,y.__)("Install %s"),l.title))}const Te=e=>{let{originalBlock:t,...l}=e;const{originalName:n,originalUndelimitedContent:r,clientId:a}=l.attributes,{replaceBlock:i}=(0,s.useDispatch)(m.store),d=()=>{i(l.clientId,(0,c.createBlock)("core/html",{content:r}))},u=!!r,p=(0,s.useSelect)((e=>{const{canInsertBlockType:t,getBlockRootClientId:l}=e(m.store);return t("core/html",l(a))}),[a]);let b=(0,y.sprintf)((0,y.__)("Your site doesn’t include support for the %s block. You can try installing the block or remove it entirely."),t.title||n);const k=[(0,o.createElement)(Ne,{key:"install",block:t,attributes:l.attributes,clientId:l.clientId})];return u&&p&&(b=(0,y.sprintf)((0,y.__)("Your site doesn’t include support for the %s block. You can try installing the block, convert it to a Custom HTML block, or remove it entirely."),t.title||n),k.push((0,o.createElement)(Q.Button,{key:"convert",onClick:d,variant:"tertiary"},(0,y.__)("Keep as HTML")))),(0,o.createElement)("div",(0,m.useBlockProps)(),(0,o.createElement)(m.Warning,{actions:k},b),(0,o.createElement)(o.RawHTML,null,r))};var Le=e=>t=>{const{originalName:l}=t.attributes,{block:n,hasPermission:r}=(0,s.useSelect)((e=>{const{getDownloadableBlocks:t}=e(G),n=t("block:"+l).filter((e=>{let{name:t}=e;return l===t}));return{hasPermission:e(J.store).canUser("read","block-directory/search"),block:n.length&&n[0]}}),[l]);return r&&n?(0,o.createElement)(Te,X({},t,{originalBlock:n})):(0,o.createElement)(e,t)};(0,a.registerPlugin)("block-directory",{render(){return(0,o.createElement)(o.Fragment,null,(0,o.createElement)(W,null),(0,o.createElement)(ye,null),(0,o.createElement)(Ie,null))}}),(0,i.addFilter)("blocks.registerBlockType","block-directory/fallback",((e,t)=>("core/missing"!==t||(e.edit=Le(e.edit)),e))),(window.wp=window.wp||{}).blockDirectory=t}(); |