magento / magento/community-features

Adding support for newlines characters to the Wysiwyg widget plugin regex

Open
#185 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Priority: P2
Dominant language
No language data
Stars
46
Forks
14
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at lib/web/mage/adminhtml/wysiwyg/tiny_mce/plugins/magentowidget/editor_plugin.js around line 126 and inspect the widget-matching regex. Verify that widget data containing newline characters is recognized without breaking existing widget handling; done means multiline widget inputs work correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Feature
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.