Problem/Motivation
The current implementation (9.1.x-beta7 and earlier) of JSON Editor in the module loads scripts and related assets for JSON Editor asynchronously via JavaScript instead of through attachments in the form render array when assembling the form. This method complicates both the JavaScript and server-side implementation by requiring the LibraryStream service to produce URLs for these assets to be exposed via JS settings, and the JS logic to parse these URLs and add them on the page.
Changes in the underlying systems for managing these assets also lead to maintenance issues like the one causing #3381549: JSON Editor theme assets do not load on Drupal 10.1.
Steps to reproduce
Proposed resolution
- Remove LibraryStream service
- Attach JSON Editor assets in form building process server-side
- Remove asynchronous asset loading logic from JS
Remaining tasks
User interface changes
API changes
Data model changes
None
Issue fork patternkit-3386854
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #4
krisahil CreditAttribution: krisahil at Red Hat commented@slucero, I started work to support these changes. The MR, as it stands now, loads the JSON Editor theme assets as a Drupal library, using
#attached
, instead of manually adding the scripts and styles to the DOM. On one site, this change has made loading the CSS and JS much more reliable (the manual method loaded CSS and JS in unpredictable order, which led to race conditions, evidenced in CKEditor 5 integration).Comment #5
sluceroThanks for getting this started @krisahil! I looked over the code so far and it all looks good. One thing I'd look into as part of this as well is whether we can remove the shadow dom versions and related checks altogether now that we've removed shadow dom support in the beta 9 release.