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

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

Open
4 tasks
LiamKarlMitchell opened this issue Jun 12, 2020 · 24 comments
Open
4 tasks
Labels
Area: Content Component: Tinymce Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P3 May be fixed according to the position in the backlog. Progress: ready for dev Reported on 2.3.0 Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch

Comments

@LiamKarlMitchell
Copy link

LiamKarlMitchell commented Jun 12, 2020

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.
magefan/module-wysiwyg-advanced#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 LiamKarlMitchell added the Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it label Jun 12, 2020
@m2-assistant
Copy link

m2-assistant bot commented Jun 12, 2020

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


@magento-engcom-team magento-engcom-team added the Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed label Jun 12, 2020
@LiamKarlMitchell
Copy link
Author

@magento give me 2.4-develop instance

@magento-engcom-team
Copy link
Contributor

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

@magento-engcom-team
Copy link
Contributor

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.

@LiamKarlMitchell
Copy link
Author

LiamKarlMitchell commented Jun 12, 2020

@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
Copy link
Author

Issue: Confirmed

@laurnts
Copy link

laurnts commented Jun 23, 2020

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.

@thorrrr
Copy link

thorrrr commented Jul 7, 2020

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

@danielpugh
Copy link

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
Copy link

danielpugh commented Oct 9, 2020

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)

@ghost ghost added Issue: ready for confirmation and removed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed labels Oct 21, 2020
@magento-engcom-team magento-engcom-team added the Reported on 2.3.0 Indicates original Magento version for the Issue report. label Nov 13, 2020
@stale
Copy link

stale bot commented Jan 29, 2021

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 stale bot added the stale issue label Jan 29, 2021
@LiamKarlMitchell
Copy link
Author

Yes still a problem stale bot.

@stale stale bot removed the stale issue label Jan 29, 2021
@engcom-Bravo engcom-Bravo self-assigned this Jan 29, 2021
@m2-assistant
Copy link

m2-assistant bot commented Jan 29, 2021

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: 👇

  • 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.

@engcom-Bravo engcom-Bravo added Component: Tinymce Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch labels Jan 29, 2021
@stale
Copy link

stale bot commented Apr 15, 2021

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 stale bot added the stale issue label Apr 15, 2021
@dverkade
Copy link
Member

Posting a comment. Issues should not be automatically closed.

@stale stale bot removed the stale issue label Apr 18, 2021
@iphigenie
Copy link

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
Copy link

iphigenie commented Apr 25, 2021

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 magento/community-features#326

@stale
Copy link

stale bot commented Sep 25, 2021

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 stale bot added the stale issue label Sep 25, 2021
@Meberem
Copy link

Meberem commented Sep 28, 2021

@stalebot this is still a problem

@stale stale bot removed the stale issue label Sep 28, 2021
@engcom-Bravo engcom-Bravo removed Progress: ready for dev Severity: S3 Affects non-critical data or functionality and does not force users to employ a workaround. Issue: ready for confirmation Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed labels Jun 27, 2024
@engcom-Bravo
Copy link
Contributor

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.

Screen.Recording.2024-06-27.at.10.03.38.mov

Tags getting removed.

Hence Confirming the issue.

Thanks.

@engcom-Bravo engcom-Bravo added Area: Content Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed labels Jun 27, 2024
@LiamKarlMitchell
Copy link
Author

Yep its been an issue for years, no traction

@github-jira-sync-bot
Copy link

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

Copy link

m2-assistant bot commented Jun 27, 2024

✅ 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Content Component: Tinymce Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P3 May be fixed according to the position in the backlog. Progress: ready for dev Reported on 2.3.0 Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch
Projects
None yet
Development

No branches or pull requests

10 participants