Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#33796] TinyMCE clean up on paste #3661

Closed
wants to merge 5 commits into from

Conversation

tQuant
Copy link
Contributor

@tQuant tQuant commented May 28, 2014

This PR adds "clean up on paste" option to TinyMCE settings. I think this is very basic and usefull settings.

For example, if you copy just 4 short string from MS Word document (attached to tracker item: http://joomlacode.org/gf/download/trackeritem/33796/159223/List%20for%20example.docx) to TinyMCE, then you will get plenty of garbage code: http://pastebin.com/7S43SQhC

If you apply PR and enable "clean up on paste" option, then when copying the same document to TinyMCE you will get this: http://pastebin.com/cwzE8Tqn

Tracker item

http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&tracker_item_id=33796&start=0

@tQuant tQuant changed the title TinyMCE clean up on paste [#33796] TinyMCE clean up on paste May 28, 2014
@@ -69,6 +69,8 @@ PLG_TINY_FIELD_PASTE_DESC="Show/Hide the Paste buttons. Only applies in Extended
PLG_TINY_FIELD_PASTE_LABEL="Paste"
PLG_TINY_FIELD_PATH_DESC="If set to ON, it displays the set classes for the marked text."
PLG_TINY_FIELD_PATH_LABEL="Element Path"
PLG_TINY_FIELD_PASTE_CLEAN_UP_DESC="If set to ON, the pasted code will be cleared and left only the tags."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean this? This to me reads the text is removed and the tags are kept. I don't think that's what you mean?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, text not removed. In fact it not jsut remove the styles, it replace some styles with tags and remove unnecessary tags. I'm trying to find the correct description of this function...
In the TinyMCE documentation about this function says simply "clean up", without details.

This description would suit?
"If enabled contents will be automatically cleaned up when you paste using Ctrl+V or similar methods."

{
$plugins[] = 'paste';
}
$clean_up_plugin = 'paste';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please review coding styles vs Joomla! Coding Standards .

A space is required after an if statement. Also for var names use camelCase. $clean_up should be $cleanUp and same for the rest of variables.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A space is required after an if statement

You mean empty line?

'$clean_up' should be '$cleanUp'

I will fix that, but all other variables in this file is in '$clean_up' style

@infograf768
Copy link
Member

Not sure about this patch:
Should not the default be to ON
It looks to me that one never wants to get the MSWord html mess, therefore should not it just be added as always true?

@tQuant
Copy link
Contributor Author

tQuant commented May 30, 2014

I totally agree with you, I'm just not familiar with the Joomla policy about changing the default behavior. And because in Joomla this feature is not used so far, then to not change habitual behavior, I turned off this option by default.
If you want, I can change it.

@infograf768
Copy link
Member

I see now better the issue in your patch:
You added the paste plugin in "Advanced mode" although we never include the plugin there

As we indeed only propose the paste plugin in Extended mode, this change

  •               plugins : \"table link image code charmap autolink lists importcss\",
    
  •               plugins : \"table link image code charmap autolink lists importcss $cleanUpPlugin\",
    

is useless
as well as the definitions for $cleanUpPlugin as the paste plugin will be loaded by

if (!$paste)
+           {
+               $plugins[] = 'paste';
``
+           }

Also please indeed default option to ON.

@tQuant
Copy link
Contributor Author

tQuant commented May 30, 2014

If I remove 'paste' plugin from "Advanced mode", then 'clean up' option will works only in "Extended mode".
So the question is: should it work in Simple and Advanced mode or only in Extended?
If it should work in Simple mode, then should I move option from 'Advanced' tab to main tab?

@dgrammatiko
Copy link
Contributor

Go for Simple and default ON 👍

@infograf768
Copy link
Member

As we use Paste only in extended mode, I guess we should implement clean up on paste there only.
This would be the most B/C imho

@ghost
Copy link

ghost commented May 31, 2014

@tested=OK

@tQuant
Copy link
Contributor Author

tQuant commented Jun 1, 2014

Ok, now 'clean up' option works only in extended mode. So to test it, you need to switch to extended mode.
I hope in newer versions of Joomla! (at least 4.0) we can turn on this option by default for all modes, since B/C there is not so important.

@tQuant
Copy link
Contributor Author

tQuant commented Jun 3, 2014

Incidentally, in the extended mode clean up happens without this PR (perhaps in another way). Therefore, if the use of cleaning up is not planned for the simple and advanced mode, this PR can be closed.

@infograf768
Copy link
Member

I suggest we discuss this on list

also, we just merged Tiny 4.0.28 version. Please test again with master

@tQuant
Copy link
Contributor Author

tQuant commented Jun 3, 2014

It seems that parameter 'paste_auto_cleanup_on_paste' not work in Tiny 4.
If 'paste' plugin is loaded then clean up on paste works, otherwise - not.

Changes necessary to add 'clean up' to extended mode only:
https://github.com/tQuant/joomla-cms/compare/cleanUpExtendedMode
To all modes:
https://github.com/tQuant/joomla-cms/compare/cleanUpAllModes

@zero-24
Copy link
Contributor

zero-24 commented Mar 13, 2015

@tQuant can you update your branche to staging?

@coolcat-creations
Copy link
Contributor

I have tested this item 🔴 unsuccessfully on 9c93fa0

Still stuff added like "" and on...


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/3661.

@brianteeman
Copy link
Contributor

I am closing this as it can not work
The code in this PR simply called a tinymce version 3 plugin
We are using tinymce 4 now and the plugins for tinymce and their syntax is different


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/3661.

@joomla-cms-bot joomla-cms-bot added the Language Change This is for Translators label Nov 12, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Language Change This is for Translators
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

10 participants