Is there a way to toggle syntax-highlighting in ace.js?
I know you can switch between syntax-highlighting modes with editor.setMode()
, but what about just straight turning the syntax-highlighting off?
I can’t seem to find any docs on this
Advertisement
Answer
You can toggle it with css, let’s say the class of your ACE editor is .ace-xcode
, here you can toggle a class monochrome
on it:
JavaScript
x
4
1
function toggleSyntaxHighlighting() {
2
document.querySelector('.ace-xcode').classList.toggle('monochrome');
3
}
4
In your css code. If the class .monochrome
is on, disable the color of the spans by assigning this rule:
JavaScript
1
4
1
.ace-xcode.monochrome span {
2
color: initial !important;
3
}
4