Skip to content
This repository has been archived by the owner on Feb 6, 2023. It is now read-only.

DraftEntityType needs to be loosened #868

Closed
jmzhang opened this issue Dec 13, 2016 · 6 comments · May be fixed by saurabharch/guesstimate-app#5
Closed

DraftEntityType needs to be loosened #868

jmzhang opened this issue Dec 13, 2016 · 6 comments · May be fixed by saurabharch/guesstimate-app#5

Comments

@jmzhang
Copy link

jmzhang commented Dec 13, 2016

From the doc that introduces Entities, it said

type: A string that indicates what kind of entity it is, e.g. 'LINK', 'MENTION', 'PHOTO'

But in the source code, the type of an Entity is limited to LINK, TOKEN , PHOTO or IMAGE, as seen in src/stubs/ComposedEntityType.js.

So my questions:

  • Is the entity type supposed to be customizable?
  • I'm considering using Flow in my projects, will a custom entity type, say VIDEO, break Flow's type checking?
  • What's the difference between PHOTO and IMAGE? I didn't find any explanations on that.
@ericbiewener
Copy link
Contributor

Agreed. Not only does it appear that you can specify any custom entity type you want, it seems like this is what you're supposed to do, that it is the primary identifier of what your entity is. The Draft JS Plugins project uses custom ones (e.g. sticker, emoji).

@akomm
Copy link

akomm commented Apr 19, 2018

I came to the same conclusion. Typing is "broken" but implementation works as intended when I use custom type.

I have a FONT_COLOR entity type.
I want my colors to be dynamic and not predefined (for the later, inline styles would be sufficient), so I need to store selected color data.

So I think it is a doc & typing issue.

@cedricmessiant
Copy link
Contributor

Same issue here, I have to add // $FlowFixMe to be able to use what I want for entity type. I guess DraftEntityType should be changed to string.

@juliankrispel juliankrispel self-assigned this Sep 23, 2018
@juliankrispel
Copy link
Contributor

yep. This flowtype is wrong imo, will bring this up 👍

@juliankrispel juliankrispel changed the title Need clarification on entity type. DraftEntityType needs to be loosened Sep 23, 2018
juliankrispel added a commit to juliankrispel/draft-js that referenced this issue Sep 23, 2018
@niveditc
Copy link
Contributor

niveditc commented Oct 4, 2018

Thanks for raising this! Loosening the Flow type here seems reasonable to me, so going to merge @juliankrispel's PR :)

@katz12
Copy link

katz12 commented Mar 11, 2019

This change is mentioned in the release notes for 0.10.5 but it seems like it did not make it into the release.

@niveditc

jdecked pushed a commit to twitter-forks/draft-js that referenced this issue Oct 9, 2019
Summary:
**Summary**
- Updated the DraftEntity flow type to be `string`. fixes facebookarchive#868

**Test Plan**
N/A
Pull Request resolved: facebookarchive#1878

Differential Revision: D10188002

fbshipit-source-id: e52da4d8dd708c7ed58e7d6f8c585e86835f1bb2
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
8 participants