| 1 |
(()=>{"use strict";const e=window.wp.blocks,t=window.wp.blockEditor,s=window.wp.components,n=window.wp.element,a=window.wp.i18n,i=JSON.parse('{"UU":"cryptx/email"}'),o=window.ReactJSXRuntime,l=e=>e.replace(/[\s\u00A0\uFEFF\u200B-\u200D\u2060]+/g,"");(0,e.registerBlockType)(i.UU,{edit:function({attributes:e,setAttributes:i}){const{address:r,linkText:c,subject:d,body:x,cc:p,bcc:_}=e,h=(0,t.useBlockProps)(),[u,m]=(0,n.useState)(""),[y,b]=(0,n.useState)(!1),g=!(""===r||/^[_a-zA-Z0-9-+]+(\.[_a-zA-Z0-9-+]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,})$/.test(l(r)))&&(0,o.jsx)(s.Notice,{status:"warning",isDismissible:!1,children:(0,a.__)("This does not look like an email address, so nothing will appear on the published page. Addresses with accented or non-Latin characters in the domain cannot be protected; write the domain in its punycode form (xn--…) instead.","cryptx")}),j=(0,o.jsxs)(t.InspectorControls,{children:[(0,o.jsx)(s.PanelBody,{title:(0,a.__)("Address","cryptx"),children:(0,o.jsxs)("div",{className:"cryptx-block-fields",children:[(0,o.jsx)(s.TextControl,{__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0,type:"email",label:(0,a.__)("Email address","cryptx"),value:r,onChange:e=>i({address:l(e)})}),(0,o.jsx)(s.TextControl,{__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0,label:(0,a.__)("Link text","cryptx"),help:(0,a.__)('Leave empty to use whatever the CryptX settings say. Fill it in to show something else, such as "Write to us".',"cryptx"),value:c,onChange:e=>i({linkText:e})})]})}),(0,o.jsx)(s.PanelBody,{title:(0,a.__)("Prefilled message","cryptx"),initialOpen:!1,children:(0,o.jsxs)("div",{className:"cryptx-block-fields",children:[(0,o.jsx)(s.TextControl,{__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0,label:(0,a.__)("Subject","cryptx"),value:d,onChange:e=>i({subject:e})}),(0,o.jsx)(s.TextareaControl,{__nextHasNoMarginBottom:!0,label:(0,a.__)("Message","cryptx"),rows:3,value:x,onChange:e=>i({body:e})}),(0,o.jsx)(s.TextControl,{__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0,label:(0,a.__)("Cc","cryptx"),value:p,onChange:e=>i({cc:e})}),(0,o.jsx)(s.TextControl,{__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0,label:(0,a.__)("Bcc","cryptx"),help:(0,a.__)("These travel inside the encrypted link, so they are not readable in the page either.","cryptx"),value:_,onChange:e=>i({bcc:e})})]})})]});return!r||y?(0,o.jsxs)("div",{...h,children:[j,(0,o.jsxs)(s.Placeholder,{icon:"email-alt",label:(0,a.__)("Protected email address","cryptx"),instructions:(0,a.__)("The address is replaced before the page is delivered, so a spam bot reading the source finds nothing to collect.","cryptx"),children:[(0,o.jsxs)("form",{onSubmit:e=>{e.preventDefault(),i({address:l(u)}),b(!1)},children:[(0,o.jsx)(s.TextControl,{__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0,type:"email",label:(0,a.__)("Email address","cryptx"),hideLabelFromVision:!0,placeholder:(0,a.__)("info@example.com","cryptx"),value:u||r,onChange:m}),(0,o.jsx)(s.Button,{__next40pxDefaultSize:!0,variant:"primary",type:"submit",disabled:!(u||r).trim(),accessibleWhenDisabled:!0,children:(0,a.__)("Use this address","cryptx")})]}),g]})]}):(0,o.jsxs)("div",{...h,children:[j,(0,o.jsx)(t.BlockControls,{children:(0,o.jsx)(s.ToolbarGroup,{children:(0,o.jsx)(s.ToolbarButton,{icon:"edit",title:(0,a.__)("Change the address","cryptx"),onClick:()=>{m(r),b(!0)}})})}),g,(0,o.jsx)("a",{href:"#cryptx-preview",onClick:e=>e.preventDefault(),children:c||l(r)})]})},save:()=>null})})(); |