Skip to content

3236361: Do not overwrite js settings data per filter method invocation.

This PR addresses the issues described in #3236361 by creating $js_settings as a static variable which can be appended to on subsequent AceFilter > process method invocations on a given page load, ensuring that multiple paragraphs will render their code snippets on the same page.

It also edits the $element_id variable assignment to use php's uniqid() function instead of an array key, which ends up being repeated in this use case of paragraph fields.

To Test

  1. Install this module and the paragraphs module.
  2. Create a text format that only uses the filter provided by this module and does not use the wysiwyg editor.
  3. Create a new paragraph that contains a formatted text field that includes your new text format.
  4. Create a node bundle that has a entity reference revisions field, allow references to the paragraph type that you created.
  5. Create a node of the new bundle you created.
  6. In your paragraphs field, add multiple paragraphs and add a code snippet to each paragraph (ie. <ace syntax="HTML"><p>Test snippet 1/2/3</p></ace>)
  7. Save and view the page
  • Observe all paragraphs render content and are styled as a code snippet.
  • Open your dev tools > console and inspect the drupalSettings.ace_filter.instances array and observe there are multiple instances.

Closes #3236361

Edited by Jes Constantine

Merge request reports

Loading