Skip to content

Commit

Permalink
bug #5928 fix(trix): fix trix editor config loading (welcoMattic)
Browse files Browse the repository at this point in the history
This PR was merged into the 4.x branch.

Discussion
----------

fix(trix): fix trix editor config loading

Ref #5725

This PR change the listen event to boot TextEditorField. Before it listen on `DOMLoadedContent`. Now it listen on `trix-before-initialize` to be sure to handle the custom configuration and render properly a `heading1` element with a custom tagName `h2` for example.

If needed, I can add some tests to cover it.

Commits
-------

1f49189 fix(trix): fix trix editor config loading
  • Loading branch information
javiereguiluz committed Sep 18, 2023
2 parents 12cc0e9 + 1f49189 commit 850496e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion assets/js/field-text-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import Trix from 'trix/dist/trix';
// Provide Trix variable globally to allow custom backend pages to use it
window.Trix = Trix;

document.addEventListener('DOMContentLoaded', () => {
// Listening to the DOMLoadedContent event is too late because the Trix editor is already initialized.
// To be sure to handle properly the custom configuration, we have to to listen to the trix-before-initialize event.
document.addEventListener('trix-before-initialize', () => {
new TextEditorField();
});

Expand Down

0 comments on commit 850496e

Please sign in to comment.