From 616c4ad625223b58eb7c2942937b71356b62aa7c Mon Sep 17 00:00:00 2001 From: Matthias Pfefferle Date: Thu, 24 Sep 2026 09:28:49 +0200 Subject: [PATCH] complete the relationship as you type --- build/link/index.asset.php | 2 +- build/link/index.js | 2 +- src/blogroll/__tests__/deprecated.test.js | 4 +++- src/blogroll/components/xfn-control.js | 8 ++++++++ 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/build/link/index.asset.php b/build/link/index.asset.php index 597d548..2f10f32 100644 --- a/build/link/index.asset.php +++ b/build/link/index.asset.php @@ -1 +1 @@ - array('react-jsx-runtime', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-element', 'wp-i18n', 'wp-primitives'), 'version' => '04539ce9911617c2f240'); + array('react-jsx-runtime', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-element', 'wp-i18n', 'wp-primitives'), 'version' => 'c33a05b3a585e76cd784'); diff --git a/build/link/index.js b/build/link/index.js index c98a2ff..dfa69e7 100644 --- a/build/link/index.js +++ b/build/link/index.js @@ -1 +1 @@ -(()=>{"use strict";const e={n:o=>{const n=o&&o.__esModule?()=>o.default:()=>o;return e.d(n,{a:n}),n},d:(o,n)=>{if(Array.isArray(n))for(var t=0;tObject.hasOwn(e,o)},o=window.wp.blocks,n=JSON.parse('{"UU":"blockroll/link"}'),t=window.wp.i18n,l=window.wp.element,r=window.wp.compose,s=window.wp.blockEditor,a=window.wp.components,i=window.wp.primitives,c=window.ReactJSXRuntime;var u=(0,c.jsx)(i.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:(0,c.jsx)(i.Path,{d:"M10 17.389H8.444A5.194 5.194 0 1 1 8.444 7H10v1.5H8.444a3.694 3.694 0 0 0 0 7.389H10v1.5ZM14 7h1.556a5.194 5.194 0 0 1 0 10.39H14v-1.5h1.556a3.694 3.694 0 0 0 0-7.39H14V7Zm-4.5 6h5v-1.5h-5V13Z"})}),d=(0,c.jsx)(i.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:(0,c.jsx)(i.Path,{d:"M5 10.2h-.8v1.5H5c1.9 0 3.8.8 5.1 2.1 1.4 1.4 2.1 3.2 2.1 5.1v.8h1.5V19c0-2.3-.9-4.5-2.6-6.2-1.6-1.6-3.8-2.6-6.1-2.6zm10.4-1.6C12.6 5.8 8.9 4.2 5 4.2h-.8v1.5H5c3.5 0 6.9 1.4 9.4 3.9s3.9 5.8 3.9 9.4v.8h1.5V19c0-3.9-1.6-7.6-4.4-10.4zM4 20h3v-3H4v3z"})});function h({value:e,onChange:o,onSubmit:n,isBusy:l,message:r,buttonLabel:s}){return(0,c.jsxs)("form",{className:"blockroll-form__row",onSubmit:e=>{e.preventDefault(),l||n()},children:[(0,c.jsx)(a.TextControl,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,label:(0,t.__)("Address","blockroll"),hideLabelFromVision:!0,help:r,className:r?"has-message":void 0,placeholder:"example.com",type:"text",inputMode:"url",autoComplete:"off",spellCheck:!1,value:e,readOnly:l,onChange:o}),(0,c.jsx)(a.Button,{__next40pxDefaultSize:!0,variant:"primary",type:"submit",isBusy:l,"aria-disabled":l,disabled:!e.trim(),children:s||(0,t.__)("Add","blockroll")})]})}const m={friendship:["friend","acquaintance","contact"],physical:["met"],professional:["co-worker","colleague"],geographical:["co-resident","neighbor"],family:["child","parent","sibling","spouse","kin"],romantic:["muse","crush","date","sweetheart"],identity:["me"]},p=["friendship","geographical","family"],f=Object.values(m).flat();function x({value:e=[],onChange:o}){return(0,c.jsx)(a.FormTokenField,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,__experimentalExpandOnFocus:!0,label:(0,t.__)("Relationship","blockroll"),value:e,suggestions:f,onChange:e=>o(function(e){return e.filter(e=>f.includes(e)).reduce((e,o)=>function(e,o){if("me"===o)return["me"];let n=e.filter(e=>"me"!==e);for(const e of p)m[e].includes(o)&&(n=n.filter(o=>!m[e].includes(o)));return[...n,o]}(e,o),[])}(e))})}const b=window.wp.apiFetch;var g=e.n(b);function _(){return(new Date).toISOString().slice(0,10)}function w(e){try{const{protocol:o,hostname:n}=new URL(String(e||"").trim());return/^https?:$/i.test(o)&&""!==n}catch{return!1}}n.UU;const v=()=>{};function k({isOpen:e,onToggle:o,onClose:n,className:t,focusOnMount:s="firstElement",label:i,children:u}){const[d,h]=(0,l.useState)(),m=(0,r.__experimentalUseFocusOutside)(n);return(0,c.jsxs)("span",{...m,children:[(0,c.jsx)(a.Button,{className:t,ref:h,"aria-expanded":e,onClick:o,children:i}),e&&(0,c.jsx)(a.Popover,{anchor:d,placement:"bottom-start",shift:!0,onClose:n,onFocusOutside:v,focusOnMount:s,className:"blockroll-link__meta-overlay",children:u})]})}const j=()=>{};var C=(0,c.jsx)(i.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:(0,c.jsx)(i.Path,{d:"M12 11v1.5h8V11h-8zm-6-1c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"})});(0,o.registerBlockType)(n.UU,{icon:C,edit:function({attributes:e,setAttributes:o,context:n,isSelected:i}){const{url:m,name:p,description:f,photo:b,feedUrl:v,xfn:C,added:S}=e,[y,O]=(0,l.useState)(""),[N,B]=(0,l.useState)(!1),[F,T]=(0,l.useState)(null),U=(0,l.useRef)(S);U.current=S;const M=function(){const e=(0,l.useRef)();return(0,l.useEffect)(()=>(e.current=new AbortController,()=>e.current.abort()),[]),e}(),[A,R]=(0,l.useState)(null),H=()=>R(null),z=(0,r.__experimentalUseFocusOutside)(H),[P,L]=(0,l.useState)(),[D,V]=(0,l.useState)(null),E=()=>V(null),I=e=>V(e===D?null:e),q=(0,l.useRef)({}),G=n["blockroll/showAvatars"]??!0,Z=i||!!v,J=i||C.length>0,$=(0,s.useBlockProps)({className:m?"h-card":void 0}),X=b?(0,c.jsx)("img",{className:"u-photo",src:b,alt:""}):(0,c.jsx)("span",{className:"blockroll-no-photo"}),K=(0,c.jsx)(s.InspectorControls,{children:(0,c.jsx)(a.PanelBody,{title:(0,t.__)("Link settings","blockroll"),children:(0,c.jsx)(a.TextControl,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,label:(0,t.__)("Added","blockroll"),help:(0,t.__)("Used when the list is sorted newest first.","blockroll"),type:"date",value:S,onChange:e=>o({added:e})})})});if(!m){const e=()=>{const e=function(e){const o=e.trim();return/^[a-z][a-z0-9+.-]*:/i.test(o)&&!/^[^:/?#]+:\d/.test(o)?o:`https://${o}`}(y);w(e)?(B(!0),function(e,o){return function(e,o){return g()({path:"/blockroll/v1/discover",method:"POST",data:{url:e},signal:o})}(e,o).then(o=>function(e,o){return{...e,name:e.name||o.name,description:e.description||o.description,feedUrl:e.feedUrl||o.feedUrl,photo:e.photo||o.photo}}({url:e},o))}(e,M.current.signal).then(e=>{o({...e,added:U.current||_()}),B(!1)},n=>{(function(e){return"AbortError"===e?.name})(n)||(o({url:e,added:U.current||_()}),B(!1))})):T((0,t.__)("Only web addresses can be added.","blockroll"))};return(0,c.jsxs)("div",{...$,children:[K,(0,c.jsx)(h,{value:y,message:F,onChange:e=>{O(e),T(null)},onSubmit:e,isBusy:N})]})}return(0,c.jsxs)(c.Fragment,{children:[K,(0,c.jsxs)("div",{...$,children:[G&&(0,c.jsx)(s.MediaReplaceFlow,{mediaURL:b,allowedTypes:["image"],accept:"image/*",onSelect:e=>o({photo:e.url}),onSelectURL:e=>o({photo:e}),onReset:()=>o({photo:""}),popoverProps:{onFocusOutside:e=>{const o=e.target.ownerDocument.activeElement;!o?.closest('[role="dialog"]')&&q.current.isOpen&&q.current.onToggle()}},renderToggle:({children:e,...o})=>(q.current={isOpen:o["aria-expanded"],onToggle:o.onClick},(0,c.jsx)(a.Button,{...o,className:"blockroll-link__photo",label:(0,t.__)("Image","blockroll"),children:X}))}),(0,c.jsxs)("span",{className:"blockroll-link__name",...z,children:[(0,c.jsx)(s.BlockControls,{group:"block",children:(0,c.jsx)(a.ToolbarButton,{icon:u,title:(0,t.__)("Link","blockroll"),isActive:!!A,onClick:()=>R("toolbar"===A?null:"toolbar")})}),i&&A&&(0,c.jsx)(a.Popover,{anchor:P,placement:"bottom-start",shift:!0,onClose:H,onFocusOutside:j,focusOnMount:"toolbar"===A&&"firstElement",children:(0,c.jsx)(s.LinkControl,{value:{url:m,title:p},settings:[],hasTextControl:!0,forceIsEditingLink:!0,showInitialSuggestions:!1,onChange:e=>{const n=e.url||"";o({url:!n||w(n)?n:m,name:e.title??p}),H()},onCancel:H})},A),(0,c.jsx)(s.RichText,{ref:L,onFocus:()=>R("name"),disableLineBreaks:!0,tagName:"a",className:"u-url p-name",href:w(m)?m:void 0,value:p,allowedFormats:[],withoutInteractiveFormatting:!0,placeholder:(0,t.__)("Site name","blockroll"),onChange:e=>o({name:e})})]}),(i||f)&&(0,c.jsx)(s.RichText,{disableLineBreaks:!0,tagName:"p",className:"p-note",value:f,allowedFormats:[],withoutInteractiveFormatting:!0,placeholder:(0,t.__)("Description","blockroll"),onChange:e=>o({description:e})}),(Z||J)&&(0,c.jsxs)("div",{className:"blockroll-meta",children:[Z&&(0,c.jsx)(k,{className:"blockroll-feed blockroll-link__meta-button",isOpen:"feed"===D,onToggle:()=>I("feed"),onClose:E,label:(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(a.Icon,{icon:d,className:"blockroll-feed-icon"}),v?(0,t.__)("feed","blockroll"):(0,t.__)("Add feed","blockroll")]}),children:(0,c.jsx)(a.TextControl,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,label:(0,t.__)("Feed address","blockroll"),help:(0,t.__)("The RSS or Atom feed of the site, for readers who subscribe to your list.","blockroll"),type:"url",value:v,onChange:e=>o({feedUrl:e})})}),Z&&J&&(0,c.jsx)("span",{className:"blockroll-divider","aria-hidden":"true",children:"·"}),J&&(0,c.jsx)(k,{className:"blockroll-link__meta-button",isOpen:"xfn"===D,onToggle:()=>I("xfn"),onClose:E,focusOnMount:!0,label:C.length>0?(0,c.jsx)("span",{className:"blockroll-xfn",children:C.map(e=>(0,c.jsx)("span",{children:e},e))}):(0,t.__)("Add relationship","blockroll"),children:(0,c.jsx)("div",{ref:e=>e&&e.ownerDocument.defaultView.requestAnimationFrame(()=>e.querySelector("input")?.focus()),children:(0,c.jsx)(x,{value:C,onChange:e=>o({xfn:e})})})})]})]})]})},save:()=>null})})(); \ No newline at end of file +(()=>{"use strict";const e={n:o=>{const t=o&&o.__esModule?()=>o.default:()=>o;return e.d(t,{a:t}),t},d:(o,t)=>{if(Array.isArray(t))for(var n=0;nObject.hasOwn(e,o)},o=window.wp.blocks,t=JSON.parse('{"UU":"blockroll/link"}'),n=window.wp.i18n,l=window.wp.element,r=window.wp.compose,s=window.wp.blockEditor,a=window.wp.components,i=window.wp.primitives,c=window.ReactJSXRuntime;var u=(0,c.jsx)(i.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:(0,c.jsx)(i.Path,{d:"M10 17.389H8.444A5.194 5.194 0 1 1 8.444 7H10v1.5H8.444a3.694 3.694 0 0 0 0 7.389H10v1.5ZM14 7h1.556a5.194 5.194 0 0 1 0 10.39H14v-1.5h1.556a3.694 3.694 0 0 0 0-7.39H14V7Zm-4.5 6h5v-1.5h-5V13Z"})}),d=(0,c.jsx)(i.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:(0,c.jsx)(i.Path,{d:"M5 10.2h-.8v1.5H5c1.9 0 3.8.8 5.1 2.1 1.4 1.4 2.1 3.2 2.1 5.1v.8h1.5V19c0-2.3-.9-4.5-2.6-6.2-1.6-1.6-3.8-2.6-6.1-2.6zm10.4-1.6C12.6 5.8 8.9 4.2 5 4.2h-.8v1.5H5c3.5 0 6.9 1.4 9.4 3.9s3.9 5.8 3.9 9.4v.8h1.5V19c0-3.9-1.6-7.6-4.4-10.4zM4 20h3v-3H4v3z"})});function h({value:e,onChange:o,onSubmit:t,isBusy:l,message:r,buttonLabel:s}){return(0,c.jsxs)("form",{className:"blockroll-form__row",onSubmit:e=>{e.preventDefault(),l||t()},children:[(0,c.jsx)(a.TextControl,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,label:(0,n.__)("Address","blockroll"),hideLabelFromVision:!0,help:r,className:r?"has-message":void 0,placeholder:"example.com",type:"text",inputMode:"url",autoComplete:"off",spellCheck:!1,value:e,readOnly:l,onChange:o}),(0,c.jsx)(a.Button,{__next40pxDefaultSize:!0,variant:"primary",type:"submit",isBusy:l,"aria-disabled":l,disabled:!e.trim(),children:s||(0,n.__)("Add","blockroll")})]})}const m={friendship:["friend","acquaintance","contact"],physical:["met"],professional:["co-worker","colleague"],geographical:["co-resident","neighbor"],family:["child","parent","sibling","spouse","kin"],romantic:["muse","crush","date","sweetheart"],identity:["me"]},p=["friendship","geographical","family"],f=Object.values(m).flat();function x({value:e=[],onChange:o}){return(0,c.jsx)(a.FormTokenField,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,__experimentalExpandOnFocus:!0,__experimentalAutoSelectFirstMatch:!0,__experimentalValidateInput:e=>f.includes(e),label:(0,n.__)("Relationship","blockroll"),value:e,suggestions:f,onChange:e=>o(function(e){return e.filter(e=>f.includes(e)).reduce((e,o)=>function(e,o){if("me"===o)return["me"];let t=e.filter(e=>"me"!==e);for(const e of p)m[e].includes(o)&&(t=t.filter(o=>!m[e].includes(o)));return[...t,o]}(e,o),[])}(e))})}const b=window.wp.apiFetch;var _=e.n(b);function g(){return(new Date).toISOString().slice(0,10)}function w(e){try{const{protocol:o,hostname:t}=new URL(String(e||"").trim());return/^https?:$/i.test(o)&&""!==t}catch{return!1}}t.UU;const v=()=>{};function k({isOpen:e,onToggle:o,onClose:t,className:n,focusOnMount:s="firstElement",label:i,children:u}){const[d,h]=(0,l.useState)(),m=(0,r.__experimentalUseFocusOutside)(t);return(0,c.jsxs)("span",{...m,children:[(0,c.jsx)(a.Button,{className:n,ref:h,"aria-expanded":e,onClick:o,children:i}),e&&(0,c.jsx)(a.Popover,{anchor:d,placement:"bottom-start",shift:!0,onClose:t,onFocusOutside:v,focusOnMount:s,className:"blockroll-link__meta-overlay",children:u})]})}const j=()=>{};var C=(0,c.jsx)(i.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:(0,c.jsx)(i.Path,{d:"M12 11v1.5h8V11h-8zm-6-1c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"})});(0,o.registerBlockType)(t.UU,{icon:C,edit:function({attributes:e,setAttributes:o,context:t,isSelected:i}){const{url:m,name:p,description:f,photo:b,feedUrl:v,xfn:C,added:S}=e,[y,O]=(0,l.useState)(""),[N,F]=(0,l.useState)(!1),[B,T]=(0,l.useState)(null),M=(0,l.useRef)(S);M.current=S;const U=function(){const e=(0,l.useRef)();return(0,l.useEffect)(()=>(e.current=new AbortController,()=>e.current.abort()),[]),e}(),[A,R]=(0,l.useState)(null),H=()=>R(null),z=(0,r.__experimentalUseFocusOutside)(H),[P,L]=(0,l.useState)(),[V,D]=(0,l.useState)(null),I=()=>D(null),E=e=>D(e===V?null:e),q=(0,l.useRef)({}),G=t["blockroll/showAvatars"]??!0,Z=i||!!v,J=i||C.length>0,$=(0,s.useBlockProps)({className:m?"h-card":void 0}),X=b?(0,c.jsx)("img",{className:"u-photo",src:b,alt:""}):(0,c.jsx)("span",{className:"blockroll-no-photo"}),K=(0,c.jsx)(s.InspectorControls,{children:(0,c.jsx)(a.PanelBody,{title:(0,n.__)("Link settings","blockroll"),children:(0,c.jsx)(a.TextControl,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,label:(0,n.__)("Added","blockroll"),help:(0,n.__)("Used when the list is sorted newest first.","blockroll"),type:"date",value:S,onChange:e=>o({added:e})})})});if(!m){const e=()=>{const e=function(e){const o=e.trim();return/^[a-z][a-z0-9+.-]*:/i.test(o)&&!/^[^:/?#]+:\d/.test(o)?o:`https://${o}`}(y);w(e)?(F(!0),function(e,o){return function(e,o){return _()({path:"/blockroll/v1/discover",method:"POST",data:{url:e},signal:o})}(e,o).then(o=>function(e,o){return{...e,name:e.name||o.name,description:e.description||o.description,feedUrl:e.feedUrl||o.feedUrl,photo:e.photo||o.photo}}({url:e},o))}(e,U.current.signal).then(e=>{o({...e,added:M.current||g()}),F(!1)},t=>{(function(e){return"AbortError"===e?.name})(t)||(o({url:e,added:M.current||g()}),F(!1))})):T((0,n.__)("Only web addresses can be added.","blockroll"))};return(0,c.jsxs)("div",{...$,children:[K,(0,c.jsx)(h,{value:y,message:B,onChange:e=>{O(e),T(null)},onSubmit:e,isBusy:N})]})}return(0,c.jsxs)(c.Fragment,{children:[K,(0,c.jsxs)("div",{...$,children:[G&&(0,c.jsx)(s.MediaReplaceFlow,{mediaURL:b,allowedTypes:["image"],accept:"image/*",onSelect:e=>o({photo:e.url}),onSelectURL:e=>o({photo:e}),onReset:()=>o({photo:""}),popoverProps:{onFocusOutside:e=>{const o=e.target.ownerDocument.activeElement;!o?.closest('[role="dialog"]')&&q.current.isOpen&&q.current.onToggle()}},renderToggle:({children:e,...o})=>(q.current={isOpen:o["aria-expanded"],onToggle:o.onClick},(0,c.jsx)(a.Button,{...o,className:"blockroll-link__photo",label:(0,n.__)("Image","blockroll"),children:X}))}),(0,c.jsxs)("span",{className:"blockroll-link__name",...z,children:[(0,c.jsx)(s.BlockControls,{group:"block",children:(0,c.jsx)(a.ToolbarButton,{icon:u,title:(0,n.__)("Link","blockroll"),isActive:!!A,onClick:()=>R("toolbar"===A?null:"toolbar")})}),i&&A&&(0,c.jsx)(a.Popover,{anchor:P,placement:"bottom-start",shift:!0,onClose:H,onFocusOutside:j,focusOnMount:"toolbar"===A&&"firstElement",children:(0,c.jsx)(s.LinkControl,{value:{url:m,title:p},settings:[],hasTextControl:!0,forceIsEditingLink:!0,showInitialSuggestions:!1,onChange:e=>{const t=e.url||"";o({url:!t||w(t)?t:m,name:e.title??p}),H()},onCancel:H})},A),(0,c.jsx)(s.RichText,{ref:L,onFocus:()=>R("name"),disableLineBreaks:!0,tagName:"a",className:"u-url p-name",href:w(m)?m:void 0,value:p,allowedFormats:[],withoutInteractiveFormatting:!0,placeholder:(0,n.__)("Site name","blockroll"),onChange:e=>o({name:e})})]}),(i||f)&&(0,c.jsx)(s.RichText,{disableLineBreaks:!0,tagName:"p",className:"p-note",value:f,allowedFormats:[],withoutInteractiveFormatting:!0,placeholder:(0,n.__)("Description","blockroll"),onChange:e=>o({description:e})}),(Z||J)&&(0,c.jsxs)("div",{className:"blockroll-meta",children:[Z&&(0,c.jsx)(k,{className:"blockroll-feed blockroll-link__meta-button",isOpen:"feed"===V,onToggle:()=>E("feed"),onClose:I,label:(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(a.Icon,{icon:d,className:"blockroll-feed-icon"}),v?(0,n.__)("feed","blockroll"):(0,n.__)("Add feed","blockroll")]}),children:(0,c.jsx)(a.TextControl,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,label:(0,n.__)("Feed address","blockroll"),help:(0,n.__)("The RSS or Atom feed of the site, for readers who subscribe to your list.","blockroll"),type:"url",value:v,onChange:e=>o({feedUrl:e})})}),Z&&J&&(0,c.jsx)("span",{className:"blockroll-divider","aria-hidden":"true",children:"·"}),J&&(0,c.jsx)(k,{className:"blockroll-link__meta-button",isOpen:"xfn"===V,onToggle:()=>E("xfn"),onClose:I,focusOnMount:!0,label:C.length>0?(0,c.jsx)("span",{className:"blockroll-xfn",children:C.map(e=>(0,c.jsx)("span",{children:e},e))}):(0,n.__)("Add relationship","blockroll"),children:(0,c.jsx)("div",{ref:e=>e&&e.ownerDocument.defaultView.requestAnimationFrame(()=>e.querySelector("input")?.focus()),children:(0,c.jsx)(x,{value:C,onChange:e=>o({xfn:e})})})})]})]})]})},save:()=>null})})(); \ No newline at end of file diff --git a/src/blogroll/__tests__/deprecated.test.js b/src/blogroll/__tests__/deprecated.test.js index 71968dc..93de80f 100644 --- a/src/blogroll/__tests__/deprecated.test.js +++ b/src/blogroll/__tests__/deprecated.test.js @@ -9,7 +9,9 @@ const legacy = { links: [ { url: 'https://a.example/', name: 'A' } ] }; describe( 'hasLinkBlocks', () => { it( 'counts link blocks only', () => { - expect( hasLinkBlocks( [ link( 'https://a.example/' ) ] ) ).toBe( true ); + expect( hasLinkBlocks( [ link( 'https://a.example/' ) ] ) ).toBe( + true + ); expect( hasLinkBlocks( [ paragraph ] ) ).toBe( false ); expect( hasLinkBlocks( [] ) ).toBe( false ); expect( hasLinkBlocks( undefined ) ).toBe( false ); diff --git a/src/blogroll/components/xfn-control.js b/src/blogroll/components/xfn-control.js index dd0b11b..c8248ad 100644 --- a/src/blogroll/components/xfn-control.js +++ b/src/blogroll/components/xfn-control.js @@ -15,6 +15,10 @@ import { ALL_TOKENS, sanitizeXfn } from './xfn'; * A token field over the XFN vocabulary; the group rules are applied * on every change, so conflicting tokens replace each other. * + * Typing completes: Enter takes the first match, so "fr" becomes + * "friend". A word that is no relationship stays in the field instead of + * being swallowed, the vocabulary is the one of the XFN spec. + * * @param {Object} props Component props. * @param {string[]} props.value Selected tokens. * @param {Function} props.onChange Change handler. @@ -25,6 +29,10 @@ export default function XfnControl( { value = [], onChange } ) { __next40pxDefaultSize __nextHasNoMarginBottom __experimentalExpandOnFocus + __experimentalAutoSelectFirstMatch + __experimentalValidateInput={ ( token ) => + ALL_TOKENS.includes( token ) + } label={ __( 'Relationship', 'blockroll' ) } value={ value } suggestions={ ALL_TOKENS }