Skip to content

Instantly share code, notes, and snippets.

@levvsha
Created June 24, 2018 13:21
Show Gist options
  • Save levvsha/5b7c3cd02f60b8dd45f8be2f6577b33f to your computer and use it in GitHub Desktop.
Save levvsha/5b7c3cd02f60b8dd45f8be2f6577b33f to your computer and use it in GitHub Desktop.
function findLinkEntities(contentBlock, callback, contentState) {
contentBlock.findEntityRanges(
(character) => {
const entityKey = character.getEntity();
return (
entityKey !== null &&
contentState.getEntity(entityKey).getType() === 'LINK'
);
},
callback
);
}
const Link = (props) => {
const { url } = props.contentState
.getEntity(props.entityKey).getData();
return (
<a href={url} title={url} className="ed-link">
{props.children}
</a>
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment