← Back
Editing: block-library.js
(()=>{"use strict";var t,e={232(t,e,a){var o={};a.r(o),a.d(o,{init:()=>U,metadata:()=>W,name:()=>Z,settings:()=>J});var r={};a.r(r),a.d(r,{init:()=>rt,metadata:()=>et,name:()=>at,settings:()=>ot});var n={};a.r(n),a.d(n,{ctaButton:()=>o,ctaButtons:()=>r});const l=window.wp.domReady;var i=a.n(l);const s=window.popupMaker.i18n,h=window.wp.element,p=((0,h.forwardRef)(({icon:t,size:e=24,...a},o)=>(0,h.cloneElement)(t,{width:e,height:e,...a,ref:o})),window.wp.primitives),c=window.ReactJSXRuntime,u=(p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.Circle,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,(0,c.jsx)(p.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,c.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"})})),S=(p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,(0,c.jsx)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,c.jsx)(p.Path,{d:"M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z"})})),d=(0,c.jsx)(p.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,c.jsx)(p.Path,{d:"M17.5 11.6L12 16l-5.5-4.4.9-1.2L12 14l4.5-3.6 1 1.2z"})}),P=(p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,(0,c.jsx)(p.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,c.jsx)(p.Path,{d:"M6.5 12.4L12 8l5.5 4.4-.9 1.2L12 10l-4.5 3.6-1-1.2z"})})),G=(p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.Path,p.Circle,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.G,p.Path,p.Path,p.SVG,p.G,p.Path,p.Path,p.SVG,p.G,p.Path,p.Path,p.SVG,p.G,p.Path,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,(0,c.jsx)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,c.jsx)(p.Path,{d:"m19 7-3-3-8.5 8.5-1 4 4-1L19 7Zm-7 11.5H5V20h7v-1.5Z"})})),V=(p.SVG,p.Path,(0,c.jsx)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,c.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"})})),m=(p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,(0,c.jsx)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,c.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"})})),x=(p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.Path,p.SVG,p.Path,(0,c.jsx)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,c.jsx)(p.Path,{fillRule:"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",clipRule:"evenodd"})})),g=(p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.Path,p.SVG,p.Path,p.Path,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,(0,c.jsxs)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:[(0,c.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,c.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"})]})),w=(p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.Path,p.SVG,p.Path,p.Path,p.Path,p.SVG,p.Path,p.Path,p.SVG,p.Path,p.Path,p.SVG,p.Path,p.Path,p.SVG,p.Path,p.Path,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,p.SVG,p.Path,window.wp.blocks);function _(t){if(!t)return;const{metadata:e,settings:a,name:o}=t;return(0,w.registerBlockType)({name:o,...e},a)}function b(t){var e,a,o="";if("string"==typeof t||"number"==typeof t)o+=t;else if("object"==typeof t)if(Array.isArray(t)){var r=t.length;for(e=0;e<r;e++)t[e]&&(a=b(t[e]))&&(o&&(o+=" "),o+=a)}else for(a in t)t[a]&&(o&&(o+=" "),o+=a);return o}const k=function(){for(var t,e,a=0,o="",r=arguments.length;a<r;a++)(t=arguments[a])&&(e=b(t))&&(o&&(o+=" "),o+=e);return o},y=window.React;var f=a.n(y);const v=window.wp.blockEditor,C=t=>({attributes:e,className:a})=>{const{tagName:o,type:r,textAlign:n,fontSize:l,linkTarget:i,rel:s,style:h,text:p,title:c,url:u,width:S}=e,d=o||"a",P="button"===d,G=r||"button",V=(0,v.__experimentalGetBorderClassesAndStyles)(e),m=(0,v.__experimentalGetColorClassesAndStyles)(e),x=(0,v.__experimentalGetSpacingClassesAndStyles)(e),g=(0,v.__experimentalGetShadowClassesAndStyles)(e),w=(0,v.getTypographyClassesAndStyles)(e),_=k(t,m.className,V.className,w.className,{[`has-text-align-${n}`]:n,"no-border-radius":0===h?.border?.radius,"has-custom-font-size":l||h?.typography?.fontSize}),b={...V.style,...m.style,...x.style,...g.style,...w.style,writingMode:void 0},y=k(a,{[`has-custom-width wp-block-popup-maker-cta-button__width-${S}`]:Boolean(S)});return f().createElement("div",v.useBlockProps.save({className:y}),f().createElement(v.RichText.Content,{tagName:d,type:P?G:null,className:_,href:P?null:u,title:c,style:b,value:p,target:P?null:i,rel:P?null:s}))},B=[{apiVersion:3,attributes:{},save:C(["wp-block-popup-maker-cta-button__link","wp-element-button"]),migrate:t=>t},{apiVersion:3,attributes:{},save:C(["wp-block-popup-maker-cta-button__link"]),migrate:t=>t}],j=window.wp.htmlEntities,T=window.wp.components,A=window.wp.data,N=window.wp.editor,z=window.wp.compose,M=window.wp.keycodes,D=window.popupMaker.components,I=window.popupMaker.coreData,E=window.popupMaker.ctaEditor;function F(t,e,a){if(!t)return;const o=[];if(["popup-maker/cta-button"].includes(e)&&a&&o.push("id","bindings"),!o.length)return;const r=Object.entries(t).reduce((t,[e,r])=>o.includes(e)?(t[e]="bindings"===e&&a?a(r):r,t):t,{});return Object.keys(r).length?r:void 0}function R(t){return t.toString().replace(/<\/?a[^>]*>/g,"")}window.wp.blob,window.wp.coreData;const O="_blank",L="nofollow",H=(0,E.withModal)(E.Editor);function $({selectedWidth:t,setAttributes:e}){const a=(0,z.useViewportMatch)("medium","<")?{}:{popoverProps:{placement:"left-start",offset:259}};return(0,c.jsx)(T.__experimentalToolsPanel,{label:(0,s.__)("Settings","default"),resetAll:()=>e({width:void 0}),dropdownMenuProps:a,children:(0,c.jsx)(T.__experimentalToolsPanelItem,{label:(0,s.__)("Button width","default"),isShownByDefault:!0,hasValue:()=>!!t,onDeselect:()=>e({width:void 0}),as:"div",__nextHasNoMarginBottom:!0,children:(0,c.jsx)(T.__experimentalToggleGroupControl,{label:(0,s.__)("Button width","default"),value:t,onChange:t=>e({width:Number(t)}),isBlock:!0,__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,children:[25,50,75,100].map(t=>(0,c.jsx)(T.__experimentalToggleGroupControlOption,{value:t,label:`${t}%`},t))})})})}const W=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:Z}=W,J={icon:u,example:{attributes:{className:"is-style-fill",text:(0,s.__)("Call to Action","popup-maker")}},edit:function(t){const{attributes:e,setAttributes:a,className:o,isSelected:r,onReplace:n,mergeBlocks:l,clientId:i}=t,{tagName:p,textAlign:u,linkTarget:_,placeholder:b,rel:f,style:C,text:B,width:E,ctaId:F}=e,W=p||"a",[Z,J]=(0,h.useState)(!1),[U,K]=(0,h.useState)(!1),q=r&&(Z||!!F),[X,Q]=(0,h.useState)(null),Y=(0,h.useRef)(null),tt=(0,h.useRef)(null),et=(0,v.useBlockProps)({ref:(0,z.useMergeRefs)([Q,Y]),onKeyDown:function(t){M.isKeyboardEvent.primary(t,"k")?(t.preventDefault(),kt()):M.isKeyboardEvent.primaryShift(t,"k")&&(yt(),tt.current?.focus())}}),at=(0,v.__experimentalUseBorderProps)(e),ot=(0,v.__experimentalUseColorProps)(e),rt=(0,v.__experimentalGetSpacingClassesAndStyles)(e),nt=(0,v.__experimentalGetShadowClassesAndStyles)(e),lt=(0,v.useBlockEditingMode)(),it=_===O,st=!!f?.includes(L),ht="a"===W,{selectedCTA:pt,hasResolvedSelectedCTA:ct}=(0,A.useSelect)(t=>{const e=t(I.callToActionStore);return{selectedCTA:F?e.getCallToAction(F):void 0,hasResolvedSelectedCTA:!!F&&e.hasFinishedResolution("getCallToAction",[F])}},[F]),{currentPostId:ut,currentPostType:St}=(0,A.useSelect)(t=>({currentPostId:t(N.store).getCurrentPostId(),currentPostType:t(N.store).getCurrentPostType()}),[]),dt=window.popupMakerBlockLibrary,Pt=dt?.homeUrl||"/",Gt=dt?.paramNames||{},Vt=Gt.cta||"cta",mt=Gt.popup_id||"pid",xt=Gt.notrack||"notrack",gt=(0,y.useCallback)((t,e=!1)=>{const a=new URLSearchParams;return a.set(Vt,t),"popup"===St&&ut&&a.set(mt,ut.toString()),e&&a.set(xt,"1"),`${Pt.replace(/\/$/,"")}/?${a.toString()}`},[Vt,ut,St,Pt,xt,mt]),{changeEditorId:wt,updateEditorValues:_t}=(0,A.useDispatch)(I.callToActionStore),bt=(0,A.useSelect)(t=>t(I.callToActionStore),[]);function kt(){J(!0)}function yt(){a({ctaId:void 0,url:void 0,linkTarget:void 0,rel:void 0}),J(!1)}(0,h.useEffect)(()=>{r||J(!1)},[r]),(0,h.useEffect)(()=>{if(F)if(pt){const t=gt(pt.uuid);a({url:t,linkTarget:pt.settings.opensInNewTab?O:void 0,rel:pt.settings.nofollow?L:void 0})}else ct&&a({url:void 0,linkTarget:void 0,rel:void 0})},[F,pt,ct,St,ut,Pt,a,gt]);const ft=function(t){const{replaceBlocks:e,selectionChange:a}=(0,A.useDispatch)(v.store),o=(0,A.useSelect)(t=>t(v.store).getBlock,[]),r=(0,A.useSelect)(t=>t(v.store).getBlockRootClientId,[]),n=(0,A.useSelect)(t=>t(v.store).getBlockIndex,[]),l=(0,h.useRef)(t);return l.current=t,(0,z.useRefEffect)(t=>{function i(t){if(t.defaultPrevented||t.keyCode!==M.ENTER)return;const{content:i,clientId:s}=l.current;if(i.length)return;t.preventDefault();const h=o(r(s)),p=n(s),c=(0,w.cloneBlock)({...h,innerBlocks:h.innerBlocks.slice(0,p)}),u=(0,w.createBlock)((0,w.getDefaultBlockName)()||""),S=h.innerBlocks.slice(p+1),d=S.length?[(0,w.cloneBlock)({...h,innerBlocks:S})]:[];e(h.clientId,[c,u,...d],1),a(u.clientId)}return t.addEventListener("keydown",i),()=>{t.removeEventListener("keydown",i)}},[])}({content:B,clientId:i}),vt=(0,z.useMergeRefs)([ft,tt]),[Ct,Bt]=(0,h.useState)(!1),jt=ht&&r&&(!!F||Z)&&!!X;async function Tt(){await wt("new"),await _t({title:(0,s.__)("New call to action","popup-maker"),status:"publish"}),K("new"),J(!0)}const[At,Nt]=(0,v.useSettings)("typography.fluid","layout"),zt=(0,v.getTypographyClassesAndStyles)(e,{typography:{fluid:At},layout:{wideSize:Nt?.wideSize}}),Mt=(0,A.useSelect)(t=>{const e=t(I.callToActionStore),a=F?e.getFetchError(F)||null:e.getFetchError()||null;return null===a?null:a.replace("Invalid post ID.",(0,s.__)("Call to action not found.","popup-maker"))},[F]);return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)("div",{...et,className:k(et.className,{[`has-custom-width wp-block-popup-maker-cta-button__width-${E}`]:E,"has-custom-font-size":et.style.fontSize}),style:{...et.style,border:Mt?"2px solid red":void 0},children:(0,c.jsx)(v.RichText,{ref:vt,"aria-label":(0,s.__)("Button text","default"),placeholder:b||(0,s.__)("Add text…","default"),value:B,onChange:t=>a({text:R(t)}),withoutInteractiveFormatting:!0,className:k(o,"wp-block-popup-maker-cta-button__link",ot.className,at.className,zt.className,{[`has-text-align-${u}`]:u,"no-border-radius":0===C?.border?.radius,"has-custom-font-size":et.style.fontSize}),style:{...at.style,...ot.style,...rt.style,...nt.style,...zt.style,writingMode:void 0},onReplace:n,onMerge:l,identifier:"text"})}),(0,c.jsxs)(v.BlockControls,{group:"block",children:["default"===lt&&(0,c.jsx)(v.AlignmentControl,{value:u,onChange:t=>{a({textAlign:t})}}),!pt&&ht&&(0,c.jsx)(T.ToolbarButton,{icon:x,title:(0,s.__)("Add Call to Action","popup-maker"),shortcut:M.displayShortcut.primary("k"),onClick:t=>{t.preventDefault(),kt()}}),pt&&ht&&(0,c.jsx)(T.ToolbarButton,{icon:m,title:(0,s.__)("Remove Call to Action","popup-maker"),shortcut:M.displayShortcut.primaryShift("k"),onClick:yt,isActive:!0})]}),jt&&(0,c.jsx)(T.Popover,{placement:"bottom",onClose:()=>{J(!1),tt.current?.focus?.()},anchor:X,focusOnMount:!!q&&"firstElement",__unstableSlotName:"__unstable-block-tools-after",shift:!0,className:"block-editor-link-control",children:(0,c.jsxs)("div",{style:{width:"300px",padding:"10px"},children:[Mt&&(0,c.jsx)("div",{className:"pum-cta-error-notice",children:(0,c.jsx)(T.Notice,{status:"error",isDismissible:!1,children:Mt})}),Z||Mt?(0,c.jsx)(T.Flex,{direction:"column",children:(0,c.jsxs)(T.Flex,{align:"center",justify:"space-between",children:[(0,c.jsx)(T.FlexItem,{style:{flexGrow:1},children:(0,c.jsx)(D.CallToActionSelectControl,{value:F&&!Mt?F:0,onChange:async t=>{"create_new"!==t?(a({ctaId:Number(t)}),J(!1)):await Tt()},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,c.jsx)(T.FlexItem,{children:(0,c.jsx)(T.Button,{icon:S,label:(0,s.__)("Save","popup-maker"),onClick:()=>J(!1)})})]})}):pt&&(0,c.jsxs)(T.Flex,{direction:"column",gap:3,children:[(0,c.jsxs)(T.Flex,{justify:"space-between",align:"center",children:[(0,c.jsx)("div",{style:{fontSize:"16px",fontWeight:"500",color:"#1e1e1e",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:(0,j.decodeEntities)(pt?.title?.rendered),children:(0,j.decodeEntities)(pt?.title?.rendered)}),(0,c.jsx)(T.Button,{icon:m,variant:"link",size:"small",style:{textDecoration:"none"},isDestructive:!0,onClick:yt,label:(0,s.__)("Remove","popup-maker")})]}),(0,c.jsxs)(T.Flex,{justify:"space-between",align:"center",style:{color:"#1e1e1e"},children:[(0,c.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: ",pt?.id]}),(0,c.jsx)(T.Button,{icon:V,variant:"tertiary",style:{borderRadius:"6px",textDecoration:"none",color:"#1e1e1e",padding:".25rem 0.75rem",flexGrow:1},href:gt(pt.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,c.jsx)(T.Button,{icon:G,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=${pt.id}`,target:"_blank",label:(0,s.__)("Edit Call to Action","popup-maker"),showTooltip:!0,children:(0,s.__)("Edit","popup-maker")})]}),(0,c.jsxs)(T.Button,{icon:g,variant:"secondary",onClick:()=>Bt(!Ct),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,c.jsx)(T.Icon,{icon:Ct?P:d})]}),Ct&&(0,c.jsxs)(T.Flex,{direction:"column",gap:3,children:[(0,c.jsx)(T.ToggleControl,{label:(0,s.__)("Open in new window","popup-maker"),checked:it,onChange:t=>{a({linkTarget:t?O:void 0})},__nextHasNoMarginBottom:!0}),(0,c.jsx)(T.ToggleControl,{label:(0,s.__)('Add rel="nofollow"',"popup-maker"),checked:st,onChange:t=>{a({rel:t?L:void 0})},__nextHasNoMarginBottom:!0})]})]})]})}),(0,c.jsx)(v.InspectorControls,{group:"settings",children:(0,c.jsx)(T.Panel,{header:(0,s.__)("CTA Settings","popup-maker"),children:(0,c.jsx)(T.PanelBody,{children:(0,c.jsx)(D.CallToActionSelectControl,{label:(0,s.__)("Choose a Call to Action","popup-maker"),value:F,placeholder:(0,s.__)("Search or create CTA…","popup-maker"),onChange:async t=>{"create_new"!==t?(a({ctaId:Number(t)}),J(!1)):await Tt()},extraOptions:[{value:"create_new",label:(0,s.__)("+ Create new CTA","popup-maker")}]})})})}),(0,c.jsx)(v.InspectorControls,{children:(0,c.jsx)($,{selectedWidth:E,setAttributes:a})}),(0,c.jsx)(v.InspectorControls,{group:"advanced",children:ht&&(0,c.jsx)(T.TextControl,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,label:(0,s.__)("Link rel","default"),value:f||"",onChange:t=>a({rel:t})})}),("new"===U||"number"==typeof U&&U>0)&&(0,c.jsx)(H,{id:U,defaultValues:{status:"publish"},onSave:t=>{const e=t.id>0?t.id:bt.getEditorId();"number"==typeof e&&e>0&&a({ctaId:e})},closeOnSave:!0,onClose:()=>{wt(void 0),K(!1)}},U)]})},save:function({attributes:t,className:e}){const{tagName:a,type:o,textAlign:r,fontSize:n,linkTarget:l,rel:i,style:s,text:h,title:p,url:u,width:S}=t,d=a||"a",P="button"===d,G=o||"button",V=(0,v.__experimentalGetBorderClassesAndStyles)(t),m=(0,v.__experimentalGetColorClassesAndStyles)(t),x=(0,v.__experimentalGetSpacingClassesAndStyles)(t),g=(0,v.__experimentalGetShadowClassesAndStyles)(t),w=(0,v.getTypographyClassesAndStyles)(t),_=k("pum-cta","wp-block-popup-maker-cta-button__link","wp-element-button",m.className,V.className,w.className,{[`has-text-align-${r}`]:r,"no-border-radius":0===s?.border?.radius,"has-custom-font-size":n||s?.typography?.fontSize}),b={...V.style,...m.style,...x.style,...g.style,...w.style,writingMode:void 0},y=k(e,{[`has-custom-width wp-block-popup-maker-cta-button__width-${S}`]:Boolean(S)});return(0,c.jsx)("div",{...v.useBlockProps.save({className:y}),children:(0,c.jsx)(v.RichText.Content,{tagName:d,type:P?G:null,className:_,href:P?null:u,title:p,style:b,value:h,target:P?null:l,rel:P?null:i})})},deprecated:B,merge:(t,{text:e=""})=>({...t,text:(t.text||"")+e})},U=()=>_({name:Z,metadata:W,settings:J}),K=window.popupMaker.icons,q=window.wp.hooks,X=[{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:t,className:e}){const{fontSize:a,style:o}=t,r=v.useBlockProps.save({className:k(e,"wp-block-buttons",{"has-custom-font-size":a||o?.typography?.fontSize})}),n=v.useInnerBlocksProps.save(r);return(0,c.jsx)("div",{...n})},migrate:(t,e)=>[t,e]}],Q=(t,e)=>(Q.body||(Q.body=t.implementation.createHTMLDocument("").body),Q.body.innerHTML=e,Q.body),Y={from:[{type:"block",isMultiBlock:!0,blocks:["popup-maker/cta-button","core/button"],transform:t=>(0,w.createBlock)("popup-maker/cta-buttons",{},t.map((t,e)=>"core/button"===e?(0,w.createBlock)("core/button",t):(0,w.createBlock)("popup-maker/cta-button",t)))},{type:"block",isMultiBlock:!0,blocks:["core/buttons"],transform:(t,e)=>(0,w.createBlock)("popup-maker/cta-buttons",{},(e||[]).flat().map(t=>(0,w.cloneBlock)(t)))},{type:"block",isMultiBlock:!0,blocks:["core/paragraph"],transform:t=>(0,w.createBlock)("popup-maker/cta-buttons",{},t.map(t=>{const{content:e,metadata:a}=t,o=Q(document,e),r=o.innerText||"",n=o.querySelector("a"),l=n?.getAttribute("href");return(0,w.createBlock)("popup-maker/cta-button",{text:r,url:l,metadata:F(a,"popup-maker/cta-button",({content:t})=>({text:t}))})})),isMatch:t=>t.every(t=>{const e=Q(document,t.content),a=e.innerText||"",o=e.querySelectorAll("a");return a.length<=30&&o.length<=1})}]},tt={name:"popup-maker/cta-button",attributesToCopy:["backgroundColor","border","className","fontFamily","fontSize","gradient","style","textColor","width"]},et=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:at}=et,ot={icon:K.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:X,transforms:Y,edit:function({attributes:t,className:e}){const{fontSize:a,layout:o,style:r}=t,n=(0,v.useBlockProps)({className:k(e,{"has-custom-font-size":a||r?.typography?.fontSize})}),{hasButtonVariations:l}=(0,A.useSelect)(t=>({hasButtonVariations:t(w.store).getBlockVariations("popup-maker/cta-button","inserter").length>0}),[]),i=(0,v.useInnerBlocksProps)(n,{defaultBlock:tt,directInsert:!l,template:[["popup-maker/cta-button"]],templateInsertUpdatesSelection:!0,orientation:o?.orientation??"horizontal"});return(0,c.jsx)("div",{...i})},save:function({attributes:t,className:e}){const{fontSize:a,style:o}=t,r=v.useBlockProps.save({className:k(e,{"has-custom-font-size":a||o?.typography?.fontSize})}),n=v.useInnerBlocksProps.save(r);return(0,c.jsx)("div",{...n})}},rt=()=>_({name:at,metadata:et,settings:ot});(0,q.addFilter)("blocks.registerBlockType","popup-maker/cta-buttons",t=>{const{name:e}=t;switch(e){case"core/button":return{...t,parent:[...t.parent,"popup-maker/cta-buttons"]};case"core/buttons":return{...t,allowedBlocks:[...t.allowedBlocks,"popup-maker/cta-button"]};default:return t}}),i()(()=>{Object.values(n).forEach(({init:t})=>{t()})})}},a={};function o(t){var r=a[t];if(void 0!==r)return r.exports;var n=a[t]={exports:{}};return e[t](n,n.exports,o),n.exports}o.m=e,t=[],o.O=(e,a,r,n)=>{if(!a){var l=1/0;for(p=0;p<t.length;p++){for(var[a,r,n]=t[p],i=!0,s=0;s<a.length;s++)(!1&n||l>=n)&&Object.keys(o.O).every(t=>o.O[t](a[s]))?a.splice(s--,1):(i=!1,n<l&&(l=n));if(i){t.splice(p--,1);var h=r();void 0!==h&&(e=h)}}return e}n=n||0;for(var p=t.length;p>0&&t[p-1][2]>n;p--)t[p]=t[p-1];t[p]=[a,r,n]},o.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return o.d(e,{a:e}),e},o.d=(t,e)=>{for(var a in e)o.o(e,a)&&!o.o(t,a)&&Object.defineProperty(t,a,{enumerable:!0,get:e[a]})},o.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),o.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},(()=>{var t={544:0,718:0};o.O.j=e=>0===t[e];var e=(e,a)=>{var r,n,[l,i,s]=a,h=0;if(l.some(e=>0!==t[e])){for(r in i)o.o(i,r)&&(o.m[r]=i[r]);if(s)var p=s(o)}for(e&&e(a);h<l.length;h++)n=l[h],o.o(t,n)&&t[n]&&t[n][0](),t[n]=0;return o.O(p)},a=globalThis.webpackChunk_popupMakerAdmin_webpackJsonp=globalThis.webpackChunk_popupMakerAdmin_webpackJsonp||[];a.forEach(e.bind(null,0)),a.push=e.bind(null,a.push.bind(a))})();var r=o.O(void 0,[718],()=>o(232));r=o.O(r),(window.popupMaker=window.popupMaker||{}).blockLibrary=r})();
Save File
Cancel