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

Add support for block-level metadata #157

Closed
wants to merge 1 commit into from

Conversation

angelf
Copy link

@angelf angelf commented Mar 4, 2016

It's now possible to associate entities to a whole block. These are
retrieved with block.getBlockEntity()

When spliting a block, the entity only remains linked to the first block
of the split

It's now possible to associate entities to a whole block. These are
retrieved with block.getBlockEntity()

When spliting a block, the entity only remains linked to the first block
of the split
@oyeanuj
Copy link

oyeanuj commented Mar 4, 2016

@angelf Thanks for this PR! Would it be possible to add to the documentation explaining this addition in a little bit more detail?

@hellendag
Copy link

@facebook-github-bot import

});
});

describe('caracter entity retrieval', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

caracter should be character

@gscottolson
Copy link
Contributor

This is awesome! Thanks, @angelf.

@facebook-github-bot
Copy link

Thanks for importing. If you are an FB employee go to Phabricator to review.

@hellendag
Copy link

It's not currently clear how to apply or remove a block entity. Some Modifier methods would be helpful, and we might also need a new EditorChangeType.

@SamyPesse
Copy link

convertToRaw is not working with blockEntity, the entity is not added to the map (https://github.com/facebook/draft-js/blob/3106fe50b845d3798575a9e34514172de2b0966e/src/model/encoding/convertFromDraftStateToRaw.js#L41).

I'll be happy to propose a PR to fix this, but I personally think that #216 is a better solution for "Block level metadatas" because:

  • Mutability of entity have no meaning for a block entity
  • Type of the entity will always equal the type of the block
  • The only property of the entity important in this case is: data

@angelf
Copy link
Author

angelf commented Mar 16, 2016

I'm happy with #216 approach. I actually find it more natural. @hellendag can you offer your thoughts on why you suggested to go with the Entity store?

@hellendag
Copy link

@angelf Mostly just to follow the same pattern as per-character entity tracking. But I'm sold on the approach in #216. :)

@angelf
Copy link
Author

angelf commented Mar 16, 2016

All right! I'm closing this one then.

@angelf angelf closed this Mar 16, 2016
ghost pushed a commit that referenced this pull request Jul 1, 2016
Summary:
This commit add support for block level metadata.

It is the same feature as #157

This PR does not rely on entity, but just add a data field to ContentBlock.

hense block metadata are store in contentState and are supported by undo/redo.

Why not using entities?
- Entity are not made for block. what does type and mutability would map to?
- Entity are planned to be integrated into contentState anyway (see #185)
Closes #216

Reviewed By: spicyj

Differential Revision: D3123774

fbshipit-source-id: 27fdf0090d8faafba2848cb72f584987af3bbe0e
ouchxp pushed a commit to ouchxp/draft-js that referenced this pull request Apr 7, 2017
Summary:
This commit add support for block level metadata.

It is the same feature as facebookarchive#157

This PR does not rely on entity, but just add a data field to ContentBlock.

hense block metadata are store in contentState and are supported by undo/redo.

Why not using entities?
- Entity are not made for block. what does type and mutability would map to?
- Entity are planned to be integrated into contentState anyway (see facebookarchive#185)
Closes facebookarchive#216

Reviewed By: spicyj

Differential Revision: D3123774

fbshipit-source-id: 27fdf0090d8faafba2848cb72f584987af3bbe0e
midas19910709 added a commit to midas19910709/draft-js that referenced this pull request Mar 30, 2022
Summary:
This commit add support for block level metadata.

It is the same feature as facebookarchive/draft-js#157

This PR does not rely on entity, but just add a data field to ContentBlock.

hense block metadata are store in contentState and are supported by undo/redo.

Why not using entities?
- Entity are not made for block. what does type and mutability would map to?
- Entity are planned to be integrated into contentState anyway (see #185)
Closes facebookarchive/draft-js#216

Reviewed By: spicyj

Differential Revision: D3123774

fbshipit-source-id: 27fdf0090d8faafba2848cb72f584987af3bbe0e
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.

None yet

6 participants