magento2-module-pagebuildersourcecode icon indicating copy to clipboard operation
magento2-module-pagebuildersourcecode copied to clipboard

Re-add Magento Widget and Variable plugins

Open robaimes opened this issue 3 years ago • 0 comments

Closes #8

Saw this issue pop up somewhere on either LInkedIn or the Magento Slack and though I'd give it a crack. :sweat_smile:

This was a slightly annoying issue to track down, but the main things to understand is that by passing an item to the additionalSettings array, this will completely override the values that are present in the default config provider in some JavaScript just prior to TinyMCE initialisation.

  1. Default config provider declares configuration, which is then Magento'd into some javascript
  2. This ends up here and is initialized via pagebuilder
  3. This then ends up here in which the magento plugins are added to the toolbar (via this.config.tinymc4.toolbar)
  4. Later in the same function, if additionalSettings exists, the settings are merged here
  5. This then initialises TinyMCE with the merged settings here

At step 3 the config would work. However, since step 4 merged the config from additionalSettings the toolbar value is then replace with the 'hardcoded' value we provide via the di.xml entry.

So we're left with 2 options:

  1. Add magentowidget and magentovariable to the toolbar value in di.xml
    • This does mean this value will trump any plugins that may exist, and will require overriding in a module that is loaded after this one to change the toolbar configuration
  2. Write an after plugin on Magento\PageBuilder\Model\Wysiwyg\DefaultConfigProvider::getConfig to add code instead of passing it in via additionalSettings

I've opted for option 1 because that's the current implementation; and the module is simplistic in nature.

image

robaimes avatar Mar 01 '22 21:03 robaimes