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

How should convertFromHTMLToContentBlocks process media tags ? #260

Closed
filod opened this issue Apr 2, 2016 · 2 comments
Closed

How should convertFromHTMLToContentBlocks process media tags ? #260

filod opened this issue Apr 2, 2016 · 2 comments
Labels

Comments

@filod
Copy link

filod commented Apr 2, 2016

convertFromHTMLToContentBlocks simply ignore media contents for now. this is obviously not what i want.

to my knowledge, draft.js suggest to provide media through Block type, but img/video/etc.. are often inline tags in DOM .

of course i can return a chunk in convertFromHTMLToContentBlocks ==> genFragment:

function genFragment(...) {
...
  if (nodeName === 'img') {
    return {
      text: '\r \r',
      inlines: [],
      entities: [],
      blocks: [{
        type: 'media',
        src: node.src,
        depth: depth
      },{
        type: 'unstyled',
        depth: depth
      }]
    }
  }
...
}

but this code makes me feel tricky, don't know if it is right, should convertFromHTMLToContentBlocks provide some hooks to allow customization of html => ContentBlocks?

Any thoughts on this?

@hellendag
Copy link

You may wish to create your own HTML conversion utility. Feature support that may be obvious to some is unnecessary for others. In this case, the limit of this conversion utility is the feature set that we have required at Facebook, as I would not have wanted to open source anything we aren't using in production.

convertFromHTML is just an exposed version of our paste processor, and is not currently expected to handle all possible use cases.

That said, #205 will provide more flexible support for mapping HTML tags to block types.

@filod
Copy link
Author

filod commented Apr 4, 2016

thanks for reply.

for those who want know how to handle media content in convertFromHTML, see this naive implementation

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants