magento2 icon indicating copy to clipboard operation
magento2 copied to clipboard

In WYSIWYG editor, i tags with class but no content are removed.

Open LiamKarlMitchell opened this issue 5 years ago • 24 comments

Summary (*)

These are used for icons to be shown in some blocks/content and so editing the content causes the icons to be removed.

It probably removes empty spans as well but I have not tried this yet.

Duplicate of #21602 which was closed for no reason. https://github.com/magefan/module-wysiwyg-advanced/issues/13

Preconditions

Magento 2.3.0 Magento 2.4-develop

Examples (*)

Steps to Reproduce

Edit a block or page content in the source edit.

<i class="icon-paperclip"></i>

Click show editor. Click hide editor.

Actual Result

And its gone... peek

Expected Result

Tag is not removed

Another example

Test
<i class="footer-icon icon-line-clock"></i>
Test

Becomes

<p>Test Test</p>

You can hack around it with an html comment as content such as

<i class="icon-paperclip"><!-- icon --></i>

But then it gets changed into an em.

<em class="icon-paperclip"><!-- icon --></em>

Font awesome for example uses i tags. In my case, WeltPixel Pearl theme uses i tags, especially their example content that is imported with the theme which we just want to edit/tweak as needed.

Proposed solution

Keep tags if they have no content when there are classes or attributes set. Maybe this should only apply to some tags such as a, i, div, span?

Perhaps not p tags as TinyMCE if I recall litters them all over the place and the removal of empty elements was made to clean up such issues, best if can consider i and span tags as non empty when they have class.


  • [ ] Severity: S0 - Affects critical data or functionality and leaves users with no workaround.
  • [x ] Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • [ ] Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • [ ] Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • [ ] Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.

LiamKarlMitchell avatar Jun 12 '20 04:06 LiamKarlMitchell

Hi @LiamKarlMitchell. Thank you for your report. To help us process this issue please make sure that you provided the following information:

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • Expected and actual results

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, please, review the Magento Contributor Assistant documentation.

Please, add a comment to assign the issue: @magento I am working on this


m2-assistant[bot] avatar Jun 12 '20 04:06 m2-assistant[bot]

@magento give me 2.4-develop instance

LiamKarlMitchell avatar Jun 12 '20 06:06 LiamKarlMitchell

Hi @LiamKarlMitchell. Thank you for your request. I'm working on Magento 2.4-develop instance for you

magento-engcom-team avatar Jun 12 '20 06:06 magento-engcom-team

Hi @LiamKarlMitchell, here is your Magento instance. Admin access: https://i-28698-2-4-develop.instances.magento-community.engineering/admin_eb47 Login: 2c8b8d46 Password: be56a0e9582a Instance will be terminated in up to 3 hours.

magento-engcom-team avatar Jun 12 '20 06:06 magento-engcom-team

@magento Confirmed on 2.4-develop image

Entered in the content in source editor.

<p>CMS homepage content goes here.</p>
<p>Icon should be here: <i class="footer-icon icon-line-clock"></i></p>

Click the Show / Hide editor, wait a moment. image

Click the Show / Hide editor again to go back to source editor. image

Content lacks the "icon" element.

<p>CMS homepage content goes here.</p>
<p>Icon should be here:</p>

LiamKarlMitchell avatar Jun 12 '20 06:06 LiamKarlMitchell

Issue: Confirmed

LiamKarlMitchell avatar Jun 12 '20 06:06 LiamKarlMitchell

This is because somehow not an entirely recognized html tag by tinymce. And tinymce also remove an empty html tag because it's "empty".

At this moment I am using <em class="fa">&nbsp;</em> this should work just fine.

laurnts avatar Jun 23 '20 07:06 laurnts

HI Guys not sure if this helps i past in code for a sales template which i always used in M1 no issue. But in M2 50 lines are stripped out which screws up my listing template Actual Script Pasted into Policy.txt M2E Stripped Out from Policy.txt

Is there a fix to stop this occurring

thorrrr avatar Jul 07 '20 10:07 thorrrr

This an issue for me on 2.3.5p2 It is a common problem might be useful https://github.com/claviska/tinymce-iconfonts

Or perhaps

