Open iphigenie opened 3 years ago
Hi @iphigenie. Thank you for your report. To help us process this issue please make sure that you provided sufficient information.
Please, add a comment to assign the issue: @magento I am working on this
am looking at extending first through a module to test, then I'll submit an extension to DefaultConfigProvider et al
my module is Alpine/AlpineCustom but it'd go in CMS I suppose.
I couldn't find anything preset for extended_valid_elements for CMS (it exists for attribute editor form) but I'm going to check deeper - the idea should be to have a config that allows choosing?
js plugin files uploaded to lib/web/tiny_mce_4/plugins/iconfonts
a di.xml for adminhtml
<type name="Magento\Cms\Model\Wysiwyg\DefaultConfigProvider">
<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)
{
$tinymceconfig = $result['tinymce4'];
$extendeds ='';
if (array_key_exists('extended_valid_elements', $result['tinymce4'])) {
$extendeds = $result['tinymce4']['extended_valid_elements'];
}
...... do something ....
$result['tinymce4'] = $tinymceconfig;
return $result;
}
}
This property used previously for Tinymce3 and now magento core still use it for init tinymce form in backend. I think this point allow we add element we can use in wysiwyg tinymce.
But in tinymce4 used in magento 2.3+ you also can use extended_valid_elements
or invalid_elements
. Default magento not allow you add these property in js but you can add some mixins or override js file below in your module
https://github.com/magento/magento2/blob/2.4-develop/lib/web/mage/adminhtml/wysiwyg/tiny_mce/tinymce4Adapter.js#L195
Imho this feature should be fix/deliver to the codebase soon. Current as frontend we can't add valid html anchor link wrap around >div. After save this format broken (bug remain 5 years with no fix)
Current we have some solutions from external repo https://github.com/betagento/Editor https://github.com/magefan/module-wysiwyg-advanced
TOPIC: what should wysiwyg allow?
I am increasingly getting warnings that wysiwyg is "temporarily" allowing certain tags, and this of course worries me that at some point these will get locked out.
One option is that this is made extensible/editable in an official, documented manner (that isn't overwritten by releases), the other option is to have a discussion and get these lists extended?
missing tags - these seem harmless why aren't they in?
blockquote / q for quotes abbr / cite for references (semantic/machine readable/accessibility) code / pre for unformatted details / summary for a hide/show mechanism in the browser dl dd dt figcaption for figure (accessibility) picture (for responsive) del / s / ins for text removed/ added that needs to remain visible as such (legal requirements in some parts) mark (for highlighter) small, sub, sup thead / caption for table (they improve accessibility!) data - for structured data/search engine enhancements col colgroup section article aside - document structure
svg - ok that's probably more complicated
should be allowed in every tag:
aria tags - some of us try to keep things accessible
making sense in static wysiwyg
role aria-colcount aria-colindex aria-rowcount aria-rowindex aria-colspan aria-rowspan aria-details aria-expanded aria-flowto aria-hidden aria-label aria-level aria-roledescription
specific combinations