← Back
Editing: block-library.js
(()=>{"use strict";var e={461(e,t,o){var r={};o.r(r),o.d(r,{init:()=>U,metadata:()=>$,name:()=>W,settings:()=>Z});var n={};o.r(n),o.d(n,{init:()=>re,metadata:()=>ee,name:()=>te,settings:()=>oe});var a={};o.r(a),o.d(a,{ctaButton:()=>r,ctaButtons:()=>n});const l=window.wp.domReady;var i=o.n(l);const s=window.popupMaker.i18n,c=window.wp.element;(0,c.forwardRef)(({icon:e,size:t=24,...o},r)=>(0,c.cloneElement)(e,{width:t,height:t,...o,ref:r}));const p=window.wp.primitives,u=window.ReactJSXRuntime;var d=(0,u.jsx)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:(0,u.jsx)(p.Path,{d:"M8 12.5h8V11H8v1.5Z M19 6.5H5a2 2 0 0 0-2 2V15a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V8.5a2 2 0 0 0-2-2ZM5 8h14a.5.5 0 0 1 .5.5V15a.5.5 0 0 1-.5.5H5a.5.5 0 0 1-.5-.5V8.5A.5.5 0 0 1 5 8Z"})}),m=(0,u.jsx)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:(0,u.jsx)(p.Path,{d:"M16.5 7.5 10 13.9l-2.5-2.4-1 1 3.5 3.6 7.5-7.6z"})}),h=(0,u.jsx)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:(0,u.jsx)(p.Path,{d:"M17.5 11.6L12 16l-5.5-4.4.9-1.2L12 14l4.5-3.6 1 1.2z"})}),x=(0,u.jsx)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:(0,u.jsx)(p.Path,{d:"M6.5 12.4L12 8l5.5 4.4-.9 1.2L12 10l-4.5 3.6-1-1.2z"})}),g=(0,u.jsx)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:(0,u.jsx)(p.Path,{d:"M19.5 4.5h-7V6h4.44l-5.97 5.97 1.06 1.06L18 7.06v4.44h1.5v-7Zm-13 1a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-3H17v3a.5.5 0 0 1-.5.5h-10a.5.5 0 0 1-.5-.5v-10a.5.5 0 0 1 .5-.5h3V5.5h-3Z"})}),w=(0,u.jsx)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:(0,u.jsx)(p.Path,{d:"M17.031 4.703 15.576 4l-1.56 3H14v.03l-2.324 4.47H9.5V13h1.396l-1.502 2.889h-.95a3.694 3.694 0 0 1 0-7.389H10V7H8.444a5.194 5.194 0 1 0 0 10.389h.17L7.5 19.53l1.416.719L15.049 8.5h.507a3.694 3.694 0 0 1 0 7.39H14v1.5h1.556a5.194 5.194 0 0 0 .273-10.383l1.202-2.304Z"})}),_=(0,u.jsx)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:(0,u.jsx)(p.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"M6.863 13.644L5 13.25h-.5a.5.5 0 01-.5-.5v-3a.5.5 0 01.5-.5H5L18 6.5h2V16h-2l-3.854-.815.026.008a3.75 3.75 0 01-7.31-1.549zm1.477.313a2.251 2.251 0 004.356.921l-4.356-.921zm-2.84-3.28L18.157 8h.343v6.5h-.343L5.5 11.823v-1.146z"})}),b=(0,u.jsx)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:(0,u.jsx)(p.Path,{d:"m19 7-3-3-8.5 8.5-1 4 4-1L19 7Zm-7 11.5H5V20h7v-1.5Z"})}),k=(0,u.jsxs)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:[(0,u.jsx)(p.Path,{d:"m19 7.5h-7.628c-.3089-.87389-1.1423-1.5-2.122-1.5-.97966 0-1.81309.62611-2.12197 1.5h-2.12803v1.5h2.12803c.30888.87389 1.14231 1.5 2.12197 1.5.9797 0 1.8131-.62611 2.122-1.5h7.628z"}),(0,u.jsx)(p.Path,{d:"m19 15h-2.128c-.3089-.8739-1.1423-1.5-2.122-1.5s-1.8131.6261-2.122 1.5h-7.628v1.5h7.628c.3089.8739 1.1423 1.5 2.122 1.5s1.8131-.6261 2.122-1.5h2.128z"})]});const f=window.wp.blocks;function y(e){if(!e)return;const{metadata:t,settings:o,name:r}=e;return(0,f.registerBlockType)({name:r,...t},o)}function v(e){var t,o,r="";if("string"==typeof e||"number"==typeof e)r+=e;else if("object"==typeof e)if(Array.isArray(e)){var n=e.length;for(t=0;t<n;t++)e[t]&&(o=v(e[t]))&&(r&&(r+=" "),r+=o)}else for(o in e)e[o]&&(r&&(r+=" "),r+=o);return r}const S=function(){for(var e,t,o=0,r="",n=arguments.length;o<n;o++)(e=arguments[o])&&(t=v(e))&&(r&&(r+=" "),r+=t);return r},C=window.React;var j=o.n(C);const B=window.wp.blockEditor,T=e=>({attributes:t,className:o})=>{const{tagName:r,type:n,textAlign:a,fontSize:l,linkTarget:i,rel:s,style:c,text:p,title:u,url:d,width:m}=t,h=r||"a",x="button"===h,g=n||"button",w=(0,B.__experimentalGetBorderClassesAndStyles)(t),_=(0,B.__experimentalGetColorClassesAndStyles)(t),b=(0,B.__experimentalGetSpacingClassesAndStyles)(t),k=(0,B.__experimentalGetShadowClassesAndStyles)(t),f=(0,B.getTypographyClassesAndStyles)(t),y=S(e,_.className,w.className,f.className,{[`has-text-align-${a}`]:a,"no-border-radius":0===c?.border?.radius,"has-custom-font-size":l||c?.typography?.fontSize}),v={...w.style,..._.style,...b.style,...k.style,...f.style,writingMode:void 0},C=S(o,{[`has-custom-width wp-block-popup-maker-cta-button__width-${m}`]:Boolean(m)});return j().createElement("div",B.useBlockProps.save({className:C}),j().createElement(B.RichText.Content,{tagName:h,type:x?g:null,className:y,href:x?null:d,title:u,style:v,value:p,target:x?null:i,rel:x?null:s}))},A=[{apiVersion:3,attributes:{},save:T(["wp-block-popup-maker-cta-button__link","wp-element-button"]),migrate:e=>e},{apiVersion:3,attributes:{},save:T(["wp-block-popup-maker-cta-button__link"]),migrate:e=>e}],N=window.wp.htmlEntities,z=window.wp.components,M=window.wp.data,P=window.wp.editor,D=window.wp.compose,I=window.wp.keycodes,V=window.popupMaker.components,E=window.popupMaker.coreData,O=window.popupMaker.ctaEditor;function F(e,t,o){if(!e)return;const r=[];if(["popup-maker/cta-button"].includes(t)&&o&&r.push("id","bindings"),!r.length)return;const n=Object.entries(e).reduce((e,[t,n])=>r.includes(t)?(e[t]="bindings"===t&&o?o(n):n,e):e,{});return Object.keys(n).length?n:void 0}function R(e){return e.toString().replace(/<\/?a[^>]*>/g,"")}window.wp.blob,window.wp.coreData;const G="nofollow",L=(0,O.withModal)(O.Editor);function H({selectedWidth:e,setAttributes:t}){const o=(0,D.useViewportMatch)("medium","<")?{}:{popoverProps:{placement:"left-start",offset:259}};return(0,u.jsx)(z.__experimentalToolsPanel,{label:(0,s.__)("Settings","default"),resetAll:()=>t({width:void 0}),dropdownMenuProps:o,children:(0,u.jsx)(z.__experimentalToolsPanelItem,{label:(0,s.__)("Button width","default"),isShownByDefault:!0,hasValue:()=>!!e,onDeselect:()=>t({width:void 0}),as:"div",__nextHasNoMarginBottom:!0,children:(0,u.jsx)(z.__experimentalToggleGroupControl,{label:(0,s.__)("Button width","default"),value:e,onChange:e=>t({width:Number(e)}),isBlock:!0,__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,children:[25,50,75,100].map(e=>(0,u.jsx)(z.__experimentalToggleGroupControlOption,{value:e,label:`${e}%`},e))})})})}const $=JSON.parse('{"$schema":"https://schemas.wp.org/trunk/block.json","apiVersion":3,"name":"popup-maker/cta-button","title":"Call to Action Button","category":"popup-maker","parent":["popup-maker/cta-buttons","core/buttons"],"description":"Prompt visitors to take action with a button-style link.","keywords":["link","button","call to action","cta","conversion"],"textdomain":"popup-maker","attributes":{"tagName":{"type":"string","enum":["a","button"],"default":"a"},"type":{"type":"string","default":"button"},"textAlign":{"type":"string"},"url":{"type":"string","source":"attribute","selector":"a","attribute":"href","role":"content"},"title":{"type":"string","source":"attribute","selector":"a,button","attribute":"title","role":"content"},"text":{"type":"rich-text","source":"rich-text","selector":"a,button","role":"content"},"linkTarget":{"type":"string","source":"attribute","selector":"a","attribute":"target","role":"content"},"rel":{"type":"string","source":"attribute","selector":"a","attribute":"rel","role":"content"},"placeholder":{"type":"string"},"backgroundColor":{"type":"string"},"textColor":{"type":"string"},"gradient":{"type":"string"},"width":{"type":"number"},"ctaId":{"type":"number"}},"supports":{"anchor":true,"splitting":true,"align":false,"alignWide":false,"color":{"__experimentalSkipSerialization":true,"gradients":true,"__experimentalDefaultControls":{"background":true,"text":true}},"typography":{"__experimentalSkipSerialization":["fontSize","lineHeight","fontFamily","fontWeight","fontStyle","textTransform","textDecoration","letterSpacing"],"fontSize":true,"lineHeight":true,"__experimentalFontFamily":true,"__experimentalFontWeight":true,"__experimentalFontStyle":true,"__experimentalTextTransform":true,"__experimentalTextDecoration":true,"__experimentalLetterSpacing":true,"__experimentalWritingMode":true,"__experimentalDefaultControls":{"fontSize":true}},"reusable":false,"shadow":{"__experimentalSkipSerialization":true},"spacing":{"__experimentalSkipSerialization":true,"padding":["horizontal","vertical"],"__experimentalDefaultControls":{"padding":true}},"__experimentalBorder":{"color":true,"radius":true,"style":true,"width":true,"__experimentalSkipSerialization":true,"__experimentalDefaultControls":{"color":true,"radius":true,"style":true,"width":true}},"__experimentalSelector":".wp-block-popup-maker-cta-button .wp-block-popup-maker-cta-button__link","interactivity":{"clientNavigation":true}},"styles":[{"name":"fill","label":"Fill","isDefault":true},{"name":"outline","label":"Outline"}],"editorStyle":"popup-maker-block-library","style":"popup-maker-block-library-style","selectors":{"root":".wp-block-popup-maker-cta-button .wp-block-popup-maker-cta-button__link","typography":{"writingMode":".wp-block-popup-maker-cta-button"}}}'),{name:W}=$,Z={icon:d,example:{attributes:{className:"is-style-fill",text:(0,s.__)("Call to Action","popup-maker")}},edit:function(e){const{attributes:t,setAttributes:o,className:r,isSelected:n,onReplace:a,mergeBlocks:l,clientId:i}=e,{tagName:p,textAlign:d,linkTarget:y,placeholder:v,rel:j,style:T,text:A,width:O,ctaId:F}=t,$=p||"a",[W,Z]=(0,c.useState)(!1),[U,J]=(0,c.useState)(!1),K=n&&(W||!!F),[q,X]=(0,c.useState)(null),Q=(0,c.useRef)(null),Y=(0,c.useRef)(null),ee=(0,B.useBlockProps)({ref:(0,D.useMergeRefs)([X,Q]),onKeyDown:function(e){I.isKeyboardEvent.primary(e,"k")?(e.preventDefault(),ve()):I.isKeyboardEvent.primaryShift(e,"k")&&(Se(),Y.current?.focus())}}),te=(0,B.__experimentalUseBorderProps)(t),oe=(0,B.__experimentalUseColorProps)(t),re=(0,B.__experimentalGetSpacingClassesAndStyles)(t),ne=(0,B.__experimentalGetShadowClassesAndStyles)(t),ae=(0,B.useBlockEditingMode)(),le="_blank"===y,ie=!!j?.includes(G),se="a"===$,{selectedCTA:ce,hasResolvedSelectedCTA:pe}=(0,M.useSelect)(e=>{const t=e(E.callToActionStore);return{selectedCTA:F?t.getCallToAction(F):void 0,hasResolvedSelectedCTA:!!F&&t.hasFinishedResolution("getCallToAction",[F])}},[F]),{currentPostId:ue,currentPostType:de}=(0,M.useSelect)(e=>({currentPostId:e(P.store).getCurrentPostId(),currentPostType:e(P.store).getCurrentPostType()}),[]),me=window.popupMakerBlockLibrary,he=me?.homeUrl||"/",xe=me?.paramNames||{},ge=xe.cta||"cta",we=xe.popup_id||"pid",_e=xe.notrack||"notrack",be=(0,C.useCallback)((e,t=!1)=>{const o=new URLSearchParams;return o.set(ge,e),"popup"===de&&ue&&o.set(we,ue.toString()),t&&o.set(_e,"1"),`${he.replace(/\/$/,"")}/?${o.toString()}`},[ge,ue,de,he,_e,we]),{changeEditorId:ke,updateEditorValues:fe}=(0,M.useDispatch)(E.callToActionStore),ye=(0,M.useSelect)(e=>e(E.callToActionStore),[]);function ve(){Z(!0)}function Se(){o({ctaId:void 0,url:void 0,linkTarget:void 0,rel:void 0}),Z(!1)}(0,c.useEffect)(()=>{n||Z(!1)},[n]),(0,c.useEffect)(()=>{if(F)if(ce){const e=be(ce.uuid);o({url:e,linkTarget:ce.settings.opensInNewTab?"_blank":void 0,rel:ce.settings.nofollow?G:void 0})}else pe&&o({url:void 0,linkTarget:void 0,rel:void 0})},[F,ce,pe,de,ue,he,o,be]);const Ce=function(e){const{replaceBlocks:t,selectionChange:o}=(0,M.useDispatch)(B.store),r=(0,M.useSelect)(e=>e(B.store).getBlock,[]),n=(0,M.useSelect)(e=>e(B.store).getBlockRootClientId,[]),a=(0,M.useSelect)(e=>e(B.store).getBlockIndex,[]),l=(0,c.useRef)(e);return l.current=e,(0,D.useRefEffect)(e=>{function i(e){if(e.defaultPrevented||e.keyCode!==I.ENTER)return;const{content:i,clientId:s}=l.current;if(i.length)return;e.preventDefault();const c=r(n(s)),p=a(s),u=(0,f.cloneBlock)({...c,innerBlocks:c.innerBlocks.slice(0,p)}),d=(0,f.createBlock)((0,f.getDefaultBlockName)()||""),m=c.innerBlocks.slice(p+1),h=m.length?[(0,f.cloneBlock)({...c,innerBlocks:m})]:[];t(c.clientId,[u,d,...h],1),o(d.clientId)}return e.addEventListener("keydown",i),()=>{e.removeEventListener("keydown",i)}},[])}({content:A,clientId:i}),je=(0,D.useMergeRefs)([Ce,Y]),[Be,Te]=(0,c.useState)(!1),Ae=se&&n&&(!!F||W)&&!!q;async function Ne(){await ke("new"),await fe({title:(0,s.__)("New call to action","popup-maker"),status:"publish"}),J("new"),Z(!0)}const[ze,Me]=(0,B.useSettings)("typography.fluid","layout"),Pe=(0,B.getTypographyClassesAndStyles)(t,{typography:{fluid:ze},layout:{wideSize:Me?.wideSize}}),De=(0,M.useSelect)(e=>{const t=e(E.callToActionStore),o=F?t.getFetchError(F)||null:t.getFetchError()||null;return null===o?null:o.replace("Invalid post ID.",(0,s.__)("Call to action not found.","popup-maker"))},[F]);return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("div",{...ee,className:S(ee.className,{[`has-custom-width wp-block-popup-maker-cta-button__width-${O}`]:O,"has-custom-font-size":ee.style.fontSize}),style:{...ee.style,border:De?"2px solid red":void 0},children:(0,u.jsx)(B.RichText,{ref:je,"aria-label":(0,s.__)("Button text","default"),placeholder:v||(0,s.__)("Add text…","default"),value:A,onChange:e=>o({text:R(e)}),withoutInteractiveFormatting:!0,className:S(r,"wp-block-popup-maker-cta-button__link",oe.className,te.className,Pe.className,{[`has-text-align-${d}`]:d,"no-border-radius":0===T?.border?.radius,"has-custom-font-size":ee.style.fontSize}),style:{...te.style,...oe.style,...re.style,...ne.style,...Pe.style,writingMode:void 0},onReplace:a,onMerge:l,identifier:"text"})}),(0,u.jsxs)(B.BlockControls,{group:"block",children:["default"===ae&&(0,u.jsx)(B.AlignmentControl,{value:d,onChange:e=>{o({textAlign:e})}}),!ce&&se&&(0,u.jsx)(z.ToolbarButton,{icon:_,title:(0,s.__)("Add Call to Action","popup-maker"),shortcut:I.displayShortcut.primary("k"),onClick:e=>{e.preventDefault(),ve()}}),ce&&se&&(0,u.jsx)(z.ToolbarButton,{icon:w,title:(0,s.__)("Remove Call to Action","popup-maker"),shortcut:I.displayShortcut.primaryShift("k"),onClick:Se,isActive:!0})]}),Ae&&(0,u.jsx)(z.Popover,{placement:"bottom",onClose:()=>{Z(!1),Y.current?.focus?.()},anchor:q,focusOnMount:!!K&&"firstElement",__unstableSlotName:"__unstable-block-tools-after",shift:!0,className:"block-editor-link-control",children:(0,u.jsxs)("div",{style:{width:"300px",padding:"10px"},children:[De&&(0,u.jsx)("div",{className:"pum-cta-error-notice",children:(0,u.jsx)(z.Notice,{status:"error",isDismissible:!1,children:De})}),W||De?(0,u.jsx)(z.Flex,{direction:"column",children:(0,u.jsxs)(z.Flex,{align:"center",justify:"space-between",children:[(0,u.jsx)(z.FlexItem,{style:{flexGrow:1},children:(0,u.jsx)(V.CallToActionSelectControl,{value:F&&!De?F:0,onChange:async e=>{"create_new"!==e?(o({ctaId:Number(e)}),Z(!1)):await Ne()},hideLabelFromVision:!0,placeholder:(0,s.__)("Search or create CTA…","popup-maker"),multiple:!1,extraOptions:[{value:"create_new",label:(0,s.__)("+ Create new CTA","popup-maker")}]})}),(0,u.jsx)(z.FlexItem,{children:(0,u.jsx)(z.Button,{icon:m,label:(0,s.__)("Save","popup-maker"),onClick:()=>Z(!1)})})]})}):ce&&(0,u.jsxs)(z.Flex,{direction:"column",gap:3,children:[(0,u.jsxs)(z.Flex,{justify:"space-between",align:"center",children:[(0,u.jsx)("div",{style:{fontSize:"16px",fontWeight:"500",color:"#1e1e1e",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:(0,N.decodeEntities)(ce?.title?.rendered),children:(0,N.decodeEntities)(ce?.title?.rendered)}),(0,u.jsx)(z.Button,{icon:w,variant:"link",size:"small",style:{textDecoration:"none"},isDestructive:!0,onClick:Se,label:(0,s.__)("Remove","popup-maker")})]}),(0,u.jsxs)(z.Flex,{justify:"space-between",align:"center",style:{color:"#1e1e1e"},children:[(0,u.jsxs)("div",{style:{fontSize:"12px",color:"#666",backgroundColor:"#f0f0f0",padding:"2px 8px",borderRadius:"12px",fontWeight:"500",flexGrow:.5,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:["ID: ",ce?.id]}),(0,u.jsx)(z.Button,{icon:g,variant:"tertiary",style:{borderRadius:"6px",textDecoration:"none",color:"#1e1e1e",padding:".25rem 0.75rem",flexGrow:1},href:be(ce.uuid,!0),target:"_blank",rel:"noopener noreferrer",showTooltip:!0,label:(0,s.__)("Preview Call To Action","popup-maker"),children:(0,s.__)("Preview","popup-maker")}),(0,u.jsx)(z.Button,{icon:b,variant:"tertiary",style:{borderRadius:"6px",textDecoration:"none",color:"#1e1e1e",padding:".25rem 0.75rem",flexGrow:1},href:`edit.php?post_type=popup&page=popup-maker-call-to-actions&edit=${ce.id}`,target:"_blank",label:(0,s.__)("Edit Call to Action","popup-maker"),showTooltip:!0,children:(0,s.__)("Edit","popup-maker")})]}),(0,u.jsxs)(z.Button,{icon:k,variant:"secondary",onClick:()=>Te(!Be),style:{width:"100%",justifyContent:"space-between",border:"1px solid #ddd",borderRadius:"6px",padding:"8px 12px"},showTooltip:!0,label:(0,s.__)("Advanced Options","popup-maker"),children:[(0,s.__)("Advanced Options","popup-maker"),(0,u.jsx)(z.Icon,{icon:Be?x:h})]}),Be&&(0,u.jsxs)(z.Flex,{direction:"column",gap:3,children:[(0,u.jsx)(z.ToggleControl,{label:(0,s.__)("Open in new window","popup-maker"),checked:le,onChange:e=>{o({linkTarget:e?"_blank":void 0})},__nextHasNoMarginBottom:!0}),(0,u.jsx)(z.ToggleControl,{label:(0,s.__)('Add rel="nofollow"',"popup-maker"),checked:ie,onChange:e=>{o({rel:e?G:void 0})},__nextHasNoMarginBottom:!0})]})]})]})}),(0,u.jsx)(B.InspectorControls,{group:"settings",children:(0,u.jsx)(z.Panel,{header:(0,s.__)("CTA Settings","popup-maker"),children:(0,u.jsx)(z.PanelBody,{children:(0,u.jsx)(V.CallToActionSelectControl,{label:(0,s.__)("Choose a Call to Action","popup-maker"),value:F,placeholder:(0,s.__)("Search or create CTA…","popup-maker"),onChange:async e=>{"create_new"!==e?(o({ctaId:Number(e)}),Z(!1)):await Ne()},extraOptions:[{value:"create_new",label:(0,s.__)("+ Create new CTA","popup-maker")}]})})})}),(0,u.jsx)(B.InspectorControls,{children:(0,u.jsx)(H,{selectedWidth:O,setAttributes:o})}),(0,u.jsx)(B.InspectorControls,{group:"advanced",children:se&&(0,u.jsx)(z.TextControl,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,label:(0,s.__)("Link rel","default"),value:j||"",onChange:e=>o({rel:e})})}),("new"===U||"number"==typeof U&&U>0)&&(0,u.jsx)(L,{id:U,defaultValues:{status:"publish"},onSave:e=>{const t=e.id>0?e.id:ye.getEditorId();"number"==typeof t&&t>0&&o({ctaId:t})},closeOnSave:!0,onClose:()=>{ke(void 0),J(!1)}},U)]})},save:function({attributes:e,className:t}){const{tagName:o,type:r,textAlign:n,fontSize:a,linkTarget:l,rel:i,style:s,text:c,title:p,url:d,width:m}=e,h=o||"a",x="button"===h,g=r||"button",w=(0,B.__experimentalGetBorderClassesAndStyles)(e),_=(0,B.__experimentalGetColorClassesAndStyles)(e),b=(0,B.__experimentalGetSpacingClassesAndStyles)(e),k=(0,B.__experimentalGetShadowClassesAndStyles)(e),f=(0,B.getTypographyClassesAndStyles)(e),y=S("pum-cta","wp-block-popup-maker-cta-button__link","wp-element-button",_.className,w.className,f.className,{[`has-text-align-${n}`]:n,"no-border-radius":0===s?.border?.radius,"has-custom-font-size":a||s?.typography?.fontSize}),v={...w.style,..._.style,...b.style,...k.style,...f.style,writingMode:void 0},C=S(t,{[`has-custom-width wp-block-popup-maker-cta-button__width-${m}`]:Boolean(m)});return(0,u.jsx)("div",{...B.useBlockProps.save({className:C}),children:(0,u.jsx)(B.RichText.Content,{tagName:h,type:x?g:null,className:y,href:x?null:d,title:p,style:v,value:c,target:x?null:l,rel:x?null:i})})},deprecated:A,merge:(e,{text:t=""})=>({...e,text:(e.text||"")+t})},U=()=>y({name:W,metadata:$,settings:Z}),J=window.popupMaker.icons,K=window.wp.hooks,q=[{apiVersion:3,attributes:{},supports:{anchor:!0,align:["wide","full"],html:!1,__experimentalExposeControlsToChildren:!0,color:{gradients:!0,text:!1,__experimentalDefaultControls:{background:!0}},spacing:{blockGap:["horizontal","vertical"],padding:!0,margin:["top","bottom"],__experimentalDefaultControls:{blockGap:!0}},typography:{fontSize:!0,lineHeight:!0,__experimentalFontFamily:!0,__experimentalFontWeight:!0,__experimentalFontStyle:!0,__experimentalTextTransform:!0,__experimentalTextDecoration:!0,__experimentalLetterSpacing:!0,__experimentalDefaultControls:{fontSize:!0}},__experimentalBorder:{color:!0,radius:!0,style:!0,width:!0,__experimentalDefaultControls:{color:!0,radius:!0,style:!0,width:!0}},layout:{allowSwitching:!1,allowInheriting:!1,default:{type:"flex"}},interactivity:{clientNavigation:!0}},save({attributes:e,className:t}){const{fontSize:o,style:r}=e,n=B.useBlockProps.save({className:S(t,"wp-block-buttons",{"has-custom-font-size":o||r?.typography?.fontSize})}),a=B.useInnerBlocksProps.save(n);return(0,u.jsx)("div",{...a})},migrate:(e,t)=>[e,t]}],X=(e,t)=>(X.body||(X.body=e.implementation.createHTMLDocument("").body),X.body.innerHTML=t,X.body),Q={from:[{type:"block",isMultiBlock:!0,blocks:["popup-maker/cta-button","core/button"],transform:e=>(0,f.createBlock)("popup-maker/cta-buttons",{},e.map((e,t)=>"core/button"===t?(0,f.createBlock)("core/button",e):(0,f.createBlock)("popup-maker/cta-button",e)))},{type:"block",isMultiBlock:!0,blocks:["core/buttons"],transform:(e,t)=>(0,f.createBlock)("popup-maker/cta-buttons",{},(t||[]).flat().map(e=>(0,f.cloneBlock)(e)))},{type:"block",isMultiBlock:!0,blocks:["core/paragraph"],transform:e=>(0,f.createBlock)("popup-maker/cta-buttons",{},e.map(e=>{const{content:t,metadata:o}=e,r=X(document,t),n=r.innerText||"",a=r.querySelector("a"),l=a?.getAttribute("href");return(0,f.createBlock)("popup-maker/cta-button",{text:n,url:l,metadata:F(o,"popup-maker/cta-button",({content:e})=>({text:e}))})})),isMatch:e=>e.every(e=>{const t=X(document,e.content),o=t.innerText||"",r=t.querySelectorAll("a");return o.length<=30&&r.length<=1})}]},Y={name:"popup-maker/cta-button",attributesToCopy:["backgroundColor","border","className","fontFamily","fontSize","gradient","style","textColor","width"]},ee=JSON.parse('{"$schema":"https://schemas.wp.org/trunk/block.json","apiVersion":3,"name":"popup-maker/cta-buttons","title":"Call to Action Buttons","category":"popup-maker","allowedBlocks":["popup-maker/cta-button","core/button"],"description":"Prompt visitors to take action with a group of button-style links.","keywords":["link","button","call to action","cta","conversion"],"textdomain":"popup-maker","attributes":{},"supports":{"anchor":true,"align":["wide","full"],"html":false,"__experimentalExposeControlsToChildren":true,"color":{"gradients":true,"text":false,"__experimentalDefaultControls":{"background":true}},"spacing":{"blockGap":["horizontal","vertical"],"padding":true,"margin":["top","bottom"],"__experimentalDefaultControls":{"padding":true,"blockGap":true}},"typography":{"fontSize":true,"lineHeight":true,"__experimentalFontFamily":true,"__experimentalFontWeight":true,"__experimentalFontStyle":true,"__experimentalTextTransform":true,"__experimentalTextDecoration":true,"__experimentalLetterSpacing":true,"__experimentalDefaultControls":{"fontSize":true}},"__experimentalBorder":{"color":true,"radius":true,"style":true,"width":true,"__experimentalDefaultControls":{"color":true,"radius":true,"style":true,"width":true}},"layout":{"allowSwitching":false,"allowInheriting":false,"default":{"type":"flex"}},"interactivity":{"clientNavigation":true}},"editorStyle":"popup-maker-block-library","style":"popup-maker-block-library-style"}'),{name:te}=ee,oe={icon:J.Mark,example:{attributes:{layout:{type:"flex",justifyContent:"center"}},innerBlocks:[{name:"popup-maker/cta-button",attributes:{text:(0,s.__)("Buy now","popup-maker")}},{name:"popup-maker/cta-button",attributes:{text:(0,s.__)("Contact us","popup-maker")}}]},deprecated:q,transforms:Q,edit:function({attributes:e,className:t}){const{fontSize:o,layout:r,style:n}=e,a=(0,B.useBlockProps)({className:S(t,{"has-custom-font-size":o||n?.typography?.fontSize})}),{hasButtonVariations:l}=(0,M.useSelect)(e=>({hasButtonVariations:e(f.store).getBlockVariations("popup-maker/cta-button","inserter").length>0}),[]),i=(0,B.useInnerBlocksProps)(a,{defaultBlock:Y,directInsert:!l,template:[["popup-maker/cta-button"]],templateInsertUpdatesSelection:!0,orientation:r?.orientation??"horizontal"});return(0,u.jsx)("div",{...i})},save:function({attributes:e,className:t}){const{fontSize:o,style:r}=e,n=B.useBlockProps.save({className:S(t,{"has-custom-font-size":o||r?.typography?.fontSize})}),a=B.useInnerBlocksProps.save(n);return(0,u.jsx)("div",{...a})}},re=()=>y({name:te,metadata:ee,settings:oe});(0,K.addFilter)("blocks.registerBlockType","popup-maker/cta-buttons",e=>{const{name:t}=e;switch(t){case"core/button":return{...e,parent:[...e.parent,"popup-maker/cta-buttons"]};case"core/buttons":return{...e,allowedBlocks:[...e.allowedBlocks,"popup-maker/cta-button"]};default:return e}}),i()(()=>{Object.values(a).forEach(({init:e})=>{e()})})}};const t={};function o(r){const n=t[r];if(void 0!==n)return n.exports;const a=t[r]={exports:{}};return e[r](a,a.exports,o),a.exports}o.m=e,(()=>{const e=[];o.O=(t,r,n,a)=>{if(r){a=a||0;for(var l=e.length;l>0&&e[l-1][2]>a;l--)e[l]=e[l-1];return void(e[l]=[r,n,a])}let i=1/0;for(l=0;l<e.length;l++){let[r,n,a]=e[l],c=!0;for(var s=0;s<r.length;s++)(!1&a||i>=a)&&Object.keys(o.O).every(e=>o.O[e](r[s]))?r.splice(s--,1):(c=!1,a<i&&(i=a));if(c){e.splice(l--,1);const o=n();void 0!==o&&(t=o)}}return t}})(),o.n=e=>{const t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},o.d=(e,t)=>{if(Array.isArray(t))for(var r=0;r<t.length;){var n=t[r++],a=t[r++];o.o(e,n)?0===a&&r++:0===a?Object.defineProperty(e,n,{enumerable:!0,value:t[r++]}):Object.defineProperty(e,n,{enumerable:!0,get:a})}else for(var n in t)o.o(t,n)&&!o.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o.o=(e,t)=>Object.hasOwn(e,t),o.r=e=>{Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{const e={544:0,385:0};o.O.j=t=>0===e[t];const t=(t,r)=>{let[n,a,l]=r;var i,s,c=0;if(n.some(t=>0!==e[t])){for(i in a)o.o(a,i)&&(o.m[i]=a[i]);if(l)var p=l(o)}for(t&&t(r);c<n.length;c++)s=n[c],o.o(e,s)&&e[s]&&e[s][0](),e[s]=0;return o.O(p)},r=globalThis.webpackChunk_popupMakerAdmin_webpackJsonp||=[];r.forEach(t.bind(null,0)),r.push=t.bind(null,r.push.bind(r))})();let r=o.O(void 0,[385],()=>o(461));r=o.O(r),(window.popupMaker=window.popupMaker||{}).blockLibrary=r})();
Save File
Cancel