tinyMCE.init({ // ... extended_valid_elements : '[]', });

danielpugh avatar Oct 08 '20 20:10 danielpugh

following last post i have installed the tinymce plugin mentioned above (tinymce-iconfonts) and it allows me to use e.g. font-awesome immediately. had to edit file to add plugin as per here - https://devdocs.magento.com/guides/v2.4/ui_comp_guide/components/wysiwyg/configure-tinymce-editor.html

added plugin to this file /vendor/magento/module-cms/Model/Wysiwyg/DefaultConfigProvider.php then uploaded the two files and deployed static content (finding location took some time, but hint on the tinymce page which shows the location it is expecting file)

danielpugh avatar Oct 09 '20 09:10 danielpugh

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 14 days if no further activity occurs. Is this issue still relevant? If so, what is blocking it? Is there anything you can do to help move it forward? Thank you for your contributions!

stale[bot] avatar Jan 29 '21 02:01 stale[bot]

Yes still a problem stale bot.

LiamKarlMitchell avatar Jan 29 '21 10:01 LiamKarlMitchell

Hi @engcom-Bravo. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

  • [ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.

  • [ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • [ ] 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • [ ] 4. Verify that the issue is reproducible on 2.4-develop branch

    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • [ ] 5. Add label Issue: Confirmed once verification is complete.

  • [ ] 6. Make sure that automatic system confirms that report has been added to the backlog.

m2-assistant[bot] avatar Jan 29 '21 11:01 m2-assistant[bot]

:white_check_mark: Confirmed by @engcom-Bravo Thank you for verifying the issue. Based on the provided information internal tickets MC-40681 were created

Issue Available: @engcom-Bravo, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

magento-engcom-team avatar Jan 29 '21 11:01 magento-engcom-team

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 14 days if no further activity occurs. Is this issue still relevant? If so, what is blocking it? Is there anything you can do to help move it forward? Thank you for your contributions!

stale[bot] avatar Apr 15 '21 13:04 stale[bot]

Posting a comment. Issues should not be automatically closed.

dverkade avatar Apr 18 '21 20:04 dverkade

There really should be a "built in" way to extend the tinymce options as part of setting up a Magento 2 site.

Currently it warns that things like aria, role etc won't be allowed (why? I would like my CMS content to be as accessibility tagged properly!

And adding icons without having to nbsp them...

iphigenie avatar Apr 25 '21 09:04 iphigenie

following last post i have installed the tinymce plugin mentioned above (tinymce-iconfonts) and it allows me to use e.g. font-awesome immediately. had to edit file to add plugin as per here - https://devdocs.magento.com/guides/v2.4/ui_comp_guide/components/wysiwyg/configure-tinymce-editor.html

added plugin to this file /vendor/magento/module-cms/Model/Wysiwyg/DefaultConfigProvider.php then uploaded the two files and deployed static content (finding location took some time, but hint on the tinymce page which shows the location it is expecting file)

Thanks to @danielpugh 's hints I dabbled a minimal implementation to integrate https://github.com/claviska/tinymce-iconfonts and at first glance it's working - though if I missed something someone please shout :)

my module is Alpine/AlpineCustom

js plugin files uploaded to lib/web/tiny_mce_4/plugins/iconfonts

a di.xml for adminhtml

        <plugin name="Alpine_AlpineCustom" type="Alpine\AlpineCustom\Plugin\Model\Cms\ExtendDefaultConfigProvider" />
    </type>

the plugin ExtendDefaultConfigProvider.php

namespace Alpine\AlpineCustom\Plugin\Model\Cms;
use Magento\Cms\Model\Wysiwyg\DefaultConfigProvider;

class ExtendDefaultConfigProvider 
{
/**
 * @param \Magento\Cms\Model\Wysiwyg\DefaultConfigProvider $subject
 * @param \Magento\Framework\DataObject $result
 * @return \Magento\Framework\DataObject $result
 * @SuppressWarnings(PHPMD.UnusedFormalParameter)
 */
    public function afterGetConfig(\Magento\Cms\Model\Wysiwyg\DefaultConfigProvider $subject, \Magento\Framework\DataObject $result)
    {
        $plugins = "". $result['tinymce4']['plugins'] ;
        $tinymceconfig = $result['tinymce4'];
        $tinymceconfig['plugins'] = $plugins  .' iconfonts';
        $result['tinymce4'] = $tinymceconfig;
        return $result;
    }
}

seems to allow i to stay empty, but alas it "eats" the style tag so modern fontawesome options arent possible - I mean it's an old plugin!

Definitely going to look at extending tinymce configuration to allow more tags as per https://github.com/magento/community-features/issues/326

iphigenie avatar Apr 25 '21 23:04 iphigenie

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 28 days if no further activity occurs. Is this issue still relevant? If so, what is blocking it? Is there anything you can do to help move it forward? Thank you for your contributions!

stale[bot] avatar Sep 25 '21 14:09 stale[bot]

@stalebot this is still a problem

Meberem avatar Sep 28 '21 09:09 Meberem

Hi @LiamKarlMitchell,

Thanks for your reporting and collaboration.

We have verified the issue in Latest 2.4-develop instance and the issue is reproducible.Kindly refer the attached video.

https://github.com/magento/magento2/assets/51680745/b6e73b97-647b-4a43-833c-8abead9bfc04

Tags getting removed.

Hence Confirming the issue.

Thanks.

engcom-Bravo avatar Jun 27 '24 04:06 engcom-Bravo

Yep its been an issue for years, no traction

LiamKarlMitchell avatar Jun 27 '24 04:06 LiamKarlMitchell

:white_check_mark: Jira issue https://jira.corp.adobe.com/browse/AC-12301 is successfully created for this GitHub issue.

github-jira-sync-bot avatar Jun 27 '24 05:06 github-jira-sync-bot

:white_check_mark: Confirmed by @engcom-Bravo. Thank you for verifying the issue.
Issue Available: @engcom-Bravo, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

m2-assistant[bot] avatar Jun 27 '24 05:06 m2-assistant[bot]