The configuration of the AceFormatter field formatter is put in the drupalSettings globally: drupalSettings.ace_formatter. This causes multiple fields using the same formatter, but with different settings not to work properly.
For instance I have two fields on a node. One setup for PHP and the other for CSS. Both fields are in the output with PHP highlighting, since the first has already added the setting "syntax: php" to the drupalSettings.
You might need to add a field-identifier to the settings object to be able to split the configuration per field and get the proper configuration for each field in the JavaScript that inits the editor.
| Comment | File | Size | Author |
|---|---|---|---|
| #13 | 2999328-support-multiple-fields-v3.patch | 1.16 KB | r_cheh |
Issue fork ace_editor-2999328
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 #2
henrijs.seso commentedThis is not a feature, it's a bug.
Comment #3
interdruper commentedPlease, check if commit https://www.drupal.org/commitlog/commit/32780/f9a7e8fdacd04d9d84b01e8c418a299ecfe9ca80 in the latest dev fixes your issue.
Comment #6
harlor commented@interdruper, Are you sure these issues are related?
We tried to introduce an optional syntax field setting that can be used to specify a field that determines the syntax (programming language).
See https://git.drupalcode.org/project/ace_editor/-/merge_requests/2/diffs
Note: I reverted the defaultSettings method to avoid a WSOD. (https://www.drupal.org/project/ace_editor/issues/3271278)
Comment #7
rajab natshahNeeds an updated issue fork and MR for the
2.0.xbranchComment #8
rajab natshahComment #11
mortona2k commentedIs this for the field widget, or display formatter?
I have a form with fields for HTML, CSS, and JS, all configured with Ace editor and corresponding syntax.
When the form is loaded, it fails to load both CKEditor and Ace Editor at the same time.
If I select one of the Ace editors for the body field, so they all use it, it works when I refresh the page.
Comment #12
mortona2k commentedThis patch fixed my problem above: https://www.drupal.org/project/drupal/issues/3496329#comment-15923800
Was related to: https://www.drupal.org/project/ace_editor/issues/3499338
Comment #13
r_cheh commentedI've just added settings via attributes to make it unique per wrapper, and it works
Comment #14
rajab natshahComment #15
mortona2k commentedI did a quick check on having different formats and it seems to be working.
When I save the display settings, I see these warnings (drupal 10.6):
I see these are new settings for the formatter, but I haven't tried them yet.
I read through the code and don't see any glaring issues, however I didn't study it too closely.
Comment #18
rajab natshahMerged as 9ccdf8e via !15 — credit to Andrew Morton and Dominik Wille, whose per-field design and syntax-field feature this is built on.
Comment #20
rajab natshah✅ Released ace_editor-2.0.4