PluginProbe
ThinkRank AI SEO – AI SEO Plugin for WordPress: Schema, XML Sitemaps, Meta Tags, Search Console & Local SEO / 2.0.0
ThinkRank AI SEO – AI SEO Plugin for WordPress: Schema, XML Sitemaps, Meta Tags, Search Console & Local SEO v2.0.0
2.7.0 2.6.0 2.5.0 2.4.0 2.3.0 2.2.0 2.1.1 2.1.0 2.0.2 2.0.1 2.0.0 1.32.0 1.31.0 1.30.0 1.29.0 1.28.0 1.27.0 1.26.0 1.25.0 trunk 1.0.0 1.0.1 1.0.2 1.1.0 1.10.0 All 48 releases
thinkrank / assets / faq-block.js

faq-block.js in ThinkRank AI SEO – AI SEO Plugin for WordPress: Schema, XML Sitemaps, Meta Tags, Search Console & Local SEO 2.0.0, at assets/faq-block.js

1 lines 8.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (()=>{"use strict";var e={24364:()=>{},24805:(e,a,t)=>{t.d(a,{A:()=>s});var n=t(51609),l=t(27723),r=t(94715),i=t(56427),o=t(36400);function s({attributes:e,setAttributes:a}){const{heading:t,headingTag:s,faqs:c,firstOpen:m,outputSchema:u,questionColor:k,questionBackground:d,answerColor:g,titleFontSize:h,itemSpacing:_,itemBackground:p,itemBorderColor:f,itemBorderRadius:v}=e,b=(0,r.useBlockProps)({className:"thinkrank-faq"}),C=s||"h2",q=Array.isArray(c)?c:[],y=(e,t)=>{a({faqs:q.map((a,n)=>n===e?{...a,...t}:a)})},w=(e,t)=>{const n=e+t;if(n<0||n>=q.length)return;const l=[...q];[l[e],l[n]]=[l[n],l[e]],a({faqs:l})};return(0,n.createElement)(n.Fragment,null,(0,n.createElement)(r.InspectorControls,null,(0,n.createElement)(i.TabPanel,{className:"thinkrank-faq-tabs",activeClass:"is-active",tabs:[{name:"general",title:(0,l.__)("General","thinkrank")},{name:"style",title:(0,l.__)("Style","thinkrank")}]},e=>"general"===e.name?(0,n.createElement)(i.PanelBody,{title:(0,l.__)("Content","thinkrank"),initialOpen:!0},(0,n.createElement)(i.TextControl,{label:(0,l.__)("Section heading","thinkrank"),value:t,onChange:e=>a({heading:e}),placeholder:(0,l.__)("Frequently asked questions","thinkrank")}),(0,n.createElement)(i.SelectControl,{label:(0,l.__)("Heading tag","thinkrank"),value:s,options:o.f,onChange:e=>a({headingTag:e})}),(0,n.createElement)(i.ToggleControl,{label:(0,l.__)("Open first item by default","thinkrank"),checked:!!m,onChange:e=>a({firstOpen:e})}),(0,n.createElement)(i.ToggleControl,{label:(0,l.__)("Output FAQ schema (JSON-LD)","thinkrank"),help:(0,l.__)("Adds FAQPage structured data for rich results.","thinkrank"),checked:!!u,onChange:e=>a({outputSchema:e})})):(0,n.createElement)(n.Fragment,null,(0,n.createElement)(r.PanelColorSettings,{title:(0,l.__)("Colors","thinkrank"),initialOpen:!0,colorSettings:[{value:k,onChange:e=>a({questionColor:e}),label:(0,l.__)("Question","thinkrank")},{value:d,onChange:e=>a({questionBackground:e}),label:(0,l.__)("Question background","thinkrank")},{value:g,onChange:e=>a({answerColor:e}),label:(0,l.__)("Answer","thinkrank")},{value:p,onChange:e=>a({itemBackground:e}),label:(0,l.__)("Item background","thinkrank")},{value:f,onChange:e=>a({itemBorderColor:e}),label:(0,l.__)("Border","thinkrank")}]}),(0,n.createElement)(i.PanelBody,{title:(0,l.__)("Spacing & size","thinkrank"),initialOpen:!1},(0,n.createElement)(i.RangeControl,{label:(0,l.__)("Question size (px)","thinkrank"),value:h,onChange:e=>a({titleFontSize:e}),min:12,max:30}),(0,n.createElement)(i.RangeControl,{label:(0,l.__)("Space between items (px)","thinkrank"),value:_,onChange:e=>a({itemSpacing:e}),min:0,max:32}),(0,n.createElement)(i.RangeControl,{label:(0,l.__)("Corner radius (px)","thinkrank"),value:v,onChange:e=>a({itemBorderRadius:e}),min:0,max:24}))))),(0,n.createElement)("div",{...b},(0,n.createElement)(r.RichText,{tagName:C,className:"thinkrank-faq__heading",value:t,onChange:e=>a({heading:e}),placeholder:(0,l.__)("Frequently asked questions","thinkrank"),allowedFormats:[]}),q.map((t,s)=>(0,n.createElement)("div",{key:s,className:"thinkrank-faq__item thinkrank-faq__item--editing",style:(0,o.nE)(e)},(0,n.createElement)(r.RichText,{tagName:"div",className:"thinkrank-faq__question",style:(0,o.mP)(e),value:t.question,onChange:e=>y(s,{question:e}),placeholder:(0,l.__)("Question…","thinkrank"),allowedFormats:["core/bold","core/italic"]}),(0,n.createElement)(r.RichText,{tagName:"div",className:"thinkrank-faq__answer",style:(0,o.W)(e),value:t.answer,onChange:e=>y(s,{answer:e}),placeholder:(0,l.__)("Answer…","thinkrank")}),t.imageUrl?(0,n.createElement)("img",{className:"thinkrank-faq__image",src:t.imageUrl,alt:t.imageAlt||""}):null,(0,n.createElement)("div",{className:"thinkrank-faq__item-actions"},(0,n.createElement)(r.MediaUploadCheck,null,(0,n.createElement)(r.MediaUpload,{onSelect:e=>y(s,{imageId:e.id,imageUrl:e.sizes?.large?.url||e.url,imageAlt:e.alt||""}),allowedTypes:["image"],value:t.imageId,render:({open:e})=>(0,n.createElement)(i.Button,{size:"small",icon:"format-image",label:t.imageUrl?(0,l.__)("Replace image","thinkrank"):(0,l.__)("Add image","thinkrank"),onClick:e})})),t.imageUrl?(0,n.createElement)(i.Button,{size:"small",icon:"no-alt",label:(0,l.__)("Remove image","thinkrank"),onClick:()=>y(s,{imageId:0,imageUrl:"",imageAlt:""})}):null,(0,n.createElement)(i.Button,{size:"small",icon:"arrow-up-alt2",label:(0,l.__)("Move up","thinkrank"),disabled:0===s,onClick:()=>w(s,-1)}),(0,n.createElement)(i.Button,{size:"small",icon:"arrow-down-alt2",label:(0,l.__)("Move down","thinkrank"),disabled:s===q.length-1,onClick:()=>w(s,1)}),(0,n.createElement)(i.Button,{size:"small",icon:"admin-page",label:(0,l.__)("Duplicate","thinkrank"),onClick:()=>(e=>{const t=[...q];t.splice(e+1,0,{...q[e]}),a({faqs:t})})(s)}),(0,n.createElement)(i.Button,{size:"small",icon:"trash",isDestructive:!0,label:(0,l.__)("Remove","thinkrank"),disabled:q.length<=1,onClick:()=>(e=>a({faqs:q.filter((a,t)=>t!==e)}))(s)})))),(0,n.createElement)(i.Button,{variant:"secondary",icon:"plus",onClick:()=>a({faqs:[...q,{question:"",answer:"",imageId:0,imageUrl:"",imageAlt:""}]}),className:"thinkrank-faq__add"},(0,l.__)("Add question","thinkrank"))))}},27723:e=>{e.exports=window.wp.i18n},36400:(e,a,t)=>{t.d(a,{W:()=>i,f:()=>n,mP:()=>r,nE:()=>l});const n=[{label:"H2",value:"h2"},{label:"H3",value:"h3"},{label:"H4",value:"h4"},{label:"Paragraph",value:"p"}];function l(e){const{itemSpacing:a,itemBackground:t,itemBorderColor:n,itemBorderRadius:l}=e;return{marginBottom:`${null!=a?a:8}px`,background:t||void 0,border:`1px solid ${n||"#e2e4e7"}`,borderRadius:`${null!=l?l:6}px`}}function r(e){var a;return{color:e.questionColor||void 0,background:e.questionBackground||void 0,fontSize:`${null!==(a=e.titleFontSize)&&void 0!==a?a:17}px`}}function i(e){return{color:e.answerColor||void 0}}},51609:e=>{e.exports=window.React},56427:e=>{e.exports=window.wp.components},72824:(e,a,t)=>{t.d(a,{A:()=>i});var n=t(51609),l=t(94715),r=t(36400);function i({attributes:e}){const{heading:a,headingTag:t,faqs:i,firstOpen:o}=e,s=l.useBlockProps.save({className:"thinkrank-faq"}),c=t||"h2",m=(i||[]).filter(e=>e.question||e.answer||e.imageUrl);return 0===m.length?null:(0,n.createElement)("div",{...s},a?(0,n.createElement)(l.RichText.Content,{tagName:c,className:"thinkrank-faq__heading",value:a}):null,m.map((a,t)=>(0,n.createElement)("details",{key:t,className:"thinkrank-faq__item",style:(0,r.nE)(e),open:!(!o||0!==t)||void 0},(0,n.createElement)(l.RichText.Content,{tagName:"summary",className:"thinkrank-faq__question",style:(0,r.mP)(e),value:a.question}),(0,n.createElement)(l.RichText.Content,{tagName:"div",className:"thinkrank-faq__answer",style:(0,r.W)(e),value:a.answer}),a.imageUrl?(0,n.createElement)("img",{className:"thinkrank-faq__image",src:a.imageUrl,alt:a.imageAlt||""}):null)))}},74997:e=>{e.exports=window.wp.blocks},94715:e=>{e.exports=window.wp.blockEditor}},a={};function t(n){var l=a[n];if(void 0!==l)return l.exports;var r=a[n]={exports:{}};return e[n](r,r.exports,t),r.exports}t.n=e=>{var a=e&&e.__esModule?()=>e.default:()=>e;return t.d(a,{a}),a},t.d=(e,a)=>{for(var n in a)t.o(a,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:a[n]})},t.o=(e,a)=>Object.prototype.hasOwnProperty.call(e,a);var n=t(74997),l=t(27723),r=t(24805),i=t(72824);t(24364),(0,n.registerBlockType)("thinkrank/faq",{apiVersion:3,title:(0,l.__)("FAQ (ThinkRank)","thinkrank"),description:(0,l.__)("Add frequently asked questions as an accordion with FAQPage schema for rich results.","thinkrank"),category:"widgets",icon:"editor-help",keywords:[(0,l.__)("faq","thinkrank"),(0,l.__)("questions","thinkrank"),(0,l.__)("accordion","thinkrank"),(0,l.__)("schema","thinkrank")],supports:{html:!1,anchor:!0},attributes:{heading:{type:"string",default:""},headingTag:{type:"string",default:"h2"},faqs:{type:"array",default:[{question:"",answer:"",imageId:0,imageUrl:"",imageAlt:""}]},firstOpen:{type:"boolean",default:!0},outputSchema:{type:"boolean",default:!0},questionColor:{type:"string"},questionBackground:{type:"string"},answerColor:{type:"string"},titleFontSize:{type:"number",default:17},itemSpacing:{type:"number",default:8},itemBackground:{type:"string"},itemBorderColor:{type:"string",default:"#e2e4e7"},itemBorderRadius:{type:"number",default:6}},edit:r.A,save:i.A})})();