MDL-76474 tiny_accessibilitychecker: Prevent placeholders to be assessed

This commit is contained in:
Huong Nguyen 2023-01-04 11:52:43 +07:00
parent c4c85a8f1c
commit d21b6d194a
5 changed files with 33 additions and 5 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -25,6 +25,7 @@ import {component} from './common';
import * as Modal from 'core/modal_factory';
import * as ModalEvents from 'core/modal_events';
import ColorBase from './colorbase';
import {getPlaceholderSelectors} from 'editor_tiny/options';
/**
* @typedef ProblemDetail
@ -48,6 +49,11 @@ export default class {
this.editor = editor;
this.colorBase = new ColorBase();
this.modal = null;
this.placeholderSelectors = null;
const placeholders = getPlaceholderSelectors(this.editor);
if (placeholders.length) {
this.placeholderSelectors = placeholders.join(', ');
}
}
destroy() {
@ -247,7 +253,14 @@ export default class {
nodeData: [],
};
warning.nodeData = [...nodes].map((node) => {
warning.nodeData = [...nodes].filter((node) => {
// If the failed node is a placeholder element. We should remove it from the list.
if (node !== this.editor && this.placeholderSelectors) {
return node.matches(this.placeholderSelectors) === false;
}
return node;
}).map((node) => {
const describedNode = getEventualNode(node);
// Find the index of the node within the type of node.

View File

@ -1,4 +1,4 @@
@editor @editor_tiny
@editor @editor_tiny @tiny_accessibilitychecker
Feature: Tiny editor accessibility checker
To write accessible content in Tiny, I need to check for accessibility warnings.
@ -43,3 +43,11 @@ Feature: Tiny editor accessibility checker
When I press "Save image"
And I click on the "Tools > Accessibility checker" menu item for the "Description" TinyMCE editor
Then I should see "Congratulations, no accessibility issues found!" in the "Accessibility checker" "dialogue"
@javascript
Scenario: Placeholder element will not be assessed by accessibility checker
Given I log in as "admin"
And I open my profile in edit mode
When I set the field "Description" to "<p>Some plain text</p><img src='/broken-image' width='1' height='1' class='behat-tinymce-placeholder'/><p>Some more text</p>"
And I click on the "Tools > Accessibility checker" menu item for the "Description" TinyMCE editor
Then I should see "Congratulations, no accessibility issues found!" in the "Accessibility checker" "dialogue"

View File

@ -0,0 +1,7 @@
This files describes API changes in tiny_accessibilitychecker - TinyMCE Accessibility checker plugin,
information provided here is intended especially for developers.
=== 4.2 ===
* The placeholder elements which were registered in placeholderSelectors in editor_tiny/options will not be
assessed by the accessibility checker plugin.