-
-
Notifications
You must be signed in to change notification settings - Fork 730
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
Replace text angular editor with trix editor in About Us and Shopfront message fields #12734
Replace text angular editor with trix editor in About Us and Shopfront message fields #12734
Conversation
b0567f7
to
837e187
Compare
…ges and about fields for enterprises and enterprise groups
837e187
to
a6d3909
Compare
@@ -1,3 +1,7 @@ | |||
trix-toolbar .trix-button-row { | |||
flex-wrap: wrap; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prevents horizontal scrollber on Trix button toolbar in smaller screens.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah less angular 🧹 ! Thanks @cillian 🙏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work, it looks much cleaner than before!
I like how you adapted to fit the extra Trix buttons in, and it means there's more space for the text area too.
I have a couple of comments that might be worth trying. Do they make sense?
If not, we can proceed as is.
config/locales/en.yml
Outdated
trix: | ||
attachFiles: "Attach Files" | ||
bold: "Bold" | ||
bullets: "Bullets" | ||
byte: "Byte" | ||
bytes: "Bytes" | ||
captionPlaceholder: "Add a caption…" | ||
code: "Code" | ||
heading1: "Heading" | ||
indent: "Increase Level" | ||
italic: "Italic" | ||
link: "Link" | ||
numbers: "Numbers" | ||
outdent: "Decrease Level" | ||
quote: "Quote" | ||
redo: "Redo" | ||
remove: "Remove" | ||
strike: "Strikethrough" | ||
undo: "Undo" | ||
unlink: "Unlink" | ||
url: "URL" | ||
urlPlaceholder: "Enter a URL…" | ||
GB: "GB" | ||
KB: "KB" | ||
MB: "MB" | ||
PB: "PB" | ||
TB: "TB" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding Trix translation keys.
These two old labels seem equivalent to new labels (I haven't checked though)
- "Insert / edit link" -> "Link"
- "Please enter a URL to insert" -> "Enter a URL…"
If so, I think it would help to use the old labels. That way, it will probably be easy for translators to copy the existing labels when adding translations for Trix. Does that make sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, that's updated in 2d6ffc0 to use the old "Please enter a URL to insert" label.
The "Link" translation is used in two places at once so the "Insert / edit link" label is a bit more awkward, see...
… set automatically
Trix.config.lang[key] = translation; | ||
|
||
// Set toolbar translations (Chrome) | ||
this.#setTranslation( | ||
`[data-trix-action="${this.#translationKeyToAttributeMappings(key)}"]`, | ||
"title", | ||
translation | ||
); | ||
this.#setTranslation( | ||
`[data-trix-attribute="${this.#translationKeyToAttributeMappings(key)}"]`, | ||
"title", | ||
translation | ||
); | ||
} | ||
|
||
// Set translations for link dialog (Chrome) | ||
this.#setTranslation(`[data-trix-dialog="href"] input`, | ||
"aria-label", I18n.t("js.trix.url")); | ||
this.#setTranslation(`[data-trix-dialog="href"] input`, | ||
"placeholder", I18n.t("js.trix.urlPlaceholder")); | ||
this.#setTranslation('.trix-dialog--link input[data-trix-method="setAttribute"]', | ||
"value", I18n.t("js.trix.link")); | ||
this.#setTranslation('.trix-dialog--link input[data-trix-method="removeAttribute"]', | ||
"value", I18n.t("js.trix.unlink")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trix.config.lang[key] = translation;
only seems to work in Firefox for some reason. The translations have to be set more manually for Chrome.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's interesting, and unfortunate because you have map quite a lot data.
According to this wiki, it suggests overwriting the lang
config in one command.
Trix.config.lang = translation
https://github.com/basecamp/trix/wiki/I18n
But you tried that and it didn't work, so it would be worth raising an issue.
I had a look for issues and could only find one.
The final comment shows another method using Object.assign
. I don't know if that would make a different, but perhaps it's worth trying.
basecamp/trix#874 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good find, fixed by 63c62ca and it works in Firefox and Chrome.
config/locales/en_AU.yml
Outdated
trix: | ||
bold: "Bold" | ||
bullets: "Bullets" | ||
code: "Code" | ||
heading1: "Heading" | ||
hr: "Horizontal rule" | ||
indent: "Increase Level" | ||
italic: "Italic" | ||
link: "Link" | ||
numbers: "Numbers" | ||
outdent: "Decrease Level" | ||
quote: "Quote" | ||
redo: "Redo" | ||
strike: "Strikethrough" | ||
undo: "Undo" | ||
unlink: "Unlink" | ||
url: "URL" | ||
urlPlaceholder: "Please enter a URL to insert" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, these will already have the default loaded from en.yml
In general , we need to avoid changing any locale files other than the default, as described here:
https://github.com/openfoodfoundation/openfoodnetwork/wiki/Internationalisation-(i18n)#development
I have to admit, I don't know if this commit will be a problem or not, but I know it's not necessary so perhaps it's safest to remove it.
Trix.config.lang[key] = translation; | ||
|
||
// Set toolbar translations (Chrome) | ||
this.#setTranslation( | ||
`[data-trix-action="${this.#translationKeyToAttributeMappings(key)}"]`, | ||
"title", | ||
translation | ||
); | ||
this.#setTranslation( | ||
`[data-trix-attribute="${this.#translationKeyToAttributeMappings(key)}"]`, | ||
"title", | ||
translation | ||
); | ||
} | ||
|
||
// Set translations for link dialog (Chrome) | ||
this.#setTranslation(`[data-trix-dialog="href"] input`, | ||
"aria-label", I18n.t("js.trix.url")); | ||
this.#setTranslation(`[data-trix-dialog="href"] input`, | ||
"placeholder", I18n.t("js.trix.urlPlaceholder")); | ||
this.#setTranslation('.trix-dialog--link input[data-trix-method="setAttribute"]', | ||
"value", I18n.t("js.trix.link")); | ||
this.#setTranslation('.trix-dialog--link input[data-trix-method="removeAttribute"]', | ||
"value", I18n.t("js.trix.unlink")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's interesting, and unfortunate because you have map quite a lot data.
According to this wiki, it suggests overwriting the lang
config in one command.
Trix.config.lang = translation
https://github.com/basecamp/trix/wiki/I18n
But you tried that and it didn't work, so it would be worth raising an issue.
I had a look for issues and could only find one.
The final comment shows another method using Object.assign
. I don't know if that would make a different, but perhaps it's worth trying.
basecamp/trix#874 (comment)
config/locales/ar.yml
Outdated
trix: | ||
urlPlaceholder: "الرجاء إدخال عنوان URL لإدراجه" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I just meant to update it in en.yml
. In general we should avoid changing other locale files directly. I'm unsure if adding new keys is a problem though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mkllnk can you help with a query here?
For convenience, Cillian has copied an existing translation to a new key (the existing translation was for angular editor, and there is an equivalent in the new trix editor). Do you know if it's ok, and if it's helpful to add new keys to the locale files?
Or should we remove this before merging?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should remove this addition. Transifex will handle it. It recognises existing translations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work! Thank you.
We just need to revert he changes to the other locales. Otherwise this is great!
config/locales/ar.yml
Outdated
shopfront_message_link_tooltip: "إدراج / تحرير الرابط" | ||
shopfront_message_link_prompt: "الرجاء إدخال عنوان URL لإدراجه" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove all changes to locales other than en.yml.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
config/locales/ar.yml
Outdated
trix: | ||
urlPlaceholder: "الرجاء إدخال عنوان URL لإدراجه" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should remove this addition. Transifex will handle it. It recognises existing translations.
Co-authored-by: David Cook <[email protected]>
…tor in the Trix editor" for all locales except :en This reverts commit 2d6ffc0.
…gions" This reverts commit 70ca031.
Thanks. I have reverted those changes to non |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, all ready to test!
@cillian Github is saying there are changes requested. Could you please have a look? I assume it's been addressed already? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Github is saying there are changes requested.
Github was waiting for my review. But the other approvals should have been enough. Anyway, you get may approval, too. 😄
Hi @cillian |
For future testing I have documented the "before" state already. |
Thanks @drummer83 I have fixed that conflict now. For reference, it was this...
To fix it I removed the |
Hi @cillian, After staging the PR
After staging the PR and updating the content
I find it surprising to see, that it's enough to edit any of the content to have the new styles applied to all of the occurences. It's no problem, maybe even an advantage looking at consistency. I assume this happens because when clicking Update, all of the tabs are saved and not just the tab I'm looking at. Summary
We can merge this one, but the branch is out of date and I can't rebase due to a conflict. I will move this to Ready To Go but add the feedback needed label to have someone else have a look at it. Maybe @filipefurtad0 or @sigmundpetersen could have a look? 🙏 Thanks again Cillian! 🚀 |
What? Why?
The trix editor was added in #11140, this PR follows on from that and replaces the remaining instances of the text-angular editor.
What should we test?
Release notes
Changelog Category (reviewers may add a label for the release notes):
Before
After
Note, in the above screenshots the trix fields are on new lines instead of being alongside the field label like they usually are. This is because there was a horizontal scrollbar if it was beside the field label, see:
I also added some wrapping to CSS to the trix editor button groups so they will automatically wrap and stop the horizontal scrollbar on smaller screens, although another solution might be to remove the whitespace to the right, see: