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

Conversation

mitermayer
Copy link
Contributor

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: #1453

- Making DraftBlockType less restrictive and allowing to distinguish
between internal types and custom user types
- While landing "" I had to change the type of ContentBlock key from DraftBlockType to string to avoid internal conflicts, but due to the new less strict typing we can revert it back
@mitermayer mitermayer force-pushed the issue-1453/fixing-too-strict-typing-for-block-types branch from 728e0ac to be51e0a Compare November 1, 2017 21:45
@@ -26,7 +26,7 @@ const {List, Map, OrderedSet, Record, Repeat} = Immutable;
const EMPTY_SET = OrderedSet();

type ContentBlockConfig = {
key?: string,
key?: DraftBlockType,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just adding back, had removed this temporarily while shipping the other PR internally, but now since DraftBlockType is more permissive we wont run in the same problem again

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My mistake in here, this should have been added to type not key but fixing it on a follow up PR #1485

Copy link
Contributor

@flarnie flarnie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

however we also want to retain a way to identify our core draft blocks.

I agree that we want to keep this strict in places where we don't expect custom user blocks. The only place inside Draft like that is the DefaultDraftBlockMap which uses DraftBlockMap type.

What do you think of creating a more specific type for our DefaultDraftBlockMap that only allows our core block types, and allowing the user-defined custom block map to use the looser DraftBlockMap type that includes CustomBlockType?

You had brought up the question of why this hasn't caused Flow errors internally, and I still wonder about that too. Can we look into that a bit before doing a release that includes this?

Also great use of type aliasing! :)

block types inference

- Making sure DefaultDraftBlockRenderMap still references the internal
supported block types
@flarnie
Copy link
Contributor

flarnie commented Nov 1, 2017

lgtm - thanks! :)

Copy link

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mitermayer is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

midas19910709 added a commit to midas19910709/draft-js that referenced this pull request 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 pull request 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 pull request 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Typescript DraftBlockType too strict?
3 participants