widgetfactory / jce

JCE - A Content Editor for Joomla
https://www.joomlacontenteditor.net
GNU General Public License v2.0
35 stars 12 forks source link

When pasting from WORD, editor removes ALL classes (derived from WORD styles), not just mso classes. #31

Closed davidascherG closed 7 years ago

davidascherG commented 7 years ago

This behavior seems to have begun with JCE v2.6.10. Looking at the code I can see that the parameter "clipboard_paste_strip_class_attributes" is not referenced anyplace in the tinymce js code although there is still php code to set the variable and to retrieve its value. This looks like whoever updated the clipboard plugin from v2.6.9 did not exactly understand the correct behavior - that is that any STYLE defined in WORD should or should not be preserved as an HTML CLASS on paste, depending upon the value of the clipboard_paste_strip_class_attributes parameter.

Since the code does not check the value of the clipboard_paste_strip_class_attributes parameter at all, it clearly cannot perform the paste operation according to the value specified in the configuration and saved in the database. Joomla 3.7.5, JCE 2.6.10-19 , Chrome Version 61.0.3163.91 (Official Build) (64-bit), Firefox Nightly 56.0a1 (2017-07-22) (64-bit) Sample WORD docx file is attached Thursday.docx

ryandemmer commented 7 years ago

When pasting content from Word, the intention is to clean and restructure the content in such a way as to create valid HTML that is useable within the context of the Content Management System, not to create an identical version of the original Word document (If this is the intention, other methods of displaying the document, such as embedding in an iframe, may be more suitable)

Internal classes used by Word, such as those prefixed with "Mso", are not transferable, as they rely on additional css classes which are not pasted with the article content.

With this in mind, all classes will be removed from content pasted from Word in future, regardless of the clipboard_paste_strip_class_attributes setting.

I will look at the possibility in future of attempting to keep some of these styles, where they are explicitly use to style content (such as the Design styles included in Word), rather than structure it (which appears to be the role of the "Mso" classes.)

davidascherG commented 6 years ago

I am in awe of the skill and imagination that must go into creating and maintaining JCE Editor. However, I am totally puzzled by the unannounced (nothing I could find in the changelog) change in this behavior in JCE Editor which I have depended on since I began using Joomla and JCE over ten years ago.

You write as if stripping out all classes from pasting a WORD document is the 'correct' thing to do, however, the JCE Editor DID NOT strip out all classes from WORD docs until v2.6.10. AND you still have the configuration option in the profile/clipboard plugin page for "Strip Class Attributes". And the plugin code still retrieves the parameter... Why bother if you think that all class attributes should be stripped out of content pasted from a Word doc? and Why was it OK to not strip those class attributes for the versions prior to v2.6.10??

On Sep 16, 2017 6:01 AM, "Ryan Demmer" notifications@github.com wrote:

When pasting content from Word, the intention is to clean and restructure the content in such a way as to create valid HTML that is useable within the context of the Content Management System, not to create an identical version of the original Word document (If this is the intention, other methods of displaying the document, such as embedding in an iframe, may be more suitable)

Internal classes used by Word, such as those prefixed with "Mso", are not transferable, as they rely on additional css classes which are not pasted with the article content.

With this in mind, all classes will be removed from content pasted from Word in future, regardless of the clipboard_paste_strip_class_attributes setting.

I will look at the possibility in future of attempting to keep some of these styles, where they are explicitly use to style content (such as the Design styles included in Word), rather than structure it (which appears to be the role of the "Mso" classes.)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/widgetfactory/jce/issues/31#issuecomment-329958983, or mute the thread https://github.com/notifications/unsubscribe-auth/AJOtNunybhAqPgVH35n__813-Wbh9W4Hks5si5yPgaJpZM4PZk_J .

ryandemmer commented 6 years ago

I have added a new "Only from Word/Office Content" option to the "Strip Class Attributes" option in the next update

https://github.com/widgetfactory/jce/commit/4c3ec0c8b525aced0df8e388821398f1b5c9708a

davidascherG commented 6 years ago

I am not entirely clear what you mean by adding that new option. I would like to think that this will allow classes (defined as styles in Word) to be preserved on paste... i.e. the same behavior that existed in v2.6.9.

However, looking at the modifications you have made in github, I am unable to see exactly what you are going to do...

In v2.6.9 the mso classes are stripped regardless of the setting of the "Strip class attributes" parameter. In (much) older versions mso classes were preserved AND WORD user defined styles (i.e. those NOT begining with "mso-" were also preserved. That (latter) behavior would be what I would prefer to see - but I have already instructed my clients to make accomodations for that - i.e. don't use any built-in styles in their WORD docs. That worked okay for them until v2.6.10.

Can I access a pre-release version of the new release so I can see what it does?

thanks again for your invaluable editor and for dealing with this issue,

Dave Ascher

On Sep 18, 2017 4:39 AM, "Ryan Demmer" notifications@github.com wrote:

I have added a new "Only from Word/Office Content" option to the "Strip Class Attributes" option in the next update

4c3ec0c https://github.com/widgetfactory/jce/commit/4c3ec0c8b525aced0df8e388821398f1b5c9708a

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/widgetfactory/jce/issues/31#issuecomment-330158949, or mute the thread https://github.com/notifications/unsubscribe-auth/AJOtNgJ8rFOtGFwHcttNpYUPoq7yF1Nyks5sjixLgaJpZM4PZk_J .

ryandemmer commented 6 years ago

When setting the option to No, then all the classes are preserved (except mso classes).

The new option allows the removal of all classes in Word only, while preserving them in other pasted content.

davidascherG commented 6 years ago

That sounds like what I was hoping for. However, when I examine the code on github, I see parameters but I don't see changes to the clipboard plugin. I'm far from expert when it comes to github, so maybe I am looking in the wrong places? or have you not yet written the changes to the clipboard plugin code?

I probably should have explained that my clients use a set of pre-agreed upon WORD user-defined styles for which the site's CSS is defined for the corresponding class. So if a user-defined paragraph style we agree they will use is named "byline", the site's CSS has entries for "p.byline". That makes it easy for the writers of the content to continue to use WORD (with which they are very familiar) and for the look of the site to be easily modified by changing the CSS. If the site owner wants to change the bylines on all the articles so they are italic ... obviously, changing the CSS does the job.

My offer to Beta test still stands.

Thank you.


From: Ryan Demmer [mailto:notifications@github.com] Sent: Monday, September 18, 2017 9:04 AM To: widgetfactory/jce Cc: Dave Ascher; Author Subject: Re: [widgetfactory/jce] When pasting from WORD, editor removes ALL classes (derived from WORD styles), not just mso classes. (#31)

When setting the option to No, then all the classes are preserved (except mso classes).

The new option allows the removal of all classes in Word only, while preserving them in other pasted content.

- You are receiving this because you authored the thread. Reply to this email directly, view https://github.com/widgetfactory/jce/issues/31#issuecomment-330212900 it on GitHub, or mute https://github.com/notifications/unsubscribe-auth/AJOtNlquOyRqY1ZVnwSDJSzDJ cm3b6_uks5sjmougaJpZM4PZk_J the thread. https://github.com/notifications/beacon/AJOtNnXBSBGXOmIGo9_zRRncX767ilF4ks5 sjmougaJpZM4PZk_J.gif