Pasting with cleanPastedHTML: true removes divs from all text
When pasting a text from an article, medium editor is removing all embeded images added with medium-editor-insert-plugin, which are figures surrounded by divs.
el.querySelectorAll('a,p,div,br') pass all text (and not only pasted text) to filterCommonBlocks, which removes the div. Is this the expected behavior?
Medium editor should not consider all text around the pasted code as already valid?
Would you mind giving a bit more context/examples about this issue? What HTML are you trying to paste and what is the resulting HTML? Apologies, but I'm having trouble understanding what you were seeing.
Sorry for the delay.
medium-editor-insert-plugin inserts a div for images or embeds. Having this text in editor, for instance:
<p>Paragraph</p>
<div class="medium-insert-images"><figure>
<img src="image.jpg" alt="">
</figure></div>
When I paste an HTML code (e.g. a simple paragraph with a A link tag), the figure div disappears.
Could you tell us which option do you enable for the paste extension?
I'm using these configs:
paste:{
forcePlainText: false,
cleanPastedHTML: true,
cleanAttrs: ['class', 'style', 'dir'],
cleanTags: ['br', 'meta', 'body', 'section', 'aside', 'article',
'span', 'h1', 'h2', 'font']
},
@oznek Could you check again with the last release (5.6.2) ? We've fixed few things related to pastes html.
@j0k3r not working. filterCommonBlocks still clean up divs with only images inside. ( textContent or innerText returns empty string ).
I got the same problem. filterCommonBlocks function remove all div elements which contain images.
Same problem here. I'm trying to paste text with images from medium.com but the images (inside a div) are always remove
the problem still exists, i updated code if (/^\s*$/.test(el.textContent) && el.parentNode) { -----> if (/^\s*$/.test(el.textContent) && el.parentNode && !el.querySelector('img')) {