Accessibility checker
The checker reads the content in the editor and reports what would make it hard to use with a screen reader or at low vision. It is built in and included in the licence, not a paid add-on. As of editor 2.6.7 it applies 18 rules, and most of them offer a one-click repair that fixes the markup while the author supplies the words.
It checks the content, not the editor: for how the editor itself behaves for keyboard and screen reader users, see Accessibility (WCAG 2.2 AA).
Using it
The toolbar button opens a panel listing what it found; selecting an issue highlights it in the document. Errors are things that leave content unusable for someone; warnings are things that make it harder.
// The checker is a plugin; it loads with all_plugins.js.
var editor = new RichTextEditor("#div_editor");
editor.accessibilityChecker.open(); // show the panel
editor.accessibilityChecker.toggle(); // show or hide it
editor.accessibilityChecker.close();
// Run it yourself - for example before saving - and read the result.
var result = editor.accessibilityChecker.run();
result.issues.forEach(function (issue) {
console.log(issue.code, issue.severity, issue.message, issue.path);
});
// Block a save while errors remain, and let warnings through.
function hasBlockingIssues() {
return editor.accessibilityChecker.run().issues.some(function (i) {
return i.severity === "error";
});
}Every issue carries a code from the tables below, a severity of error or warning, a message written for the author, and a path identifying the element.
Images, links, colour and language
| Rule | Level | What it catches | One-click repair |
|---|---|---|---|
image-missing-alt | Error | An image with no alt text. A screen reader announces only “image”. | Type the description; it is written to alt. |
image-alt-filename | Error | Alt text that is a file name (IMG_4021.jpg), which describes nothing. | Type a real description. |
image-alt-too-long | Warning | Alt text over 150 characters: a burden to listen to. | Type a shorter description. |
link-empty | Error | A link with no text, announced as just “link”. | Add link text, or an aria-label when the link is an icon. |
link-ambiguous-text | Warning | “Click here”, “read more”: useless in a screen reader’s list of links. | — (rewrite the text yourself) |
link-adjacent-duplicate | Warning | An image link beside a text link to the same place: announced twice. | Merges them into one link. |
contrast-insufficient | Error | Text below WCAG AA contrast: 4.5:1 for body text, 3:1 for large text. | — (choose a different colour) |
duplicate-id | Error | Two elements sharing an id, so any label pointing at it resolves to the first. | — (change one id) |
language-of-parts | Warning | A run of text in another script with no lang attribute, so it is read in the wrong voice. | Marks the run with the language you choose. |
Headings and structure
| Rule | Level | What it catches | One-click repair |
|---|---|---|---|
heading-empty | Warning | A heading with no text, which still appears in the document outline. | Type the heading text. |
heading-level-skip | Warning | A jump from H1 to H3: the outline loses a level. | Converts it to the next level. |
paragraph-as-heading | Warning | Bold, large text alone on a line: it looks like a heading but cannot be navigated to. | Converts it into a real heading. |
fake-list | Warning | Lines typed as “1.” or “-”: not announced as a list, and the item count is lost. | Converts them into a real list. |
blockquote-as-indent | Warning | A blockquote used for indentation, announced as a quotation. | — (use the indent button instead) |
Tables
| Rule | Level | What it catches | One-click repair |
|---|---|---|---|
table-missing-header | Warning | A data table with no header cells, so no column or row has a name. | Promotes the first row to headers, or marks the table as layout-only. |
table-header-empty | Error | A header cell with no text: the column it labels is announced nameless. | Type the label, or demote it to an ordinary cell. |
table-missing-caption | Warning | A data table with no caption, so listeners enter it without knowing what it holds. | Type the caption. |
layout-table-semantics | Error | A layout table still carrying header cells or a caption, announcing relationships it does not have. | Strips the data-table markup. |
Repairing an issue
A repair changes the markup; it never invents words. Where a rule needs text, pass it in and the checker writes it into the right place, then re-runs so the list stays true.
// Repair issue 0. The options an issue needs depend on its rule:
// the author supplies words, the editor does the markup.
var issues = editor.accessibilityChecker.getIssues();
editor.accessibilityChecker.repair(0, { altText: "Crew fitting the new roof" }); // image-missing-alt, image-alt-filename, image-alt-too-long
editor.accessibilityChecker.repair(0, { headingText: "Opening hours" }); // heading-empty
editor.accessibilityChecker.repair(0, { targetLevel: 2 }); // heading-level-skip, paragraph-as-heading
editor.accessibilityChecker.repair(0, { captionText: "Sales by month" }); // table-missing-caption
editor.accessibilityChecker.repair(0, { markLayout: true }); // table-missing-header, as a layout table
editor.accessibilityChecker.repair(0, {}); // fake-list, link-adjacent-duplicate: nothing to supplyThree rules have no automatic repair, and deliberately so: ambiguous link text, insufficient contrast and a duplicate id all need a human decision about wording, colour or which element keeps the id.
What it does not do
- It reads the content in the editor, not your published page: styles applied by your site can change contrast after saving.
- It cannot judge whether alt text is accurate, only whether it is present, not a file name and not excessively long.
- A phrase in another language written in the same script (French inside English) is not detectable; the language rule keys off the writing system.
- It is not a substitute for testing with a real screen reader before a launch.