Artem-Schander/quill-paste-smart

Pasting code is not working as expected

bharath6365 opened this issue · 3 comments

When I paste this code in the editor quill-paste-smart is trimming all the white space

Expectation
2021-04-07 at 5 17 PM

This is how it actually looks with quill-paste-smart enabled
2021-04-07 at 5 18 PM

What should I do to ensure that there are proper line breaks?
This is my allowed configuration
allowed: {
tags: [
'a',
'b',
'i',
'p',
'br',
'ul',
'ol',
'li',
'pre',
'span',
'h1',
'h2',
],
attributes: ['href', 'rel', 'target'],
},

Hi @bharath6365
thanks for raising this issue. I'll look into it in a few hours.

Hi @bharath6365
It took a bit longer but I'm on a good way to get a decent solution.

The thing is, this tool behaves correctly. The tags you're pasting (in this case div) are not allowed and so they are getting stripped. Only allowed tags remain (in this case span). So block type tags are gone and inline ones are still there .. results in one line.

However I think you're not wrong assuming this is an issue, since I would also expect rows (block elements) stay rows.
The solution I'm now working on, would be a substitution.
So the Idea is to replace all not allowed block elements with a p tag (assuming it is allowed). I think I will also replace (as long as not allowed) all heading tags with a b/strong wrapped with p.

This will be available in the upcoming minor release. Should not take that long.

Hi @bharath6365,

I've added the setting substituteBlockElements to the latest release. It is enabled by default. Just update the package and you're good.

Feel free to reopen this issue if you feel like it :)