draft-js-utils icon indicating copy to clipboard operation
draft-js-utils copied to clipboard

img tag &nbsp

Open sandywk opened this issue 6 years ago • 0 comments

   entityStyleFn: (entity) => {
    const entityType = entity.get('type').toLowerCase();
    const data = entity.getData();
    switch(entityType){
      case 'image':
      return {
        element: 'img',
        attributes: { src: data.src },
        style: { maxWidth: '100%', height: 'auto' }
      }
    }
  }
 let html = stateToHTML(contentState, options)

html : <figure><img src="...." style="max-width: 100%; height: auto">&nbsp;</img></figure>

&nbsp Causes placeholders under images

How to turn into: <figure><img src="...." style="max-width: 100%; height: auto" /></figure>

sandywk avatar May 13 '19 03:05 sandywk