We ask the user here to define html, so add a div
or a section or something like that. So, I want the validation-tooltips when editing my HTML. But don't wanna have the doc-type warning.
We ask the user here to define html, so add a div
or a section or something like that. So, I want the validation-tooltips when editing my HTML. But don't wanna have the doc-type warning.
- As stated in this thread, it doesn't seem to be possible to filter certain errors, though you can disable them all. – Jelle De Loecker Commented Oct 20, 2015 at 14:52
3 Answers
Reset to default 12Try this
var session = editor.getSession();
session.on("changeAnnotation", function() {
var annotations = session.getAnnotations()||[], i = len = annotations.length;
while (i--) {
if(/doctype first\. Expected/.test(annotations[i].text)) {
annotations.splice(i, 1);
}
}
if(len>annotations.length) {
session.setAnnotations(annotations);
}
});
With "Unexpected End of File. Expected DOCTYPE." warning filtered.
var session = editor.getSession();
session.on("changeAnnotation", function () {
var annotations = session.getAnnotations() || [], i = len = annotations.length;
while (i--) {
if (/doctype first\. Expected/.test(annotations[i].text)) {
annotations.splice(i, 1);
}
else if (/Unexpected End of file\. Expected/.test(annotations[i].text)) {
annotations.splice(i, 1);
}
}
if (len > annotations.length) {
session.setAnnotations(annotations);
}
});
If instead you operate on the annotations
directly and call the editor onChangeAnnotation
method directly to update the annotations on the page you can prevent firing another changeAnnotation
event and calling this event handler twice as Chris's answer does.
var editor = Application.ace.edit(element),
session = editor.getSession();
session.on('changeAnnotation', function () {
session.$annotations = session.$annotations.filter(function(annotation){
return !(/doctype first\. Expected/.test(annotation.text) || /Unexpected End of file\. Expected/.test(annotation.text))
});
editor.$onChangeAnnotation();
});