-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Loading Trix javascript after trix-editor
is in the DOM: Setting Trix.config.lang
does not set custom text in toolbar
#874
Comments
@woodhull I tested with that version! see original post |
@warsucks Interesting! I just tried to test this fix in a fork here, where I've run blade to rebuild the dist folder: Needed to fork the upstream repository to be able to recompile a new Unfortunately, its still not working for me in my test case. |
Trix.config.lang
does not set custom text in toolbartrix-editor
is in the DOM: Setting Trix.config.lang
does not set custom text in toolbar
Update: We have changed our implementation to get around this issue:
This fixes the issue where the text wasn't being set in time before the editor was rendered, on page loads where the script does run before the editor is rendered. This desired behavior occurs when we enter the page URL directly in the browser or refresh the page. However, we still run into the issue that if the page is loaded by turbolinks, the Webpacker packed script included via Therefore, we've had to disable turbolinks on the pages where we show a Trix editor :( @javan Please let us know if we can provide any further info to help debug and/or fix this issue! Does it make sense to support running the |
This issue has been automatically marked as stale after 90 days of inactivity. It will be closed if no further activity occurs. |
I've just experienced a similar bug. You cannot set My working implementation using Turbolinks + Webpacker looks like this: import Trix from 'trix'
import translations from "./translations"
addEventListener("trix-before-initialize", () => Object.assign(Trix.config.lang, translations)) It is also possible to change the caption placeholder in the Update: Clarify I'm using Turbolinks and webpacker |
Expected: Toolbar texts are set according to those specified in
Trix.config.lang
Actual:
We are running
trix/dist/trix.js
AFTER thetrix-editor
is already in the DOM.Using Rails 6.0 and Webpacker.
Steps to Reproduce
javascript code, which is loaded asynchronously (not placed in the DOM in a script tag before the
trix-editor
element).The
trix-editor
element is placed in the DOM via ActionTextrich_text_area
, which is in a server-rendered Rails template.Details
The text was updated successfully, but these errors were encountered: