From your above code snippet, what I understood is the image on the converted HTML does not have <figure> tag wrapped. Draftjs by default only display image which has <figure> element wrapped. So to fix this issue, open \node_modules\draftjs-to-html\lib\block.js file in the editor and search for a line "entity.type === 'IMAGE". Inside of that condition statement, replace the below line,
if (entity.type === "IMAGE") {
const { alignment } = entity.data;
if (alignment && alignment.length) {
return `
<div style="text-align:${alignment};">
<img src="${entity.data.src}" alt="${entity.data.alt}" style="height: ${entity.data.height};width: ${entity.data.width}"/>
</div>`;
}
return `<img src="${entity.data.src}" alt="${entity.data.alt}" style="height: ${entity.data.height};width: ${entity.data.width}"/>`;
}
with this line
if (entity.type === "IMAGE") {
const { alignment } = entity.data;
if (alignment && alignment.length) {
return `
<figure style="text-align:${alignment};">
<img src="${entity.data.src}" alt="${entity.data.alt}" style="height: ${entity.data.height};width: ${entity.data.width}"/>
</figure>`;
}
return `
<figure>
<img src="${entity.data.src}" alt="${entity.data.alt}" style="height: ${entity.data.height};width: ${entity.data.width}"/>
</figure>
`;
}
That's it. Now rebuild the project and see whether it's working. Hopefully, this would work.
Note: Please keep in mind that the changes you made in the above file get reset when a new draftjs-to-html version arrives.