Permalink
Browse files

Insert `@username` for user mention autocomplete (#4444)

Rather than inserting a static link and the display name, both of which may change over time and lead to stale content, follow the pattern of existing user mentions in WordPress projects and insert a plaintext mention using the username.
  • Loading branch information...
helen authored and pento committed Jan 16, 2018
1 parent 2e276ad commit 7f7b607cc4916e8c40d21bb8a8ce12caf6f61b3e
Showing with 4 additions and 4 deletions.
  1. +4 −4 blocks/autocompleters/index.js
@@ -101,7 +101,7 @@ export function blockAutocompleter( { onReplace } ) {
};
}
/**
* Returns a "completer" definition for inserting links to the posts of a user.
* Returns a "completer" definition for inserting a user mention.
* The definition can be understood by the Autocomplete component.
*
* @returns {Completer} Completer object used by the Autocomplete component.
@@ -123,12 +123,12 @@ export function userAutocompleter() {
} );
};
const allowNode = ( textNode ) => {
return textNode.parentElement.closest( 'a' ) === null;
const allowNode = () => {
return true;
};
const onSelect = ( user ) => {
return <a href={ user.link }>{ '@' + user.name }</a>;
return ( '@' + user.slug );
};
return {

0 comments on commit 7f7b607

Please sign in to comment.