You need to be logged in to post in the forum - Log In

An active JCE Pro Subscription is required to post in the forum - Buy a Subscription

Support is currently Offline

Official support hours
Monday to Friday
09:00 - 17:00 Europe/London (BST)

Please create a new Ticket and we will get back to you as soon as we can.

#109879 Code Formatting not Saving in Code Editor with latest Pro Update

Posted in ‘Editor’
This is a public ticket

Everybody will be able to see its contents. Do not include usernames, passwords or any other sensitive information.

Latest post by Marsolais on Friday, 07 January 2022 13:41 GMT

snapbug
I prefer the editor code to stay as I format it and not mesh together after I save it. It makes it more difficult to find points to edit. Very aggravating.

<p style="padding-left: 20px; align: justify;"><b>Learning the truth about <i>Christian Religion</i>. <br /><br /> 
Learn about God, the Bible and Christianity. <br /><br /> 
Do I really want to go to heaven? Am I a Christian?<br /><br /> 
What must I do to be saved? How do I become a Christian?<br /><br /> 
What is true worship? Am I worshiping God as He commands? <br /><br /> 
Where should I worship? Where is the truth being preached? <br /><br /> 
Apostasy - Can I lose my salvation or is it really once saved always saved? <br /><br /> 
What is the sinners prayer, where did it originate, and can it save me? <br /><br />
Should not look like this after saving...

<p style="padding-left: 20px; align: justify;"><b>Learning the truth about <i>Christian Religion</i>. <br /><br /> Learn about God, the Bible and Christianity. <br /><br /> Do I really want to go to heaven? Am I a Christian?<br /><br /> What must I do to be saved? How do I become a Christian?<br /><br /> What is true worship? Am I worshiping God as He commands? <br /><br /> Where should I worship? Where is the truth being preached? <br /><br /> Apostasy - Can I lose my salvation or is it really once saved always saved? <br /><br /> What is the sinners prayer, where did it originate, and can it save me? <br /><br />
What am I doing wrong? It's not the word wrap... I tried that, but it still does not retain the formatting. Regards, Sonnie

snapbug
I believe this is because of the <br /> code. When I replace it with the <p></p> code it retains the formatting in the code editor.

These articles were written a while back with an editor that inserted page breaks with the carriage return, and I think I got used to using those instead of paragraphs like I probably should have been using.

Regards,
Sonnie

Ryan
The Source Code editor will only break and indent on block elements, eg:

,

,

etc.

You can retain custom formatting in the Code editor if you save in the Code tab (without toggling to the Editor tab), and if the Validate Content option is set to No in Editor Profiles -> Plugin Parameters -> Code Editor.

Ryan Demmer

Lead Developer / CEO / CTO

Just because you're not paranoid doesn't mean everybody isn't out to get you.

snapbug
I have indeed discovered this.

I like having the content validated too.

Regards,
Sonnie

Marsolais
I also was playing with bringing code from the Ecwid plugin in Joomla articles and modules. Could not get them JCE to leave the code alone on saving, even though I had followed the instructions for Jommla filtering and RSFirewall. Finally got code to stay with no editor, followed by TinyMCE. It's not till I seen this post and remove the validation in JCE that the code no longer get stripped. Works like a charm but lost the validation option. Thanks to Sonnie and Ryan for this post.

Ryan
I also was playing with bringing code from the Ecwid plugin in Joomla articles and modules.


What does this code look like? What was being removed?

Ryan Demmer

Lead Developer / CEO / CTO

Just because you're not paranoid doesn't mean everybody isn't out to get you.

Marsolais
Here it is not validated :



Here is the differnce

Attachments

Marsolais
Ryan, I'm not a programmer, hope i'm not waisting your time.

snapbug
I have HTML validation turned on and the code keeps its formatting. Are you saying validation causes the code to lose its formatting?

Regards,
Sonnie

Marsolais
Sonnie, Yes, it appears that for me (Joomla 4) turning that validation on/off makes the difference.

Ryan
@Marsolais - apart from the formatting, are there any other changes when validation is on?

Ryan Demmer

Lead Developer / CEO / CTO

Just because you're not paranoid doesn't mean everybody isn't out to get you.

Marsolais
Not that I have notice, everything else seems fine.

Ryan
Validation removes whitespace in between HTML elements, such as tabs and spaces, which removes the formatting, an unfortunate consequence of the validation process. HTML formatting of this type is not necessary for the correct rendering of the HTML in the front-end.

Ryan Demmer

Lead Developer / CEO / CTO

Just because you're not paranoid doesn't mean everybody isn't out to get you.

Marsolais
Thank you. This certainly answer my question.