PluginProbe
Gutenify – Visual Site Builder Blocks & Starter Templates / trunk
Gutenify – Visual Site Builder Blocks & Starter Templates vtrunk
1.9.0 1.8.0 1.7.0 1.6.6 1.6.5 1.6.4 trunk 0.0.1 0.0.2 0.0.3 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 All 74 releases
gutenify / core / dist / blocks / term-thumbnail / index.js

index.js in Gutenify – Visual Site Builder Blocks & Starter Templates trunk, at core/dist/blocks/term-thumbnail/index.js

1 lines 7.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (()=>{"use strict";var e,t={4481:(e,t,l)=>{const n=window.wp.blocks,r=JSON.parse('{"$schema":"https://schemas.wp.org/trunk/block.json","apiVersion":3,"name":"gutenify/term-thumbnail","version":"1","title":"Term Thumbnail","category":"gutenify","description":"Display the current taxonomy term\'s thumbnail image. Intended for use inside core\'s Terms Query Loop → Term Template.","keywords":["term","taxonomy","thumbnail","image","category"],"textdomain":"gutenify","usesContext":["termId","taxonomy"],"attributes":{"previewTermId":{"type":"integer","default":0},"previewTaxonomy":{"type":"string","default":""},"imageSize":{"type":"string","default":"thumbnail"},"aspectRatio":{"type":"string","default":"1"},"scale":{"type":"string","default":"cover"},"focalPoint":{"type":"object","default":{"x":0.5,"y":0.5}},"linkToTerm":{"type":"boolean","default":true},"linkTarget":{"type":"string","default":"_self"},"rel":{"type":"string","default":""},"overlayColor":{"type":"string"},"customOverlayColor":{"type":"string"},"dimRatio":{"type":"number","default":0},"gradient":{"type":"string"},"customGradient":{"type":"string"}},"supports":{"align":["wide","full"],"html":false,"color":{"text":true,"background":true,"gradients":true,"__experimentalDefaultControls":{"background":true,"text":true}},"spacing":{"padding":true,"margin":true,"__experimentalDefaultControls":{"padding":true}},"__experimentalBorder":{"color":true,"radius":true,"style":true,"width":true,"__experimentalSkipSerialization":true,"__experimentalDefaultControls":{"color":true,"radius":true,"width":true}},"shadow":true},"editorScript":["file:./index.js"],"editorStyle":["file:./index.css"],"style":["file:./style-index.css"],"render":"file:./render.php"}'),a=window.React,i=window.wp.blockEditor,o=window.wp.components,u=window.wp.data,s=window.wp.i18n,c=window.wp.serverSideRender;var g=l.n(c);const d=(0,a.createElement)(o.SVG,{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},(0,a.createElement)(o.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"M4 5C4 3.89543 4.89543 3 6 3H18C19.1046 3 20 3.89543 20 5V19C20 20.1046 19.1046 21 18 21H6C4.89543 21 4 20.1046 4 19V5ZM18 5H6V14.5858L8.29289 12.2929C8.68342 11.9024 9.31658 11.9024 9.70711 12.2929L13 15.5858L15.2929 13.2929C15.6834 12.9024 16.3166 12.9024 16.7071 13.2929L18 14.5858V5ZM6 17.4142V19H18V17.4142L16 15.4142L13.7071 17.7071C13.3166 18.0976 12.6834 18.0976 12.2929 17.7071L9 14.4142L6 17.4142ZM9.5 10C10.3284 10 11 9.32843 11 8.5C11 7.67157 10.3284 7 9.5 7C8.67157 7 8 7.67157 8 8.5C8 9.32843 8.67157 10 9.5 10Z",fill:"currentColor"})),m=[{label:(0,s.__)("Thumbnail","gutenify"),value:"thumbnail"},{label:(0,s.__)("Medium","gutenify"),value:"medium"},{label:(0,s.__)("Large","gutenify"),value:"large"},{label:(0,s.__)("Full Size","gutenify"),value:"full"}],p=[{label:(0,s.__)("Original","gutenify"),value:"auto"},{label:(0,s.__)("Square - 1:1","gutenify"),value:"1"},{label:(0,s.__)("Standard - 4:3","gutenify"),value:"4/3"},{label:(0,s.__)("Portrait - 3:4","gutenify"),value:"3/4"},{label:(0,s.__)("Classic - 3:2","gutenify"),value:"3/2"},{label:(0,s.__)("Classic Portrait - 2:3","gutenify"),value:"2/3"},{label:(0,s.__)("Wide - 16:9","gutenify"),value:"16/9"},{label:(0,s.__)("Tall - 9:16","gutenify"),value:"9/16"},{label:(0,s.__)("Custom","gutenify"),value:"custom",disabled:!0,hidden:!0}];function f(e=[],t){return e.flatMap((e=>Array.isArray(e[t])?e[t]:[e]))}(0,n.registerBlockType)(r.name,{...r,icon:{foreground:"#2196f3",src:d},edit:function({attributes:e,context:t,setAttributes:l}){const{imageSize:n,aspectRatio:r,scale:c,focalPoint:y,linkToTerm:_,linkTarget:v,overlayColor:b,customOverlayColor:h,dimRatio:C,gradient:w,customGradient:x}=e,{termId:T,taxonomy:k}=t||{},O=(0,i.useBlockProps)(),{focalPointImageUrl:E}=(0,u.useSelect)((e=>{if(!T||!k)return{focalPointImageUrl:""};const t=e("core").getEntityRecord("taxonomy",k,T),l=t?.meta?.thumbnail_id,n=l?e("core").getMedia(l):null;return{focalPointImageUrl:n?.source_url||""}}),[T,k]),S=(0,i.__experimentalUseMultipleOriginColorsAndGradients)(),P=f(S?.colors,"colors"),L=f(S?.gradients,"gradients"),R=b&&P.find((({slug:e})=>e===b))?.color||h,G=w&&L.find((({slug:e})=>e===w))?.gradient||x,I=(0,u.useSelect)((e=>{const t=e("core/block-editor").getSettings();return(t?.imageSizes||[]).map((e=>({label:e.name,value:e.slug})))}),[]);return T?(0,a.createElement)("div",{...O},(0,a.createElement)(i.InspectorControls,null,(0,a.createElement)(o.PanelBody,{title:(0,s.__)("Image settings","gutenify"),initialOpen:!0},(0,a.createElement)(o.SelectControl,{label:(0,s.__)("Image size","gutenify"),value:n,options:I.length?I:m,onChange:e=>l({imageSize:e})}),(0,a.createElement)(o.SelectControl,{label:(0,s.__)("Aspect ratio","gutenify"),value:r||"1",options:p,onChange:e=>l({aspectRatio:e})}),"auto"!==(r||"1")&&(0,a.createElement)(o.__experimentalToggleGroupControl,{label:(0,s.__)("Scale","gutenify"),value:c||"cover",isBlock:!0,onChange:e=>l({scale:e})},(0,a.createElement)(o.__experimentalToggleGroupControlOption,{value:"cover",label:(0,s.__)("Cover","gutenify")}),(0,a.createElement)(o.__experimentalToggleGroupControlOption,{value:"contain",label:(0,s.__)("Contain","gutenify")}),(0,a.createElement)(o.__experimentalToggleGroupControlOption,{value:"fill",label:(0,s.__)("Fill","gutenify")})),"auto"!==(r||"1")&&"cover"===(c||"cover")&&(0,a.createElement)(o.FocalPointPicker,{label:(0,s.__)("Focal point","gutenify"),url:E,value:y,onChange:e=>l({focalPoint:e})}),(0,a.createElement)(o.ToggleControl,{label:(0,s.__)("Link to term archive","gutenify"),checked:_,onChange:e=>l({linkToTerm:e})}),_&&(0,a.createElement)(o.ToggleControl,{label:(0,s.__)("Open in new tab","gutenify"),checked:"_blank"===v,onChange:e=>{const t=e?"_blank":"_self";l({linkTarget:t,rel:"_blank"===t?"noreferrer noopener":""})}})),(0,a.createElement)(i.__experimentalPanelColorGradientSettings,{title:(0,s.__)("Overlay","gutenify"),initialOpen:!1,settings:[{colorValue:R,gradientValue:G,onColorChange:e=>{const t=P.find((({color:t})=>t===e));l({overlayColor:t?t.slug:void 0,customOverlayColor:t?void 0:e})},onGradientChange:e=>{const t=L.find((({gradient:t})=>t===e));l({gradient:t?t.slug:void 0,customGradient:t?void 0:e})},label:(0,s.__)("Overlay","gutenify")}],...S},(0,a.createElement)(o.RangeControl,{label:(0,s.__)("Opacity","gutenify"),min:0,max:100,step:10,value:C,onChange:e=>l({dimRatio:e})}))),(0,a.createElement)(g(),{block:"gutenify/term-thumbnail",attributes:{...e,previewTermId:T,previewTaxonomy:k||""}})):(0,a.createElement)("div",{...O},(0,a.createElement)(o.Placeholder,{icon:d,label:(0,s.__)("Term Thumbnail","gutenify"),instructions:(0,s.__)("This block displays the current taxonomy term’s thumbnail image. Place it inside a Terms Query Loop → Term Template block so it can receive a term.","gutenify")}))},save:()=>null})}},l={};function n(e){var r=l[e];if(void 0!==r)return r.exports;var a=l[e]={exports:{}};return t[e](a,a.exports,n),a.exports}n.m=t,e=[],n.O=(t,l,r,a)=>{if(!l){var i=1/0;for(c=0;c<e.length;c++){for(var[l,r,a]=e[c],o=!0,u=0;u<l.length;u++)(!1&a||i>=a)&&Object.keys(n.O).every((e=>n.O[e](l[u])))?l.splice(u--,1):(o=!1,a<i&&(i=a));if(o){e.splice(c--,1);var s=r();void 0!==s&&(t=s)}}return t}a=a||0;for(var c=e.length;c>0&&e[c-1][2]>a;c--)e[c]=e[c-1];e[c]=[l,r,a]},n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var l in t)n.o(t,l)&&!n.o(e,l)&&Object.defineProperty(e,l,{enumerable:!0,get:t[l]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{var e={1075:0,4491:0};n.O.j=t=>0===e[t];var t=(t,l)=>{var r,a,[i,o,u]=l,s=0;if(i.some((t=>0!==e[t]))){for(r in o)n.o(o,r)&&(n.m[r]=o[r]);if(u)var c=u(n)}for(t&&t(l);s<i.length;s++)a=i[s],n.o(e,a)&&e[a]&&e[a][0](),e[a]=0;return n.O(c)},l=globalThis.webpackChunkgutenify=globalThis.webpackChunkgutenify||[];l.forEach(t.bind(null,0)),l.push=t.bind(null,l.push.bind(l))})();var r=n.O(void 0,[4491],(()=>n(4481)));r=n.O(r)})();