From c067965ec122810cb4997073d5939a60366375e4 Mon Sep 17 00:00:00 2001 From: iapyang Date: Fri, 28 Aug 2020 14:41:23 +0800 Subject: [PATCH 1/3] =?UTF-8?q?KERNEL-5172=20fix:=20editor=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- demo/js/base/editor/demo.editor.js | 4 +-- src/base/single/editor/editor.js | 52 +++++++++++++----------------- 2 files changed, 25 insertions(+), 31 deletions(-) diff --git a/demo/js/base/editor/demo.editor.js b/demo/js/base/editor/demo.editor.js index 6268cc54d..208b8f596 100644 --- a/demo/js/base/editor/demo.editor.js +++ b/demo/js/base/editor/demo.editor.js @@ -16,7 +16,7 @@ Demo.Editor = BI.inherit(BI.Widget, { }); var editor2 = BI.createWidget({ type: "bi.editor", - cls: "mvc-border", + cls: "bi-border", watermark: "输入'a'会有错误信息", disabled: true, errorText: "字段不可重名", @@ -32,7 +32,7 @@ Demo.Editor = BI.inherit(BI.Widget, { }); var editor3 = BI.createWidget({ type: "bi.editor", - cls: "mvc-border", + cls: "bi-border", watermark: "输入'a'会有错误信息且回车键不能退出编辑", errorText: "字段不可重名", value: "a", diff --git a/src/base/single/editor/editor.js b/src/base/single/editor/editor.js index 793c7da6e..a5c455ed1 100644 --- a/src/base/single/editor/editor.js +++ b/src/base/single/editor/editor.js @@ -6,6 +6,7 @@ BI.Editor = BI.inherit(BI.Single, { _defaultConfig: function () { var conf = BI.Editor.superclass._defaultConfig.apply(this, arguments); + return BI.extend(conf, { baseCls: "bi-editor bi-focus-shadow", hgap: 4, @@ -21,7 +22,7 @@ BI.Editor = BI.inherit(BI.Single, { quitChecker: BI.emptyFn, allowBlank: false, watermark: "", - errorText: "" + errorText: "", }); }, @@ -46,27 +47,6 @@ BI.Editor = BI.inherit(BI.Single, { padding: "0", margin: "0" }); - if (BI.isKey(this.options.watermark)) { - this._assertWaterMark(); - } - - var _items = []; - if (this.watermark) { - _items.push({ - el: this.watermark, - left: 3, - right: 3, - top: 0, - bottom: 0 - }); - } - _items.push({ - el: this.editor, - left: 0, - right: 0, - top: 0, - bottom: 0 - }); var items = [{ el: { @@ -74,7 +54,13 @@ BI.Editor = BI.inherit(BI.Single, { ref: function(_ref) { self.contentWrapper = _ref; }, - items: _items + items: [{ + el: this.editor, + left: 0, + right: 0, + top: 0, + bottom: 0 + }] }, left: o.hgap + o.lgap, right: o.hgap + o.rgap, @@ -87,6 +73,9 @@ BI.Editor = BI.inherit(BI.Single, { element: this, items: items }); + + this.setWaterMark(this.options.watermark); + this.editor.on(BI.Controller.EVENT_CHANGE, function () { self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); }); @@ -199,7 +188,7 @@ BI.Editor = BI.inherit(BI.Single, { type: "bi.label", cls: "bi-water-mark", text: this.options.watermark, - height: o.height - 2 * (o.vgap + o.tgap), + height: o.height - 2 * o.vgap - o.tgap, whiteSpace: "nowrap", textAlign: "left" }); @@ -247,8 +236,13 @@ BI.Editor = BI.inherit(BI.Single, { }, setWaterMark: function(v) { + if (!BI.isKey(v)) { + return; + } + this.options.watermark = v; - if(BI.isNull(this.watermark)) { + + if (BI.isNull(this.watermark)) { this._assertWaterMark(); BI.createWidget({ type: "bi.absolute", @@ -258,11 +252,11 @@ BI.Editor = BI.inherit(BI.Single, { left: 3, right: 3, top: 0, - bottom: 0 - }] - }) + bottom: 0, + }], + }); } - BI.isKey(v) && this.watermark.setText(v); + this.watermark.setText(v); }, _setErrorVisible: function (b) { From 197a2bb607647bd0563f3c538e5d6b75edbee50e Mon Sep 17 00:00:00 2001 From: iapyang Date: Fri, 28 Aug 2020 15:09:55 +0800 Subject: [PATCH 2/3] =?UTF-8?q?refactor:=20=E4=BF=AE=E6=94=B9demo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- demo/js/base/editor/demo.editor.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demo/js/base/editor/demo.editor.js b/demo/js/base/editor/demo.editor.js index 208b8f596..26c4ed4f2 100644 --- a/demo/js/base/editor/demo.editor.js +++ b/demo/js/base/editor/demo.editor.js @@ -6,7 +6,7 @@ Demo.Editor = BI.inherit(BI.Widget, { var editor1 = BI.createWidget({ type: "bi.editor", cls: "bi-border", - watermark: "alert信息显示在下面", + watermark: "报错信息显示在控件上方", errorText: "字段不可重名!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!", width: 200, height: 24 From 11ef5ac737e33f71670424a711eeb8aa068b52dc Mon Sep 17 00:00:00 2001 From: iapyang Date: Fri, 28 Aug 2020 15:13:36 +0800 Subject: [PATCH 3/3] =?UTF-8?q?chore:=20=E4=BF=AE=E6=94=B9dev=E5=91=BD?= =?UTF-8?q?=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2f80c1469..a9660f89c 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,7 @@ "webpack-merge": "4.2.1" }, "scripts": { - "webpack:dev": "webpack-dev-server -p --progress --host 0.0.0.0 --config=webpack/webpack.dev.js --mode development", + "webpack:dev": "node --max_old_space_size=4096 node_modules/.bin/webpack-dev-server -p --progress --host 0.0.0.0 --config=webpack/webpack.dev.js --mode development", "webpack:prod": "webpack -p --progress --config=webpack/webpack.prod.js --mode production", "start": "node server.js", "build": "npm run webpack:prod && tsc",