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 Online

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

#116196 JCE PRO changes ‘something’ when no change is made to the code on second save action.

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 BraGIS on Tuesday, 20 February 2024 08:15 GMT

BraGIS
I want to develop an article only in pure plain text HTML / Javascript / PHP without the use of a WYSIWYG editor. JCE PRO should be able to support this. I use sourcerer to be able to launch PHP code when the article is loaded in the frontend.

I have a very simple piece of code: there is no way to add it to this post, it won't get accepted. I first tried the code, but the administrator of this forum told me to put the code in an image. Also the image of the code is not accepted when I try to upload. Let me know how I can add an image without being denied...

[ADMIN NOTE: I have added you image as an attachment]

The 2 line simple code generates a simple string in PHP and puts it in a Javascript variable. Then I show it with the Javascript alert function. Just 2 lines of code.

When I paste this code into an empty article and push the Save button, the article on the frontend displays the alert box with the text generated in PHP.

When I make no change at all, but push a second time on the Save button, JCE messes up the article, The code displays the same in the backend code editor, but it’s not executed any more. What settings do I have to make that the code keeps executing no matter how many times I push the save button? This behaviour results in a way of actually developing code which is very hard with my current settings. The code should be written in an external program and copied at each change into the editor, because you only have 1 save action. I think it is a bug...

Versions:
JCE PRO version 2.9.61
Sourcerer 10.0.4
Joomal 5.0.2

Attachments

Ryan
I want to develop an article only in pure plain text HTML / Javascript / PHP without the use of a WYSIWYG editor. JCE PRO should be able to support this.


JCE Pro is an HTML WYSIWYG Editor. An alternative is to use the Joomla "No Editor", which is not a WYSIWYG Editor.

The content you have added in the Code Editor is a text string, eg: {source} follwoed by some HTML and PHP code. JCE Pro is able to support the inclusion of script and PHP tags if enabled in Editor Profiles -> Editor Parameters -> Advanced, but must process the code in a particular way in order to do so.

Please try this:

In Editor Profiles -> Editor Parameters -> Advanced, in the Code Blocks section, set Enable Code Blocks to Yes.

https://cdn.joomlacontenteditor.net/tmp/116196-jce-pro-changes-something-when-no-change-is-made-to-the-code-on-second-save-action-1.jpg

Then scroll down and set Protect Shortcode to Yes.

https://cdn.joomlacontenteditor.net/tmp/116196-jce-pro-changes-something-when-no-change-is-made-to-the-code-on-second-save-action-2.jpg

Then in the Code Editor, paste or type in your code, eg:

https://cdn.joomlacontenteditor.net/tmp/116196-jce-pro-changes-something-when-no-change-is-made-to-the-code-on-second-save-action-3.jpg

Whe you switch to the Editor Tab, you will see the code inside a Shortcode Block, eg:

https://cdn.joomlacontenteditor.net/tmp/116196-jce-pro-changes-something-when-no-change-is-made-to-the-code-on-second-save-action-4.jpg

You can also create a Shortcode Block in the editor by selecting the Shortcode option from the Format menu, then typing or pasting in your code.

Ryan Demmer

Lead Developer / CEO / CTO

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

BraGIS
Thank you for your reply but it didn't brought a solution. The behaviour still exists. I had to dig a little deeper to find out what's going on and it is clear to me now. Good working raw text editors, use no TAB characters with an ASCII code 9. To indent text, ASCII character 32 is used a few times (2 times, 3 times, 4 times).

If I paste in the code used above without TABS (ASCII 9) or without SPACE (ASCII 32) characters, it works. There is a 1:1 write tot the database.
When the save action is finished, JCE PRO reads the content back and adds a tab character TABS (ASCII 9). When that is saved, it messes up the code.

If I paste in the code used above from a working raw code with text indents, made by an editor like ROKpad, it works, ROKpad uses ASCII 32 characters for a TAB.

Because JCE puts in automatically the TAB (ASCII 9) character, you do not have working code anymore.

Is there a way JCE PRO does not add a TAB (ASCII 9) character, but 2 or more SPACE (ASCII 32) characters? Then it provides for a decent and good working raw code editor.

Ryan
Please try JCE Pro 2.9.62 Beta - https://www.joomlacontenteditor.net/downloads/editor/pro/development

Clear your browser cache after install.

The Code Editor reformats code for readability on start up or when the Format HTML button is pressed. This used the beautifyjs library with tab indents, but has now been reconfigured to use the default of 4 space characters.

Ryan Demmer

Lead Developer / CEO / CTO

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

BraGIS
Thank you Ryan. That is an improvement, but there is still 1 issue. This version puts spaces in between the PHP opening tag characters, which breaks PHP execution. Also the end tag of the PHP code block gets a space in-between the 2 characters. Is there a solution so the PHP tags will not get the extra spaces when loading the article?

Appreciated!

Ryan
In Editor Profiles -> Plugin Parameters -> Code Editor, set Format HTML to No and Validate HTML to No.

Ryan Demmer

Lead Developer / CEO / CTO

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

BraGIS
YES! Thank you Ryan for your efforts. Now I have a working code editor with just a few minor issues in comparison with the Joomla 3 ROKpad editor. For our project we ended up with 10000 lines of Javascript code and a lot of PHP insertion, in 1 Joomla article, to interact with a huge Javascript API, so we are totally not using a WYSIWYG editor. Pure code editing is what we do, directly in the browser, almost 100% each day, so a good Editor that does not change code is essential.

The only feature I wish for is a AJAX driven save option to save the article without any changes to the position of the cursor in the article, but I can live without that. In ROKpad when you are editing on line, let say, 9100, you can save the article without having to scroll back to line 9100 after a save action. Nice to have.