implements accessibility measures and finishes Link richText element

This commit is contained in:
James
2020-10-03 13:04:15 -04:00
parent 0764f34c64
commit febe213e80
16 changed files with 176 additions and 50 deletions

View File

@@ -0,0 +1,3 @@
export default [{
children: [{ text: '' }],
}];

View File

@@ -1,3 +1,5 @@
const defaultRichTextValue = require('./richText/defaultValue');
const defaultMessage = 'This field is required.';
const optionsToValidatorMap = {
@@ -92,15 +94,9 @@ const optionsToValidatorMap = {
return true;
},
richText: (value, options) => {
//! Need better way to share an empty text node
//! it is used here and in field-types/RichText
const emptyRichTextNode = [{
children: [{ text: '' }],
}];
if (options.required) {
const blankSlateJSNode = JSON.stringify(emptyRichTextNode);
if (value && JSON.stringify(value) !== blankSlateJSNode) return true;
const stringifiedDefaultValue = JSON.stringify(defaultRichTextValue);
if (value && JSON.stringify(value) !== stringifiedDefaultValue) return true;
return 'This field is required.';
}