draft-js-utils icon indicating copy to clipboard operation
draft-js-utils copied to clipboard

Possibility to use Link from react-router-dom package to render mention entity

Open manoelneto opened this issue 7 years ago • 1 comments

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

manoelneto avatar Feb 21 '18 19:02 manoelneto

I'll suggest reuploading images

polakowski avatar Apr 12 '21 16:04 polakowski