slab / quill

Quill is a modern WYSIWYG editor built for compatibility and extensibility
https://quilljs.com
BSD 3-Clause "New" or "Revised" License
43.18k stars 3.35k forks source link

Whitespace is collapsed in code blocks when using deltas #2830

Closed gigaj0ule closed 5 months ago

gigaj0ule commented 4 years ago

I have found that white space is collapsed in code blocks when you get a delta of the quill editor contents. This of course leads to corrupt python programs!

The offending line seems to be

text = text.replace(/\s\s+/g, replacer.bind(replacer, true)); // collapse whitespace

in modules/clipboard.js.

When commenting out this line, the problem is resolved.

yamamoto19730701 commented 4 years ago

I am also in trouble with this issue. Because of this code, full-width spaces(\u3000) are also collapsed in UTF8. I think it's better not to replace "\s".

v1talii-dev commented 2 years ago

I find solution for Quill 2.0.0-dev.4:

import Quill from 'quill';

const CodeBlock = Quill.import('formats/code-block');
// See - https://github.com/quilljs/quill/blob/develop/modules/clipboard.js#L513
CodeBlock.tagName = 'PRE';

Quill.register({
  'formats/code-block': CodeBlock
});
quill-bot commented 5 months ago

Quill 2.0 has been released (announcement post) with many changes and fixes. If this is still an issue please create a new issue after reviewing our updated Contributing guide :pray: