Changeset 2999611
- Timestamp:
- 11/21/2023 02:37:22 PM (9 months ago)
- Location:
- multisite-shared-blocks
- Files:
-
- 28 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
multisite-shared-blocks/tags/1.1.0/build/blocks/shared-block/block.json
r2795737 r2999611 3 3 "apiVersion": 2, 4 4 "name": "multisite-shared-blocks/shared-block", 5 "version": "1. 0.0",5 "version": "1..0", 6 6 "title": "Shared Block", 7 7 "category": "design", -
multisite-shared-blocks/tags/1.1.0/build/blocks/shared-block/index.asset.php
r2795737 r2999611 1 <?php return array('dependencies' => array(' lodash', 'react', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n', 'wp-primitives', 'wp-url'), 'version' => '378f9221b631a49d79a6');1 <?php return array('dependencies' => array(''); -
multisite-shared-blocks/tags/1.1.0/build/blocks/shared-block/index.js
r2795737 r2999611 1 !function(){"use strict";var e,t={128:function(e,t,o){var r=window.wp.blocks,n=window.wp.element,l=window.lodash,s=window.wp.blockEditor,i=window.wp.components,a=window.wp.i18n,c=window.React,h=o.n(c),p=function(e,t){return p=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var o in t)t.hasOwnProperty(o)&&(e[o]=t[o])},p(e,t)},u=function(){return u=Object.assign||function(e){for(var t,o=1,r=arguments.length;o<r;o++)for(var n in t=arguments[o])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},u.apply(this,arguments)},d="Pixel",m="Percent",f={unit:m,value:.8};function v(e){return"number"==typeof e?{unit:m,value:100*e}:"string"==typeof e?e.match(/^(\d*(\.\d+)?)px$/)?{unit:d,value:parseFloat(e)}:e.match(/^(\d*(\.\d+)?)%$/)?{unit:m,value:parseFloat(e)}:(console.warn('scrollThreshold format is invalid. Valid formats: "120px", "50%"...'),f):(console.warn("scrollThreshold should be string or number"),f)}var g=function(e){function t(t){var o=e.call(this,t)||this;return o.lastScrollTop=0,o.actionTriggered=!1,o.startY=0,o.currentY=0,o.dragging=!1,o.maxPullDownDistance=0,o.getScrollableTarget=function(){return o.props.scrollableTarget instanceof HTMLElement?o.props.scrollableTarget:"string"==typeof o.props.scrollableTarget?document.getElementById(o.props.scrollableTarget):(null===o.props.scrollableTarget&&console.warn("You are trying to pass scrollableTarget but it is null. This might\n happen because the element may not have been added to DOM yet.\n See https://github.com/ankeetmaini/react-infinite-scroll-component/issues/59 for more info.\n "),null)},o.onStart=function(e){o.lastScrollTop||(o.dragging=!0,e instanceof MouseEvent?o.startY=e.pageY:e instanceof TouchEvent&&(o.startY=e.touches[0].pageY),o.currentY=o.startY,o._infScroll&&(o._infScroll.style.willChange="transform",o._infScroll.style.transition="transform 0.2s cubic-bezier(0,0,0.31,1)"))},o.onMove=function(e){o.dragging&&(e instanceof MouseEvent?o.currentY=e.pageY:e instanceof TouchEvent&&(o.currentY=e.touches[0].pageY),o.currentY<o.startY||(o.currentY-o.startY>=Number(o.props.pullDownToRefreshThreshold)&&o.setState({pullToRefreshThresholdBreached:!0}),o.currentY-o.startY>1.5*o.maxPullDownDistance||o._infScroll&&(o._infScroll.style.overflow="visible",o._infScroll.style.transform="translate3d(0px, "+(o.currentY-o.startY)+"px, 0px)")))},o.onEnd=function(){o.startY=0,o.currentY=0,o.dragging=!1,o.state.pullToRefreshThresholdBreached&&(o.props.refreshFunction&&o.props.refreshFunction(),o.setState({pullToRefreshThresholdBreached:!1})),requestAnimationFrame((function(){o._infScroll&&(o._infScroll.style.overflow="auto",o._infScroll.style.transform="none",o._infScroll.style.willChange="unset")}))},o.onScrollListener=function(e){"function"==typeof o.props.onScroll&&setTimeout((function(){return o.props.onScroll&&o.props.onScroll(e)}),0);var t=o.props.height||o._scrollableNode?e.target:document.documentElement.scrollTop?document.documentElement:document.body;o.actionTriggered||((o.props.inverse?o.isElementAtTop(t,o.props.scrollThreshold):o.isElementAtBottom(t,o.props.scrollThreshold))&&o.props.hasMore&&(o.actionTriggered=!0,o.setState({showLoader:!0}),o.props.next&&o.props.next()),o.lastScrollTop=t.scrollTop)},o.state={showLoader:!1,pullToRefreshThresholdBreached:!1,prevDataLength:t.dataLength},o.throttledOnScrollListener=function(e,t,o,r){var n,l=!1,s=0;function i(){n&&clearTimeout(n)}function a(){var a=this,c=Date.now()-s,h=arguments;function p(){s=Date.now(),o.apply(a,h)}function u(){n=void 0}l||(r&&!n&&p(),i(),void 0===r&&c>e?p():!0!==t&&(n=setTimeout(r?u:p,void 0===r?e-c:e)))}return"boolean"!=typeof t&&(r=o,o=t,t=void 0),a.cancel=function(){i(),l=!0},a}(150,o.onScrollListener).bind(o),o.onStart=o.onStart.bind(o),o.onMove=o.onMove.bind(o),o.onEnd=o.onEnd.bind(o),o}return function(e,t){function __(){this.constructor=e}p(e,t),e.prototype=null===t?Object.create(t):(__.prototype=t.prototype,new __)}(t,e),t.prototype.componentDidMount=function(){if(void 0===this.props.dataLength)throw new Error('mandatory prop "dataLength" is missing. The prop is needed when loading more content. Check README.md for usage');if(this._scrollableNode=this.getScrollableTarget(),this.el=this.props.height?this._infScroll:this._scrollableNode||window,this.el&&this.el.addEventListener("scroll",this.throttledOnScrollListener),"number"==typeof this.props.initialScrollY&&this.el&&this.el instanceof HTMLElement&&this.el.scrollHeight>this.props.initialScrollY&&this.el.scrollTo(0,this.props.initialScrollY),this.props.pullDownToRefresh&&this.el&&(this.el.addEventListener("touchstart",this.onStart),this.el.addEventListener("touchmove",this.onMove),this.el.addEventListener("touchend",this.onEnd),this.el.addEventListener("mousedown",this.onStart),this.el.addEventListener("mousemove",this.onMove),this.el.addEventListener("mouseup",this.onEnd),this.maxPullDownDistance=this._pullDown&&this._pullDown.firstChild&&this._pullDown.firstChild.getBoundingClientRect().height||0,this.forceUpdate(),"function"!=typeof this.props.refreshFunction))throw new Error('Mandatory prop "refreshFunction" missing.\n Pull Down To Refresh functionality will not work\n as expected. Check README.md for usage\'')},t.prototype.componentWillUnmount=function(){this.el&&(this.el.removeEventListener("scroll",this.throttledOnScrollListener),this.props.pullDownToRefresh&&(this.el.removeEventListener("touchstart",this.onStart),this.el.removeEventListener("touchmove",this.onMove),this.el.removeEventListener("touchend",this.onEnd),this.el.removeEventListener("mousedown",this.onStart),this.el.removeEventListener("mousemove",this.onMove),this.el.removeEventListener("mouseup",this.onEnd)))},t.prototype.componentDidUpdate=function(e){this.props.dataLength!==e.dataLength&&(this.actionTriggered=!1,this.setState({showLoader:!1}))},t.getDerivedStateFromProps=function(e,t){return e.dataLength!==t.prevDataLength?u(u({},t),{prevDataLength:e.dataLength}):null},t.prototype.isElementAtTop=function(e,t){void 0===t&&(t=.8);var o=e===document.body||e===document.documentElement?window.screen.availHeight:e.clientHeight,r=v(t);return r.unit===d?e.scrollTop<=r.value+o-e.scrollHeight+1:e.scrollTop<=r.value/100+o-e.scrollHeight+1},t.prototype.isElementAtBottom=function(e,t){void 0===t&&(t=.8);var o=e===document.body||e===document.documentElement?window.screen.availHeight:e.clientHeight,r=v(t);return r.unit===d?e.scrollTop+o>=e.scrollHeight-r.value:e.scrollTop+o>=r.value/100*e.scrollHeight},t.prototype.render=function(){var e=this,t=u({height:this.props.height||"auto",overflow:"auto",WebkitOverflowScrolling:"touch"},this.props.style),o=this.props.hasChildren||!!(this.props.children&&this.props.children instanceof Array&&this.props.children.length),r=this.props.pullDownToRefresh&&this.props.height?{overflow:"auto"}:{};return h().createElement("div",{style:r,className:"infinite-scroll-component__outerdiv"},h().createElement("div",{className:"infinite-scroll-component "+(this.props.className||""),ref:function(t){return e._infScroll=t},style:t},this.props.pullDownToRefresh&&h().createElement("div",{style:{position:"relative"},ref:function(t){return e._pullDown=t}},h().createElement("div",{style:{position:"absolute",left:0,right:0,top:-1*this.maxPullDownDistance}},this.state.pullToRefreshThresholdBreached?this.props.releaseToRefreshContent:this.props.pullDownToRefreshContent)),this.props.children,!this.state.showLoader&&!o&&this.props.hasMore&&this.props.loader,this.state.showLoader&&this.props.hasMore&&this.props.loader,!this.props.hasMore&&this.props.endMessage))},t}(c.Component),b=g,w=window.wp.apiFetch,_=o.n(w),E=window.wp.url;function y(e){let{onItemSelect:t}=e;const{sites:o=[],post_types:r=[]}=multisiteSharedBlocksEditorData,l=Object.keys(o).map((e=>({label:o[e],value:e}))),s=Object.keys(r).map((e=>({label:r[e],value:e}))),[c,h]=(0,n.useState)({search:"",postType:"",site:0}),[p,u]=(0,n.useState)([]),[d,m]=(0,n.useState)(!0),[f,v]=(0,n.useState)(1),[g,w]=(0,n.useState)(!1),y=()=>{u([]),v(1),w(!1),m(!0)};(0,n.useEffect)((()=>{const e=void 0===window.AbortController?void 0:new window.AbortController;return k(c,e),()=>null==e?void 0:e.abort()}),[c]);const k=(e,t)=>{(function(e,t){const o=(0,E.addQueryArgs)("/multisite-shared-blocks/v1/search",{search:e.search||"",post_type:e.postType&&""!==e.postType?[e.postType]:[],site_in:e.site&&0!==e.site?[e.site]:[],page:e.page||1,per_page:e.per_page||30});return _()({path:o,signal:null==t?void 0:t.signal})})({...e,page:f},t).then((e=>p.length||e.length?e.length?(u([...p,...e]),v(f+1),m(!0),void w(!0)):void w(!1):(m(!1),void w(!1)))).catch((e=>{w(!1),"rest_search_invalid_page_number"!==e.code&&(u([]),m(!1),v(1))}))};return(0,n.createElement)("div",{className:"shared-block-selector"},(0,n.createElement)("div",{className:"shared-block-selector__filters"},(0,n.createElement)("div",{className:"filter filter--sites"},(0,n.createElement)(i.SelectControl,{label:(0,a.__)("Filter by site","multisite-shared-blocks"),value:c.site,options:[{value:0,label:(0,a.__)("All","multisite-shared-blocks")},...l],onChange:e=>{var t;t="0"!==e?+e:0,h({...c,site:t}),y()}})),(0,n.createElement)("div",{className:"filter filter--posttypes"},(0,n.createElement)(i.SelectControl,{label:(0,a.__)("Filter by post type","multisite-shared-blocks"),value:c.postType,options:[{value:0,label:(0,a.__)("All","multisite-shared-blocks")},...s],onChange:e=>{var t;t="0"!==e?e:"",h({...c,postType:t}),y()}})),(0,n.createElement)(i.TextControl,{label:(0,a.__)("Search for a shared block","multisite-shared-blocks"),className:"filter filter--search",onChange:e=>{var t;t=e,h({...c,search:t}),y()}})),(0,n.createElement)("div",{className:"shared-block-selector__results"},d?(0,n.createElement)(b,{dataLength:p.length,next:()=>k(c),hasMore:g,height:300,loader:(0,n.createElement)(i.Spinner,null)},p.map((e=>(0,n.createElement)("div",{key:e.id,className:"results__item"},(0,n.createElement)(i.Button,{variant:"link",label:(0,a.sprintf)(//translators: %s shared block title 2 (0,a.__)('Select block "%s"',"multisite-shared-blocks"),e.block_title),onClick:()=>{t(e)}},`${e.full_block_title}`))))):(0,n.createElement)("div",{className:"no-results"},(0,a.__)("No results.","multisite-shared-blocks"))))}var k=window.wp.primitives,T=(0,n.createElement)(k.SVG,{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",fill:"none",viewBox:"0 0 24 24"},(0,n.createElement)(k.Path,{fill:"#000","fill-rule":"evenodd",d:"M14.247 0H9.753c-.715 0-1.327.647-1.327 1.402V4.8c0 .755.612 1.402 1.327 1.402h1.736v2.034c-1.599.242-2.857 1.601-3.04 3.306h-1.3v-1.295c0-.755-.613-1.402-1.328-1.402H1.328C.613 8.845 0 9.492 0 10.247v3.398c0 .755.613 1.402 1.328 1.402H5.82c.715 0 1.328-.647 1.328-1.402V12.62h1.329c.262 1.602 1.48 2.859 3.011 3.09v2.088H9.753c-.715 0-1.327.647-1.327 1.402v3.398c0 .755.612 1.402 1.327 1.402h4.494c.715 0 1.328-.647 1.328-1.402V19.2c0-.809-.613-1.402-1.328-1.402H12.51V15.71c1.53-.231 2.75-1.488 3.011-3.09h1.329v1.025c0 .755.613 1.402 1.328 1.402h4.493c.715 0 1.328-.647 1.328-1.402v-3.398c0-.755-.613-1.402-1.328-1.402H18.18c-.715 0-1.328.647-1.328 1.402v1.295h-1.3c-.183-1.705-1.441-3.064-3.04-3.306V6.202h1.736c.715 0 1.328-.647 1.328-1.402V1.402C15.575.593 14.962 0 14.247 0Zm.306 4.746c0 .162-.153.324-.306.324H9.753c-.153 0-.306-.162-.306-.324V1.402c0-.162.153-.323.306-.323h4.494c.153 0 .306.108.306.323v3.344ZM12 9.276c-1.41 0-2.553 1.208-2.553 2.697 0 1.49 1.143 2.697 2.553 2.697s2.553-1.208 2.553-2.697c0-1.49-1.143-2.697-2.553-2.697Zm10.979 4.369c0 .162-.153.324-.307.324H18.18c-.153 0-.307-.162-.307-.324v-3.398c0-.162.154-.323.307-.323h4.493c.154 0 .307.161.307.323v3.398Zm-17.158.324c.153 0 .307-.162.307-.324v-3.398c0-.162-.154-.323-.307-.323H1.328c-.154 0-.307.161-.307.323v3.398c0 .162.153.324.307.324H5.82Zm8.426 8.898c.153 0 .306-.161.306-.323v-3.398c0-.162-.153-.323-.306-.323H9.753c-.153 0-.306.161-.306.323v3.398c0 .162.153.323.306.323h4.494Z","clip-rule":"evenodd"}));(0,r.registerBlockType)("multisite-shared-blocks/shared-block",{icon:T,edit:function(e){let{attributes:t,setAttributes:o}=e;const{blockId:r,blockTitle:c,display:h}=t,[p,u]=(0,n.useState)(!1),d=e=>{o({display:e})};return(0,n.createElement)("div",(0,s.useBlockProps)(),(0,n.createElement)(s.InspectorControls,null,(0,n.createElement)(i.PanelBody,{title:(0,a.__)("Display options","multisite-shared-blocks")},(0,n.createElement)(i.ButtonGroup,null,(0,n.createElement)(i.Button,{onClick:()=>d("full"),isPressed:"full"===h},(0,a.__)("Full content","multisite-shared-blocks")),(0,n.createElement)(i.Button,{onClick:()=>d("excerpt"),isPressed:"excerpt"===h},(0,a.__)("Excerpt","multisite-shared-blocks"))))),(0,l.isEmpty)(r)||p?(0,n.createElement)("div",{className:"shared-block-selector-wrapper"},!1===(0,l.isEmpty)(r)&&(0,n.createElement)("div",{className:"shared-block-selector-wrapper__cancel"},(0,n.createElement)("div",{className:"shared-block-selector-wrapper__cancel--message"},(0,a.__)("Cancel changes and keep current selected block ?","multisite-shared-blocks")),(0,n.createElement)(i.Button,{className:"shared-block-selector-wrapper__cancel--button",variant:"secondary",isDestructive:!0,onClick:()=>u(!1)},(0,a.__)("Cancel changes","multisite-shared-blocks"))),(0,n.createElement)(y,{onItemSelect:e=>{var t;o({siteId:(t=e).site_id,postId:t.post_id,blockId:t.block_id,blockTitle:t.full_block_title}),u(!1)}})):(0,n.createElement)(i.Placeholder,{icon:T,label:(0,a.__)("Shared Block","multisite-shared-blocks"),instructions:(m=h,"full"===m?(0,n.createElement)("p",null,(0,n.createInterpolateElement)((0,a.sprintf)(// translators: %s is the shared block's title 3 (0,a.__)('Shared block <strong>"%s"</strong> will be displayed here.',"multisite-shared-blocks"),c),{strong:(0,n.createElement)("strong",null)})):(0,n.createElement)("p",null,(0,n.createInterpolateElement)((0,a.sprintf)(// translators: %s is the shared block's title 4 (0,a.__)('Excerpt for the shared block <strong>"%s"</strong> will be displayed here.',"multisite-shared-blocks"),c),{strong:(0,n.createElement)("strong",null)}))),className:"shared-block-placeholder"},(0,n.createElement)(i.Button,{variant:"primary",onClick:()=>u(!0)},(0,a.__)("Choose a new block","multisite-shared-blocks"))));var m}})}},o={};function r(e){var n=o[e];if(void 0!==n)return n.exports;var l=o[e]={exports:{}};return t[e](l,l.exports,r),l.exports}r.m=t,e=[],r.O=function(t,o,n,l){if(!o){var s=1/0;for(h=0;h<e.length;h++){o=e[h][0],n=e[h][1],l=e[h][2];for(var i=!0,a=0;a<o.length;a++)(!1&l||s>=l)&&Object.keys(r.O).every((function(e){return r.O[e](o[a])}))?o.splice(a--,1):(i=!1,l<s&&(s=l));if(i){e.splice(h--,1);var c=n();void 0!==c&&(t=c)}}return t}l=l||0;for(var h=e.length;h>0&&e[h-1][2]>l;h--)e[h]=e[h-1];e[h]=[o,n,l]},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,{a:t}),t},r.d=function(e,t){for(var o in t)r.o(t,o)&&!r.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},function(){var e={261:0,570:0};r.O.j=function(t){return 0===e[t]};var t=function(t,o){var n,l,s=o[0],i=o[1],a=o[2],c=0;if(s.some((function(t){return 0!==e[t]}))){for(n in i)r.o(i,n)&&(r.m[n]=i[n]);if(a)var h=a(r)}for(t&&t(o);c<s.length;c++)l=s[c],r.o(e,l)&&e[l]&&e[l][0](),e[l]=0;return r.O(h)},o=self.webpackChunkmultisite_shared_blocks=self.webpackChunkmultisite_shared_blocks||[];o.forEach(t.bind(null,0)),o.push=t.bind(null,o.push.bind(o))}();var n=r.O(void 0,[570],(function(){return r(128)}));n=r.O(n)}(); 1 (()=>{"use strict";var e,t={843:(e,t,o)=>{const r=window.wp.blocks,l=window.React;var n=o.n(l);const s=window.wp.blockEditor,i=window.wp.element,a=window.wp.components,c=window.wp.i18n;var h=function(e,t){return h=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var o in t)t.hasOwnProperty(o)&&(e[o]=t[o])},h(e,t)},p=function(){return p=Object.assign||function(e){for(var t,o=1,r=arguments.length;o<r;o++)for(var l in t=arguments[o])Object.prototype.hasOwnProperty.call(t,l)&&(e[l]=t[l]);return e},p.apply(this,arguments)},u="Pixel",d="Percent",m={unit:d,value:.8};function v(e){return"number"==typeof e?{unit:d,value:100*e}:"string"==typeof e?e.match(/^(\d*(\.\d+)?)px$/)?{unit:u,value:parseFloat(e)}:e.match(/^(\d*(\.\d+)?)%$/)?{unit:d,value:parseFloat(e)}:(console.warn('scrollThreshold format is invalid. Valid formats: "120px", "50%"...'),m):(console.warn("scrollThreshold should be string or number"),m)}const f=function(e){function t(t){var o=e.call(this,t)||this;return o.lastScrollTop=0,o.actionTriggered=!1,o.startY=0,o.currentY=0,o.dragging=!1,o.maxPullDownDistance=0,o.getScrollableTarget=function(){return o.props.scrollableTarget instanceof HTMLElement?o.props.scrollableTarget:"string"==typeof o.props.scrollableTarget?document.getElementById(o.props.scrollableTarget):(null===o.props.scrollableTarget&&console.warn("You are trying to pass scrollableTarget but it is null. This might\n happen because the element may not have been added to DOM yet.\n See https://github.com/ankeetmaini/react-infinite-scroll-component/issues/59 for more info.\n "),null)},o.onStart=function(e){o.lastScrollTop||(o.dragging=!0,e instanceof MouseEvent?o.startY=e.pageY:e instanceof TouchEvent&&(o.startY=e.touches[0].pageY),o.currentY=o.startY,o._infScroll&&(o._infScroll.style.willChange="transform",o._infScroll.style.transition="transform 0.2s cubic-bezier(0,0,0.31,1)"))},o.onMove=function(e){o.dragging&&(e instanceof MouseEvent?o.currentY=e.pageY:e instanceof TouchEvent&&(o.currentY=e.touches[0].pageY),o.currentY<o.startY||(o.currentY-o.startY>=Number(o.props.pullDownToRefreshThreshold)&&o.setState({pullToRefreshThresholdBreached:!0}),o.currentY-o.startY>1.5*o.maxPullDownDistance||o._infScroll&&(o._infScroll.style.overflow="visible",o._infScroll.style.transform="translate3d(0px, "+(o.currentY-o.startY)+"px, 0px)")))},o.onEnd=function(){o.startY=0,o.currentY=0,o.dragging=!1,o.state.pullToRefreshThresholdBreached&&(o.props.refreshFunction&&o.props.refreshFunction(),o.setState({pullToRefreshThresholdBreached:!1})),requestAnimationFrame((function(){o._infScroll&&(o._infScroll.style.overflow="auto",o._infScroll.style.transform="none",o._infScroll.style.willChange="unset")}))},o.onScrollListener=function(e){"function"==typeof o.props.onScroll&&setTimeout((function(){return o.props.onScroll&&o.props.onScroll(e)}),0);var t=o.props.height||o._scrollableNode?e.target:document.documentElement.scrollTop?document.documentElement:document.body;o.actionTriggered||((o.props.inverse?o.isElementAtTop(t,o.props.scrollThreshold):o.isElementAtBottom(t,o.props.scrollThreshold))&&o.props.hasMore&&(o.actionTriggered=!0,o.setState({showLoader:!0}),o.props.next&&o.props.next()),o.lastScrollTop=t.scrollTop)},o.state={showLoader:!1,pullToRefreshThresholdBreached:!1,prevDataLength:t.dataLength},o.throttledOnScrollListener=function(e,t,o,r){var l,n=!1,s=0;function i(){l&&clearTimeout(l)}function a(){var e=this,a=Date.now()-s,c=arguments;function h(){s=Date.now(),o.apply(e,c)}n||(r&&!l&&h(),i(),void 0===r&&a>150?h():!0!==t&&(l=setTimeout(r?function(){l=void 0}:h,void 0===r?150-a:150)))}return"boolean"!=typeof t&&(r=o,o=t,t=void 0),a.cancel=function(){i(),n=!0},a}(0,o.onScrollListener).bind(o),o.onStart=o.onStart.bind(o),o.onMove=o.onMove.bind(o),o.onEnd=o.onEnd.bind(o),o}return function(e,t){function __(){this.constructor=e}h(e,t),e.prototype=null===t?Object.create(t):(__.prototype=t.prototype,new __)}(t,e),t.prototype.componentDidMount=function(){if(void 0===this.props.dataLength)throw new Error('mandatory prop "dataLength" is missing. The prop is needed when loading more content. Check README.md for usage');if(this._scrollableNode=this.getScrollableTarget(),this.el=this.props.height?this._infScroll:this._scrollableNode||window,this.el&&this.el.addEventListener("scroll",this.throttledOnScrollListener),"number"==typeof this.props.initialScrollY&&this.el&&this.el instanceof HTMLElement&&this.el.scrollHeight>this.props.initialScrollY&&this.el.scrollTo(0,this.props.initialScrollY),this.props.pullDownToRefresh&&this.el&&(this.el.addEventListener("touchstart",this.onStart),this.el.addEventListener("touchmove",this.onMove),this.el.addEventListener("touchend",this.onEnd),this.el.addEventListener("mousedown",this.onStart),this.el.addEventListener("mousemove",this.onMove),this.el.addEventListener("mouseup",this.onEnd),this.maxPullDownDistance=this._pullDown&&this._pullDown.firstChild&&this._pullDown.firstChild.getBoundingClientRect().height||0,this.forceUpdate(),"function"!=typeof this.props.refreshFunction))throw new Error('Mandatory prop "refreshFunction" missing.\n Pull Down To Refresh functionality will not work\n as expected. Check README.md for usage\'')},t.prototype.componentWillUnmount=function(){this.el&&(this.el.removeEventListener("scroll",this.throttledOnScrollListener),this.props.pullDownToRefresh&&(this.el.removeEventListener("touchstart",this.onStart),this.el.removeEventListener("touchmove",this.onMove),this.el.removeEventListener("touchend",this.onEnd),this.el.removeEventListener("mousedown",this.onStart),this.el.removeEventListener("mousemove",this.onMove),this.el.removeEventListener("mouseup",this.onEnd)))},t.prototype.componentDidUpdate=function(e){this.props.dataLength!==e.dataLength&&(this.actionTriggered=!1,this.setState({showLoader:!1}))},t.getDerivedStateFromProps=function(e,t){return e.dataLength!==t.prevDataLength?p(p({},t),{prevDataLength:e.dataLength}):null},t.prototype.isElementAtTop=function(e,t){void 0===t&&(t=.8);var o=e===document.body||e===document.documentElement?window.screen.availHeight:e.clientHeight,r=v(t);return r.unit===u?e.scrollTop<=r.value+o-e.scrollHeight+1:e.scrollTop<=r.value/100+o-e.scrollHeight+1},t.prototype.isElementAtBottom=function(e,t){void 0===t&&(t=.8);var o=e===document.body||e===document.documentElement?window.screen.availHeight:e.clientHeight,r=v(t);return r.unit===u?e.scrollTop+o>=e.scrollHeight-r.value:e.scrollTop+o>=r.value/100*e.scrollHeight},t.prototype.render=function(){var e=this,t=p({height:this.props.height||"auto",overflow:"auto",WebkitOverflowScrolling:"touch"},this.props.style),o=this.props.hasChildren||!!(this.props.children&&this.props.children instanceof Array&&this.props.children.length),r=this.props.pullDownToRefresh&&this.props.height?{overflow:"auto"}:{};return n().createElement("div",{style:r,className:"infinite-scroll-component__outerdiv"},n().createElement("div",{className:"infinite-scroll-component "+(this.props.className||""),ref:function(t){return e._infScroll=t},style:t},this.props.pullDownToRefresh&&n().createElement("div",{style:{position:"relative"},ref:function(t){return e._pullDown=t}},n().createElement("div",{style:{position:"absolute",left:0,right:0,top:-1*this.maxPullDownDistance}},this.state.pullToRefreshThresholdBreached?this.props.releaseToRefreshContent:this.props.pullDownToRefreshContent)),this.props.children,!this.state.showLoader&&!o&&this.props.hasMore&&this.props.loader,this.state.showLoader&&this.props.hasMore&&this.props.loader,!this.props.hasMore&&this.props.endMessage))},t}(l.Component),g=window.wp.apiFetch;var b=o.n(g);const w=window.wp.url;function _({onItemSelect:e}){const{sites:t=[],post_types:o=[]}=multisiteSharedBlocksEditorData,r=Object.keys(t).map((e=>({label:t[e],value:e}))),n=Object.keys(o).map((e=>({label:o[e],value:e}))),[s,h]=(0,i.useState)({search:"",postType:"",site:0}),[p,u]=(0,i.useState)([]),[d,m]=(0,i.useState)(!0),[v,g]=(0,i.useState)(1),[_,E]=(0,i.useState)(!1),y=()=>{u([]),g(1),E(!1),m(!0)};(0,i.useEffect)((()=>{const e=void 0===window.AbortController?void 0:new window.AbortController;return k(s,e),()=>e?.abort()}),[s]);const k=(e,t)=>{(function(e,t){const o=(0,w.addQueryArgs)("/multisite-shared-blocks/v1/search",{search:e.search||"",post_type:e.postType&&""!==e.postType?[e.postType]:[],site_in:e.site&&0!==e.site?[e.site]:[],page:e.page||1,per_page:e.per_page||30});return b()({path:o,signal:t?.signal})})({...e,page:v},t).then((e=>p.length||e.length?e.length?(u([...p,...e]),g(v+1),m(!0),void E(!0)):void E(!1):(m(!1),void E(!1)))).catch((e=>{E(!1),"rest_search_invalid_page_number"!==e.code&&(u([]),m(!1),g(1))}))};return(0,l.createElement)("div",{className:"shared-block-selector"},(0,l.createElement)("div",{className:"shared-block-selector__filters"},(0,l.createElement)("div",{className:"filter filter--sites"},(0,l.createElement)(a.SelectControl,{label:(0,c.__)("Filter by site","multisite-shared-blocks"),value:s.site,options:[{value:0,label:(0,c.__)("All","multisite-shared-blocks")},...r],onChange:e=>{var t;t="0"!==e?+e:0,h({...s,site:t}),y()}})),(0,l.createElement)("div",{className:"filter filter--posttypes"},(0,l.createElement)(a.SelectControl,{label:(0,c.__)("Filter by post type","multisite-shared-blocks"),value:s.postType,options:[{value:0,label:(0,c.__)("All","multisite-shared-blocks")},...n],onChange:e=>{var t;t="0"!==e?e:"",h({...s,postType:t}),y()}})),(0,l.createElement)(a.TextControl,{label:(0,c.__)("Search for a shared block","multisite-shared-blocks"),className:"filter filter--search",onChange:e=>{var t;t=e,h({...s,search:t}),y()}})),(0,l.createElement)("div",{className:"shared-block-selector__results"},d?(0,l.createElement)(f,{dataLength:p.length,next:()=>k(s),hasMore:_,height:300,loader:(0,l.createElement)(a.Spinner,null)},p.map((t=>(0,l.createElement)("div",{key:t.id,className:"results__item"},(0,l.createElement)(a.Button,{variant:"link",label:(0,c.sprintf)( 2 //translators: %s shared block title 3 (0,c.__)('Select block "%s"',"multisite-shared-blocks"),t.block_title),onClick:()=>{e(t)}},`${t.full_block_title}`))))):(0,l.createElement)("div",{className:"no-results"},(0,c.__)("No results.","multisite-shared-blocks"))))}const E=window.wp.primitives,y=(0,l.createElement)(E.SVG,{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",fill:"none",viewBox:"0 0 24 24"},(0,l.createElement)(E.Path,{fill:"#000",fillRule:"evenodd",d:"M14.247 0H9.753c-.715 0-1.327.647-1.327 1.402V4.8c0 .755.612 1.402 1.327 1.402h1.736v2.034c-1.599.242-2.857 1.601-3.04 3.306h-1.3v-1.295c0-.755-.613-1.402-1.328-1.402H1.328C.613 8.845 0 9.492 0 10.247v3.398c0 .755.613 1.402 1.328 1.402H5.82c.715 0 1.328-.647 1.328-1.402V12.62h1.329c.262 1.602 1.48 2.859 3.011 3.09v2.088H9.753c-.715 0-1.327.647-1.327 1.402v3.398c0 .755.612 1.402 1.327 1.402h4.494c.715 0 1.328-.647 1.328-1.402V19.2c0-.809-.613-1.402-1.328-1.402H12.51V15.71c1.53-.231 2.75-1.488 3.011-3.09h1.329v1.025c0 .755.613 1.402 1.328 1.402h4.493c.715 0 1.328-.647 1.328-1.402v-3.398c0-.755-.613-1.402-1.328-1.402H18.18c-.715 0-1.328.647-1.328 1.402v1.295h-1.3c-.183-1.705-1.441-3.064-3.04-3.306V6.202h1.736c.715 0 1.328-.647 1.328-1.402V1.402C15.575.593 14.962 0 14.247 0Zm.306 4.746c0 .162-.153.324-.306.324H9.753c-.153 0-.306-.162-.306-.324V1.402c0-.162.153-.323.306-.323h4.494c.153 0 .306.108.306.323v3.344ZM12 9.276c-1.41 0-2.553 1.208-2.553 2.697 0 1.49 1.143 2.697 2.553 2.697s2.553-1.208 2.553-2.697c0-1.49-1.143-2.697-2.553-2.697Zm10.979 4.369c0 .162-.153.324-.307.324H18.18c-.153 0-.307-.162-.307-.324v-3.398c0-.162.154-.323.307-.323h4.493c.154 0 .307.161.307.323v3.398Zm-17.158.324c.153 0 .307-.162.307-.324v-3.398c0-.162-.154-.323-.307-.323H1.328c-.154 0-.307.161-.307.323v3.398c0 .162.153.324.307.324H5.82Zm8.426 8.898c.153 0 .306-.161.306-.323v-3.398c0-.162-.153-.323-.306-.323H9.753c-.153 0-.306.161-.306.323v3.398c0 .162.153.323.306.323h4.494Z",clipRule:"evenodd"}));(0,r.registerBlockType)("multisite-shared-blocks/shared-block",{icon:y,edit:function({attributes:e,setAttributes:t}){const{blockId:o,blockTitle:r,display:n}=e,h=!!(o&&o.length>0),[p,u]=(0,i.useState)(!1),d=e=>{t({display:e})};return(0,l.createElement)("div",{...(0,s.useBlockProps)()},(0,l.createElement)(s.InspectorControls,null,(0,l.createElement)(a.PanelBody,{title:(0,c.__)("Display options","multisite-shared-blocks")},(0,l.createElement)(a.ButtonGroup,null,(0,l.createElement)(a.Button,{onClick:()=>d("full"),isPressed:"full"===n},(0,c.__)("Full content","multisite-shared-blocks")),(0,l.createElement)(a.Button,{onClick:()=>d("excerpt"),isPressed:"excerpt"===n},(0,c.__)("Excerpt","multisite-shared-blocks"))))),!h||p?(0,l.createElement)("div",{className:"shared-block-selector-wrapper"},h&&(0,l.createElement)("div",{className:"shared-block-selector-wrapper__cancel"},(0,l.createElement)("div",{className:"shared-block-selector-wrapper__cancel--message"},(0,c.__)("Cancel changes and keep current selected block ?","multisite-shared-blocks")),(0,l.createElement)(a.Button,{className:"shared-block-selector-wrapper__cancel--button",variant:"secondary",isDestructive:!0,onClick:()=>u(!1)},(0,c.__)("Cancel changes","multisite-shared-blocks"))),(0,l.createElement)(_,{onItemSelect:e=>{var o;t({siteId:(o=e).site_id,postId:o.post_id,blockId:o.block_id,blockTitle:o.full_block_title}),u(!1)}})):(0,l.createElement)(a.Placeholder,{icon:y,label:(0,c.__)("Shared Block","multisite-shared-blocks"),className:"shared-block-placeholder"},"full"===n?(0,l.createElement)("p",null,(0,i.createInterpolateElement)((0,c.sprintf)( 4 // translators: %s is the shared block's title 5 (0,c.__)('Shared block <strong>"%s"</strong> will be displayed here.',"multisite-shared-blocks"),r),{strong:(0,l.createElement)("strong",null)})):(0,l.createElement)("p",null,(0,i.createInterpolateElement)((0,c.sprintf)( 6 // translators: %s is the shared block's title 7 (0,c.__)('Excerpt for the shared block <strong>"%s"</strong> will be displayed here.',"multisite-shared-blocks"),r),{strong:(0,l.createElement)("strong",null)})),(0,l.createElement)(a.Button,{variant:"primary",onClick:()=>u(!0)},(0,c.__)("Choose a new block","multisite-shared-blocks"))))}})}},o={};function r(e){var l=o[e];if(void 0!==l)return l.exports;var n=o[e]={exports:{}};return t[e](n,n.exports,r),n.exports}r.m=t,e=[],r.O=(t,o,l,n)=>{if(!o){var s=1/0;for(h=0;h<e.length;h++){for(var[o,l,n]=e[h],i=!0,a=0;a<o.length;a++)(!1&n||s>=n)&&Object.keys(r.O).every((e=>r.O[e](o[a])))?o.splice(a--,1):(i=!1,n<s&&(s=n));if(i){e.splice(h--,1);var c=l();void 0!==c&&(t=c)}}return t}n=n||0;for(var h=e.length;h>0&&e[h-1][2]>n;h--)e[h]=e[h-1];e[h]=[o,l,n]},r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var o in t)r.o(t,o)&&!r.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{var e={261:0,570:0};r.O.j=t=>0===e[t];var t=(t,o)=>{var l,n,[s,i,a]=o,c=0;if(s.some((t=>0!==e[t]))){for(l in i)r.o(i,l)&&(r.m[l]=i[l]);if(a)var h=a(r)}for(t&&t(o);c<s.length;c++)n=s[c],r.o(e,n)&&e[n]&&e[n][0](),e[n]=0;return r.O(h)},o=globalThis.webpackChunkmultisite_shared_blocks=globalThis.webpackChunkmultisite_shared_blocks||[];o.forEach(t.bind(null,0)),o.push=t.bind(null,o.push.bind(o))})();var l=r.O(void 0,[570],(()=>r(843)));l=r.O(l)})(); -
multisite-shared-blocks/tags/1.1.0/build/hooks/index.asset.php
r2795737 r2999611 1 <?php return array('dependencies' => array(' lodash', 'wp-block-editor', 'wp-components', 'wp-compose', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-primitives', 'wp-wordcount'), 'version' => '7f97294b81488f990fb4');1 <?php return array('dependencies' => array(''); -
multisite-shared-blocks/tags/1.1.0/build/hooks/index.js
r2795737 r2999611 1 !function(){"use strict";var e=window.wp.hooks,t=window.lodash;function r(e){var t;return!(null!==(t=multisiteSharedBlocksHooksData.excluded_blocks)&&void 0!==t?t:[]).includes(e)}var o,s=window.wp.element,n=new Uint8Array(16);function l(){if(!o&&!(o="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return o(n)}for(var i=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i,a=function(e){return"string"==typeof e&&i.test(e)},c=[],d=0;d<256;++d)c.push((d+256).toString(16).substr(1));var h=function(e,t,r){var o=(e=e||{}).random||(e.rng||l)();if(o[6]=15&o[6]|64,o[8]=63&o[8]|128,t){r=r||0;for(var s=0;s<16;++s)t[r+s]=o[s];return t}return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=(c[e[t+0]]+c[e[t+1]]+c[e[t+2]]+c[e[t+3]]+"-"+c[e[t+4]]+c[e[t+5]]+"-"+c[e[t+6]]+c[e[t+7]]+"-"+c[e[t+8]]+c[e[t+9]]+"-"+c[e[t+10]]+c[e[t+11]]+c[e[t+12]]+c[e[t+13]]+c[e[t+14]]+c[e[t+15]]).toLowerCase();if(!a(r))throw TypeError("Stringified UUID is invalid");return r}(o)},u=window.wp.compose,m=(0,u.createHigherOrderComponent)((e=>class extends s.Component{componentDidMount(){const{name:e,setAttributes:t,attributes:{sharedBlockId:o}=!1}=this.props;r(e)&&!o&&t({sharedBlockId:h()})}render(){return(0,s.createElement)(e,this.props)}}),"sharedBlockIdComponent"),p=window.wp.blockEditor,w=window.wp.components,b=window.wp.wordcount,k=window.wp.i18n,v=window.wp.primitives,f=(0,s.createElement)(v.SVG,{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",fill:"none",viewBox:"0 0 24 24"},(0,s.createElement)(v.Path,{fill:"#000","fill-rule":"evenodd",d:"M14.247 0H9.753c-.715 0-1.327.647-1.327 1.402V4.8c0 .755.612 1.402 1.327 1.402h1.736v2.034c-1.599.242-2.857 1.601-3.04 3.306h-1.3v-1.295c0-.755-.613-1.402-1.328-1.402H1.328C.613 8.845 0 9.492 0 10.247v3.398c0 .755.613 1.402 1.328 1.402H5.82c.715 0 1.328-.647 1.328-1.402V12.62h1.329c.262 1.602 1.48 2.859 3.011 3.09v2.088H9.753c-.715 0-1.327.647-1.327 1.402v3.398c0 .755.612 1.402 1.327 1.402h4.494c.715 0 1.328-.647 1.328-1.402V19.2c0-.809-.613-1.402-1.328-1.402H12.51V15.71c1.53-.231 2.75-1.488 3.011-3.09h1.329v1.025c0 .755.613 1.402 1.328 1.402h4.493c.715 0 1.328-.647 1.328-1.402v-3.398c0-.755-.613-1.402-1.328-1.402H18.18c-.715 0-1.328.647-1.328 1.402v1.295h-1.3c-.183-1.705-1.441-3.064-3.04-3.306V6.202h1.736c.715 0 1.328-.647 1.328-1.402V1.402C15.575.593 14.962 0 14.247 0Zm.306 4.746c0 .162-.153.324-.306.324H9.753c-.153 0-.306-.162-.306-.324V1.402c0-.162.153-.323.306-.323h4.494c.153 0 .306.108.306.323v3.344ZM12 9.276c-1.41 0-2.553 1.208-2.553 2.697 0 1.49 1.143 2.697 2.553 2.697s2.553-1.208 2.553-2.697c0-1.49-1.143-2.697-2.553-2.697Zm10.979 4.369c0 .162-.153.324-.307.324H18.18c-.153 0-.307-.162-.307-.324v-3.398c0-.162.154-.323.307-.323h4.493c.154 0 .307.161.307.323v3.398Zm-17.158.324c.153 0 .307-.162.307-.324v-3.398c0-.162-.154-.323-.307-.323H1.328c-.154 0-.307.161-.307.323v3.398c0 .162.153.324.307.324H5.82Zm8.426 8.898c.153 0 .306-.161.306-.323v-3.398c0-.162-.153-.323-.306-.323H9.753c-.153 0-.306.161-.306.323v3.398c0 .162.153.323.306.323h4.494Z","clip-rule":"evenodd"})),g=(0,u.createHigherOrderComponent)((e=>o=>{const{name:n,attributes:l,setAttributes:i}=o,{sharedBlockId:a,sharedBlockIsShared:c,sharedBlockShareTitle:d}=l;return r(n)?(0,s.createElement)(s.Fragment,null,(0,s.createElement)(e,o),(0,s.createElement)(p.InspectorControls,null,(0,s.createElement)(w.PanelBody,{title:(0,k.__)("Multisite sharing options","multisite-shared-blocks"),icon:f},(0,s.createElement)(w.ToggleControl,{label:(0,k.__)("Share the block on the network","multisite-shared-blocks"),help:(0,k.__)("This block will be available on all sites of the network.","multisite-shared-blocks"),checked:c,onChange:()=>{i({sharedBlockIsShared:!c})}}),!!c&&(0,s.createElement)(s.Fragment,null,(0,s.createElement)(w.TextControl,{label:(0,k.sprintf)(// translators: %d is the current number of characters of the title 2 (0,k.__)("Public title for the shared block (%d/200)","multisite-shared-blocks"),(h=d,(0,t.isEmpty)(h)?"0":(0,b.count)(d,"characters_including_spaces",{}))),value:d,onChange:e=>{i({sharedBlockShareTitle:e})},help:(0,k.__)("Try to choose a title as descriptive as possible that will allow other users to understand what the block is about (200 characteres max).","multisite-shared-blocks")}),(0,t.isEmpty)(d)&&(0,s.createElement)("p",null,(0,s.createElement)("small",null,(0,s.createInterpolateElement)((0,k.sprintf)(// translators: %s is default title 3 (0,k.__)('Current title for the shared block is empty, it\'ll be view has <strong>"%s"</strong>',"multisite-shared-blocks"),(0,k.sprintf)(// translators: %s share block unique id 4 (0,k.__)("Shared block %s","multisite-shared-blocks"),a)),{strong:(0,s.createElement)("strong",null)}))))))):(0,s.createElement)(e,o);var h}),"sharedBlockIdControls");(0,e.addFilter)("blocks.registerBlockType","multisite-shared-blocks/shared-block-id-attribute",((e,o)=>{const s=multisiteSharedBlocksHooksData.attributes||{};return!r(o)||(0,t.isEmpty)(s)?e:(0,t.assign)({},e,{attributes:(0,t.assign)({},e.attributes,s)})})),(0,e.addFilter)("editor.BlockEdit","multisite-shared-blocks/shared-block-id",m),(0,e.addFilter)("editor.BlockEdit","multisite-shared-blocks/shared-block-id-controls",g)}(); 1 (()=>{"use strict";const e=window.wp.hooks;function t(e){var t;return!(null!==(t=multisiteSharedBlocksHooksData.excluded_blocks)&&void 0!==t?t:[]).includes(e)}const o=window.React,r={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};let l;const n=new Uint8Array(16);function c(){if(!l&&(l="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!l))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return l(n)}const s=[];for(let e=0;e<256;++e)s.push((e+256).toString(16).slice(1));const i=function(e,t,o){if(r.randomUUID&&!t&&!e)return r.randomUUID();const l=(e=e||{}).random||(e.rng||c)();if(l[6]=15&l[6]|64,l[8]=63&l[8]|128,t){o=o||0;for(let e=0;e<16;++e)t[o+e]=l[e];return t}return function(e,t=0){return s[e[t+0]]+s[e[t+1]]+s[e[t+2]]+s[e[t+3]]+"-"+s[e[t+4]]+s[e[t+5]]+"-"+s[e[t+6]]+s[e[t+7]]+"-"+s[e[t+8]]+s[e[t+9]]+"-"+s[e[t+10]]+s[e[t+11]]+s[e[t+12]]+s[e[t+13]]+s[e[t+14]]+s[e[t+15]]}(l)},a=window.wp.element,d=window.wp.compose,h=(0,d.createHigherOrderComponent)((e=>class extends a.Component{componentDidMount(){const{name:e,setAttributes:o,attributes:{sharedBlockId:r}=!1}=this.props;t(e)&&!r&&o({sharedBlockId:i()})}render(){return(0,o.createElement)(e,{...this.props})}}),"sharedBlockIdComponent"),u=window.wp.blockEditor,m=window.wp.components,p=window.wp.wordcount,k=window.wp.i18n,w=window.wp.primitives,b=(0,o.createElement)(w.SVG,{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",fill:"none",viewBox:"0 0 24 24"},(0,o.createElement)(w.Path,{fill:"#000",fillRule:"evenodd",d:"M14.247 0H9.753c-.715 0-1.327.647-1.327 1.402V4.8c0 .755.612 1.402 1.327 1.402h1.736v2.034c-1.599.242-2.857 1.601-3.04 3.306h-1.3v-1.295c0-.755-.613-1.402-1.328-1.402H1.328C.613 8.845 0 9.492 0 10.247v3.398c0 .755.613 1.402 1.328 1.402H5.82c.715 0 1.328-.647 1.328-1.402V12.62h1.329c.262 1.602 1.48 2.859 3.011 3.09v2.088H9.753c-.715 0-1.327.647-1.327 1.402v3.398c0 .755.612 1.402 1.327 1.402h4.494c.715 0 1.328-.647 1.328-1.402V19.2c0-.809-.613-1.402-1.328-1.402H12.51V15.71c1.53-.231 2.75-1.488 3.011-3.09h1.329v1.025c0 .755.613 1.402 1.328 1.402h4.493c.715 0 1.328-.647 1.328-1.402v-3.398c0-.755-.613-1.402-1.328-1.402H18.18c-.715 0-1.328.647-1.328 1.402v1.295h-1.3c-.183-1.705-1.441-3.064-3.04-3.306V6.202h1.736c.715 0 1.328-.647 1.328-1.402V1.402C15.575.593 14.962 0 14.247 0Zm.306 4.746c0 .162-.153.324-.306.324H9.753c-.153 0-.306-.162-.306-.324V1.402c0-.162.153-.323.306-.323h4.494c.153 0 .306.108.306.323v3.344ZM12 9.276c-1.41 0-2.553 1.208-2.553 2.697 0 1.49 1.143 2.697 2.553 2.697s2.553-1.208 2.553-2.697c0-1.49-1.143-2.697-2.553-2.697Zm10.979 4.369c0 .162-.153.324-.307.324H18.18c-.153 0-.307-.162-.307-.324v-3.398c0-.162.154-.323.307-.323h4.493c.154 0 .307.161.307.323v3.398Zm-17.158.324c.153 0 .307-.162.307-.324v-3.398c0-.162-.154-.323-.307-.323H1.328c-.154 0-.307.161-.307.323v3.398c0 .162.153.324.307.324H5.82Zm8.426 8.898c.153 0 .306-.161.306-.323v-3.398c0-.162-.153-.323-.306-.323H9.753c-.153 0-.306.161-.306.323v3.398c0 .162.153.323.306.323h4.494Z",clipRule:"evenodd"})),g=(0,d.createHigherOrderComponent)((e=>r=>{const{name:l,attributes:n,setAttributes:c}=r,{sharedBlockId:s,sharedBlockIsShared:i,sharedBlockShareTitle:d}=n,h=!!(d&&d.length>0);return t(l)?(0,o.createElement)(o.Fragment,null,(0,o.createElement)(e,{...r}),(0,o.createElement)(u.InspectorControls,null,(0,o.createElement)(m.PanelBody,{title:(0,k.__)("Multisite sharing options","multisite-shared-blocks"),icon:b},(0,o.createElement)(m.ToggleControl,{label:(0,k.__)("Share the block on the network","multisite-shared-blocks"),help:(0,k.__)("This block will be available on all sites of the network.","multisite-shared-blocks"),checked:i,onChange:()=>{c({sharedBlockIsShared:!i})}}),!!i&&(0,o.createElement)(o.Fragment,null,(0,o.createElement)(m.TextControl,{label:(0,k.sprintf)( 2 // translators: %d is the current number of characters of the title 3 (0,k.__)("Public title for the shared block (%d/200)","multisite-shared-blocks"),h?(w=d,w&&w.length>0?(0,p.count)(w,"characters_including_spaces",{}):0):0),value:d,onChange:e=>{c({sharedBlockShareTitle:e})},help:(0,k.__)("Try to choose a title as descriptive as possible that will allow other users to understand what the block is about (200 characteres max).","multisite-shared-blocks")}),!h&&(0,o.createElement)("p",null,(0,o.createElement)("small",null,(0,a.createInterpolateElement)((0,k.sprintf)( 4 // translators: %s is default title 5 (0,k.__)('Current title for the shared block is empty, it\'ll be view has <strong>"%s"</strong>',"multisite-shared-blocks"),(0,k.sprintf)( 6 // translators: %s share block unique id 7 (0,k.__)("Shared block %s","multisite-shared-blocks"),s)),{strong:(0,o.createElement)("strong",null)}))))))):(0,o.createElement)(e,{...r});var w}),"sharedBlockIdControls");(0,e.addFilter)("blocks.registerBlockType","multisite-shared-blocks/shared-block-id-attribute",((e,o)=>{const r=multisiteSharedBlocksHooksData.attributes||{};return t(o)&&0!==Object.keys(r).length?{...e,attributes:{...e.attributes,...r}}:e})),(0,e.addFilter)("editor.BlockEdit","multisite-shared-blocks/shared-block-id",h),(0,e.addFilter)("editor.BlockEdit","multisite-shared-blocks/shared-block-id-controls",g)})(); -
multisite-shared-blocks/tags/1.1.0/includes/Rest/RenderBlockRestController.php
r2795737 r2999611 101 101 102 102 /** This filter is documented in wp-includes/post-template.php */ 103 $block_render = apply_filters( 'the_content', render_block( $shared_block_data ) );103 $block_render = apply_filters( 'the_content', _block( $shared_block_data ) ); 104 104 105 105 // Get list of block types used while rendering the shared block. -
multisite-shared-blocks/tags/1.1.0/multisite-shared-blocks.php
r2795737 r2999611 4 4 * Plugin URI: https://github.com/BeAPI/multisite-shared-blocks 5 5 * Description: Share blocks between network's sites. 6 * Version: 1. 0.16 * Version: 1. 7 7 * Requires at least: 5.9 8 8 * Requires PHP: 7.2 … … 32 32 33 33 // Plugin constants 34 define( 'MULTISITE_SHARED_BLOCKS_VERSION', '1. 0.1' );34 define( 'MULTISITE_SHARED_BLOCKS_VERSION', '1.' ); 35 35 define( 'MULTISITE_SHARED_BLOCKS_CACHE_VERSION', '1' ); 36 36 define( 'MULTISITE_SHARED_BLOCKS_VIEWS_FOLDER_NAME', 'multisite-shared-blocks' ); -
multisite-shared-blocks/tags/1.1.0/readme.txt
r2795737 r2999611 3 3 Tags: network, multisite, block, share, gutenberg 4 4 Requires at least: 5.9 5 Tested up to: 6. 06 Stable tag: 1. 0.15 Tested up to: 6. 6 Stable tag: 1. 7 7 Requires PHP: 7.2 8 8 License: GPL v2 or later … … 27 27 == Changelog == 28 28 29 30 31 32 33 29 34 = 1.0.1 - 2022-10-07 = 30 35 * Add check for multisite installation -
multisite-shared-blocks/tags/1.1.0/vendor/autoload.php
r2795737 r2999611 4 4 5 5 if (PHP_VERSION_ID < 50600) { 6 echo 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL; 7 exit(1); 6 if (!headers_sent()) { 7 header('HTTP/1.1 500 Internal Server Error'); 8 } 9 $err = 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL; 10 if (!ini_get('display_errors')) { 11 if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') { 12 fwrite(STDERR, $err); 13 } elseif (!headers_sent()) { 14 echo $err; 15 } 16 } 17 trigger_error( 18 $err, 19 E_USER_ERROR 20 ); 8 21 } 9 22 10 23 require_once __DIR__ . '/composer/autoload_real.php'; 11 24 12 return ComposerAutoloaderInit 05cbe3e4608e27985c01f389568018d6::getLoader();25 return ComposerAutoloaderInit::getLoader(); -
multisite-shared-blocks/tags/1.1.0/vendor/composer/ClassLoader.php
r2795737 r2999611 43 43 class ClassLoader 44 44 { 45 /** @var ?string */ 45 /** @var \Closure(string):void */ 46 private static $includeFile; 47 48 /** @var string|null */ 46 49 private $vendorDir; 47 50 48 51 // PSR-4 49 52 /** 50 * @var array[] 51 * @psalm-var array<string, array<string, int>> 53 * @var array<string, array<string, int>> 52 54 */ 53 55 private $prefixLengthsPsr4 = array(); 54 56 /** 55 * @var array[] 56 * @psalm-var array<string, array<int, string>> 57 * @var array<string, list<string>> 57 58 */ 58 59 private $prefixDirsPsr4 = array(); 59 60 /** 60 * @var array[] 61 * @psalm-var array<string, string> 61 * @var list<string> 62 62 */ 63 63 private $fallbackDirsPsr4 = array(); … … 65 65 // PSR-0 66 66 /** 67 * @var array[] 68 * @psalm-var array<string, array<string, string[]>> 67 * List of PSR-0 prefixes 68 * 69 * Structured as array('F (first letter)' => array('Foo\Bar (full prefix)' => array('path', 'path2'))) 70 * 71 * @var array<string, array<string, list<string>>> 69 72 */ 70 73 private $prefixesPsr0 = array(); 71 74 /** 72 * @var array[] 73 * @psalm-var array<string, string> 75 * @var list<string> 74 76 */ 75 77 private $fallbackDirsPsr0 = array(); … … 79 81 80 82 /** 81 * @var string[] 82 * @psalm-var array<string, string> 83 * @var array<string, string> 83 84 */ 84 85 private $classMap = array(); … … 88 89 89 90 /** 90 * @var bool[] 91 * @psalm-var array<string, bool> 91 * @var array<string, bool> 92 92 */ 93 93 private $missingClasses = array(); 94 94 95 /** @var ?string*/95 /** @var */ 96 96 private $apcuPrefix; 97 97 98 98 /** 99 * @var self[]99 * @var 100 100 */ 101 101 private static $registeredLoaders = array(); 102 102 103 103 /** 104 * @param ?string$vendorDir104 * @param $vendorDir 105 105 */ 106 106 public function __construct($vendorDir = null) 107 107 { 108 108 $this->vendorDir = $vendorDir; 109 } 110 111 /** 112 * @return string[] 109 self::initializeIncludeClosure(); 110 } 111 112 /** 113 * @return array<string, list<string>> 113 114 */ 114 115 public function getPrefixes() … … 122 123 123 124 /** 124 * @return array[] 125 * @psalm-return array<string, array<int, string>> 125 * @return array<string, list<string>> 126 126 */ 127 127 public function getPrefixesPsr4() … … 131 131 132 132 /** 133 * @return array[] 134 * @psalm-return array<string, string> 133 * @return list<string> 135 134 */ 136 135 public function getFallbackDirs() … … 140 139 141 140 /** 142 * @return array[] 143 * @psalm-return array<string, string> 141 * @return list<string> 144 142 */ 145 143 public function getFallbackDirsPsr4() … … 149 147 150 148 /** 151 * @return string[] Array of classname => path 152 * @psalm-return array<string, string> 149 * @return array<string, string> Array of classname => path 153 150 */ 154 151 public function getClassMap() … … 158 155 159 156 /** 160 * @param string[] $classMap Class to filename map 161 * @psalm-param array<string, string> $classMap 157 * @param array<string, string> $classMap Class to filename map 162 158 * 163 159 * @return void … … 176 172 * appending or prepending to the ones previously set for this prefix. 177 173 * 178 * @param string $prefix The prefix179 * @param string[]|string $paths The PSR-0 root directories180 * @param bool $prepend Whether to prepend the directories174 * @param string $prefix The prefix 175 * @param |string $paths The PSR-0 root directories 176 * @param bool $prepend Whether to prepend the directories 181 177 * 182 178 * @return void … … 184 180 public function add($prefix, $paths, $prepend = false) 185 181 { 182 186 183 if (!$prefix) { 187 184 if ($prepend) { 188 185 $this->fallbackDirsPsr0 = array_merge( 189 (array)$paths,186 $paths, 190 187 $this->fallbackDirsPsr0 191 188 ); … … 193 190 $this->fallbackDirsPsr0 = array_merge( 194 191 $this->fallbackDirsPsr0, 195 (array)$paths192 $paths 196 193 ); 197 194 } … … 202 199 $first = $prefix[0]; 203 200 if (!isset($this->prefixesPsr0[$first][$prefix])) { 204 $this->prefixesPsr0[$first][$prefix] = (array)$paths;201 $this->prefixesPsr0[$first][$prefix] = $paths; 205 202 206 203 return; … … 208 205 if ($prepend) { 209 206 $this->prefixesPsr0[$first][$prefix] = array_merge( 210 (array)$paths,207 $paths, 211 208 $this->prefixesPsr0[$first][$prefix] 212 209 ); … … 214 211 $this->prefixesPsr0[$first][$prefix] = array_merge( 215 212 $this->prefixesPsr0[$first][$prefix], 216 (array)$paths213 $paths 217 214 ); 218 215 } … … 223 220 * appending or prepending to the ones previously set for this namespace. 224 221 * 225 * @param string $prefix The prefix/namespace, with trailing '\\'226 * @param string[]|string $paths The PSR-4 base directories227 * @param bool $prepend Whether to prepend the directories222 * @param string $prefix The prefix/namespace, with trailing '\\' 223 * @param |string $paths The PSR-4 base directories 224 * @param bool $prepend Whether to prepend the directories 228 225 * 229 226 * @throws \InvalidArgumentException … … 233 230 public function addPsr4($prefix, $paths, $prepend = false) 234 231 { 232 235 233 if (!$prefix) { 236 234 // Register directories for the root namespace. 237 235 if ($prepend) { 238 236 $this->fallbackDirsPsr4 = array_merge( 239 (array)$paths,237 $paths, 240 238 $this->fallbackDirsPsr4 241 239 ); … … 243 241 $this->fallbackDirsPsr4 = array_merge( 244 242 $this->fallbackDirsPsr4, 245 (array)$paths243 $paths 246 244 ); 247 245 } … … 253 251 } 254 252 $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; 255 $this->prefixDirsPsr4[$prefix] = (array)$paths;253 $this->prefixDirsPsr4[$prefix] = $paths; 256 254 } elseif ($prepend) { 257 255 // Prepend directories for an already registered namespace. 258 256 $this->prefixDirsPsr4[$prefix] = array_merge( 259 (array)$paths,257 $paths, 260 258 $this->prefixDirsPsr4[$prefix] 261 259 ); … … 264 262 $this->prefixDirsPsr4[$prefix] = array_merge( 265 263 $this->prefixDirsPsr4[$prefix], 266 (array)$paths264 $paths 267 265 ); 268 266 } … … 273 271 * replacing any others previously set for this prefix. 274 272 * 275 * @param string $prefix The prefix276 * @param string[]|string $paths The PSR-0 base directories273 * @param string $prefix The prefix 274 * @param |string $paths The PSR-0 base directories 277 275 * 278 276 * @return void … … 291 289 * replacing any others previously set for this namespace. 292 290 * 293 * @param string $prefix The prefix/namespace, with trailing '\\'294 * @param string[]|string $paths The PSR-4 base directories291 * @param string $prefix The prefix/namespace, with trailing '\\' 292 * @param |string $paths The PSR-4 base directories 295 293 * 296 294 * @throws \InvalidArgumentException … … 426 424 { 427 425 if ($file = $this->findFile($class)) { 428 includeFile($file); 426 $includeFile = self::$includeFile; 427 $includeFile($file); 429 428 430 429 return true; … … 477 476 478 477 /** 479 * Returns the currently registered loaders indexed by their corresponding vendor directories.480 * 481 * @return self[]478 * Returns the currently registered loaders ed by their corresponding vendor directories. 479 * 480 * @return 482 481 */ 483 482 public static function getRegisteredLoaders() … … 556 555 return false; 557 556 } 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 558 579 } 559 560 /**561 * Scope isolated include.562 *563 * Prevents access to $this/self from included files.564 *565 * @param string $file566 * @return void567 * @private568 */569 function includeFile($file)570 {571 include $file;572 } -
multisite-shared-blocks/tags/1.1.0/vendor/composer/InstalledVersions.php
r2795737 r2999611 99 99 foreach (self::getInstalled() as $installed) { 100 100 if (isset($installed['versions'][$packageName])) { 101 return $includeDevRequirements || empty($installed['versions'][$packageName]['dev_requirement']);101 return $includeDevRequirements || ; 102 102 } 103 103 } … … 120 120 public static function satisfies(VersionParser $parser, $packageName, $constraint) 121 121 { 122 $constraint = $parser->parseConstraints( $constraint);122 $constraint = $parser->parseConstraints($constraint); 123 123 $provided = $parser->parseConstraints(self::getVersionRanges($packageName)); 124 124 … … 329 329 $installed[] = self::$installedByVendor[$vendorDir]; 330 330 } elseif (is_file($vendorDir.'/composer/installed.php')) { 331 $installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php'; 331 /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */ 332 $required = require $vendorDir.'/composer/installed.php'; 333 $installed[] = self::$installedByVendor[$vendorDir] = $required; 332 334 if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) { 333 335 self::$installed = $installed[count($installed) - 1]; … … 341 343 // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 342 344 if (substr(__DIR__, -8, 1) !== 'C') { 343 self::$installed = require __DIR__ . '/installed.php'; 345 /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */ 346 $required = require __DIR__ . '/installed.php'; 347 self::$installed = $required; 344 348 } else { 345 349 self::$installed = array(); 346 350 } 347 351 } 348 $installed[] = self::$installed; 352 353 if (self::$installed !== array()) { 354 $installed[] = self::$installed; 355 } 349 356 350 357 return $installed; -
multisite-shared-blocks/tags/1.1.0/vendor/composer/autoload_real.php
r2795737 r2999611 3 3 // autoload_real.php @generated by Composer 4 4 5 class ComposerAutoloaderInit 05cbe3e4608e27985c01f389568018d65 class ComposerAutoloaderInit 6 6 { 7 7 private static $loader; … … 23 23 } 24 24 25 spl_autoload_register(array('ComposerAutoloaderInit 05cbe3e4608e27985c01f389568018d6', 'loadClassLoader'), true, true);25 spl_autoload_register(array('ComposerAutoloaderInit', 'loadClassLoader'), true, true); 26 26 self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); 27 spl_autoload_unregister(array('ComposerAutoloaderInit 05cbe3e4608e27985c01f389568018d6', 'loadClassLoader'));27 spl_autoload_unregister(array('ComposerAutoloaderInit', 'loadClassLoader')); 28 28 29 29 require __DIR__ . '/autoload_static.php'; 30 call_user_func(\Composer\Autoload\ComposerStaticInit 05cbe3e4608e27985c01f389568018d6::getInitializer($loader));30 call_user_func(\Composer\Autoload\ComposerStaticInit::getInitializer($loader)); 31 31 32 32 $loader->register(true); -
multisite-shared-blocks/tags/1.1.0/vendor/composer/autoload_static.php
r2795737 r2999611 5 5 namespace Composer\Autoload; 6 6 7 class ComposerStaticInit 05cbe3e4608e27985c01f389568018d67 class ComposerStaticInit 8 8 { 9 9 public static $prefixLengthsPsr4 = array ( … … 156 156 { 157 157 return \Closure::bind(function () use ($loader) { 158 $loader->prefixLengthsPsr4 = ComposerStaticInit 05cbe3e4608e27985c01f389568018d6::$prefixLengthsPsr4;159 $loader->prefixDirsPsr4 = ComposerStaticInit 05cbe3e4608e27985c01f389568018d6::$prefixDirsPsr4;160 $loader->classMap = ComposerStaticInit 05cbe3e4608e27985c01f389568018d6::$classMap;158 $loader->prefixLengthsPsr4 = ComposerStaticInit::$prefixLengthsPsr4; 159 $loader->prefixDirsPsr4 = ComposerStaticInit::$prefixDirsPsr4; 160 $loader->classMap = ComposerStaticInit::$classMap; 161 161 162 162 }, null, ClassLoader::class); -
multisite-shared-blocks/tags/1.1.0/vendor/composer/installed.php
r2795737 r2999611 4 4 'pretty_version' => 'dev-main', 5 5 'version' => 'dev-main', 6 'reference' => ' f1858b313ce8a43de9fe052a72cc29760ccf6a18',6 'reference' => '', 7 7 'type' => 'wordpress-plugin', 8 8 'install_path' => __DIR__ . '/../../', … … 14 14 'pretty_version' => 'dev-main', 15 15 'version' => 'dev-main', 16 'reference' => ' f1858b313ce8a43de9fe052a72cc29760ccf6a18',16 'reference' => '', 17 17 'type' => 'wordpress-plugin', 18 18 'install_path' => __DIR__ . '/../../', -
multisite-shared-blocks/trunk/build/blocks/shared-block/block.json
r2795737 r2999611 3 3 "apiVersion": 2, 4 4 "name": "multisite-shared-blocks/shared-block", 5 "version": "1. 0.0",5 "version": "1..0", 6 6 "title": "Shared Block", 7 7 "category": "design", -
multisite-shared-blocks/trunk/build/blocks/shared-block/index.asset.php
r2795737 r2999611 1 <?php return array('dependencies' => array(' lodash', 'react', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n', 'wp-primitives', 'wp-url'), 'version' => '378f9221b631a49d79a6');1 <?php return array('dependencies' => array(''); -
multisite-shared-blocks/trunk/build/blocks/shared-block/index.js
r2795737 r2999611 1 !function(){"use strict";var e,t={128:function(e,t,o){var r=window.wp.blocks,n=window.wp.element,l=window.lodash,s=window.wp.blockEditor,i=window.wp.components,a=window.wp.i18n,c=window.React,h=o.n(c),p=function(e,t){return p=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var o in t)t.hasOwnProperty(o)&&(e[o]=t[o])},p(e,t)},u=function(){return u=Object.assign||function(e){for(var t,o=1,r=arguments.length;o<r;o++)for(var n in t=arguments[o])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},u.apply(this,arguments)},d="Pixel",m="Percent",f={unit:m,value:.8};function v(e){return"number"==typeof e?{unit:m,value:100*e}:"string"==typeof e?e.match(/^(\d*(\.\d+)?)px$/)?{unit:d,value:parseFloat(e)}:e.match(/^(\d*(\.\d+)?)%$/)?{unit:m,value:parseFloat(e)}:(console.warn('scrollThreshold format is invalid. Valid formats: "120px", "50%"...'),f):(console.warn("scrollThreshold should be string or number"),f)}var g=function(e){function t(t){var o=e.call(this,t)||this;return o.lastScrollTop=0,o.actionTriggered=!1,o.startY=0,o.currentY=0,o.dragging=!1,o.maxPullDownDistance=0,o.getScrollableTarget=function(){return o.props.scrollableTarget instanceof HTMLElement?o.props.scrollableTarget:"string"==typeof o.props.scrollableTarget?document.getElementById(o.props.scrollableTarget):(null===o.props.scrollableTarget&&console.warn("You are trying to pass scrollableTarget but it is null. This might\n happen because the element may not have been added to DOM yet.\n See https://github.com/ankeetmaini/react-infinite-scroll-component/issues/59 for more info.\n "),null)},o.onStart=function(e){o.lastScrollTop||(o.dragging=!0,e instanceof MouseEvent?o.startY=e.pageY:e instanceof TouchEvent&&(o.startY=e.touches[0].pageY),o.currentY=o.startY,o._infScroll&&(o._infScroll.style.willChange="transform",o._infScroll.style.transition="transform 0.2s cubic-bezier(0,0,0.31,1)"))},o.onMove=function(e){o.dragging&&(e instanceof MouseEvent?o.currentY=e.pageY:e instanceof TouchEvent&&(o.currentY=e.touches[0].pageY),o.currentY<o.startY||(o.currentY-o.startY>=Number(o.props.pullDownToRefreshThreshold)&&o.setState({pullToRefreshThresholdBreached:!0}),o.currentY-o.startY>1.5*o.maxPullDownDistance||o._infScroll&&(o._infScroll.style.overflow="visible",o._infScroll.style.transform="translate3d(0px, "+(o.currentY-o.startY)+"px, 0px)")))},o.onEnd=function(){o.startY=0,o.currentY=0,o.dragging=!1,o.state.pullToRefreshThresholdBreached&&(o.props.refreshFunction&&o.props.refreshFunction(),o.setState({pullToRefreshThresholdBreached:!1})),requestAnimationFrame((function(){o._infScroll&&(o._infScroll.style.overflow="auto",o._infScroll.style.transform="none",o._infScroll.style.willChange="unset")}))},o.onScrollListener=function(e){"function"==typeof o.props.onScroll&&setTimeout((function(){return o.props.onScroll&&o.props.onScroll(e)}),0);var t=o.props.height||o._scrollableNode?e.target:document.documentElement.scrollTop?document.documentElement:document.body;o.actionTriggered||((o.props.inverse?o.isElementAtTop(t,o.props.scrollThreshold):o.isElementAtBottom(t,o.props.scrollThreshold))&&o.props.hasMore&&(o.actionTriggered=!0,o.setState({showLoader:!0}),o.props.next&&o.props.next()),o.lastScrollTop=t.scrollTop)},o.state={showLoader:!1,pullToRefreshThresholdBreached:!1,prevDataLength:t.dataLength},o.throttledOnScrollListener=function(e,t,o,r){var n,l=!1,s=0;function i(){n&&clearTimeout(n)}function a(){var a=this,c=Date.now()-s,h=arguments;function p(){s=Date.now(),o.apply(a,h)}function u(){n=void 0}l||(r&&!n&&p(),i(),void 0===r&&c>e?p():!0!==t&&(n=setTimeout(r?u:p,void 0===r?e-c:e)))}return"boolean"!=typeof t&&(r=o,o=t,t=void 0),a.cancel=function(){i(),l=!0},a}(150,o.onScrollListener).bind(o),o.onStart=o.onStart.bind(o),o.onMove=o.onMove.bind(o),o.onEnd=o.onEnd.bind(o),o}return function(e,t){function __(){this.constructor=e}p(e,t),e.prototype=null===t?Object.create(t):(__.prototype=t.prototype,new __)}(t,e),t.prototype.componentDidMount=function(){if(void 0===this.props.dataLength)throw new Error('mandatory prop "dataLength" is missing. The prop is needed when loading more content. Check README.md for usage');if(this._scrollableNode=this.getScrollableTarget(),this.el=this.props.height?this._infScroll:this._scrollableNode||window,this.el&&this.el.addEventListener("scroll",this.throttledOnScrollListener),"number"==typeof this.props.initialScrollY&&this.el&&this.el instanceof HTMLElement&&this.el.scrollHeight>this.props.initialScrollY&&this.el.scrollTo(0,this.props.initialScrollY),this.props.pullDownToRefresh&&this.el&&(this.el.addEventListener("touchstart",this.onStart),this.el.addEventListener("touchmove",this.onMove),this.el.addEventListener("touchend",this.onEnd),this.el.addEventListener("mousedown",this.onStart),this.el.addEventListener("mousemove",this.onMove),this.el.addEventListener("mouseup",this.onEnd),this.maxPullDownDistance=this._pullDown&&this._pullDown.firstChild&&this._pullDown.firstChild.getBoundingClientRect().height||0,this.forceUpdate(),"function"!=typeof this.props.refreshFunction))throw new Error('Mandatory prop "refreshFunction" missing.\n Pull Down To Refresh functionality will not work\n as expected. Check README.md for usage\'')},t.prototype.componentWillUnmount=function(){this.el&&(this.el.removeEventListener("scroll",this.throttledOnScrollListener),this.props.pullDownToRefresh&&(this.el.removeEventListener("touchstart",this.onStart),this.el.removeEventListener("touchmove",this.onMove),this.el.removeEventListener("touchend",this.onEnd),this.el.removeEventListener("mousedown",this.onStart),this.el.removeEventListener("mousemove",this.onMove),this.el.removeEventListener("mouseup",this.onEnd)))},t.prototype.componentDidUpdate=function(e){this.props.dataLength!==e.dataLength&&(this.actionTriggered=!1,this.setState({showLoader:!1}))},t.getDerivedStateFromProps=function(e,t){return e.dataLength!==t.prevDataLength?u(u({},t),{prevDataLength:e.dataLength}):null},t.prototype.isElementAtTop=function(e,t){void 0===t&&(t=.8);var o=e===document.body||e===document.documentElement?window.screen.availHeight:e.clientHeight,r=v(t);return r.unit===d?e.scrollTop<=r.value+o-e.scrollHeight+1:e.scrollTop<=r.value/100+o-e.scrollHeight+1},t.prototype.isElementAtBottom=function(e,t){void 0===t&&(t=.8);var o=e===document.body||e===document.documentElement?window.screen.availHeight:e.clientHeight,r=v(t);return r.unit===d?e.scrollTop+o>=e.scrollHeight-r.value:e.scrollTop+o>=r.value/100*e.scrollHeight},t.prototype.render=function(){var e=this,t=u({height:this.props.height||"auto",overflow:"auto",WebkitOverflowScrolling:"touch"},this.props.style),o=this.props.hasChildren||!!(this.props.children&&this.props.children instanceof Array&&this.props.children.length),r=this.props.pullDownToRefresh&&this.props.height?{overflow:"auto"}:{};return h().createElement("div",{style:r,className:"infinite-scroll-component__outerdiv"},h().createElement("div",{className:"infinite-scroll-component "+(this.props.className||""),ref:function(t){return e._infScroll=t},style:t},this.props.pullDownToRefresh&&h().createElement("div",{style:{position:"relative"},ref:function(t){return e._pullDown=t}},h().createElement("div",{style:{position:"absolute",left:0,right:0,top:-1*this.maxPullDownDistance}},this.state.pullToRefreshThresholdBreached?this.props.releaseToRefreshContent:this.props.pullDownToRefreshContent)),this.props.children,!this.state.showLoader&&!o&&this.props.hasMore&&this.props.loader,this.state.showLoader&&this.props.hasMore&&this.props.loader,!this.props.hasMore&&this.props.endMessage))},t}(c.Component),b=g,w=window.wp.apiFetch,_=o.n(w),E=window.wp.url;function y(e){let{onItemSelect:t}=e;const{sites:o=[],post_types:r=[]}=multisiteSharedBlocksEditorData,l=Object.keys(o).map((e=>({label:o[e],value:e}))),s=Object.keys(r).map((e=>({label:r[e],value:e}))),[c,h]=(0,n.useState)({search:"",postType:"",site:0}),[p,u]=(0,n.useState)([]),[d,m]=(0,n.useState)(!0),[f,v]=(0,n.useState)(1),[g,w]=(0,n.useState)(!1),y=()=>{u([]),v(1),w(!1),m(!0)};(0,n.useEffect)((()=>{const e=void 0===window.AbortController?void 0:new window.AbortController;return k(c,e),()=>null==e?void 0:e.abort()}),[c]);const k=(e,t)=>{(function(e,t){const o=(0,E.addQueryArgs)("/multisite-shared-blocks/v1/search",{search:e.search||"",post_type:e.postType&&""!==e.postType?[e.postType]:[],site_in:e.site&&0!==e.site?[e.site]:[],page:e.page||1,per_page:e.per_page||30});return _()({path:o,signal:null==t?void 0:t.signal})})({...e,page:f},t).then((e=>p.length||e.length?e.length?(u([...p,...e]),v(f+1),m(!0),void w(!0)):void w(!1):(m(!1),void w(!1)))).catch((e=>{w(!1),"rest_search_invalid_page_number"!==e.code&&(u([]),m(!1),v(1))}))};return(0,n.createElement)("div",{className:"shared-block-selector"},(0,n.createElement)("div",{className:"shared-block-selector__filters"},(0,n.createElement)("div",{className:"filter filter--sites"},(0,n.createElement)(i.SelectControl,{label:(0,a.__)("Filter by site","multisite-shared-blocks"),value:c.site,options:[{value:0,label:(0,a.__)("All","multisite-shared-blocks")},...l],onChange:e=>{var t;t="0"!==e?+e:0,h({...c,site:t}),y()}})),(0,n.createElement)("div",{className:"filter filter--posttypes"},(0,n.createElement)(i.SelectControl,{label:(0,a.__)("Filter by post type","multisite-shared-blocks"),value:c.postType,options:[{value:0,label:(0,a.__)("All","multisite-shared-blocks")},...s],onChange:e=>{var t;t="0"!==e?e:"",h({...c,postType:t}),y()}})),(0,n.createElement)(i.TextControl,{label:(0,a.__)("Search for a shared block","multisite-shared-blocks"),className:"filter filter--search",onChange:e=>{var t;t=e,h({...c,search:t}),y()}})),(0,n.createElement)("div",{className:"shared-block-selector__results"},d?(0,n.createElement)(b,{dataLength:p.length,next:()=>k(c),hasMore:g,height:300,loader:(0,n.createElement)(i.Spinner,null)},p.map((e=>(0,n.createElement)("div",{key:e.id,className:"results__item"},(0,n.createElement)(i.Button,{variant:"link",label:(0,a.sprintf)(//translators: %s shared block title 2 (0,a.__)('Select block "%s"',"multisite-shared-blocks"),e.block_title),onClick:()=>{t(e)}},`${e.full_block_title}`))))):(0,n.createElement)("div",{className:"no-results"},(0,a.__)("No results.","multisite-shared-blocks"))))}var k=window.wp.primitives,T=(0,n.createElement)(k.SVG,{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",fill:"none",viewBox:"0 0 24 24"},(0,n.createElement)(k.Path,{fill:"#000","fill-rule":"evenodd",d:"M14.247 0H9.753c-.715 0-1.327.647-1.327 1.402V4.8c0 .755.612 1.402 1.327 1.402h1.736v2.034c-1.599.242-2.857 1.601-3.04 3.306h-1.3v-1.295c0-.755-.613-1.402-1.328-1.402H1.328C.613 8.845 0 9.492 0 10.247v3.398c0 .755.613 1.402 1.328 1.402H5.82c.715 0 1.328-.647 1.328-1.402V12.62h1.329c.262 1.602 1.48 2.859 3.011 3.09v2.088H9.753c-.715 0-1.327.647-1.327 1.402v3.398c0 .755.612 1.402 1.327 1.402h4.494c.715 0 1.328-.647 1.328-1.402V19.2c0-.809-.613-1.402-1.328-1.402H12.51V15.71c1.53-.231 2.75-1.488 3.011-3.09h1.329v1.025c0 .755.613 1.402 1.328 1.402h4.493c.715 0 1.328-.647 1.328-1.402v-3.398c0-.755-.613-1.402-1.328-1.402H18.18c-.715 0-1.328.647-1.328 1.402v1.295h-1.3c-.183-1.705-1.441-3.064-3.04-3.306V6.202h1.736c.715 0 1.328-.647 1.328-1.402V1.402C15.575.593 14.962 0 14.247 0Zm.306 4.746c0 .162-.153.324-.306.324H9.753c-.153 0-.306-.162-.306-.324V1.402c0-.162.153-.323.306-.323h4.494c.153 0 .306.108.306.323v3.344ZM12 9.276c-1.41 0-2.553 1.208-2.553 2.697 0 1.49 1.143 2.697 2.553 2.697s2.553-1.208 2.553-2.697c0-1.49-1.143-2.697-2.553-2.697Zm10.979 4.369c0 .162-.153.324-.307.324H18.18c-.153 0-.307-.162-.307-.324v-3.398c0-.162.154-.323.307-.323h4.493c.154 0 .307.161.307.323v3.398Zm-17.158.324c.153 0 .307-.162.307-.324v-3.398c0-.162-.154-.323-.307-.323H1.328c-.154 0-.307.161-.307.323v3.398c0 .162.153.324.307.324H5.82Zm8.426 8.898c.153 0 .306-.161.306-.323v-3.398c0-.162-.153-.323-.306-.323H9.753c-.153 0-.306.161-.306.323v3.398c0 .162.153.323.306.323h4.494Z","clip-rule":"evenodd"}));(0,r.registerBlockType)("multisite-shared-blocks/shared-block",{icon:T,edit:function(e){let{attributes:t,setAttributes:o}=e;const{blockId:r,blockTitle:c,display:h}=t,[p,u]=(0,n.useState)(!1),d=e=>{o({display:e})};return(0,n.createElement)("div",(0,s.useBlockProps)(),(0,n.createElement)(s.InspectorControls,null,(0,n.createElement)(i.PanelBody,{title:(0,a.__)("Display options","multisite-shared-blocks")},(0,n.createElement)(i.ButtonGroup,null,(0,n.createElement)(i.Button,{onClick:()=>d("full"),isPressed:"full"===h},(0,a.__)("Full content","multisite-shared-blocks")),(0,n.createElement)(i.Button,{onClick:()=>d("excerpt"),isPressed:"excerpt"===h},(0,a.__)("Excerpt","multisite-shared-blocks"))))),(0,l.isEmpty)(r)||p?(0,n.createElement)("div",{className:"shared-block-selector-wrapper"},!1===(0,l.isEmpty)(r)&&(0,n.createElement)("div",{className:"shared-block-selector-wrapper__cancel"},(0,n.createElement)("div",{className:"shared-block-selector-wrapper__cancel--message"},(0,a.__)("Cancel changes and keep current selected block ?","multisite-shared-blocks")),(0,n.createElement)(i.Button,{className:"shared-block-selector-wrapper__cancel--button",variant:"secondary",isDestructive:!0,onClick:()=>u(!1)},(0,a.__)("Cancel changes","multisite-shared-blocks"))),(0,n.createElement)(y,{onItemSelect:e=>{var t;o({siteId:(t=e).site_id,postId:t.post_id,blockId:t.block_id,blockTitle:t.full_block_title}),u(!1)}})):(0,n.createElement)(i.Placeholder,{icon:T,label:(0,a.__)("Shared Block","multisite-shared-blocks"),instructions:(m=h,"full"===m?(0,n.createElement)("p",null,(0,n.createInterpolateElement)((0,a.sprintf)(// translators: %s is the shared block's title 3 (0,a.__)('Shared block <strong>"%s"</strong> will be displayed here.',"multisite-shared-blocks"),c),{strong:(0,n.createElement)("strong",null)})):(0,n.createElement)("p",null,(0,n.createInterpolateElement)((0,a.sprintf)(// translators: %s is the shared block's title 4 (0,a.__)('Excerpt for the shared block <strong>"%s"</strong> will be displayed here.',"multisite-shared-blocks"),c),{strong:(0,n.createElement)("strong",null)}))),className:"shared-block-placeholder"},(0,n.createElement)(i.Button,{variant:"primary",onClick:()=>u(!0)},(0,a.__)("Choose a new block","multisite-shared-blocks"))));var m}})}},o={};function r(e){var n=o[e];if(void 0!==n)return n.exports;var l=o[e]={exports:{}};return t[e](l,l.exports,r),l.exports}r.m=t,e=[],r.O=function(t,o,n,l){if(!o){var s=1/0;for(h=0;h<e.length;h++){o=e[h][0],n=e[h][1],l=e[h][2];for(var i=!0,a=0;a<o.length;a++)(!1&l||s>=l)&&Object.keys(r.O).every((function(e){return r.O[e](o[a])}))?o.splice(a--,1):(i=!1,l<s&&(s=l));if(i){e.splice(h--,1);var c=n();void 0!==c&&(t=c)}}return t}l=l||0;for(var h=e.length;h>0&&e[h-1][2]>l;h--)e[h]=e[h-1];e[h]=[o,n,l]},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,{a:t}),t},r.d=function(e,t){for(var o in t)r.o(t,o)&&!r.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},function(){var e={261:0,570:0};r.O.j=function(t){return 0===e[t]};var t=function(t,o){var n,l,s=o[0],i=o[1],a=o[2],c=0;if(s.some((function(t){return 0!==e[t]}))){for(n in i)r.o(i,n)&&(r.m[n]=i[n]);if(a)var h=a(r)}for(t&&t(o);c<s.length;c++)l=s[c],r.o(e,l)&&e[l]&&e[l][0](),e[l]=0;return r.O(h)},o=self.webpackChunkmultisite_shared_blocks=self.webpackChunkmultisite_shared_blocks||[];o.forEach(t.bind(null,0)),o.push=t.bind(null,o.push.bind(o))}();var n=r.O(void 0,[570],(function(){return r(128)}));n=r.O(n)}(); 1 (()=>{"use strict";var e,t={843:(e,t,o)=>{const r=window.wp.blocks,l=window.React;var n=o.n(l);const s=window.wp.blockEditor,i=window.wp.element,a=window.wp.components,c=window.wp.i18n;var h=function(e,t){return h=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var o in t)t.hasOwnProperty(o)&&(e[o]=t[o])},h(e,t)},p=function(){return p=Object.assign||function(e){for(var t,o=1,r=arguments.length;o<r;o++)for(var l in t=arguments[o])Object.prototype.hasOwnProperty.call(t,l)&&(e[l]=t[l]);return e},p.apply(this,arguments)},u="Pixel",d="Percent",m={unit:d,value:.8};function v(e){return"number"==typeof e?{unit:d,value:100*e}:"string"==typeof e?e.match(/^(\d*(\.\d+)?)px$/)?{unit:u,value:parseFloat(e)}:e.match(/^(\d*(\.\d+)?)%$/)?{unit:d,value:parseFloat(e)}:(console.warn('scrollThreshold format is invalid. Valid formats: "120px", "50%"...'),m):(console.warn("scrollThreshold should be string or number"),m)}const f=function(e){function t(t){var o=e.call(this,t)||this;return o.lastScrollTop=0,o.actionTriggered=!1,o.startY=0,o.currentY=0,o.dragging=!1,o.maxPullDownDistance=0,o.getScrollableTarget=function(){return o.props.scrollableTarget instanceof HTMLElement?o.props.scrollableTarget:"string"==typeof o.props.scrollableTarget?document.getElementById(o.props.scrollableTarget):(null===o.props.scrollableTarget&&console.warn("You are trying to pass scrollableTarget but it is null. This might\n happen because the element may not have been added to DOM yet.\n See https://github.com/ankeetmaini/react-infinite-scroll-component/issues/59 for more info.\n "),null)},o.onStart=function(e){o.lastScrollTop||(o.dragging=!0,e instanceof MouseEvent?o.startY=e.pageY:e instanceof TouchEvent&&(o.startY=e.touches[0].pageY),o.currentY=o.startY,o._infScroll&&(o._infScroll.style.willChange="transform",o._infScroll.style.transition="transform 0.2s cubic-bezier(0,0,0.31,1)"))},o.onMove=function(e){o.dragging&&(e instanceof MouseEvent?o.currentY=e.pageY:e instanceof TouchEvent&&(o.currentY=e.touches[0].pageY),o.currentY<o.startY||(o.currentY-o.startY>=Number(o.props.pullDownToRefreshThreshold)&&o.setState({pullToRefreshThresholdBreached:!0}),o.currentY-o.startY>1.5*o.maxPullDownDistance||o._infScroll&&(o._infScroll.style.overflow="visible",o._infScroll.style.transform="translate3d(0px, "+(o.currentY-o.startY)+"px, 0px)")))},o.onEnd=function(){o.startY=0,o.currentY=0,o.dragging=!1,o.state.pullToRefreshThresholdBreached&&(o.props.refreshFunction&&o.props.refreshFunction(),o.setState({pullToRefreshThresholdBreached:!1})),requestAnimationFrame((function(){o._infScroll&&(o._infScroll.style.overflow="auto",o._infScroll.style.transform="none",o._infScroll.style.willChange="unset")}))},o.onScrollListener=function(e){"function"==typeof o.props.onScroll&&setTimeout((function(){return o.props.onScroll&&o.props.onScroll(e)}),0);var t=o.props.height||o._scrollableNode?e.target:document.documentElement.scrollTop?document.documentElement:document.body;o.actionTriggered||((o.props.inverse?o.isElementAtTop(t,o.props.scrollThreshold):o.isElementAtBottom(t,o.props.scrollThreshold))&&o.props.hasMore&&(o.actionTriggered=!0,o.setState({showLoader:!0}),o.props.next&&o.props.next()),o.lastScrollTop=t.scrollTop)},o.state={showLoader:!1,pullToRefreshThresholdBreached:!1,prevDataLength:t.dataLength},o.throttledOnScrollListener=function(e,t,o,r){var l,n=!1,s=0;function i(){l&&clearTimeout(l)}function a(){var e=this,a=Date.now()-s,c=arguments;function h(){s=Date.now(),o.apply(e,c)}n||(r&&!l&&h(),i(),void 0===r&&a>150?h():!0!==t&&(l=setTimeout(r?function(){l=void 0}:h,void 0===r?150-a:150)))}return"boolean"!=typeof t&&(r=o,o=t,t=void 0),a.cancel=function(){i(),n=!0},a}(0,o.onScrollListener).bind(o),o.onStart=o.onStart.bind(o),o.onMove=o.onMove.bind(o),o.onEnd=o.onEnd.bind(o),o}return function(e,t){function __(){this.constructor=e}h(e,t),e.prototype=null===t?Object.create(t):(__.prototype=t.prototype,new __)}(t,e),t.prototype.componentDidMount=function(){if(void 0===this.props.dataLength)throw new Error('mandatory prop "dataLength" is missing. The prop is needed when loading more content. Check README.md for usage');if(this._scrollableNode=this.getScrollableTarget(),this.el=this.props.height?this._infScroll:this._scrollableNode||window,this.el&&this.el.addEventListener("scroll",this.throttledOnScrollListener),"number"==typeof this.props.initialScrollY&&this.el&&this.el instanceof HTMLElement&&this.el.scrollHeight>this.props.initialScrollY&&this.el.scrollTo(0,this.props.initialScrollY),this.props.pullDownToRefresh&&this.el&&(this.el.addEventListener("touchstart",this.onStart),this.el.addEventListener("touchmove",this.onMove),this.el.addEventListener("touchend",this.onEnd),this.el.addEventListener("mousedown",this.onStart),this.el.addEventListener("mousemove",this.onMove),this.el.addEventListener("mouseup",this.onEnd),this.maxPullDownDistance=this._pullDown&&this._pullDown.firstChild&&this._pullDown.firstChild.getBoundingClientRect().height||0,this.forceUpdate(),"function"!=typeof this.props.refreshFunction))throw new Error('Mandatory prop "refreshFunction" missing.\n Pull Down To Refresh functionality will not work\n as expected. Check README.md for usage\'')},t.prototype.componentWillUnmount=function(){this.el&&(this.el.removeEventListener("scroll",this.throttledOnScrollListener),this.props.pullDownToRefresh&&(this.el.removeEventListener("touchstart",this.onStart),this.el.removeEventListener("touchmove",this.onMove),this.el.removeEventListener("touchend",this.onEnd),this.el.removeEventListener("mousedown",this.onStart),this.el.removeEventListener("mousemove",this.onMove),this.el.removeEventListener("mouseup",this.onEnd)))},t.prototype.componentDidUpdate=function(e){this.props.dataLength!==e.dataLength&&(this.actionTriggered=!1,this.setState({showLoader:!1}))},t.getDerivedStateFromProps=function(e,t){return e.dataLength!==t.prevDataLength?p(p({},t),{prevDataLength:e.dataLength}):null},t.prototype.isElementAtTop=function(e,t){void 0===t&&(t=.8);var o=e===document.body||e===document.documentElement?window.screen.availHeight:e.clientHeight,r=v(t);return r.unit===u?e.scrollTop<=r.value+o-e.scrollHeight+1:e.scrollTop<=r.value/100+o-e.scrollHeight+1},t.prototype.isElementAtBottom=function(e,t){void 0===t&&(t=.8);var o=e===document.body||e===document.documentElement?window.screen.availHeight:e.clientHeight,r=v(t);return r.unit===u?e.scrollTop+o>=e.scrollHeight-r.value:e.scrollTop+o>=r.value/100*e.scrollHeight},t.prototype.render=function(){var e=this,t=p({height:this.props.height||"auto",overflow:"auto",WebkitOverflowScrolling:"touch"},this.props.style),o=this.props.hasChildren||!!(this.props.children&&this.props.children instanceof Array&&this.props.children.length),r=this.props.pullDownToRefresh&&this.props.height?{overflow:"auto"}:{};return n().createElement("div",{style:r,className:"infinite-scroll-component__outerdiv"},n().createElement("div",{className:"infinite-scroll-component "+(this.props.className||""),ref:function(t){return e._infScroll=t},style:t},this.props.pullDownToRefresh&&n().createElement("div",{style:{position:"relative"},ref:function(t){return e._pullDown=t}},n().createElement("div",{style:{position:"absolute",left:0,right:0,top:-1*this.maxPullDownDistance}},this.state.pullToRefreshThresholdBreached?this.props.releaseToRefreshContent:this.props.pullDownToRefreshContent)),this.props.children,!this.state.showLoader&&!o&&this.props.hasMore&&this.props.loader,this.state.showLoader&&this.props.hasMore&&this.props.loader,!this.props.hasMore&&this.props.endMessage))},t}(l.Component),g=window.wp.apiFetch;var b=o.n(g);const w=window.wp.url;function _({onItemSelect:e}){const{sites:t=[],post_types:o=[]}=multisiteSharedBlocksEditorData,r=Object.keys(t).map((e=>({label:t[e],value:e}))),n=Object.keys(o).map((e=>({label:o[e],value:e}))),[s,h]=(0,i.useState)({search:"",postType:"",site:0}),[p,u]=(0,i.useState)([]),[d,m]=(0,i.useState)(!0),[v,g]=(0,i.useState)(1),[_,E]=(0,i.useState)(!1),y=()=>{u([]),g(1),E(!1),m(!0)};(0,i.useEffect)((()=>{const e=void 0===window.AbortController?void 0:new window.AbortController;return k(s,e),()=>e?.abort()}),[s]);const k=(e,t)=>{(function(e,t){const o=(0,w.addQueryArgs)("/multisite-shared-blocks/v1/search",{search:e.search||"",post_type:e.postType&&""!==e.postType?[e.postType]:[],site_in:e.site&&0!==e.site?[e.site]:[],page:e.page||1,per_page:e.per_page||30});return b()({path:o,signal:t?.signal})})({...e,page:v},t).then((e=>p.length||e.length?e.length?(u([...p,...e]),g(v+1),m(!0),void E(!0)):void E(!1):(m(!1),void E(!1)))).catch((e=>{E(!1),"rest_search_invalid_page_number"!==e.code&&(u([]),m(!1),g(1))}))};return(0,l.createElement)("div",{className:"shared-block-selector"},(0,l.createElement)("div",{className:"shared-block-selector__filters"},(0,l.createElement)("div",{className:"filter filter--sites"},(0,l.createElement)(a.SelectControl,{label:(0,c.__)("Filter by site","multisite-shared-blocks"),value:s.site,options:[{value:0,label:(0,c.__)("All","multisite-shared-blocks")},...r],onChange:e=>{var t;t="0"!==e?+e:0,h({...s,site:t}),y()}})),(0,l.createElement)("div",{className:"filter filter--posttypes"},(0,l.createElement)(a.SelectControl,{label:(0,c.__)("Filter by post type","multisite-shared-blocks"),value:s.postType,options:[{value:0,label:(0,c.__)("All","multisite-shared-blocks")},...n],onChange:e=>{var t;t="0"!==e?e:"",h({...s,postType:t}),y()}})),(0,l.createElement)(a.TextControl,{label:(0,c.__)("Search for a shared block","multisite-shared-blocks"),className:"filter filter--search",onChange:e=>{var t;t=e,h({...s,search:t}),y()}})),(0,l.createElement)("div",{className:"shared-block-selector__results"},d?(0,l.createElement)(f,{dataLength:p.length,next:()=>k(s),hasMore:_,height:300,loader:(0,l.createElement)(a.Spinner,null)},p.map((t=>(0,l.createElement)("div",{key:t.id,className:"results__item"},(0,l.createElement)(a.Button,{variant:"link",label:(0,c.sprintf)( 2 //translators: %s shared block title 3 (0,c.__)('Select block "%s"',"multisite-shared-blocks"),t.block_title),onClick:()=>{e(t)}},`${t.full_block_title}`))))):(0,l.createElement)("div",{className:"no-results"},(0,c.__)("No results.","multisite-shared-blocks"))))}const E=window.wp.primitives,y=(0,l.createElement)(E.SVG,{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",fill:"none",viewBox:"0 0 24 24"},(0,l.createElement)(E.Path,{fill:"#000",fillRule:"evenodd",d:"M14.247 0H9.753c-.715 0-1.327.647-1.327 1.402V4.8c0 .755.612 1.402 1.327 1.402h1.736v2.034c-1.599.242-2.857 1.601-3.04 3.306h-1.3v-1.295c0-.755-.613-1.402-1.328-1.402H1.328C.613 8.845 0 9.492 0 10.247v3.398c0 .755.613 1.402 1.328 1.402H5.82c.715 0 1.328-.647 1.328-1.402V12.62h1.329c.262 1.602 1.48 2.859 3.011 3.09v2.088H9.753c-.715 0-1.327.647-1.327 1.402v3.398c0 .755.612 1.402 1.327 1.402h4.494c.715 0 1.328-.647 1.328-1.402V19.2c0-.809-.613-1.402-1.328-1.402H12.51V15.71c1.53-.231 2.75-1.488 3.011-3.09h1.329v1.025c0 .755.613 1.402 1.328 1.402h4.493c.715 0 1.328-.647 1.328-1.402v-3.398c0-.755-.613-1.402-1.328-1.402H18.18c-.715 0-1.328.647-1.328 1.402v1.295h-1.3c-.183-1.705-1.441-3.064-3.04-3.306V6.202h1.736c.715 0 1.328-.647 1.328-1.402V1.402C15.575.593 14.962 0 14.247 0Zm.306 4.746c0 .162-.153.324-.306.324H9.753c-.153 0-.306-.162-.306-.324V1.402c0-.162.153-.323.306-.323h4.494c.153 0 .306.108.306.323v3.344ZM12 9.276c-1.41 0-2.553 1.208-2.553 2.697 0 1.49 1.143 2.697 2.553 2.697s2.553-1.208 2.553-2.697c0-1.49-1.143-2.697-2.553-2.697Zm10.979 4.369c0 .162-.153.324-.307.324H18.18c-.153 0-.307-.162-.307-.324v-3.398c0-.162.154-.323.307-.323h4.493c.154 0 .307.161.307.323v3.398Zm-17.158.324c.153 0 .307-.162.307-.324v-3.398c0-.162-.154-.323-.307-.323H1.328c-.154 0-.307.161-.307.323v3.398c0 .162.153.324.307.324H5.82Zm8.426 8.898c.153 0 .306-.161.306-.323v-3.398c0-.162-.153-.323-.306-.323H9.753c-.153 0-.306.161-.306.323v3.398c0 .162.153.323.306.323h4.494Z",clipRule:"evenodd"}));(0,r.registerBlockType)("multisite-shared-blocks/shared-block",{icon:y,edit:function({attributes:e,setAttributes:t}){const{blockId:o,blockTitle:r,display:n}=e,h=!!(o&&o.length>0),[p,u]=(0,i.useState)(!1),d=e=>{t({display:e})};return(0,l.createElement)("div",{...(0,s.useBlockProps)()},(0,l.createElement)(s.InspectorControls,null,(0,l.createElement)(a.PanelBody,{title:(0,c.__)("Display options","multisite-shared-blocks")},(0,l.createElement)(a.ButtonGroup,null,(0,l.createElement)(a.Button,{onClick:()=>d("full"),isPressed:"full"===n},(0,c.__)("Full content","multisite-shared-blocks")),(0,l.createElement)(a.Button,{onClick:()=>d("excerpt"),isPressed:"excerpt"===n},(0,c.__)("Excerpt","multisite-shared-blocks"))))),!h||p?(0,l.createElement)("div",{className:"shared-block-selector-wrapper"},h&&(0,l.createElement)("div",{className:"shared-block-selector-wrapper__cancel"},(0,l.createElement)("div",{className:"shared-block-selector-wrapper__cancel--message"},(0,c.__)("Cancel changes and keep current selected block ?","multisite-shared-blocks")),(0,l.createElement)(a.Button,{className:"shared-block-selector-wrapper__cancel--button",variant:"secondary",isDestructive:!0,onClick:()=>u(!1)},(0,c.__)("Cancel changes","multisite-shared-blocks"))),(0,l.createElement)(_,{onItemSelect:e=>{var o;t({siteId:(o=e).site_id,postId:o.post_id,blockId:o.block_id,blockTitle:o.full_block_title}),u(!1)}})):(0,l.createElement)(a.Placeholder,{icon:y,label:(0,c.__)("Shared Block","multisite-shared-blocks"),className:"shared-block-placeholder"},"full"===n?(0,l.createElement)("p",null,(0,i.createInterpolateElement)((0,c.sprintf)( 4 // translators: %s is the shared block's title 5 (0,c.__)('Shared block <strong>"%s"</strong> will be displayed here.',"multisite-shared-blocks"),r),{strong:(0,l.createElement)("strong",null)})):(0,l.createElement)("p",null,(0,i.createInterpolateElement)((0,c.sprintf)( 6 // translators: %s is the shared block's title 7 (0,c.__)('Excerpt for the shared block <strong>"%s"</strong> will be displayed here.',"multisite-shared-blocks"),r),{strong:(0,l.createElement)("strong",null)})),(0,l.createElement)(a.Button,{variant:"primary",onClick:()=>u(!0)},(0,c.__)("Choose a new block","multisite-shared-blocks"))))}})}},o={};function r(e){var l=o[e];if(void 0!==l)return l.exports;var n=o[e]={exports:{}};return t[e](n,n.exports,r),n.exports}r.m=t,e=[],r.O=(t,o,l,n)=>{if(!o){var s=1/0;for(h=0;h<e.length;h++){for(var[o,l,n]=e[h],i=!0,a=0;a<o.length;a++)(!1&n||s>=n)&&Object.keys(r.O).every((e=>r.O[e](o[a])))?o.splice(a--,1):(i=!1,n<s&&(s=n));if(i){e.splice(h--,1);var c=l();void 0!==c&&(t=c)}}return t}n=n||0;for(var h=e.length;h>0&&e[h-1][2]>n;h--)e[h]=e[h-1];e[h]=[o,l,n]},r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var o in t)r.o(t,o)&&!r.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{var e={261:0,570:0};r.O.j=t=>0===e[t];var t=(t,o)=>{var l,n,[s,i,a]=o,c=0;if(s.some((t=>0!==e[t]))){for(l in i)r.o(i,l)&&(r.m[l]=i[l]);if(a)var h=a(r)}for(t&&t(o);c<s.length;c++)n=s[c],r.o(e,n)&&e[n]&&e[n][0](),e[n]=0;return r.O(h)},o=globalThis.webpackChunkmultisite_shared_blocks=globalThis.webpackChunkmultisite_shared_blocks||[];o.forEach(t.bind(null,0)),o.push=t.bind(null,o.push.bind(o))})();var l=r.O(void 0,[570],(()=>r(843)));l=r.O(l)})(); -
multisite-shared-blocks/trunk/build/hooks/index.asset.php
r2795737 r2999611 1 <?php return array('dependencies' => array(' lodash', 'wp-block-editor', 'wp-components', 'wp-compose', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-primitives', 'wp-wordcount'), 'version' => '7f97294b81488f990fb4');1 <?php return array('dependencies' => array(''); -
multisite-shared-blocks/trunk/build/hooks/index.js
r2795737 r2999611 1 !function(){"use strict";var e=window.wp.hooks,t=window.lodash;function r(e){var t;return!(null!==(t=multisiteSharedBlocksHooksData.excluded_blocks)&&void 0!==t?t:[]).includes(e)}var o,s=window.wp.element,n=new Uint8Array(16);function l(){if(!o&&!(o="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return o(n)}for(var i=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i,a=function(e){return"string"==typeof e&&i.test(e)},c=[],d=0;d<256;++d)c.push((d+256).toString(16).substr(1));var h=function(e,t,r){var o=(e=e||{}).random||(e.rng||l)();if(o[6]=15&o[6]|64,o[8]=63&o[8]|128,t){r=r||0;for(var s=0;s<16;++s)t[r+s]=o[s];return t}return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=(c[e[t+0]]+c[e[t+1]]+c[e[t+2]]+c[e[t+3]]+"-"+c[e[t+4]]+c[e[t+5]]+"-"+c[e[t+6]]+c[e[t+7]]+"-"+c[e[t+8]]+c[e[t+9]]+"-"+c[e[t+10]]+c[e[t+11]]+c[e[t+12]]+c[e[t+13]]+c[e[t+14]]+c[e[t+15]]).toLowerCase();if(!a(r))throw TypeError("Stringified UUID is invalid");return r}(o)},u=window.wp.compose,m=(0,u.createHigherOrderComponent)((e=>class extends s.Component{componentDidMount(){const{name:e,setAttributes:t,attributes:{sharedBlockId:o}=!1}=this.props;r(e)&&!o&&t({sharedBlockId:h()})}render(){return(0,s.createElement)(e,this.props)}}),"sharedBlockIdComponent"),p=window.wp.blockEditor,w=window.wp.components,b=window.wp.wordcount,k=window.wp.i18n,v=window.wp.primitives,f=(0,s.createElement)(v.SVG,{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",fill:"none",viewBox:"0 0 24 24"},(0,s.createElement)(v.Path,{fill:"#000","fill-rule":"evenodd",d:"M14.247 0H9.753c-.715 0-1.327.647-1.327 1.402V4.8c0 .755.612 1.402 1.327 1.402h1.736v2.034c-1.599.242-2.857 1.601-3.04 3.306h-1.3v-1.295c0-.755-.613-1.402-1.328-1.402H1.328C.613 8.845 0 9.492 0 10.247v3.398c0 .755.613 1.402 1.328 1.402H5.82c.715 0 1.328-.647 1.328-1.402V12.62h1.329c.262 1.602 1.48 2.859 3.011 3.09v2.088H9.753c-.715 0-1.327.647-1.327 1.402v3.398c0 .755.612 1.402 1.327 1.402h4.494c.715 0 1.328-.647 1.328-1.402V19.2c0-.809-.613-1.402-1.328-1.402H12.51V15.71c1.53-.231 2.75-1.488 3.011-3.09h1.329v1.025c0 .755.613 1.402 1.328 1.402h4.493c.715 0 1.328-.647 1.328-1.402v-3.398c0-.755-.613-1.402-1.328-1.402H18.18c-.715 0-1.328.647-1.328 1.402v1.295h-1.3c-.183-1.705-1.441-3.064-3.04-3.306V6.202h1.736c.715 0 1.328-.647 1.328-1.402V1.402C15.575.593 14.962 0 14.247 0Zm.306 4.746c0 .162-.153.324-.306.324H9.753c-.153 0-.306-.162-.306-.324V1.402c0-.162.153-.323.306-.323h4.494c.153 0 .306.108.306.323v3.344ZM12 9.276c-1.41 0-2.553 1.208-2.553 2.697 0 1.49 1.143 2.697 2.553 2.697s2.553-1.208 2.553-2.697c0-1.49-1.143-2.697-2.553-2.697Zm10.979 4.369c0 .162-.153.324-.307.324H18.18c-.153 0-.307-.162-.307-.324v-3.398c0-.162.154-.323.307-.323h4.493c.154 0 .307.161.307.323v3.398Zm-17.158.324c.153 0 .307-.162.307-.324v-3.398c0-.162-.154-.323-.307-.323H1.328c-.154 0-.307.161-.307.323v3.398c0 .162.153.324.307.324H5.82Zm8.426 8.898c.153 0 .306-.161.306-.323v-3.398c0-.162-.153-.323-.306-.323H9.753c-.153 0-.306.161-.306.323v3.398c0 .162.153.323.306.323h4.494Z","clip-rule":"evenodd"})),g=(0,u.createHigherOrderComponent)((e=>o=>{const{name:n,attributes:l,setAttributes:i}=o,{sharedBlockId:a,sharedBlockIsShared:c,sharedBlockShareTitle:d}=l;return r(n)?(0,s.createElement)(s.Fragment,null,(0,s.createElement)(e,o),(0,s.createElement)(p.InspectorControls,null,(0,s.createElement)(w.PanelBody,{title:(0,k.__)("Multisite sharing options","multisite-shared-blocks"),icon:f},(0,s.createElement)(w.ToggleControl,{label:(0,k.__)("Share the block on the network","multisite-shared-blocks"),help:(0,k.__)("This block will be available on all sites of the network.","multisite-shared-blocks"),checked:c,onChange:()=>{i({sharedBlockIsShared:!c})}}),!!c&&(0,s.createElement)(s.Fragment,null,(0,s.createElement)(w.TextControl,{label:(0,k.sprintf)(// translators: %d is the current number of characters of the title 2 (0,k.__)("Public title for the shared block (%d/200)","multisite-shared-blocks"),(h=d,(0,t.isEmpty)(h)?"0":(0,b.count)(d,"characters_including_spaces",{}))),value:d,onChange:e=>{i({sharedBlockShareTitle:e})},help:(0,k.__)("Try to choose a title as descriptive as possible that will allow other users to understand what the block is about (200 characteres max).","multisite-shared-blocks")}),(0,t.isEmpty)(d)&&(0,s.createElement)("p",null,(0,s.createElement)("small",null,(0,s.createInterpolateElement)((0,k.sprintf)(// translators: %s is default title 3 (0,k.__)('Current title for the shared block is empty, it\'ll be view has <strong>"%s"</strong>',"multisite-shared-blocks"),(0,k.sprintf)(// translators: %s share block unique id 4 (0,k.__)("Shared block %s","multisite-shared-blocks"),a)),{strong:(0,s.createElement)("strong",null)}))))))):(0,s.createElement)(e,o);var h}),"sharedBlockIdControls");(0,e.addFilter)("blocks.registerBlockType","multisite-shared-blocks/shared-block-id-attribute",((e,o)=>{const s=multisiteSharedBlocksHooksData.attributes||{};return!r(o)||(0,t.isEmpty)(s)?e:(0,t.assign)({},e,{attributes:(0,t.assign)({},e.attributes,s)})})),(0,e.addFilter)("editor.BlockEdit","multisite-shared-blocks/shared-block-id",m),(0,e.addFilter)("editor.BlockEdit","multisite-shared-blocks/shared-block-id-controls",g)}(); 1 (()=>{"use strict";const e=window.wp.hooks;function t(e){var t;return!(null!==(t=multisiteSharedBlocksHooksData.excluded_blocks)&&void 0!==t?t:[]).includes(e)}const o=window.React,r={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};let l;const n=new Uint8Array(16);function c(){if(!l&&(l="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!l))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return l(n)}const s=[];for(let e=0;e<256;++e)s.push((e+256).toString(16).slice(1));const i=function(e,t,o){if(r.randomUUID&&!t&&!e)return r.randomUUID();const l=(e=e||{}).random||(e.rng||c)();if(l[6]=15&l[6]|64,l[8]=63&l[8]|128,t){o=o||0;for(let e=0;e<16;++e)t[o+e]=l[e];return t}return function(e,t=0){return s[e[t+0]]+s[e[t+1]]+s[e[t+2]]+s[e[t+3]]+"-"+s[e[t+4]]+s[e[t+5]]+"-"+s[e[t+6]]+s[e[t+7]]+"-"+s[e[t+8]]+s[e[t+9]]+"-"+s[e[t+10]]+s[e[t+11]]+s[e[t+12]]+s[e[t+13]]+s[e[t+14]]+s[e[t+15]]}(l)},a=window.wp.element,d=window.wp.compose,h=(0,d.createHigherOrderComponent)((e=>class extends a.Component{componentDidMount(){const{name:e,setAttributes:o,attributes:{sharedBlockId:r}=!1}=this.props;t(e)&&!r&&o({sharedBlockId:i()})}render(){return(0,o.createElement)(e,{...this.props})}}),"sharedBlockIdComponent"),u=window.wp.blockEditor,m=window.wp.components,p=window.wp.wordcount,k=window.wp.i18n,w=window.wp.primitives,b=(0,o.createElement)(w.SVG,{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",fill:"none",viewBox:"0 0 24 24"},(0,o.createElement)(w.Path,{fill:"#000",fillRule:"evenodd",d:"M14.247 0H9.753c-.715 0-1.327.647-1.327 1.402V4.8c0 .755.612 1.402 1.327 1.402h1.736v2.034c-1.599.242-2.857 1.601-3.04 3.306h-1.3v-1.295c0-.755-.613-1.402-1.328-1.402H1.328C.613 8.845 0 9.492 0 10.247v3.398c0 .755.613 1.402 1.328 1.402H5.82c.715 0 1.328-.647 1.328-1.402V12.62h1.329c.262 1.602 1.48 2.859 3.011 3.09v2.088H9.753c-.715 0-1.327.647-1.327 1.402v3.398c0 .755.612 1.402 1.327 1.402h4.494c.715 0 1.328-.647 1.328-1.402V19.2c0-.809-.613-1.402-1.328-1.402H12.51V15.71c1.53-.231 2.75-1.488 3.011-3.09h1.329v1.025c0 .755.613 1.402 1.328 1.402h4.493c.715 0 1.328-.647 1.328-1.402v-3.398c0-.755-.613-1.402-1.328-1.402H18.18c-.715 0-1.328.647-1.328 1.402v1.295h-1.3c-.183-1.705-1.441-3.064-3.04-3.306V6.202h1.736c.715 0 1.328-.647 1.328-1.402V1.402C15.575.593 14.962 0 14.247 0Zm.306 4.746c0 .162-.153.324-.306.324H9.753c-.153 0-.306-.162-.306-.324V1.402c0-.162.153-.323.306-.323h4.494c.153 0 .306.108.306.323v3.344ZM12 9.276c-1.41 0-2.553 1.208-2.553 2.697 0 1.49 1.143 2.697 2.553 2.697s2.553-1.208 2.553-2.697c0-1.49-1.143-2.697-2.553-2.697Zm10.979 4.369c0 .162-.153.324-.307.324H18.18c-.153 0-.307-.162-.307-.324v-3.398c0-.162.154-.323.307-.323h4.493c.154 0 .307.161.307.323v3.398Zm-17.158.324c.153 0 .307-.162.307-.324v-3.398c0-.162-.154-.323-.307-.323H1.328c-.154 0-.307.161-.307.323v3.398c0 .162.153.324.307.324H5.82Zm8.426 8.898c.153 0 .306-.161.306-.323v-3.398c0-.162-.153-.323-.306-.323H9.753c-.153 0-.306.161-.306.323v3.398c0 .162.153.323.306.323h4.494Z",clipRule:"evenodd"})),g=(0,d.createHigherOrderComponent)((e=>r=>{const{name:l,attributes:n,setAttributes:c}=r,{sharedBlockId:s,sharedBlockIsShared:i,sharedBlockShareTitle:d}=n,h=!!(d&&d.length>0);return t(l)?(0,o.createElement)(o.Fragment,null,(0,o.createElement)(e,{...r}),(0,o.createElement)(u.InspectorControls,null,(0,o.createElement)(m.PanelBody,{title:(0,k.__)("Multisite sharing options","multisite-shared-blocks"),icon:b},(0,o.createElement)(m.ToggleControl,{label:(0,k.__)("Share the block on the network","multisite-shared-blocks"),help:(0,k.__)("This block will be available on all sites of the network.","multisite-shared-blocks"),checked:i,onChange:()=>{c({sharedBlockIsShared:!i})}}),!!i&&(0,o.createElement)(o.Fragment,null,(0,o.createElement)(m.TextControl,{label:(0,k.sprintf)( 2 // translators: %d is the current number of characters of the title 3 (0,k.__)("Public title for the shared block (%d/200)","multisite-shared-blocks"),h?(w=d,w&&w.length>0?(0,p.count)(w,"characters_including_spaces",{}):0):0),value:d,onChange:e=>{c({sharedBlockShareTitle:e})},help:(0,k.__)("Try to choose a title as descriptive as possible that will allow other users to understand what the block is about (200 characteres max).","multisite-shared-blocks")}),!h&&(0,o.createElement)("p",null,(0,o.createElement)("small",null,(0,a.createInterpolateElement)((0,k.sprintf)( 4 // translators: %s is default title 5 (0,k.__)('Current title for the shared block is empty, it\'ll be view has <strong>"%s"</strong>',"multisite-shared-blocks"),(0,k.sprintf)( 6 // translators: %s share block unique id 7 (0,k.__)("Shared block %s","multisite-shared-blocks"),s)),{strong:(0,o.createElement)("strong",null)}))))))):(0,o.createElement)(e,{...r});var w}),"sharedBlockIdControls");(0,e.addFilter)("blocks.registerBlockType","multisite-shared-blocks/shared-block-id-attribute",((e,o)=>{const r=multisiteSharedBlocksHooksData.attributes||{};return t(o)&&0!==Object.keys(r).length?{...e,attributes:{...e.attributes,...r}}:e})),(0,e.addFilter)("editor.BlockEdit","multisite-shared-blocks/shared-block-id",h),(0,e.addFilter)("editor.BlockEdit","multisite-shared-blocks/shared-block-id-controls",g)})(); -
multisite-shared-blocks/trunk/includes/Rest/RenderBlockRestController.php
r2795737 r2999611 101 101 102 102 /** This filter is documented in wp-includes/post-template.php */ 103 $block_render = apply_filters( 'the_content', render_block( $shared_block_data ) );103 $block_render = apply_filters( 'the_content', _block( $shared_block_data ) ); 104 104 105 105 // Get list of block types used while rendering the shared block. -
multisite-shared-blocks/trunk/multisite-shared-blocks.php
r2795737 r2999611 4 4 * Plugin URI: https://github.com/BeAPI/multisite-shared-blocks 5 5 * Description: Share blocks between network's sites. 6 * Version: 1. 0.16 * Version: 1. 7 7 * Requires at least: 5.9 8 8 * Requires PHP: 7.2 … … 32 32 33 33 // Plugin constants 34 define( 'MULTISITE_SHARED_BLOCKS_VERSION', '1. 0.1' );34 define( 'MULTISITE_SHARED_BLOCKS_VERSION', '1.' ); 35 35 define( 'MULTISITE_SHARED_BLOCKS_CACHE_VERSION', '1' ); 36 36 define( 'MULTISITE_SHARED_BLOCKS_VIEWS_FOLDER_NAME', 'multisite-shared-blocks' ); -
multisite-shared-blocks/trunk/readme.txt
r2795737 r2999611 3 3 Tags: network, multisite, block, share, gutenberg 4 4 Requires at least: 5.9 5 Tested up to: 6. 06 Stable tag: 1. 0.15 Tested up to: 6. 6 Stable tag: 1. 7 7 Requires PHP: 7.2 8 8 License: GPL v2 or later … … 27 27 == Changelog == 28 28 29 30 31 32 33 29 34 = 1.0.1 - 2022-10-07 = 30 35 * Add check for multisite installation -
multisite-shared-blocks/trunk/vendor/autoload.php
r2795737 r2999611 4 4 5 5 if (PHP_VERSION_ID < 50600) { 6 echo 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL; 7 exit(1); 6 if (!headers_sent()) { 7 header('HTTP/1.1 500 Internal Server Error'); 8 } 9 $err = 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL; 10 if (!ini_get('display_errors')) { 11 if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') { 12 fwrite(STDERR, $err); 13 } elseif (!headers_sent()) { 14 echo $err; 15 } 16 } 17 trigger_error( 18 $err, 19 E_USER_ERROR 20 ); 8 21 } 9 22 10 23 require_once __DIR__ . '/composer/autoload_real.php'; 11 24 12 return ComposerAutoloaderInit 05cbe3e4608e27985c01f389568018d6::getLoader();25 return ComposerAutoloaderInit::getLoader(); -
multisite-shared-blocks/trunk/vendor/composer/ClassLoader.php
r2795737 r2999611 43 43 class ClassLoader 44 44 { 45 /** @var ?string */ 45 /** @var \Closure(string):void */ 46 private static $includeFile; 47 48 /** @var string|null */ 46 49 private $vendorDir; 47 50 48 51 // PSR-4 49 52 /** 50 * @var array[] 51 * @psalm-var array<string, array<string, int>> 53 * @var array<string, array<string, int>> 52 54 */ 53 55 private $prefixLengthsPsr4 = array(); 54 56 /** 55 * @var array[] 56 * @psalm-var array<string, array<int, string>> 57 * @var array<string, list<string>> 57 58 */ 58 59 private $prefixDirsPsr4 = array(); 59 60 /** 60 * @var array[] 61 * @psalm-var array<string, string> 61 * @var list<string> 62 62 */ 63 63 private $fallbackDirsPsr4 = array(); … … 65 65 // PSR-0 66 66 /** 67 * @var array[] 68 * @psalm-var array<string, array<string, string[]>> 67 * List of PSR-0 prefixes 68 * 69 * Structured as array('F (first letter)' => array('Foo\Bar (full prefix)' => array('path', 'path2'))) 70 * 71 * @var array<string, array<string, list<string>>> 69 72 */ 70 73 private $prefixesPsr0 = array(); 71 74 /** 72 * @var array[] 73 * @psalm-var array<string, string> 75 * @var list<string> 74 76 */ 75 77 private $fallbackDirsPsr0 = array(); … … 79 81 80 82 /** 81 * @var string[] 82 * @psalm-var array<string, string> 83 * @var array<string, string> 83 84 */ 84 85 private $classMap = array(); … … 88 89 89 90 /** 90 * @var bool[] 91 * @psalm-var array<string, bool> 91 * @var array<string, bool> 92 92 */ 93 93 private $missingClasses = array(); 94 94 95 /** @var ?string*/95 /** @var */ 96 96 private $apcuPrefix; 97 97 98 98 /** 99 * @var self[]99 * @var 100 100 */ 101 101 private static $registeredLoaders = array(); 102 102 103 103 /** 104 * @param ?string$vendorDir104 * @param $vendorDir 105 105 */ 106 106 public function __construct($vendorDir = null) 107 107 { 108 108 $this->vendorDir = $vendorDir; 109 } 110 111 /** 112 * @return string[] 109 self::initializeIncludeClosure(); 110 } 111 112 /** 113 * @return array<string, list<string>> 113 114 */ 114 115 public function getPrefixes() … … 122 123 123 124 /** 124 * @return array[] 125 * @psalm-return array<string, array<int, string>> 125 * @return array<string, list<string>> 126 126 */ 127 127 public function getPrefixesPsr4() … … 131 131 132 132 /** 133 * @return array[] 134 * @psalm-return array<string, string> 133 * @return list<string> 135 134 */ 136 135 public function getFallbackDirs() … … 140 139 141 140 /** 142 * @return array[] 143 * @psalm-return array<string, string> 141 * @return list<string> 144 142 */ 145 143 public function getFallbackDirsPsr4() … … 149 147 150 148 /** 151 * @return string[] Array of classname => path 152 * @psalm-return array<string, string> 149 * @return array<string, string> Array of classname => path 153 150 */ 154 151 public function getClassMap() … … 158 155 159 156 /** 160 * @param string[] $classMap Class to filename map 161 * @psalm-param array<string, string> $classMap 157 * @param array<string, string> $classMap Class to filename map 162 158 * 163 159 * @return void … … 176 172 * appending or prepending to the ones previously set for this prefix. 177 173 * 178 * @param string $prefix The prefix179 * @param string[]|string $paths The PSR-0 root directories180 * @param bool $prepend Whether to prepend the directories174 * @param string $prefix The prefix 175 * @param |string $paths The PSR-0 root directories 176 * @param bool $prepend Whether to prepend the directories 181 177 * 182 178 * @return void … … 184 180 public function add($prefix, $paths, $prepend = false) 185 181 { 182 186 183 if (!$prefix) { 187 184 if ($prepend) { 188 185 $this->fallbackDirsPsr0 = array_merge( 189 (array)$paths,186 $paths, 190 187 $this->fallbackDirsPsr0 191 188 ); … … 193 190 $this->fallbackDirsPsr0 = array_merge( 194 191 $this->fallbackDirsPsr0, 195 (array)$paths192 $paths 196 193 ); 197 194 } … … 202 199 $first = $prefix[0]; 203 200 if (!isset($this->prefixesPsr0[$first][$prefix])) { 204 $this->prefixesPsr0[$first][$prefix] = (array)$paths;201 $this->prefixesPsr0[$first][$prefix] = $paths; 205 202 206 203 return; … … 208 205 if ($prepend) { 209 206 $this->prefixesPsr0[$first][$prefix] = array_merge( 210 (array)$paths,207 $paths, 211 208 $this->prefixesPsr0[$first][$prefix] 212 209 ); … … 214 211 $this->prefixesPsr0[$first][$prefix] = array_merge( 215 212 $this->prefixesPsr0[$first][$prefix], 216 (array)$paths213 $paths 217 214 ); 218 215 } … … 223 220 * appending or prepending to the ones previously set for this namespace. 224 221 * 225 * @param string $prefix The prefix/namespace, with trailing '\\'226 * @param string[]|string $paths The PSR-4 base directories227 * @param bool $prepend Whether to prepend the directories222 * @param string $prefix The prefix/namespace, with trailing '\\' 223 * @param |string $paths The PSR-4 base directories 224 * @param bool $prepend Whether to prepend the directories 228 225 * 229 226 * @throws \InvalidArgumentException … … 233 230 public function addPsr4($prefix, $paths, $prepend = false) 234 231 { 232 235 233 if (!$prefix) { 236 234 // Register directories for the root namespace. 237 235 if ($prepend) { 238 236 $this->fallbackDirsPsr4 = array_merge( 239 (array)$paths,237 $paths, 240 238 $this->fallbackDirsPsr4 241 239 ); … … 243 241 $this->fallbackDirsPsr4 = array_merge( 244 242 $this->fallbackDirsPsr4, 245 (array)$paths243 $paths 246 244 ); 247 245 } … … 253 251 } 254 252 $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; 255 $this->prefixDirsPsr4[$prefix] = (array)$paths;253 $this->prefixDirsPsr4[$prefix] = $paths; 256 254 } elseif ($prepend) { 257 255 // Prepend directories for an already registered namespace. 258 256 $this->prefixDirsPsr4[$prefix] = array_merge( 259 (array)$paths,257 $paths, 260 258 $this->prefixDirsPsr4[$prefix] 261 259 ); … … 264 262 $this->prefixDirsPsr4[$prefix] = array_merge( 265 263 $this->prefixDirsPsr4[$prefix], 266 (array)$paths264 $paths 267 265 ); 268 266 } … … 273 271 * replacing any others previously set for this prefix. 274 272 * 275 * @param string $prefix The prefix276 * @param string[]|string $paths The PSR-0 base directories273 * @param string $prefix The prefix 274 * @param |string $paths The PSR-0 base directories 277 275 * 278 276 * @return void … … 291 289 * replacing any others previously set for this namespace. 292 290 * 293 * @param string $prefix The prefix/namespace, with trailing '\\'294 * @param string[]|string $paths The PSR-4 base directories291 * @param string $prefix The prefix/namespace, with trailing '\\' 292 * @param |string $paths The PSR-4 base directories 295 293 * 296 294 * @throws \InvalidArgumentException … … 426 424 { 427 425 if ($file = $this->findFile($class)) { 428 includeFile($file); 426 $includeFile = self::$includeFile; 427 $includeFile($file); 429 428 430 429 return true; … … 477 476 478 477 /** 479 * Returns the currently registered loaders indexed by their corresponding vendor directories.480 * 481 * @return self[]478 * Returns the currently registered loaders ed by their corresponding vendor directories. 479 * 480 * @return 482 481 */ 483 482 public static function getRegisteredLoaders() … … 556 555 return false; 557 556 } 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 558 579 } 559 560 /**561 * Scope isolated include.562 *563 * Prevents access to $this/self from included files.564 *565 * @param string $file566 * @return void567 * @private568 */569 function includeFile($file)570 {571 include $file;572 } -
multisite-shared-blocks/trunk/vendor/composer/InstalledVersions.php
r2795737 r2999611 99 99 foreach (self::getInstalled() as $installed) { 100 100 if (isset($installed['versions'][$packageName])) { 101 return $includeDevRequirements || empty($installed['versions'][$packageName]['dev_requirement']);101 return $includeDevRequirements || ; 102 102 } 103 103 } … … 120 120 public static function satisfies(VersionParser $parser, $packageName, $constraint) 121 121 { 122 $constraint = $parser->parseConstraints( $constraint);122 $constraint = $parser->parseConstraints($constraint); 123 123 $provided = $parser->parseConstraints(self::getVersionRanges($packageName)); 124 124 … … 329 329 $installed[] = self::$installedByVendor[$vendorDir]; 330 330 } elseif (is_file($vendorDir.'/composer/installed.php')) { 331 $installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php'; 331 /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */ 332 $required = require $vendorDir.'/composer/installed.php'; 333 $installed[] = self::$installedByVendor[$vendorDir] = $required; 332 334 if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) { 333 335 self::$installed = $installed[count($installed) - 1]; … … 341 343 // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 342 344 if (substr(__DIR__, -8, 1) !== 'C') { 343 self::$installed = require __DIR__ . '/installed.php'; 345 /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */ 346 $required = require __DIR__ . '/installed.php'; 347 self::$installed = $required; 344 348 } else { 345 349 self::$installed = array(); 346 350 } 347 351 } 348 $installed[] = self::$installed; 352 353 if (self::$installed !== array()) { 354 $installed[] = self::$installed; 355 } 349 356 350 357 return $installed; -
multisite-shared-blocks/trunk/vendor/composer/autoload_real.php
r2795737 r2999611 3 3 // autoload_real.php @generated by Composer 4 4 5 class ComposerAutoloaderInit 05cbe3e4608e27985c01f389568018d65 class ComposerAutoloaderInit 6 6 { 7 7 private static $loader; … … 23 23 } 24 24 25 spl_autoload_register(array('ComposerAutoloaderInit 05cbe3e4608e27985c01f389568018d6', 'loadClassLoader'), true, true);25 spl_autoload_register(array('ComposerAutoloaderInit', 'loadClassLoader'), true, true); 26 26 self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); 27 spl_autoload_unregister(array('ComposerAutoloaderInit 05cbe3e4608e27985c01f389568018d6', 'loadClassLoader'));27 spl_autoload_unregister(array('ComposerAutoloaderInit', 'loadClassLoader')); 28 28 29 29 require __DIR__ . '/autoload_static.php'; 30 call_user_func(\Composer\Autoload\ComposerStaticInit 05cbe3e4608e27985c01f389568018d6::getInitializer($loader));30 call_user_func(\Composer\Autoload\ComposerStaticInit::getInitializer($loader)); 31 31 32 32 $loader->register(true); -
multisite-shared-blocks/trunk/vendor/composer/autoload_static.php
r2795737 r2999611 5 5 namespace Composer\Autoload; 6 6 7 class ComposerStaticInit 05cbe3e4608e27985c01f389568018d67 class ComposerStaticInit 8 8 { 9 9 public static $prefixLengthsPsr4 = array ( … … 156 156 { 157 157 return \Closure::bind(function () use ($loader) { 158 $loader->prefixLengthsPsr4 = ComposerStaticInit 05cbe3e4608e27985c01f389568018d6::$prefixLengthsPsr4;159 $loader->prefixDirsPsr4 = ComposerStaticInit 05cbe3e4608e27985c01f389568018d6::$prefixDirsPsr4;160 $loader->classMap = ComposerStaticInit 05cbe3e4608e27985c01f389568018d6::$classMap;158 $loader->prefixLengthsPsr4 = ComposerStaticInit::$prefixLengthsPsr4; 159 $loader->prefixDirsPsr4 = ComposerStaticInit::$prefixDirsPsr4; 160 $loader->classMap = ComposerStaticInit::$classMap; 161 161 162 162 }, null, ClassLoader::class); -
multisite-shared-blocks/trunk/vendor/composer/installed.php
r2795737 r2999611 4 4 'pretty_version' => 'dev-main', 5 5 'version' => 'dev-main', 6 'reference' => ' f1858b313ce8a43de9fe052a72cc29760ccf6a18',6 'reference' => '', 7 7 'type' => 'wordpress-plugin', 8 8 'install_path' => __DIR__ . '/../../', … … 14 14 'pretty_version' => 'dev-main', 15 15 'version' => 'dev-main', 16 'reference' => ' f1858b313ce8a43de9fe052a72cc29760ccf6a18',16 'reference' => '', 17 17 'type' => 'wordpress-plugin', 18 18 'install_path' => __DIR__ . '/../../',
Note: See TracChangeset
for help on using the changeset viewer.