draft-js-utils
draft-js-utils copied to clipboard
Possibility to use Link from react-router-dom package to render mention entity
I`m trying to do this
import { Link } from 'react-router-dom';
...
entityStyleFn: (entity) => {
const entityType = entity.getType().toLowerCase();
if (entityType === "mention") {
let {mention: {id}} = entity.getData();
return {
element: "Link", // also tryied Link without quotes
attributes: {
to: `/users/${id}`
}
};
}
},
I got this
https://www.dropbox.com/s/8c4nzcbxxxx4joe/Captura%20de%20tela%202018-02-21%2016.08.43.png?dl=0
switching to "a" element, works
entityStyleFn: (entity) => {
const entityType = entity.getType().toLowerCase();
if (entityType === "mention") {
let {mention: {id}} = entity.getData();
return {
element: "a",
attributes: {
href: `/users/${id}`
}
};
}
},
https://www.dropbox.com/s/nnfq9gi6ck9pz44/Captura%20de%20tela%202018-02-21%2016.09.45.png?dl=0
I'll suggest reuploading images