quill icon indicating copy to clipboard operation
quill copied to clipboard

Whitespace is collapsed in code blocks when using deltas

Open gigaj0ule opened this issue 6 years ago • 2 comments

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.

gigaj0ule avatar Oct 31 '19 00:10 gigaj0ule

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".

yamamoto19730701 avatar Nov 30 '19 20:11 yamamoto19730701

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
});

v1talii-dev avatar Aug 24 '22 10:08 v1talii-dev

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:

quill-bot avatar Apr 17 '24 11:04 quill-bot