Created
June 24, 2018 13:21
-
-
Save levvsha/5b7c3cd02f60b8dd45f8be2f6577b33f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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