gutenberg_advanced_link-1.0.1/dist/blocks.js
dist/blocks.js
(()=>{"use strict";const e=window.React,t=window.wp.primitives,l=(0,e.createElement)(t.SVG,{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg"},(0,e.createElement)(t.Path,{d:"M14.2186 3.31061C13.7838 2.89252 13.0834 2.89708 12.6543 3.32078L9.22512 6.70711C9.17494 6.75668 9.13068 6.80978 9.09236 6.86558L7.36613 8.57021L11.393 12.4419L16.362 7.50771L16.6812 7.1925C17.1103 6.76879 17.1056 6.08638 16.6708 5.66828L14.2186 3.31061Z",fill:"black"}),(0,e.createElement)(t.Path,{d:"M6.81914 9.10588L10.8041 12.9457L9.79592 13.9391C9.42424 14.3053 8.84982 14.3575 8.42039 14.0938L7.83675 13.8883L7.01822 14.6819L5.03321 12.7381L5.86163 11.9349L5.67624 11.454C5.39121 11.0373 5.43547 10.4692 5.811 10.0992L6.81914 9.10588Z",fill:"black"}),(0,e.createElement)(t.Path,{d:"M5.11329 13.6189L6.13911 14.5945L5.70907 15L4 14.592L5.11329 13.6189Z",fill:"black"})),n=window.wp.blockEditor,a=window.wp.richText,o=window.wp.element,r=window.wp.i18n,c=window.wp.components,i={title:"Infobulle",tagName:"a",className:"custom-a",attributes:{href:"href",class:"class",target:"target",rel:"rel"},edit:function(t){var a=t.isActive,c=t.value,i=t.onChange,d=(t.attributes,t.contentRef),m=t.activeAttributes;const[u,b]=(0,o.useState)(!1),k=()=>{b(e=>!e)},v=l;return(0,e.createElement)(e.Fragment,null,(0,e.createElement)(n.RichTextToolbarButton,{icon:v,title:(0,r.__)("Advanced link","gutenberg-advanced-link"),isActive:a,onClick:()=>{k()}}),u&&(0,e.createElement)(s,{isActive:a,activeAttributes:m,value:c,onChange:i,contentRef:d,onClose:k}))}};function s({isActive:t,activeAttributes:l,value:n,onChange:s,onClose:d,contentRef:m}){const u=(0,a.useAnchor)({editableContentElement:m.current,settings:i}),[b,k]=(0,o.useState)(l.href),[v,_]=(0,o.useState)(l.class),[f,g]=(0,o.useState)(l.target||"_self"),[w,h]=(0,o.useState)(l.rel);return(0,e.createElement)(e.Fragment,null,(0,e.createElement)(c.Popover,{anchor:u,headerTitle:"Class CSS",className:"block-editor-href-popover",onClose:d},(0,e.createElement)(c.__experimentalVStack,{as:"form",spacing:4,className:"block-editor-format-toolbar__language-container-content",onSubmit:e=>{if(e.preventDefault(),b)s((0,a.applyFormat)(n,{type:"gutenberg-advanced-link/advanced-link",attributes:{href:b||"",class:v||"",target:f||"",rel:w||""}}));else{k(""),_(""),g(""),h("");const e=(0,a.removeFormat)(n,"gutenberg-advanced-link/advanced-link");s(e)}d()}},(0,e.createElement)("div",{class:"block-editor-link-control"},(0,e.createElement)(c.TextControl,{label:"Url",className:"block-editor-link-control__field block-editor-link-control__text-content",value:b,onChange:e=>k(e||"")}),(0,e.createElement)(c.TextControl,{label:"Class",className:"block-editor-link-control__field block-editor-link-control__text-content",value:v,onChange:e=>_(e||"")}),(0,e.createElement)(c.SelectControl,{className:"block-editor-link-control__field block-editor-link-control__text-content",label:"Target",value:f,options:[{label:"_none",value:"_self"},{label:"_blank",value:"_blank"},{label:"_self",value:"_self"},{label:"_parent",value:"_top"}],onChange:e=>g(e||"")}),(0,e.createElement)(c.TextControl,{label:"Target - framename",className:"block-editor-link-control__field block-editor-link-control__text-content",value:f,onChange:e=>g(e||"")}),(0,e.createElement)(c.CheckboxControl,{label:"nofollow",checked:"nofollow"==w,className:"block-editor-link-control__field ",onChange:e=>h(e?"nofollow":"")})),(0,e.createElement)("div",null,(0,e.createElement)(c.Button,{__next40pxDefaultSize:!0,variant:"primary",type:"submit",text:(0,r.__)("Apply")})))))}const d=i;(0,a.registerFormatType)("gutenberg-advanced-link/advanced-link",d)})();