Fixed Inserting code doubles line breaks

DragonByte Tech

Well-known member
Affected version
2.0.0 XF.com Edition
When I try to paste a block of code into the code editor (Insert -> Code), I get double line breaks. This does not happen on my local install (2.0.0 Gold).
 
This also happens when pasting code directly into the editor, but does not happen when I copy multi-line text FROM the editor and paste it back into the editor.

Interestingly enough, it only appears to happen when I paste from VSCode. EDIT: Just to clarify, the exact same clipboard contents does not double-linebreak on my local install (same browser) but does here @ XF.com.


Fillip
 
If it's specific to here, it might be Froala 2.7.2 related, as we've just updated to that.

Though if it's VSCode related, I'd need to know exactly how the HTML we receive is being formatted to make a determination.
 
If it's specific to here, it might be Froala 2.7.2 related, as we've just updated to that.

Though if it's VSCode related, I'd need to know exactly how the HTML we receive is being formatted to make a determination.
How can I get that information to you?

I do notice that in this post: https://xenforo.com/community/posts/1198608/ the same issue occurred for that member, so maybe you can replicate the issue by pasting a server error log entry from your own test installs?


Fillip
 
This is a Froala bug and I have reported it to them.

However, I have identified a workaround, so I believe this should be resolved both for the code dialog and when pasting. The code dialog I'm fairly certain of, but @DragonByte Tech, can you double check when pasting from VSCode directly? (Or any other scenario where you could repro it when pasting into the editor directly.) The latest code has been rolled out here.
 
However, I have identified a workaround, so I believe this should be resolved both for the code dialog and when pasting. The code dialog I'm fairly certain of, but @DragonByte Tech, can you double check when pasting from VSCode directly? (Or any other scenario where you could repro it when pasting into the editor directly.) The latest code has been rolled out here.
Unfortunately direct pasting is not working, although I can confirm the code dialog works for me (latest Chrome, Win10).

Seems to me like Froala has had a fair amount of issues since you switched :(

I should probably open a new ticket, but if I use Ctrl+B (or U) to start formatting, then Ctrl+B (or U) to end, then immediately hit the space bar, the formatting comes back.

Up until right now I wasn't able to reproduce it reliably but I seem to be able to now.

test ddd
test ddd
test test
 
To clarify further, the issue does not appear to occur when clicking the buttons in the editor manually:

test test
test test
test test


Fillip
 
Moving this back to check that, but at this point, I think I need to know the HTML being pasted.

To do this, I'll need you to check this on your local install as you need to run the full JS so you can make some tweaks to it. Make sure this is in src/config.php if it isn't already:
Code:
$config['development']['fullJs'] = true;

Then, would you mind making 2 edits to js/xf/editor.js. First, before:
Code:
return XF.adjustHtmlForRte(content);
Add:
Code:
console.log(content);

Then then before:
Code:
return t.normalizePaste(content);
Add:
Code:
console.log(content);

If you hard refresh and paste from VSCode, 2 things should go in the console. Can you paste them here exactly as you see them?
 
I think that the VSCode pasting issue may not be new -- you just noticed it because of the other bug. It relates to the fact that the editor is generally based on a single tag (in our case, <p>) and that your pasting has <div> tags instead. They are converted to <p>'s internally and that triggers some of our extra behaviors.

There is a way we can workaround it, but it requires a change/bug fix in Froala. I have made a request for this, but it is arguably an enhancement or there may be reasons not to do it, so it may not be applied. I will tag this as a service issue though l will leave it open pending a resolution on their end.

I should note that the insert code dialog will work as expected now, so that part of the bug is fixed.
 
There is a way we can workaround it, but it requires a change/bug fix in Froala. I have made a request for this, but it is arguably an enhancement or there may be reasons not to do it, so it may not be applied. I will tag this as a service issue though l will leave it open pending a resolution on their end.
I've voted on it on GitHub :)

Should I open a separate thread for the issue described in posts #8 and #9?


Fillip
 
Arguably not -- I have reproduced it in the past if I'm very quick, but if I delay a bit, so it may be more tied to the speed in which certain events happen.
I can reproduce it if I wait less than approx. 1 second. Tested it a few times with the stopwatch on my phone.


Fillip
 
There is a way we can workaround it, but it requires a change/bug fix in Froala. I have made a request for this, but it is arguably an enhancement or there may be reasons not to do it, so it may not be applied. I will tag this as a service issue though l will leave it open pending a resolution on their end.
The relevant changes for this are included in the upcoming XF 2.0.2 and have been rolled out here if you'd like to test. Thank you.
 
Top Bottom