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
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions administrator/language/en-GB/en-GB.plg_editors_tinymce.ini
Expand Up @@ -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."

PLG_TINY_FIELD_PASTE_CLEAN_UP_LABEL="Clean up on paste"
PLG_TINY_FIELD_PRINT_DESC="Turn on/off the print and print preview icons in the editor. Only works in Extended mode."
PLG_TINY_FIELD_PRINT_LABEL="Print/Preview"
PLG_TINY_FIELD_PROHIBITED_DESC="Elements that will be cleaned from the text. Do not leave empty - if you do not want to prohibit anything enter dummy text e.g.cms"
Expand Down
21 changes: 20 additions & 1 deletion plugins/editors/tinymce/tinymce.php
Expand Up @@ -387,6 +387,23 @@ public function onInit()
$toolbar4_add[] = 'paste';
}

// Clean up on paste
$clean_up = $this->params->get('paste_clean_up', 0);

if ($clean_up)
{
if (!$paste)
{
$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

$clean_up_param = 'paste_auto_cleanup_on_paste: true,';
}
else
{
$clean_up_param = '';
}

$toolbar4_add[] = '|';

// Visualchars
Expand Down Expand Up @@ -627,9 +644,10 @@ public function onInit()
extended_valid_elements : \"$elements\",
$forcenewline
$smallButtons
$clean_up_param
invalid_elements : \"$invalid_elements\",
// Plugins
plugins : \"table link image code charmap autolink lists importcss\",
plugins : \"table link image code charmap autolink lists importcss $clean_up_plugin\",
// Toolbar
toolbar1: \"$toolbar1\",
toolbar2: \"$toolbar2\",
Expand Down Expand Up @@ -671,6 +689,7 @@ public function onInit()
extended_valid_elements : \"$elements\",
$forcenewline
$smallButtons
$clean_up_param
invalid_elements : \"$invalid_elements\",
// Plugins
plugins : \"$plugins\",
Expand Down
10 changes: 10 additions & 0 deletions plugins/editors/tinymce/tinymce.xml
Expand Up @@ -182,6 +182,16 @@
<option value="0">JOFF</option>
</field>

<field name="paste_clean_up" type="radio"
class="btn-group btn-group-yesno"
default="0"
description="PLG_TINY_FIELD_PASTE_CLEAN_UP_DESC"
label="PLG_TINY_FIELD_PASTE_CLEAN_UP_LABEL"
>
<option value="1">JON</option>
<option value="0">JOFF</option>
</field>

<field name="spacer" type="spacer" class="text"
label="PLG_TINY_FIELD_NAME_EXTENDED_LABEL"
/>
Expand Down