From beba91068f345b19ed643ef1e807d2c170bb2c5c Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Tue, 17 Oct 2017 19:41:35 +0800 Subject: [PATCH] =?UTF-8?q?codeeditor=E6=8F=92=E5=85=A5=E5=90=AB=E6=9C=89?= =?UTF-8?q?=E6=9F=90=E4=BA=9B=E5=AD=97=E7=AC=A6=E7=9A=84=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E6=97=B6=E4=BA=A4=E4=BA=92=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/base/formula/codemirror/formula-mode.js | 4 ++++ src/base/single/editor/editor.code.js | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/base/formula/codemirror/formula-mode.js b/src/base/formula/codemirror/formula-mode.js index 52afc5ca6..1f017806a 100644 --- a/src/base/formula/codemirror/formula-mode.js +++ b/src/base/formula/codemirror/formula-mode.js @@ -23,6 +23,10 @@ nextUntilUnescaped(stream, ch); return "string"; } + if (ch === '\u200b') { + nextUntilUnescaped(stream, ch); + return "field"; + } if (/[\[\],\(\)]/.test(ch)) { return 'bracket'; } diff --git a/src/base/single/editor/editor.code.js b/src/base/single/editor/editor.code.js index 4ba118bf4..dc99d0f17 100644 --- a/src/base/single/editor/editor.code.js +++ b/src/base/single/editor/editor.code.js @@ -25,7 +25,8 @@ BI.CodeEditor = BI.inherit(BI.Single, { textWrapping: true, lineWrapping: true, 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"); this.editor.on("change", function (cm, change) { @@ -110,7 +111,7 @@ BI.CodeEditor = BI.inherit(BI.Single, { var value = param; param = this.options.paramFormatter(param); var from = this.editor.getCursor(); - this.editor.replaceSelection(param); + this.editor.replaceSelection('\u200b' + param + '\u200b'); var to = this.editor.getCursor(); var options = {className: 'param', atomic: true}; if (BI.isNotNull(param.match(/^$/))) { @@ -118,7 +119,6 @@ BI.CodeEditor = BI.inherit(BI.Single, { } options.value = value; this.editor.markText(from, to, options); - this.editor.replaceSelection(" "); this.editor.focus(); },