mirror of
https://github.com/10h30/display-featured-image-genesis.git
synced 2026-06-05 15:08:20 +09:00
Update block script
This commit is contained in:
@@ -40,7 +40,7 @@
|
||||
BlockAlignmentToolbar = wp.editor.BlockAlignmentToolbar;
|
||||
return [
|
||||
DFIGBlockObject.el( ServerSideRender, {
|
||||
block: DFIGBlockObject.params.block,
|
||||
block: params.block,
|
||||
attributes: attributes
|
||||
} ),
|
||||
DFIGBlockObject.el( Fragment, null,
|
||||
@@ -55,7 +55,7 @@
|
||||
),
|
||||
),
|
||||
DFIGBlockObject.el( InspectorControls, {},
|
||||
_getPanels( props )
|
||||
_getPanels( props, params )
|
||||
)
|
||||
];
|
||||
},
|
||||
@@ -70,15 +70,16 @@
|
||||
* Get the panels for the block controls.
|
||||
*
|
||||
* @param props
|
||||
* @param params
|
||||
* @return {Array}
|
||||
* @private
|
||||
*/
|
||||
function _getPanels( props ) {
|
||||
function _getPanels( props, params ) {
|
||||
const panels = [],
|
||||
PanelBody = wp.components.PanelBody;
|
||||
Object.keys( DFIGBlockObject.params.panels ).forEach( function ( key, index ) {
|
||||
if ( DFIGBlockObject.params.panels.hasOwnProperty( key ) ) {
|
||||
const IndividualPanel = DFIGBlockObject.params.panels[key];
|
||||
Object.keys( params.panels ).forEach( function ( key, index ) {
|
||||
if ( params.panels.hasOwnProperty( key ) ) {
|
||||
const IndividualPanel = params.panels[key];
|
||||
panels[index] = DFIGBlockObject.el( PanelBody, {
|
||||
title: IndividualPanel.title,
|
||||
initialOpen: IndividualPanel.initialOpen,
|
||||
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
!function(e,t){"use strict";const n={el:e.element.createElement};n.init=function(t){const o=e.blocks.registerBlockType,l=e.components.ServerSideRender,r=e.editor.InspectorControls;o(t.block,{title:t.title,description:t.description,keywords:t.keywords,icon:t.icon,category:t.category,supports:{html:!1},getEditWrapperProps:({blockAlignment:e})=>({"data-align":e}),edit:t=>{const{attributes:o,setAttributes:i}=t,s=e.element.Fragment,a=e.editor.BlockControls,c=e.editor.BlockAlignmentToolbar;return[n.el(l,{block:n.params.block,attributes:o}),n.el(s,null,n.el(a,null,n.el(c,{value:o.blockAlignment,controls:["wide","full"],onChange:e=>{i({blockAlignment:e})}}))),n.el(r,{},function(t){const o=[],l=e.components.PanelBody;return Object.keys(n.params.panels).forEach(function(r,i){if(n.params.panels.hasOwnProperty(r)){const s=n.params.panels[r];o[i]=n.el(l,{title:s.title,initialOpen:s.initialOpen,className:"scriptless-panel-"+r},function(t,o){const l=[];return Object.keys(o).forEach(function(r,i){if(o.hasOwnProperty(r)){if(-1!==["blockAlignment","className"].indexOf(r))return;const s=o[r],a=function(t,n){const{TextControl:o,SelectControl:l,RangeControl:r,CheckboxControl:i,TextareaControl:s}=e.components,a=o;return"select"===t?l:"number"===t&&"number"===n?r:"checkbox"===t?i:"textarea"===t?s:a}(s.method,s.type);l[i]=n.el(a,function(e,t,n){const{attributes:o,setAttributes:l}=n,r={label:t.label,value:o[e],className:"displayfeaturedimagegenesis-"+e,onChange:t=>{l({[e]:t})}};return"select"===t.method?r.options=t.options:"number"===t.method?(r.min=t.min,r.max=t.max,"number"!==t.type?r.type="number":r.initialPosition=t.min):"checkbox"===t.method&&(r.checked=o[e]),r}(r,s,t))}}),l}(t,s.attributes))}}),o}(t))]},save:e=>null})},n.params="undefined"==typeof DisplayFeaturedImageTestBlock?"":DisplayFeaturedImageTestBlock,void 0!==n.params&&n.init(n.params)}(wp);
|
||||
!function(e,t){"use strict";const n={el:e.element.createElement};n.init=function(t){const o=e.blocks.registerBlockType,l=e.components.ServerSideRender,i=e.editor.InspectorControls;o(t.block,{title:t.title,description:t.description,keywords:t.keywords,icon:t.icon,category:t.category,supports:{html:!1},getEditWrapperProps:({blockAlignment:e})=>({"data-align":e}),edit:o=>{const{attributes:r,setAttributes:s}=o,c=e.element.Fragment,a=e.editor.BlockControls,u=e.editor.BlockAlignmentToolbar;return[n.el(l,{block:t.block,attributes:r}),n.el(c,null,n.el(a,null,n.el(u,{value:r.blockAlignment,controls:["wide","full"],onChange:e=>{s({blockAlignment:e})}}))),n.el(i,{},function(t,o){const l=[],i=e.components.PanelBody;return Object.keys(o.panels).forEach(function(r,s){if(o.panels.hasOwnProperty(r)){const c=o.panels[r];l[s]=n.el(i,{title:c.title,initialOpen:c.initialOpen,className:"scriptless-panel-"+r},function(t,o){const l=[];return Object.keys(o).forEach(function(i,r){if(o.hasOwnProperty(i)){if(-1!==["blockAlignment","className"].indexOf(i))return;const s=o[i],c=function(t,n){const{TextControl:o,SelectControl:l,RangeControl:i,CheckboxControl:r,TextareaControl:s}=e.components,c=o;return"select"===t?l:"number"===t&&"number"===n?i:"checkbox"===t?r:"textarea"===t?s:c}(s.method,s.type);l[r]=n.el(c,function(e,t,n){const{attributes:o,setAttributes:l}=n,i={label:t.label,value:o[e],className:"displayfeaturedimagegenesis-"+e,onChange:t=>{l({[e]:t})}};return"select"===t.method?i.options=t.options:"number"===t.method?(i.min=t.min,i.max=t.max,"number"!==t.type?i.type="number":i.initialPosition=t.min):"checkbox"===t.method&&(i.checked=o[e]),i}(i,s,t))}}),l}(t,c.attributes))}}),l}(o,t))]},save:e=>null})},n.params="undefined"==typeof DisplayFeaturedImageTestBlock?"":DisplayFeaturedImageTestBlock,void 0!==n.params&&n.init(n.params)}(wp);
|
||||
Reference in New Issue
Block a user