From 6291d1ea65fc52a42305a5e316bed81b22af6df3 Mon Sep 17 00:00:00 2001 From: ckcz123 Date: Mon, 30 Aug 2021 20:11:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96blockly=E5=A4=9A=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _server/MotaAction.g4 | 16 ++++++++-------- _server/editor_blockly.js | 15 ++++++++++++++- _server/thirdparty/caret-position.js | 2 +- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/_server/MotaAction.g4 b/_server/MotaAction.g4 index d2676d2c..a831a758 100644 --- a/_server/MotaAction.g4 +++ b/_server/MotaAction.g4 @@ -2055,37 +2055,37 @@ return code; */; animate_s - : '显示动画' IdString '位置' 'x' PosString? 'y' PosString? '相对窗口坐标' Bool '不等待执行完毕' Bool Newline + : '显示动画' EvalString '位置' 'x' PosString? 'y' PosString? '相对窗口坐标' Bool '不等待执行完毕' Bool Newline /* animate_s tooltip : animate:显示动画,位置填hero或者1,2形式的位置,或者不填代表当前事件点 helpUrl : /_docs/#/instruction default : ["zone","","",false,false] -allAnimates : ['IdString_0'] -material : ["./project/animates/", "IdString_0"] +allAnimates : ['EvalString_0'] +material : ["./project/animates/", "EvalString_0"] menu : [['选择位置', 'editor_blockly.selectPoint(block, ["PosString_0", "PosString_1"])']] colour : this.soundColor var loc = PosString_0&&PosString_1?(', "loc": ['+PosString_0+','+PosString_1+']'):''; Bool_0 = Bool_0?', "alignWindow": true':''; Bool_1 = Bool_1?', "async": true':''; -var code = '{"type": "animate", "name": "'+IdString_0+'"'+loc+Bool_0+Bool_1+'},\n'; +var code = '{"type": "animate", "name": "'+EvalString_0+'"'+loc+Bool_0+Bool_1+'},\n'; return code; */; animate_1_s - : '显示动画并跟随角色' IdString '不等待执行完毕' Bool Newline + : '显示动画并跟随角色' EvalString '不等待执行完毕' Bool Newline /* animate_1_s tooltip : animate:显示动画并跟随角色 helpUrl : /_docs/#/instruction default : ["zone",false] -allAnimates : ['IdString_0'] -material : ["./project/animates/", "IdString_0"] +allAnimates : ['EvalString_0'] +material : ["./project/animates/", "EvalString_0"] colour : this.soundColor Bool_0 = Bool_0?', "async": true':''; -var code = '{"type": "animate", "name": "'+IdString_0+'", "loc": "hero"'+Bool_0+'},\n'; +var code = '{"type": "animate", "name": "'+EvalString_0+'", "loc": "hero"'+Bool_0+'},\n'; return code; */; diff --git a/_server/editor_blockly.js b/_server/editor_blockly.js index af5b87bc..7c477ff9 100644 --- a/_server/editor_blockly.js +++ b/_server/editor_blockly.js @@ -1188,4 +1188,17 @@ Blockly.FieldDropdown.prototype.doValueUpdate_ = function (newValue) { options.push([this.value_, this.value_]); this.selectedOption_ = options[options.length - 1]; } -}; \ No newline at end of file +}; + +Blockly.FieldMultilineInput.prototype.getDisplayText_ = function() { + var value = this.value_; + if (!value) return Blockly.Field.NBSP; + var curr = '', text = ''; + for (var i = 0; i < value.length; ++i) { + if (value[i] == '\n' || curr.length == this.maxDisplayLength) { + text += curr.replace(/\s/g, Blockly.Field.NBSP) + '\n'; + curr = value[i] == '\n' ? '' : value[i]; + } else curr += value[i]; + } + return text + curr; +}; diff --git a/_server/thirdparty/caret-position.js b/_server/thirdparty/caret-position.js index 8294e99f..b6e14aa6 100644 --- a/_server/thirdparty/caret-position.js +++ b/_server/thirdparty/caret-position.js @@ -109,7 +109,7 @@ } }); if (!isInput) - style.whiteSpace = 'pre'; + style.whiteSpace = 'pre-wrap'; if (isFirefox) { // Firefox lies about the overflow property for textareas: https://bugzilla.mozilla.org/show_bug.cgi?id=984275