fix: #3618752 Stop the option lists leaking into settings and attach with configuration from any source

Issue: https://www.drupal.org/project/ace_editor/issues/3618752

Two defects found while testing a fresh install, both in the settings path:

1. The editor never attached when its configuration came from anywhere but the format form. AceEditor::getJsSettings() read $settings['fieldset'] unguarded while buildConfigurationForm() already handled both shapes, so configuration created by a recipe, a config import, or an older release handed the JavaScript editorSettings: null. The browser then threw TypeError: Cannot read properties of null (reading 'theme') and the plain textarea stayed in place. Reproduced on a fresh Drupal 11.4.5 site. Now both shapes are accepted and missing keys are completed from the defaults; the JavaScript also falls back to sane values instead of throwing.

2. The theme and syntax option lists leaked into saved configuration. AceEditor::getDefaultSettings() and AceFormatter::defaultSettings() returned the whole module configuration, including theme_list (34 entries) and syntax_list (140 entries). Drupal merges plugin defaults into the saved entity, so every editor and every view display saved outside the settings form persisted both maps - bloating exported configuration and breaking its schema. Both methods now return only the actual settings.

Also adds the configuration schemas the tests proved missing: editor.settings.ace_editor (issue #3605370, credit to nakazasora for the diagnosis in !24) and field.formatter.settings.ace_formatter, factored into a shared ace_editor.editor_settings type so the key list is defined once instead of three times, and declaring both the nested and the flat shape.

Tests: AceEditorJsSettingsTest - nested settings, flat settings, empty settings falling back to defaults, partial settings completed, and the option lists absent from saved configuration. Verified locally: kernel+unit suite 19 tests / 35 assertions green, PHPStan clean, PHPCS clean, full local pipeline green (cspell, eslint, MkDocs, 12/12 functional scenarios).

Sequencing: this builds on the hook conversion in !27 (merged) (issue #3594544); land that first.

AI-Generated: Yes

Checkpoints:

  • File an issue
  • Addition/Change/Update/Fix
  • Testing to ensure no regression
  • Automated unit testing coverage
  • Automated functional testing coverage
  • UX/UI designer responsibilities
  • Readability
  • Accessibility
  • Performance
  • Security
  • Developer Documentation
  • User Guide Documentation
  • Reviewed by human
  • Code review by maintainers
  • Full testing and approval
  • Credit contributors
  • Review with the product owner
  • Release notes snippet
  • Release
Edited by Rajab Natshah

Merge request reports

Loading