I get the console error "Uncaught DOMException: Failed to execute 'importScripts' on 'WorkerGlobalScope': The script at 'https://www.site.ca/node/1/worker-html.js' failed to load." when using JS aggregation.

The ace editor still works, but I cannot do search, etc, in the editor.

Could be related to https://www.drupal.org/project/ace_editor/issues/2090921

Issue fork ace_editor-3326303

Command icon 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

jglynn created an issue. See original summary.

jglynn’s picture

angrytoast’s picture

Adding a patch for this bug that looks to work for both 1.4.0 and 2.0.0-alpha1 as of 2023-07-05.

It adds a general setup.js that calls ace.config.set('basePath') to make sure it has the value of the discovered library path from the module.

angrytoast’s picture

Status: Active » Needs review
angrytoast’s picture

A quick update to the previous patch in #3. Currently ace_editor_lib_path doesn't cache its discovered library path so it must run through the filesystem each time it is run. Because the patch adds a hook_page_attachments implementation to populate drupalSettings, it's helpful to cache the path for future use.

A better solution would be to introduce a service that can be used in both procedural code and the various plugins this module provides but that seems like a bigger refactor that should be tackled separately.

angrytoast’s picture

StatusFileSize
new3.38 KB

Following up again, here's a slightly different approach that limits the drupalSettings addition by not using hook_page_attachments. Instead it adds them in the respective plugin files so that it's only added when needed, which feels better.

That said, we only use the filter functionality. I can confirm it works there, but can't confirm for the AceFormatter use case. I'm also not familiar with editor plugins so the base_path isn't added there to drupalSettings and will need more work.

In summary:

  • Patch #5 should work in general across situations at the cost of adding drupalSettings.ace_editor.base_path to every page
  • Patch #6 should work for text filters, probably for field formatters, and not for editor plugins. More work need there.
rajab natshah’s picture

Version: 8.x-1.4 » 2.0.x-dev
Status: Needs review » Needs work

Needs an updated issue fork and MR for the 2.0.x branch

klaasvw made their first commit to this issue’s fork.

klaasvw’s picture

Status: Needs work » Needs review
StatusFileSize
new3.54 KB

I've pushed a MR again 2.0.x containing the changes from #5.

This version will only add the setting if one of the ace_editor libraries is loaded.

Also note that not only the Ace basePath is set but also the theme-, worker- and modePath.

psf_’s picture

Hi,

#10 works for me using "ace_editor" 2.0.1 on Drupal 10.3.10.

Before installing the patch, the "ace formatter" didn't display themes, and there was no syntax highlighting.