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

  Monday, 28 November 2022
  9 Replies
  286 Visits
I am on joomla 4.2.5, JCE 2.9.32, Safari 16.1, php 7.4.26

In the existing html text below, I have replaced the semicolon with colon so the &nbsp: will not disappear.

<p>Hello,&nbsp:How&nbsp:are&nbsp:you?</p>

If this text is already in an article, and I have "Keep non-breaking spaces" set to YES, then when I save the text, it is returned to the database table as it existed before, that is, in the actual character sequence of "&nbsp:" .

If I change my global setting of "Keep non-breaking spaces" to NO, open the above article, and save it, the "&nbsp:" disappear but in the database table for the article, instead of being saved as a regular space hex 20, they are saved as two hex bytes "c2 a0" .

If I display this article with Safari, and use the Safari Web Inspector to copy the paragraph, it is obvious that the &nbsp: are still there.

I would hope that JCE would leave them in the &nbsp: form so existing &nbsp: could be searched and replaced manually.

Please see two attached hex dumps of introtext field of article in concern. Look for the word "Hello". One is result of save of existing article with global setting to "Yes", and the other is result after the save of existing article with global setting to "No".

Thanks
more than a month ago
·
#112432
With reference to this post - https://www.joomlacontenteditor.net/support/forum/112369-after-setting-keep-non-breaking-spaces-and-pad-empty-tags-to-no-,-i-stil-get-nbsp - what is the source of the content? Are you still pasting in from Pages?

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

more than a month ago
·
#112436
Your content may contain utf-8 non-breaking spaces, which are are converted to   when "Keep non-breaking spaces" is set to YES. When this is set to No, then they are not converted, and are saved as utf-8 non-breaking spaces - https://www.fileformat.info/info/unicode/char/00a0/index.htm - which equates to "c2 a0" in hex format. JCE has done nothing to the content in this instance, and it is saved to the db as input.

You can convert the utf-8 nbsp characters to "basic" space characters by doing the following:

1. Create a file called editor.js in media/jce/js
2. Add the following code to the file and save:


tinyMCE.onAddEditor.add(function (mgr, ed) {
ed.onPostProcess.addToTop(function (ed, o) {
if (o.get) {
o.content = o.content.replace(/\u00a0/g, ' ');
}
});
});

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

more than a month ago
·
#112438
I think I am beginning to understand. ( In your response the text "&nbsp:" disappeared but I see where it goes.)

The situation arises where I want to keep the existing non-breaking spaces so I have to set the global option to Yes.

However, I would like to be able to strip them out with new pastes from the Clipboard.

In existing articles, I want the option to be able to use them in selected places, like keeping headers (h2) from wrapping, etc.

So, would it be feasible to have an option, similar to the "Cleanup HTML" to convert all   and then I can selectively add them where I need them.

OR

Have an option in the plugin parameters for the Clipboard, to convert &nbsp on paste action? I know it will do this with Global option set to "no", but then I have issue of not being able to use new ones, and not being able to see existing ones.

thanks
more than a month ago
·
#112439
Never mind, the cut and paste is working fine (without firefox). Now I know I have to leave global option to Yes. And I can use the code editor to do the search and replace.

thanks.
more than a month ago
·
#112440
If you want to mess with stuff on pasting, then try:


tinyMCE.onAddEditor.add(function (mgr, ed) {
ed.onPasteBeforeInsert.add(function (ed, o) {
o.content = o.content.replace(/\u00a0/g, ' ');
});
});

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

more than a month ago
·
#112441
Yes, I like the above idea. The first java-script snippet works in media/jce/js/editor.js file. However, I took it out because I want to keep some &nbps: 

The second one, onPasteBeforeInsert, gives me a blank editor section when I open an article for edit. The editor top layout rows are missing along with the editor text box being blank. However the plugin buttons under the editor text box are there.

Any suggestions on change of the code?

Otherwise, I am still good to go with the search and replace in the code tool.

thanks
more than a month ago
·
#112442
Try this:


tinyMCE.onAddEditor.add(function (mgr, ed) {
ed.onPreInit.add(function () {
ed.onPasteBeforeInsert.add(function (ed, o) {
o.content = o.content.replace(/\u00a0/g, ' ');
});
});
});

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

more than a month ago
·
#112443
It seems to be working. I will experiment more with it and report later.

Thanks!
more than a month ago
·
#112460
This is great. With the above code I can replace anything on paste.

I also added a line:


o.content = o.content.replace(/\&nbsp\;/g, ' ');


Thanks!
  • Page :
  • 1
There are no replies made for this post yet.
Be one of the first to reply to this post!