Cleanup and improve CodeMirror integration
Fixed some issues, improved css/layout, added autoscroll to invalid line on errorpull/5657/head
parent
ae4d3d0f65
commit
4452a16f7f
@ -1,35 +0,0 @@
|
||||
var cmeditor;
|
||||
|
||||
function createErrorElem(msg)
|
||||
{
|
||||
var marker = document.createElement("div");
|
||||
marker.style.color = "#822";
|
||||
marker.innerHTML = "●";
|
||||
marker.title = msg;
|
||||
return marker;
|
||||
}
|
||||
|
||||
if (window.rcmail) {
|
||||
rcmail.addEventListener('init', function(evt) {
|
||||
var textArea = document.getElementById('rawfiltersettxt');
|
||||
if (textArea) {
|
||||
cmeditor = CodeMirror.fromTextArea(textArea, {
|
||||
mode: 'sieve',
|
||||
lineNumbers: true,
|
||||
gutters: ["CodeMirror-linenumbers", "errorGutter"],
|
||||
styleActiveLine: true
|
||||
});
|
||||
|
||||
// fetching errors from environment and setting the line background
|
||||
// and a gutter element with the error message accordingly
|
||||
var errors = rcmail.env.sieve_errors;
|
||||
if (errors !== undefined) {
|
||||
errors.forEach(function(err) {
|
||||
var lineNo = Number(err.line) - 1;
|
||||
cmeditor.addLineClass(lineNo, 'background', 'line-error');
|
||||
cmeditor.setGutterMarker(lineNo, 'errorGutter', createErrorElem(err.msg));
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
.CodeMirror {
|
||||
height: 600px;
|
||||
}
|
||||
|
||||
.CodeMirror-linebackground.line-error {
|
||||
background-color: #f66;
|
||||
}
|
||||
|
||||
.errorGutter {
|
||||
width: 0.8em;
|
||||
}
|
Loading…
Reference in New Issue