Browse Source

给code editor加一个标红规则

es6
windy 8 years ago
parent
commit
d7733adab1
  1. 7
      src/base/single/editor/editor.code.js

7
src/base/single/editor/editor.code.js

@ -85,7 +85,11 @@ BI.CodeEditor = BI.inherit(BI.Single, {
var from = this.editor.getCursor();
this.editor.replaceSelection(param);
var to = this.editor.getCursor();
this.editor.markText(from, to, {className: 'param', atomic: true});
var options = {className: 'param', atomic: true};
if(BI.isNotNull(param.match(/<!.*!>/))){
options.className = 'error-param';
}
this.editor.markText(from, to, options);
this.editor.replaceSelection(" ");
this.editor.focus();
},
@ -102,6 +106,7 @@ BI.CodeEditor = BI.inherit(BI.Single, {
_.forEach(line.markedSpans, function (i, ms) {
switch (i.marker.className) {
case "param":
case "error-param":
var fieldNameLength = i.to - i.from;
value = value.substr(0, i.from + num) + "$\{" + value.substr(i.from + num, fieldNameLength) + "\}" + value.substr(i.to + num, value.length);
num += 3;

Loading…
Cancel
Save