magento / community-features

Magento Features Development is an Initiative to Allows Community Memebers Join to Development of Magento Features
46 stars 18 forks source link

Adding support for newlines characters to the Wysiwyg widget plugin regex #185

Open simonlandry0 opened 4 years ago

simonlandry0 commented 4 years ago

Pulling my old issue from https://github.com/magento/magento2/issues/23571

Description (*)

The Magento Wysiwyg plugin for tinymce4 does not detect a widget when it has a new line in the data because of a regex. Changing this regex would add support for textarea inputs and other inputs which might have a newline in widgets.

https://github.com/magento/magento2/blob/2.3-develop/lib/web/mage/adminhtml/wysiwyg/tiny_mce/plugins/magentowidget/editor_plugin.js#L126

This regex should be changed: (old) return content.gsub(/\{\{widget(.*?)\}\}/i, function (match) { (suggested) return content.gsub(/\{\{widget([^}]*?)\}\}/i, function (match) {

Expected behavior (*)

Wysiwyg widgets should not break with newline characters in the text data.

Benefits

Would allow for widgets with data that have newlines inside them. Currently the base installation of Magento does not have any widget inputs that can have newlines in them, but would add room for developers to create their own textarea/wysiwyg inputs.

Additional information