From fca45a2ca5695cefcd8cdf253afabdcf69c6d3fd Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Sun, 1 Apr 2018 16:58:50 +0800 Subject: [PATCH] =?UTF-8?q?BI-17382=20rich=5Feditor=E4=BA=A4=E4=BA=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- demo/js/base/editor/demo.rich_editor.js | 3 +- dist/base.css | 5 ++ dist/bundle.css | 5 ++ dist/bundle.js | 78 +++++++++++-------- dist/case.js | 60 ++++++++------ dist/core.js | 14 ++-- dist/demo.js | 3 +- dist/fineui.css | 5 ++ dist/widget.js | 4 +- .../richeditor/bar/action.richeditor.param.js | 10 ++- src/case/richeditor/richeditor.js | 50 +++++++----- src/core/func/function.js | 14 ++-- src/css/base/richeditor/richeditor.css | 5 ++ src/less/base/richeditor/richeditor.less | 7 ++ src/widget/datepane/datepane.js | 2 +- src/widget/datetimepane/datetimepane.js | 2 +- 16 files changed, 170 insertions(+), 97 deletions(-) create mode 100644 src/css/base/richeditor/richeditor.css create mode 100644 src/less/base/richeditor/richeditor.less diff --git a/demo/js/base/editor/demo.rich_editor.js b/demo/js/base/editor/demo.rich_editor.js index 61059fc2d..80e0c8b07 100644 --- a/demo/js/base/editor/demo.rich_editor.js +++ b/demo/js/base/editor/demo.rich_editor.js @@ -29,8 +29,7 @@ Demo.RichEditor = BI.inherit(BI.Widget, { var image = BI.DOM.getImage("测试"); var src = image.src; var style = image.style; - - this.editor.setValue("
这是一条测试数据
"); + this.editor.setValue("
这是一条测试数据
"); } }); BI.shortcut("demo.rich_editor", Demo.RichEditor); \ No newline at end of file diff --git a/dist/base.css b/dist/base.css index 4226264e3..2a743c213 100644 --- a/dist/base.css +++ b/dist/base.css @@ -958,6 +958,11 @@ li.CodeMirror-hint-active { .bi-direction-pager .direction-pager-next { font-size: 16px; } +.bi-rich-editor .rich-editor-param { + -webkit-border-radius: 12px; + -moz-border-radius: 12px; + border-radius: 12px; +} .bi-rich-editor-text-toolbar .text-toolbar-button { font-size: 16px; } diff --git a/dist/bundle.css b/dist/bundle.css index 15e926abe..5cefebc55 100644 --- a/dist/bundle.css +++ b/dist/bundle.css @@ -2996,6 +2996,11 @@ li.CodeMirror-hint-active { .bi-direction-pager .direction-pager-next { font-size: 16px; } +.bi-rich-editor .rich-editor-param { + -webkit-border-radius: 12px; + -moz-border-radius: 12px; + border-radius: 12px; +} .bi-rich-editor-text-toolbar .text-toolbar-button { font-size: 16px; } diff --git a/dist/bundle.js b/dist/bundle.js index 44a94abe1..bf21151a8 100644 --- a/dist/bundle.js +++ b/dist/bundle.js @@ -28465,17 +28465,19 @@ BI.extend(BI.DOM, { $("body").append(canvas); var w = BI.DOM.getTextSizeWidth(param, 14) + 6; canvas.width = w; - canvas.height = 16; + canvas.height = 24; var ctx = canvas.getContext("2d"); - ctx.font = "14px Georgia"; - ctx.fillStyle = "#ffffff"; - ctx.fillText(param, 3, 14); + // ctx.fillStyle = "#EAF2FD"; + ctx.font = "12px Georgia"; + ctx.fillStyle = "#3D4D66"; + ctx.textBaseline = "middle"; + ctx.fillText(param, 6, 12); $(canvas).destroy(); return { width: w, - height: 16, + height: 24, src: canvas.toDataURL("image/png"), - style: "background-color: #3f8ce8; vertical-align: sub; margin: 0 3px;", + style: "background-color: #EAF2FD; vertical-align: sub; margin: 0 3px;", alt: param }; } @@ -81966,7 +81968,11 @@ BI.RichEditorAction = BI.inherit(BI.Widget, { */ BI.RichEditorParamAction = BI.inherit(BI.RichEditorAction, { _defaultConfig: function () { - return BI.extend(BI.RichEditorParamAction.superclass._defaultConfig.apply(this, arguments), {}); + return BI.extend(BI.RichEditorParamAction.superclass._defaultConfig.apply(this, arguments), { + paramFormatter: function (v) { + return v; + } + }); }, _init: function () { @@ -82001,11 +82007,11 @@ BI.RichEditorParamAction = BI.inherit(BI.RichEditorAction, { var o = this.options; var instance = o.editor.instance; var image = new Image(); - var attrs = BI.DOM.getImage(param); + var attrs = BI.DOM.getImage(o.paramFormatter(param)); image.src = attrs.src; image.alt = param; image.style = attrs.style; - + $(image).addClass("rich-editor-param"); var sel = this._get$Sel(); var wrapper = o.editor.instance.getElm().element; if (wrapper.find(sel).length <= 0) { @@ -83037,20 +83043,23 @@ BI.shortcut("bi.rich_editor_size_chooser", BI.RichEditorSizeChooser);/** * @extends BI.Widget */ BI.RichEditor = BI.inherit(BI.Widget, { - _defaultConfig: function () { - return BI.extend(BI.RichEditor.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-rich-editor", - toolbar: {} - }); + + props: { + baseCls: "bi-rich-editor", + toolbar: {}, + readOnly: false }, - _init: function () { - BI.RichEditor.superclass._init.apply(this, arguments); + + render: function () { var self = this, o = this.options; - this.editor = BI.createWidget({ + var editor = { type: "bi.nic_editor", width: o.width, height: o.height, readOnly: o.readOnly, + ref: function () { + self.editor = this; + }, listeners: [{ eventName: BI.NicEditor.EVENT_BLUR, action: function () { @@ -83059,23 +83068,28 @@ BI.RichEditor = BI.inherit(BI.Widget, { }, { eventName: BI.NicEditor.EVENT_FOCUS, action: function () { - if(!self.combo.isViewVisible()) { + if (!o.readOnly && !self.combo.isViewVisible()) { self.combo.showView(); } self.fireEvent(BI.RichEditor.EVENT_FOCUS); } }] - }); - - this.combo = BI.createWidget({ + }; + if(o.readOnly) { + return editor; + } + this.editor = BI.createWidget(editor); + return { type: "bi.combo", - element: this, toggle: false, - trigger: o.readOnly ? "" : "click", + trigger: "click", direction: "top,right", isNeedAdjustWidth: false, isNeedAdjustHeight: false, adjustLength: 1, + ref: function () { + self.combo = this; + }, el: this.editor, popup: { el: BI.extend({ @@ -83085,12 +83099,14 @@ BI.RichEditor = BI.inherit(BI.Widget, { height: 30, stopPropagation: true, stopEvent: true - } - }); - - this.combo.on(BI.Combo.EVENT_AFTER_HIDEVIEW, function () { - self.fireEvent(BI.RichEditor.EVENT_AFTER_HIDEVIEW); - }); + }, + listeners: [{ + eventName: BI.Combo.EVENT_AFTER_HIDEVIEW, + action: function () { + self.fireEvent(BI.RichEditor.EVENT_AFTER_HIDEVIEW); + } + }] + }; }, focus: function () { @@ -88128,7 +88144,7 @@ BI.shortcut("bi.static_date_pane_card", BI.StaticDatePaneCard);BI.DynamicDatePan } }], ref: function () { - self.switch = this; + self.switcher = this; } }, height: 30 @@ -88863,7 +88879,7 @@ BI.shortcut("bi.static_date_time_pane_card", BI.StaticDateTimePaneCard);BI.Dynam } }], ref: function () { - self.switch = this; + self.switcher = this; } }, height: 30 diff --git a/dist/case.js b/dist/case.js index 527371664..53d151eaa 100644 --- a/dist/case.js +++ b/dist/case.js @@ -10035,7 +10035,11 @@ BI.RichEditorAction = BI.inherit(BI.Widget, { */ BI.RichEditorParamAction = BI.inherit(BI.RichEditorAction, { _defaultConfig: function () { - return BI.extend(BI.RichEditorParamAction.superclass._defaultConfig.apply(this, arguments), {}); + return BI.extend(BI.RichEditorParamAction.superclass._defaultConfig.apply(this, arguments), { + paramFormatter: function (v) { + return v; + } + }); }, _init: function () { @@ -10070,11 +10074,11 @@ BI.RichEditorParamAction = BI.inherit(BI.RichEditorAction, { var o = this.options; var instance = o.editor.instance; var image = new Image(); - var attrs = BI.DOM.getImage(param); + var attrs = BI.DOM.getImage(o.paramFormatter(param)); image.src = attrs.src; image.alt = param; image.style = attrs.style; - + $(image).addClass("rich-editor-param"); var sel = this._get$Sel(); var wrapper = o.editor.instance.getElm().element; if (wrapper.find(sel).length <= 0) { @@ -11106,20 +11110,23 @@ BI.shortcut("bi.rich_editor_size_chooser", BI.RichEditorSizeChooser);/** * @extends BI.Widget */ BI.RichEditor = BI.inherit(BI.Widget, { - _defaultConfig: function () { - return BI.extend(BI.RichEditor.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-rich-editor", - toolbar: {} - }); + + props: { + baseCls: "bi-rich-editor", + toolbar: {}, + readOnly: false }, - _init: function () { - BI.RichEditor.superclass._init.apply(this, arguments); + + render: function () { var self = this, o = this.options; - this.editor = BI.createWidget({ + var editor = { type: "bi.nic_editor", width: o.width, height: o.height, readOnly: o.readOnly, + ref: function () { + self.editor = this; + }, listeners: [{ eventName: BI.NicEditor.EVENT_BLUR, action: function () { @@ -11128,23 +11135,28 @@ BI.RichEditor = BI.inherit(BI.Widget, { }, { eventName: BI.NicEditor.EVENT_FOCUS, action: function () { - if(!self.combo.isViewVisible()) { + if (!o.readOnly && !self.combo.isViewVisible()) { self.combo.showView(); } self.fireEvent(BI.RichEditor.EVENT_FOCUS); } }] - }); - - this.combo = BI.createWidget({ + }; + if(o.readOnly) { + return editor; + } + this.editor = BI.createWidget(editor); + return { type: "bi.combo", - element: this, toggle: false, - trigger: o.readOnly ? "" : "click", + trigger: "click", direction: "top,right", isNeedAdjustWidth: false, isNeedAdjustHeight: false, adjustLength: 1, + ref: function () { + self.combo = this; + }, el: this.editor, popup: { el: BI.extend({ @@ -11154,12 +11166,14 @@ BI.RichEditor = BI.inherit(BI.Widget, { height: 30, stopPropagation: true, stopEvent: true - } - }); - - this.combo.on(BI.Combo.EVENT_AFTER_HIDEVIEW, function () { - self.fireEvent(BI.RichEditor.EVENT_AFTER_HIDEVIEW); - }); + }, + listeners: [{ + eventName: BI.Combo.EVENT_AFTER_HIDEVIEW, + action: function () { + self.fireEvent(BI.RichEditor.EVENT_AFTER_HIDEVIEW); + } + }] + }; }, focus: function () { diff --git a/dist/core.js b/dist/core.js index bb332bde7..6be0fadb6 100644 --- a/dist/core.js +++ b/dist/core.js @@ -28465,17 +28465,19 @@ BI.extend(BI.DOM, { $("body").append(canvas); var w = BI.DOM.getTextSizeWidth(param, 14) + 6; canvas.width = w; - canvas.height = 16; + canvas.height = 24; var ctx = canvas.getContext("2d"); - ctx.font = "14px Georgia"; - ctx.fillStyle = "#ffffff"; - ctx.fillText(param, 3, 14); + // ctx.fillStyle = "#EAF2FD"; + ctx.font = "12px Georgia"; + ctx.fillStyle = "#3D4D66"; + ctx.textBaseline = "middle"; + ctx.fillText(param, 6, 12); $(canvas).destroy(); return { width: w, - height: 16, + height: 24, src: canvas.toDataURL("image/png"), - style: "background-color: #3f8ce8; vertical-align: sub; margin: 0 3px;", + style: "background-color: #EAF2FD; vertical-align: sub; margin: 0 3px;", alt: param }; } diff --git a/dist/demo.js b/dist/demo.js index 23a00fd2b..eaa207616 100644 --- a/dist/demo.js +++ b/dist/demo.js @@ -882,8 +882,7 @@ BI.shortcut("demo.multifile_editor", Demo.CodeEditor);Demo.RichEditor = BI.inher var image = BI.DOM.getImage("测试"); var src = image.src; var style = image.style; - - this.editor.setValue("
这是一条测试数据
"); + this.editor.setValue("
这是一条测试数据
"); } }); BI.shortcut("demo.rich_editor", Demo.RichEditor);/** diff --git a/dist/fineui.css b/dist/fineui.css index 6c9ae539a..c6a02c98f 100644 --- a/dist/fineui.css +++ b/dist/fineui.css @@ -2996,6 +2996,11 @@ li.CodeMirror-hint-active { .bi-direction-pager .direction-pager-next { font-size: 16px; } +.bi-rich-editor .rich-editor-param { + -webkit-border-radius: 12px; + -moz-border-radius: 12px; + border-radius: 12px; +} .bi-rich-editor-text-toolbar .text-toolbar-button { font-size: 16px; } diff --git a/dist/widget.js b/dist/widget.js index 62520f30e..61c1cd36b 100644 --- a/dist/widget.js +++ b/dist/widget.js @@ -1628,7 +1628,7 @@ BI.shortcut("bi.static_date_pane_card", BI.StaticDatePaneCard);BI.DynamicDatePan } }], ref: function () { - self.switch = this; + self.switcher = this; } }, height: 30 @@ -2363,7 +2363,7 @@ BI.shortcut("bi.static_date_time_pane_card", BI.StaticDateTimePaneCard);BI.Dynam } }], ref: function () { - self.switch = this; + self.switcher = this; } }, height: 30 diff --git a/src/case/richeditor/bar/action.richeditor.param.js b/src/case/richeditor/bar/action.richeditor.param.js index 222774ff3..3bbfea611 100644 --- a/src/case/richeditor/bar/action.richeditor.param.js +++ b/src/case/richeditor/bar/action.richeditor.param.js @@ -6,7 +6,11 @@ */ BI.RichEditorParamAction = BI.inherit(BI.RichEditorAction, { _defaultConfig: function () { - return BI.extend(BI.RichEditorParamAction.superclass._defaultConfig.apply(this, arguments), {}); + return BI.extend(BI.RichEditorParamAction.superclass._defaultConfig.apply(this, arguments), { + paramFormatter: function (v) { + return v; + } + }); }, _init: function () { @@ -41,11 +45,11 @@ BI.RichEditorParamAction = BI.inherit(BI.RichEditorAction, { var o = this.options; var instance = o.editor.instance; var image = new Image(); - var attrs = BI.DOM.getImage(param); + var attrs = BI.DOM.getImage(o.paramFormatter(param)); image.src = attrs.src; image.alt = param; image.style = attrs.style; - + $(image).addClass("rich-editor-param"); var sel = this._get$Sel(); var wrapper = o.editor.instance.getElm().element; if (wrapper.find(sel).length <= 0) { diff --git a/src/case/richeditor/richeditor.js b/src/case/richeditor/richeditor.js index e7f8acc22..809c2a671 100644 --- a/src/case/richeditor/richeditor.js +++ b/src/case/richeditor/richeditor.js @@ -6,20 +6,23 @@ * @extends BI.Widget */ BI.RichEditor = BI.inherit(BI.Widget, { - _defaultConfig: function () { - return BI.extend(BI.RichEditor.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-rich-editor", - toolbar: {} - }); + + props: { + baseCls: "bi-rich-editor", + toolbar: {}, + readOnly: false }, - _init: function () { - BI.RichEditor.superclass._init.apply(this, arguments); + + render: function () { var self = this, o = this.options; - this.editor = BI.createWidget({ + var editor = { type: "bi.nic_editor", width: o.width, height: o.height, readOnly: o.readOnly, + ref: function () { + self.editor = this; + }, listeners: [{ eventName: BI.NicEditor.EVENT_BLUR, action: function () { @@ -28,23 +31,28 @@ BI.RichEditor = BI.inherit(BI.Widget, { }, { eventName: BI.NicEditor.EVENT_FOCUS, action: function () { - if(!self.combo.isViewVisible()) { + if (!o.readOnly && !self.combo.isViewVisible()) { self.combo.showView(); } self.fireEvent(BI.RichEditor.EVENT_FOCUS); } }] - }); - - this.combo = BI.createWidget({ + }; + if(o.readOnly) { + return editor; + } + this.editor = BI.createWidget(editor); + return { type: "bi.combo", - element: this, toggle: false, - trigger: o.readOnly ? "" : "click", + trigger: "click", direction: "top,right", isNeedAdjustWidth: false, isNeedAdjustHeight: false, adjustLength: 1, + ref: function () { + self.combo = this; + }, el: this.editor, popup: { el: BI.extend({ @@ -54,12 +62,14 @@ BI.RichEditor = BI.inherit(BI.Widget, { height: 30, stopPropagation: true, stopEvent: true - } - }); - - this.combo.on(BI.Combo.EVENT_AFTER_HIDEVIEW, function () { - self.fireEvent(BI.RichEditor.EVENT_AFTER_HIDEVIEW); - }); + }, + listeners: [{ + eventName: BI.Combo.EVENT_AFTER_HIDEVIEW, + action: function () { + self.fireEvent(BI.RichEditor.EVENT_AFTER_HIDEVIEW); + } + }] + }; }, focus: function () { diff --git a/src/core/func/function.js b/src/core/func/function.js index 64c6f6454..3877f7e7a 100644 --- a/src/core/func/function.js +++ b/src/core/func/function.js @@ -306,17 +306,19 @@ BI.extend(BI.DOM, { $("body").append(canvas); var w = BI.DOM.getTextSizeWidth(param, 14) + 6; canvas.width = w; - canvas.height = 16; + canvas.height = 24; var ctx = canvas.getContext("2d"); - ctx.font = "14px Georgia"; - ctx.fillStyle = "#ffffff"; - ctx.fillText(param, 3, 14); + // ctx.fillStyle = "#EAF2FD"; + ctx.font = "12px Georgia"; + ctx.fillStyle = "#3D4D66"; + ctx.textBaseline = "middle"; + ctx.fillText(param, 6, 12); $(canvas).destroy(); return { width: w, - height: 16, + height: 24, src: canvas.toDataURL("image/png"), - style: "background-color: #3f8ce8; vertical-align: sub; margin: 0 3px;", + style: "background-color: #EAF2FD; vertical-align: sub; margin: 0 3px;", alt: param }; } diff --git a/src/css/base/richeditor/richeditor.css b/src/css/base/richeditor/richeditor.css new file mode 100644 index 000000000..84375e60c --- /dev/null +++ b/src/css/base/richeditor/richeditor.css @@ -0,0 +1,5 @@ +.bi-rich-editor .rich-editor-param { + -webkit-border-radius: 12px; + -moz-border-radius: 12px; + border-radius: 12px; +} diff --git a/src/less/base/richeditor/richeditor.less b/src/less/base/richeditor/richeditor.less new file mode 100644 index 000000000..52d0cd876 --- /dev/null +++ b/src/less/base/richeditor/richeditor.less @@ -0,0 +1,7 @@ +@import "../../index"; + +.bi-rich-editor { + & .rich-editor-param{ + .border-radius(12px); + } +} \ No newline at end of file diff --git a/src/widget/datepane/datepane.js b/src/widget/datepane/datepane.js index f559cb8c8..1104fe74c 100644 --- a/src/widget/datepane/datepane.js +++ b/src/widget/datepane/datepane.js @@ -47,7 +47,7 @@ BI.DynamicDatePane = BI.inherit(BI.Widget, { } }], ref: function () { - self.switch = this; + self.switcher = this; } }, height: 30 diff --git a/src/widget/datetimepane/datetimepane.js b/src/widget/datetimepane/datetimepane.js index 64b41be51..97b0eff4a 100644 --- a/src/widget/datetimepane/datetimepane.js +++ b/src/widget/datetimepane/datetimepane.js @@ -47,7 +47,7 @@ BI.DynamicDateTimePane = BI.inherit(BI.Widget, { } }], ref: function () { - self.switch = this; + self.switcher = this; } }, height: 30