Browse Source

codeeditor插入含有某些字符的参数时交互问题

es6
windy 7 years ago
parent
commit
beba91068f
  1. 4
      src/base/formula/codemirror/formula-mode.js
  2. 6
      src/base/single/editor/editor.code.js

4
src/base/formula/codemirror/formula-mode.js

@ -23,6 +23,10 @@
nextUntilUnescaped(stream, ch); nextUntilUnescaped(stream, ch);
return "string"; return "string";
} }
if (ch === '\u200b') {
nextUntilUnescaped(stream, ch);
return "field";
}
if (/[\[\],\(\)]/.test(ch)) { if (/[\[\],\(\)]/.test(ch)) {
return 'bracket'; return 'bracket';
} }

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

@ -25,7 +25,8 @@ BI.CodeEditor = BI.inherit(BI.Single, {
textWrapping: true, textWrapping: true,
lineWrapping: true, lineWrapping: true,
lineNumbers: false, lineNumbers: false,
readOnly: o.readOnly readOnly: o.readOnly,
specialChars: /[\u0000-\u001f\u007f\u00ad\u200c-\u200f\u2028\u2029\ufeff]/
}); });
o.lineHeight === 1 ? this.element.addClass("codemirror-low-line-height") : this.element.addClass("codemirror-high-line-height"); o.lineHeight === 1 ? this.element.addClass("codemirror-low-line-height") : this.element.addClass("codemirror-high-line-height");
this.editor.on("change", function (cm, change) { this.editor.on("change", function (cm, change) {
@ -110,7 +111,7 @@ BI.CodeEditor = BI.inherit(BI.Single, {
var value = param; var value = param;
param = this.options.paramFormatter(param); param = this.options.paramFormatter(param);
var from = this.editor.getCursor(); var from = this.editor.getCursor();
this.editor.replaceSelection(param); this.editor.replaceSelection('\u200b' + param + '\u200b');
var to = this.editor.getCursor(); var to = this.editor.getCursor();
var options = {className: 'param', atomic: true}; var options = {className: 'param', atomic: true};
if (BI.isNotNull(param.match(/^<!.*!>$/))) { if (BI.isNotNull(param.match(/^<!.*!>$/))) {
@ -118,7 +119,6 @@ BI.CodeEditor = BI.inherit(BI.Single, {
} }
options.value = value; options.value = value;
this.editor.markText(from, to, options); this.editor.markText(from, to, options);
this.editor.replaceSelection(" ");
this.editor.focus(); this.editor.focus();
}, },

Loading…
Cancel
Save