diff --git a/build/blocks/modal-manager/block.json b/build/blocks/modal-manager/block.json new file mode 100644 index 000000000..bed9602fa --- /dev/null +++ b/build/blocks/modal-manager/block.json @@ -0,0 +1,19 @@ +{ + "$schema": "https://schemas.wp.org/trunk/block.json", + "apiVersion": 3, + "name": "gatherpress/modal-manager", + "version": "1.0.0", + "title": "Modal Manager", + "category": "gatherpress", + "icon": "external", + "example": {}, + "description": "Manage modals and their triggers with ease.", + "attributes": {}, + "supports": { + "html": false, + "interactivity": true + }, + "textdomain": "gatherpress", + "editorScript": "file:./index.js", + "viewScriptModule": "file:./view.js" +} \ No newline at end of file diff --git a/build/blocks/modal-manager/index.asset.php b/build/blocks/modal-manager/index.asset.php new file mode 100644 index 000000000..a9418dd84 --- /dev/null +++ b/build/blocks/modal-manager/index.asset.php @@ -0,0 +1 @@ + array('react-jsx-runtime', 'wp-block-editor', 'wp-blocks'), 'version' => '1097ba5f24d0a9952920'); diff --git a/build/blocks/modal-manager/index.js b/build/blocks/modal-manager/index.js new file mode 100644 index 000000000..395f66752 --- /dev/null +++ b/build/blocks/modal-manager/index.js @@ -0,0 +1 @@ +(()=>{"use strict";const e=window.wp.blocks,s=window.wp.blockEditor,t=window.ReactJSXRuntime,r=JSON.parse('{"$schema":"https://schemas.wp.org/trunk/block.json","apiVersion":3,"name":"gatherpress/modal-manager","version":"1.0.0","title":"Modal Manager","category":"gatherpress","icon":"external","example":{},"description":"Manage modals and their triggers with ease.","attributes":{},"supports":{"html":false,"interactivity":true},"textdomain":"gatherpress","editorScript":"file:./index.js","viewScriptModule":"file:./view.js"}');(0,e.registerBlockType)(r,{edit:()=>{const e=(0,s.useBlockProps)();return(0,t.jsx)("div",{...e,children:(0,t.jsx)(s.InnerBlocks,{template:[["gatherpress/modal",{},[["gatherpress/modal-content",{}]]]]})})},save:()=>(0,t.jsx)("div",{...s.useBlockProps.save(),children:(0,t.jsx)(s.InnerBlocks.Content,{})})})})(); \ No newline at end of file diff --git a/build/blocks/modal-manager/view.asset.php b/build/blocks/modal-manager/view.asset.php new file mode 100644 index 000000000..62f81b2ab --- /dev/null +++ b/build/blocks/modal-manager/view.asset.php @@ -0,0 +1 @@ + array('@wordpress/interactivity'), 'version' => '78bbf04e2bbfe6dd79f3', 'type' => 'module'); diff --git a/build/blocks/modal-manager/view.js b/build/blocks/modal-manager/view.js new file mode 100644 index 000000000..e19180ebd --- /dev/null +++ b/build/blocks/modal-manager/view.js @@ -0,0 +1 @@ +import*as e from"@wordpress/interactivity";var t={d:(e,r)=>{for(var s in r)t.o(r,s)&&!t.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:r[s]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const r=(s={getElement:()=>e.getElement,store:()=>e.store},o={},t.d(o,s),o);var s,o;(0,r.store)("gatherpress/modal",{actions:{openModal(e){e.preventDefault();const t=(0,r.getElement)().ref.closest(".wp-block-gatherpress-modal-manager");if(t){const e=t.querySelector(".wp-block-gatherpress-modal");e&&e.classList.add("gatherpress--is-visible")}},closeModal(e){e.preventDefault();const t=(0,r.getElement)().ref.closest(".wp-block-gatherpress-modal-manager");if(t){const e=t.querySelector(".wp-block-gatherpress-modal");e&&e.classList.remove("gatherpress--is-visible")}}}}); \ No newline at end of file diff --git a/build/blocks/modal/block.json b/build/blocks/modal/block.json index 76a120000..e4f989ec5 100644 --- a/build/blocks/modal/block.json +++ b/build/blocks/modal/block.json @@ -4,6 +4,9 @@ "name": "gatherpress/modal", "version": "1.0.0", "title": "Modal", + "parent": [ + "gatherpress/modal-manager" + ], "category": "gatherpress", "icon": "external", "example": {}, diff --git a/build/blocks/modal/index.asset.php b/build/blocks/modal/index.asset.php index 51e35517b..aa667534f 100644 --- a/build/blocks/modal/index.asset.php +++ b/build/blocks/modal/index.asset.php @@ -1 +1 @@ - array('react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-data'), 'version' => 'f0f47369380caa31bad3'); + array('react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-data'), 'version' => 'd1d1ac2fd0477b184bb0'); diff --git a/build/blocks/modal/index.js b/build/blocks/modal/index.js index bfdccf326..4a22b92bc 100644 --- a/build/blocks/modal/index.js +++ b/build/blocks/modal/index.js @@ -1 +1 @@ -(()=>{"use strict";var e,r={373:()=>{const e=window.wp.blocks,r=window.wp.blockEditor,t=window.wp.data,s=window.ReactJSXRuntime,o=JSON.parse('{"$schema":"https://schemas.wp.org/trunk/block.json","apiVersion":3,"name":"gatherpress/modal","version":"1.0.0","title":"Modal","category":"gatherpress","icon":"external","example":{},"description":"Enables members to easily confirm their attendance for an event.","attributes":{"style":{"type":"object","default":{"color":{"background":"rgba(0, 0, 0, 0.5)"}}}},"supports":{"html":false,"color":{"gradients":true,"__experimentalDefaultControls":{"background":true}}},"allowedBlocks":["gatherpress/modal-content"],"textdomain":"gatherpress","editorScript":"file:./index.js","style":"file:./style-index.css"}');(0,e.registerBlockType)(o,{edit:({clientId:e,isSelected:o})=>{const n=(0,t.useSelect)((t=>t(r.store).hasSelectedInnerBlock(e,!0)),[e]),a=(0,r.useBlockProps)({style:{display:o||n?"block":"none",maxWidth:"none"}});return(0,s.jsx)("div",{...a,children:(0,s.jsx)(r.InnerBlocks,{template:[["gatherpress/modal-content",{}]]})})},save:()=>(0,s.jsx)("div",{...r.useBlockProps.save(),children:(0,s.jsx)(r.InnerBlocks.Content,{})})})}},t={};function s(e){var o=t[e];if(void 0!==o)return o.exports;var n=t[e]={exports:{}};return r[e](n,n.exports,s),n.exports}s.m=r,e=[],s.O=(r,t,o,n)=>{if(!t){var a=1/0;for(p=0;p=n)&&Object.keys(s.O).every((e=>s.O[e](t[i])))?t.splice(i--,1):(l=!1,n0&&e[p-1][2]>n;p--)e[p]=e[p-1];e[p]=[t,o,n]},s.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),(()=>{var e={310:0,170:0};s.O.j=r=>0===e[r];var r=(r,t)=>{var o,n,a=t[0],l=t[1],i=t[2],c=0;if(a.some((r=>0!==e[r]))){for(o in l)s.o(l,o)&&(s.m[o]=l[o]);if(i)var p=i(s)}for(r&&r(t);cs(373)));o=s.O(o)})(); \ No newline at end of file +(()=>{"use strict";var e,r={373:()=>{const e=window.wp.blocks,r=window.wp.blockEditor,t=window.wp.data,s=window.ReactJSXRuntime,o=JSON.parse('{"$schema":"https://schemas.wp.org/trunk/block.json","apiVersion":3,"name":"gatherpress/modal","version":"1.0.0","title":"Modal","parent":["gatherpress/modal-manager"],"category":"gatherpress","icon":"external","example":{},"description":"Enables members to easily confirm their attendance for an event.","attributes":{"style":{"type":"object","default":{"color":{"background":"rgba(0, 0, 0, 0.5)"}}}},"supports":{"html":false,"color":{"gradients":true,"__experimentalDefaultControls":{"background":true}}},"allowedBlocks":["gatherpress/modal-content"],"textdomain":"gatherpress","editorScript":"file:./index.js","style":"file:./style-index.css"}');(0,e.registerBlockType)(o,{edit:({clientId:e,isSelected:o})=>{const n=(0,t.useSelect)((t=>t(r.store).hasSelectedInnerBlock(e,!0)),[e]),a=(0,r.useBlockProps)({style:{display:o||n?"block":"none",maxWidth:"none"}});return(0,s.jsx)("div",{...a,children:(0,s.jsx)(r.InnerBlocks,{template:[["gatherpress/modal-content",{}]]})})},save:()=>(0,s.jsx)("div",{...r.useBlockProps.save(),children:(0,s.jsx)(r.InnerBlocks.Content,{})})})}},t={};function s(e){var o=t[e];if(void 0!==o)return o.exports;var n=t[e]={exports:{}};return r[e](n,n.exports,s),n.exports}s.m=r,e=[],s.O=(r,t,o,n)=>{if(!t){var a=1/0;for(p=0;p=n)&&Object.keys(s.O).every((e=>s.O[e](t[i])))?t.splice(i--,1):(l=!1,n0&&e[p-1][2]>n;p--)e[p]=e[p-1];e[p]=[t,o,n]},s.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),(()=>{var e={310:0,170:0};s.O.j=r=>0===e[r];var r=(r,t)=>{var o,n,a=t[0],l=t[1],i=t[2],c=0;if(a.some((r=>0!==e[r]))){for(o in l)s.o(l,o)&&(s.m[o]=l[o]);if(i)var p=i(s)}for(r&&r(t);cs(373)));o=s.O(o)})(); \ No newline at end of file diff --git a/includes/core/classes/blocks/class-modal-manager.php b/includes/core/classes/blocks/class-modal-manager.php new file mode 100644 index 000000000..bfdafbe23 --- /dev/null +++ b/includes/core/classes/blocks/class-modal-manager.php @@ -0,0 +1,110 @@ +setup_hooks(); + } + + /** + * Set up hooks for various purposes. + * + * This method adds hooks for different purposes as needed. + * + * @since 1.0.0 + * + * @return void + */ + protected function setup_hooks(): void { + add_filter( 'render_block', array( $this, 'inject_modal_behavior' ), 10, 2 ); + } + + /** + * Injects modal interactivity behavior into block content. + * + * This method enhances `core/button` blocks with specific classes by injecting + * attributes necessary for modal interactivity. It supports both `