-
-
Notifications
You must be signed in to change notification settings - Fork 5.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
Desktop,Mobile: Accessibility: Announce formatting changes to the Markdown editor for screen readers #11441
Conversation
This commit announces changes (e.g. "added block code") made by most Markdown commands. Currently: - This is done on both mobile and desktop. - The goal is to give screen reader users a brief description of how an action changed the document. - It's possible that this change will be more annoying than useful (more content read by the screen reader?) Related to laurent22#10795.
…tor/announce-formatting-changes
let announcement = ''; | ||
if (charsAdded > 0) { | ||
announcement = _('Added %s markup', accessibleName); | ||
} else if (charsAdded < 0) { | ||
announcement = _('Removed %s markup', accessibleName); | ||
} | ||
|
||
if (changedLineCount > 1) { | ||
announcement += ` ${_('on %d lines', changedLineCount)}`; | ||
} else { | ||
announcement += ` ${_('to line start')}`; | ||
} |
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 cannot concatenate localised strings since the concatenation might not work in certain languages due to words being in a different order.
I'm not too sure what's the solution here, but maybe simplifying the message would help even if we lose a bit of information. It would also make the work of translators easier.
I'm closing this due to concerns about whether these announcements are useful/necessary (and maintainability concerns). If such screen reader announcements would be useful, I can re-open this pull request. |
Summary
This pull request causes screen readers to describe certain formatting changes in the Markdown editor after they are made. For example, pressing ctrl-b in an empty now announces "four star characters, added bold Markup" (Web client/Chromium/Linux+Orca). Previously, it only announced "four star characters".
Related to #10795.
Example announcements
Added italic markup
Added header level 2 markup at the start of the current line.
Added indent markup on 5 lines.
Removed indent markup on 5 lines.
Implementation notes
On mobile, code in
packages/editor
runs in aWebView
is bundled separately from the main application. If it uses@joplin/lib/locale
directly, the bundle size increases from roughly 2 MB to 5 MB. To avoid this size increase, this pull request:_(...)
localization function inpackages/editor
.packages/editor
uses the TypeScript compiler API to find all uses of_(...)
in theeditor
package. The format strings passed to_(...)
are then written topackages/editor
are saved tolocalizationPatterns.ts
.localizations/localizationPatterns.ts
are looked up and sent to the editor's localization logic.To summarize, at buildtime:
Then at runtime:
Testing plan
Desktop/Fedora 41/Ocra:
Web/Chromium/Linux+Orca:
Additional testing:
packages/app-mobile/components/NoteEditor.tsx
, replacemakeLocalizations(rawStringInCurrentLocale)
withmakeLocalizations(() => 'PASS!')
.