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
question from:
https://stackoverflow.com/questions/65926245/how-can-a11ychecker-run-process-on-content-after-ckeditor-dom-element-change 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…