UX: add title and aria-label to md/rich editor toggle (#31784)

This commit is contained in:
Renato Atilio
2025-03-12 20:53:09 -03:00
committed by GitHub
parent ce05f9ece5
commit 159aa43cfe
2 changed files with 13 additions and 0 deletions

View File

@ -3,6 +3,7 @@ import { on } from "@ember/modifier";
import { action } from "@ember/object";
import concatClass from "discourse/helpers/concat-class";
import icon from "discourse/helpers/d-icon";
import { i18n } from "discourse-i18n";
export default class ComposerToggleSwitch extends Component {
@action
@ -12,6 +13,14 @@ export default class ComposerToggleSwitch extends Component {
}
}
get label() {
if (this.args.state) {
return i18n("composer.switch_to_markdown");
} else {
return i18n("composer.switch_to_rich_text");
}
}
<template>
{{! template-lint-disable no-redundant-role }}
<button
@ -22,6 +31,8 @@ export default class ComposerToggleSwitch extends Component {
type="button"
role="switch"
aria-checked={{if @state "true" "false"}}
aria-label={{this.label}}
title={{this.label}}
{{! template-lint-disable no-pointer-down-event-binding }}
{{on "mousedown" this.mouseDown}}
...attributes

View File

@ -2753,6 +2753,8 @@ en:
show_preview: "show preview"
hide_preview: "hide preview"
switch_to_markdown: "Switch to standard Markdown editor"
switch_to_rich_text: "Switch to new rich text editor"
quote_post_title: "Quote whole post"
bold_label: "B"
bold_title: "Strong"