I am trying to tag number strings and date strings with class span.numberstring
|span.datestring
such that CKeditor A11ychecker plugin will find them and render a Quickfix form to populate <abbr title>
attribute with screen-readable text. I use the following script to run a regex search when 'beforeCommandExec' equals 'a11ychecker'. After editor contents is replaced, the 'CKEDITOR.dom.element' shows as 'null' and the error response is:
plugin.js?t=K87C:32 Uncaught TypeError: Cannot read property 'getPosition' of null
txtGroupEditor.on('beforeCommandExec',function(event){
var commandName = event.data.name;
if(commandName == 'a11ychecker'){
var dataRegex=/([0-9]{4,4})(?!<\/span>)/g,
string=this.getData(),
m;
do {
m = dataRegex.exec(string);
if (m) {
string=string.replace(m[0],'<span class="numberstring">' + m[0] + '</span>');
}
} while (m);
this.setData(string);
}
});
Is this a timing issue? I have tried firing the a11ychecker process after the regex operation is completed, but that does not work either and it still seems to unbind itself from the instance. Thank you, in advance, for the help.
Result without regex operation
Result with regex operation
Conclusion: Forcing two operations to run, in sequence (tagging then a11ychecker) when clicking on a11ychecker button, appears to have its challenges.
Solution: Breaking out the tagging operation into its own button appears to be more effective and reliable. Now, tagging operation is required to run before enabling the a11ychecker button. When the editor contents is activated on 'key' down, the a11ychecker button will be disabled to assume that content has been altered and should be run through the tagging operation again.