mirror of
https://github.com/discourse/discourse.git
synced 2026-03-03 23:54:20 +08:00
When editing site texts or email templates, admins need to know which
interpolation keys are available and whether they're being used
correctly.
Previously there was no UI for this.
Show interpolation keys as clickable pill buttons below the editor:
- Unused keys are dimmed — clicking inserts %{key} at the last cursor
position
- Used keys are highlighted green to confirm they're present in the text
- Invalid keys (typos or unknown keys) appear in red as non-clickable
pills
Implementation:
- New `<AdminInterpolationKeys>` template-only component renders the
pills
- New `interpolationKeysWithStatus()` utility in admin/lib centralizes
the
logic for computing key statuses (used/unused/invalid) across both
editors
- Controllers track textarea focus and cursor position via private
fields
(no @Tracked — these are only read imperatively on pill click)
- Uses document.execCommand("insertText") for native undo/redo support
- Fix duplicate keys in backend by using Array#| (set union) instead of
Array#+
<img width="1662" height="1355" alt="2026-02-26 @ 17 09 32"
src="https://github.com/user-attachments/assets/05497832-4e17-4eb2-b4c1-e9e0e036304a"
/>
<img width="1662" height="1355" alt="2026-02-26 @ 17 09 19"
src="https://github.com/user-attachments/assets/f13271ad-511e-4fa1-9bec-eb6fbc7a66d8"
/>
Ref - t/172375
|
||
|---|---|---|
| .. | ||
| config | ||
| admin_controller.rb | ||
| admin_notices_controller.rb | ||
| api_controller.rb | ||
| backups_controller.rb | ||
| badges_controller.rb | ||
| color_schemes_controller.rb | ||
| dashboard_controller.rb | ||
| email_controller.rb | ||
| email_logs_controller.rb | ||
| email_styles_controller.rb | ||
| email_templates_controller.rb | ||
| embeddable_hosts_controller.rb | ||
| embedding_controller.rb | ||
| emoji_controller.rb | ||
| form_templates_controller.rb | ||
| groups_controller.rb | ||
| impersonate_controller.rb | ||
| permalinks_controller.rb | ||
| plugins_controller.rb | ||
| reports_controller.rb | ||
| robots_txt_controller.rb | ||
| screened_emails_controller.rb | ||
| screened_ip_addresses_controller.rb | ||
| screened_urls_controller.rb | ||
| search_controller.rb | ||
| search_logs_controller.rb | ||
| section_controller.rb | ||
| site_settings_controller.rb | ||
| site_texts_controller.rb | ||
| staff_action_logs_controller.rb | ||
| staff_controller.rb | ||
| themes_controller.rb | ||
| unknown_reviewables_controller.rb | ||
| user_fields_controller.rb | ||
| users_controller.rb | ||
| versions_controller.rb | ||
| watched_words_controller.rb | ||
| web_hooks_controller.rb | ||