-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Editor] - Code block eats up lines if it's added in the beginning of article content #374
Comments
part of reason for thematters/matters-web#2114 is server not saving exactly same pre code-block, as <pre class="ql-syntax" spellcheck="false">Pre1\n</pre><p>next paragraph... server side is always dropping the `spellcheck="false"`, then next time when editor is loading the pre code-block incomplete, it triggers `clipboard.convert` to parse again, and in MattersArticleEditor the `mentionContainer` reference is causing ReactQuill to re-initialize twice every time, caused converting between `HTML <=> Delta` happening 6 or even more times, and eventually caused wrong parsing
the minimum reproducible content is like this:
in other words: all paragraphs except the last one are eaten up into the pre block the root cause is at https://github.com/quilljs/quill/blame/1.3.7/modules/clipboard.js#L80-L85 because quill editor initialization code is calling same thematters/matters-server#2285 only fixed part of the problem: if re-initialize the editor with the complete attributes, the preferred HTML from
then for some reason, the getFormat in https://github.com/quilljs/quill/blame/1.3.7/modules/clipboard.js#L80-L85 got an empty |
part of reason for thematters/matters-web#2114 is server not saving exactly same pre code-block, as <pre class="ql-syntax" spellcheck="false">Pre1\n</pre><p>next paragraph... server side is always dropping the `spellcheck="false"`, then next time when editor is loading the pre code-block incomplete, it triggers `clipboard.convert` to parse again, and in MattersArticleEditor the `mentionContainer` reference is causing ReactQuill to re-initialize twice every time, caused converting between `HTML <=> Delta` happening 6 or even more times, and eventually caused wrong parsing
a minimum reproducing with just the Quilt editor's default QuickStart code https://quilljs.com/docs/quickstart/ the root cause why it reproduced in MattersEditor not ReactQuill is MattersEditor always calling initializing twice (because of mention reference change after DOM mount); calling > quill.setContents( { ops:[] } ) // set with an empty Delta
Delta {ops: Array(1)}
> quill.setContents(quill.clipboard.convert('<pre>pre1</pre><p>p2</p><p>p3</p><p>p4 <b>bold</b> <a href="/link/to">link</a></p>')); quill.root.innerHTML
'<pre class="ql-syntax" spellcheck="false">pre1\n</pre><p>p2</p><p>p3</p><p>p4 <strong>bold</strong> <a href="/link/to" rel="noopener noreferrer" target="_blank">link</a></p>'
> quill.setContents(quill.clipboard.convert('<pre>pre1</pre><p>p2</p><p>p3</p><p>p4 <b>bold</b> <a href="/link/to">link</a></p>')); quill.root.innerHTML
'<pre class="ql-syntax" spellcheck="false">pre1\n\np2\n\np3\n\n</pre><p>p4 bold link</p>' |
should the ultimate fix #374 Code block eats up lines if it's added in the beginning of article content 5 pt bug have tried many ways to remove this empty line after end of initialization, but does not work or have other complications would be better to leave it, user can always delete this empty line before publishing current sympton of #374 is losing all rich text formatting, all paragraphs (except the last one) are losing format; bottom line is not to lose all rich text formatting
The text was updated successfully, but these errors were encountered: