This repository has been archived by the owner on Feb 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Typescript DraftBlockType too strict? #1453
Labels
Comments
Hi @camurai, Thanks for reporting this issue |
Not working again... https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/draft-js/index.d.ts#LC299 |
Hi @xFloooo,
|
midas19910709
added a commit
to midas19910709/draft-js
that referenced
this issue
Mar 30, 2022
Summary: DraftBlockType needs to be less strict in order to allow user defined block types however we also want to retain a way to identify our core draft blocks. fixes: facebookarchive/draft-js#1453 Closes facebookarchive/draft-js#1480 Differential Revision: D6215628 fbshipit-source-id: e4647bf2bafe9adb7788740ec64c1445e307e632
alicayan008
pushed a commit
to alicayan008/draft-js
that referenced
this issue
Jul 4, 2023
Summary: DraftBlockType needs to be less strict in order to allow user defined block types however we also want to retain a way to identify our core draft blocks. fixes: facebookarchive/draft-js#1453 Closes facebookarchive/draft-js#1480 Differential Revision: D6215628 fbshipit-source-id: e4647bf2bafe9adb7788740ec64c1445e307e632
aforismesen
added a commit
to aforismesen/draft-js
that referenced
this issue
Jul 12, 2024
Summary: DraftBlockType needs to be less strict in order to allow user defined block types however we also want to retain a way to identify our core draft blocks. fixes: facebookarchive/draft-js#1453 Closes facebookarchive/draft-js#1480 Differential Revision: D6215628 fbshipit-source-id: e4647bf2bafe9adb7788740ec64c1445e307e632
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Its possible that I am missing an obvious way I am supposed to be doing this, but it seems like the DraftBlockType is too specific, making it impossible to add in custom block types in typescript. I was following the example found in the docs here:
https://draftjs.org/docs/advanced-topics-block-components.html#content
Trying to use the code in the example in a typescript project, I got the following error, coming from the line where the Editor object is created in the render function:
This seems to stem from the fact that blockRenderMap is expecting a Immutable.Map<DraftBlockType, any>, while anything I create with the merge will have to be Immutable.Map<string, any>
I've tried setting the types, but since DraftBlockType does not contain my custom block type, and blockRenderMap expects the key to be DraftBlockType, no custom Block types can be added.
To test things out I edited the type for DraftBlockType in the node-module and set it to just be "string" instead of "unstyled" | "paragraph" | ....
This seems to make it so I am able to compile without the error messages.
So is there a different way to create a Custom Block Component that gets around the DraftBlockType, or was DraftBlockType just made too strict when the type file was setup?
The text was updated successfully, but these errors were encountered: