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.

Issue fork ace_editor-2999328

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

Marty2081 created an issue. See original summary.

henrijs.seso’s picture

Category: Feature request » Bug report

This is not a feature, it's a bug.

interdruper’s picture

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

harlor’s picture

Status: Active » Needs review

@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)

rajab natshah’s picture

Version: 8.x-1.x-dev » 2.0.x-dev

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

rajab natshah’s picture

Status: Needs review » Needs work

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

mortona2k’s picture

Is 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.

mortona2k’s picture

r_cheh’s picture

StatusFileSize
new1.16 KB

I've just added settings via attributes to make it unique per wrapper, and it works

rajab natshah’s picture

Status: Needs work » Needs review
mortona2k’s picture

I 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):

Warning: Undefined array key "syntax_field" in Drupal\ace_editor\Plugin\Field\FieldFormatter\AceFormatter->settingsForm() (line 173 of modules/contrib/ace_editor/src/Plugin/Field/FieldFormatter/AceFormatter.php).

Warning: Undefined array key "modelist" in Drupal\ace_editor\Plugin\Field\FieldFormatter\AceFormatter->settingsForm() (line 180 of modules/contrib/ace_editor/src/Plugin/Field/FieldFormatter/AceFormatter.php).

Warning: Undefined array key "inline" in Drupal\ace_editor\Plugin\Field\FieldFormatter\AceFormatter->settingsForm() (line 186 of modules/contrib/ace_editor/src/Plugin/Field/FieldFormatter/AceFormatter.php).

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.

rajab natshah’s picture

Status: Needs review » Fixed

Merged as 9ccdf8e via !15 — credit to Andrew Morton and Dominik Wille, whose per-field design and syntax-field feature this is built on.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

rajab natshah’s picture

Issue tags: +ace_editor-2.0.4

✅ Released ace_editor-2.0.4