Skip to content

draft-js-import-markdown doesn't display images #147

Closed
@kildem

Description

@kildem

I have try this test: 503e012#diff-e009bb42daadca1e8c6103199d3b13b1

It says that it should support images. But this obj:

{
  blocks: [{
         data: {},
         depth: 0,
         entityRanges: [{
           key: 0,
           length: 1,
           offset: 0,
         }],
         inlineStyleRanges: [],
         text: ' ',
         type: 'unstyled',
       }],
       entityMap: {
         // This is necessary due to flow not supporting non-string literal property keys
         // eslint-disable-next-line quote-props
         '0': {
           data: {
             src: 'imgur.com/asdf.jpg',
           },
           mutability: 'MUTABLE',
           type: 'IMAGE',
         }
     }
}

doesn't show images.
It is missing atomic block in order to display image.
this one display image:

      const obj = {
 blocks: [
          {
            text: ' ',
            type: 'atomic',
            depth: 0,
            inlineStyleRanges: [],
            entityRanges: [
              {
                offset: 0,
                length: 1,
                key: 0
              }
            ],
            data: {},
            key: 'foo'
          },
          {
            text: '',
            type: 'unstyled',
            depth: 0,
            inlineStyleRanges: [],
            entityRanges: [],
            data: {},
            key: 'foo1'
          }
        ],
        entityMap: {
          // This is necessary due to flow not supporting non-string literal property keys
          // eslint-disable-next-line quote-props
          '0': {
            type: 'IMAGE',
            mutability: 'MUTABLE',
            data: {
              src: 'imgur.com/asdf.jpg',
            }
          }
        }
      }
      //return EditorState.createWithContent(convertFromRaw(obj))
     ```

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions