I am trying to enforce a character limit for a custom richText component in the Editor. However, I’m noticing that using regex
or onChange
does not seem to work with richText. Is this intentional? They both seem to be working perfectly fine with strings, however. What would be the best way to enforce a character limit for richText?
Here is what I am trying to do
{
name: 'content',
type: 'richText',
defaultValue: 'I wanna hold \'em like they do in Texas, please' +
'Fold \'em, let \'em hit me, raise it, baby, stay with me (I love it) ' +
'Love game intuition, play the cards with spades to start' +
'And after he\'s been hooked, I\'ll play the one that\'s on his heart',
onChange: (options) => {
if (options.get('content').length > CONTENT_CHAR_LIMIT) {
options.set('content', options.get('content').slice(0, CONTENT_CHAR_LIMIT));
alert(`Maximum number of characters is ${CONTENT_CHAR_LIMIT}. Please lessen number of characters..`);
}
},
},