[opencms-dev] How to prevent editors from removing span elements
Paul-Inge Flakstad
flakstad at npolar.no
Fri Nov 15 18:02:06 CET 2013
Hi Andreas,
Thanks for the quick reply.
There's no cleanup going on here, content-conversion is not set.
Re-did a small number of test cases just now:
1.) Spans are preserved as long as they're not empty. Empty spans are stripped. (I can live with that.)
2.) Things like ° are preserved. (Although one of our editors complained ° got stripped when she tried it...)
3.) is stripped. (Bad. Many spaces should be non-breaking. Increasingly important with fluid/responsive designs.)
So, the symptoms may not be as bad as I initially described, but [3] is still bad. Let me illustrate:
The editor works 99
% of the time.
How much water? 2
l.
There are over 1 000 000
000 stars in our galaxy.
These look strange, and not only that, but legibility is also severely reduced (more evident in wider text columns).
OK, but what's the problem? -TinyMCE's stripping of nbsp's is easily fixed:
tinyMCE.init({
...
entity_encoding: 'named',
entities: '160,nbsp'
...
});
(See http://www.abeautifulsite.net/blog/2009/12/tinymce-removes-non-breaking-spaces/)
Well, the real problem isn't tinyMCE, but OpenCms' adaptation of it:
- *Where* do we set these config values?
- *Where* is tinyMCE's init method invoked?
I found one candidate: /system/workplace/editors/tinymce/editor.jsp. Around line 754, I changed the code from:
entity_encoding: "raw",
to:
entity_encoding : "named",
entities : "160,nbsp",
Saved, published, re-initialized workplace. Made no difference whatsoever (at least not for xmlcontent editing).
I found no other candidates, but editing an xmlcontent file (in back-end mode) I noticed some tinyMCE config settings in the HTML source; a short javascript printed along with its associated textarea (or "OpenCmsHtml element"). That javascript code can be traced to the method org.opencms.editors.tinymce.CmsTinyMCEWidget#getTinyMceConfiguration(CmsObject, I_CmsWidgetParameter), in which tinyMCE's "entity_encoding" is hard-coded (!):
result.put("entity_encoding", "raw");
(See line 237 of https://github.com/alkacon/opencms-core/blob/a22b61ee7bf38dcd706dc43302f5834b5b02b45f/src-modules/org/opencms/editors/tinymce/CmsTinyMCEWidget.java)
A more edit-friendly, transparent, and ultimately *user-friendly* way of storing the editors' default config would be most welcome. (Like key-value-pair text files, xml or json files.) My point: Making me fiddle with core classes just to change a tinyMCE setting isn't very plugin-esque. And honestly, I don't feel like going down that road. Guess it's back to FCKEditor ... :(
PS: Given that the FCKEditor is no longer available (since v9, I believe?), I sincerely hope you address this issue.
Best regards,
Paul
-----Original Message-----
From: opencms-dev-bounces at opencms.org [mailto:opencms-dev-bounces at opencms.org] On Behalf Of Andreas Zahner
Sent: 15. november 2013 14:00
To: opencms-dev at opencms.org
Subject: Re: [opencms-dev] How to prevent editors from removing span elements
Hi Paul-Inge,
the <span> Element might be removed by the automatic code cleanup of OpenCms. This is configured using the property "content-conversion". If the value of this property is set somewhere on the file or super folders to "cleanup", this removes some code, e.g. <span> elements.
Check if this property is set somewhere on your file or if it is inherited from a folder.
Unfortunately, I have currently no solution for the non breakable spaces.
Kind regards,
The Alkacon OpenCms Support Team
-------------------
Please make all OpenCms support inquiries by sending an email to 'opencms-support at alkacon.com'.
Alkacon Software GmbH - The OpenCms Experts An der Wachsfabrik 13
50996 Koeln, DE
Tel: +49 (0)2236 3826-22 [PIN required]
Fax: +49 (0)2236 3826-20
Email: opencms-support at alkacon.com
http://www.alkacon.com
http://www.opencms.org
Am 15.11.2013 12:23, schrieb Paul-Inge Flakstad:
> Hi everyone,
>
> I'm desperate for help, as I just realized TinyMCE also strips
> non-breaking space ( ), and more (e.g. °).
>
> This is a huge disappointment. First of all, we actually *need* those
> characters (if you can believe that). Secondly, we've spent much time
> painstakingly inserting these special characters where needed, in a
> lot of pages. Most of those pages have since been edited in TinyMCE
> because we're migrating to a newer version. Which means ... all that
> work is LOST ..!
>
> So - this is the *default* behavior of the *default* editor? No good,
> if you ask me. No good at all. Having an editor strip valid html
> without asking is wrong!
>
> I need to configure it to stop stripping stuff, or alternatively
> remove/disable TinyMCE. Is it possible? (How?)
>
> Best regards,
>
> Paul
>
> *From:*opencms-dev-bounces at opencms.org
> [mailto:opencms-dev-bounces at opencms.org] *On Behalf Of *Paul-Inge
> Flakstad
> *Sent:* 16. oktober 2013 11:10
> *To:* The OpenCms mailing list
> *Subject:* [opencms-dev] How to prevent editors from removing span
> elements
>
> Hi,
>
> Where/how can I tell the editor(s) to leave my spans alone (and
> possibly other elements as well)? TinyMCE and FCKEditor are by default
> both stripping away perfectly valid span elements from the content.
> Terribly annoying.
>
> My OpenCms version is 8.5.
>
> Cheers,
>
> Paul
>
>
>
> _______________________________________________
> This mail is sent to you from the opencms-dev mailing list To change
> your list options, or to unsubscribe from the list, please visit
> http://lists.opencms.org/cgi-bin/mailman/listinfo/opencms-dev
>
>
>
_______________________________________________
This mail is sent to you from the opencms-dev mailing list To change your list options, or to unsubscribe from the list, please visit http://lists.opencms.org/cgi-bin/mailman/listinfo/opencms-dev
More information about the opencms-dev
mailing list