mirror of
https://github.com/10h30/display-featured-image-genesis.git
synced 2026-07-13 03:26:02 +09:00
1 line
1.8 KiB
JavaScript
1 line
1.8 KiB
JavaScript
!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); |