editor细节调整

This commit is contained in:
YouWei Zhao 2018-03-10 21:00:18 +08:00
parent 628d7eeafa
commit ae0a8be8f1
5 changed files with 41 additions and 13 deletions

View File

@ -35,8 +35,17 @@
height: 780px;
}
#left6 #blocklyDiv {height: 480px; width: 940px;float:left;}
#left6 #codeArea {width: 99.5%; height: 15.4em;overflow:y;/* resize:none; */clear:both;}
#left6 #blocklyDiv {
height: 480px;
width: 940px;
}
#left6 .CodeMirror {
border: 1px solid #eee;
height: 200px;
width: 1300px;
}
#left6 #codeArea {width: 99.5%; height: 15.4em;overflow:y;/* resize:none; */}
#left7 {
/* height: 440px; width: 375px;float:left; */

View File

@ -209,9 +209,9 @@ initscript=String.raw`
}
try {
var code = Blockly.JavaScript.workspaceToCode(workspace);
document.getElementById('codeArea').value = code;
codeAreaHL.setValue(code);
} catch (error) {
document.getElementById('codeArea').value = String(error);
codeAreaHL.setValue(String(error));
if (error instanceof OmitedError){
var blockName = error.blockName;
var varName = error.varName;
@ -267,6 +267,14 @@ xhr.onreadystatechange = function (){
xhr.open('GET','_server/blockly/MotaAction.g4',true);
xhr.send(null);
var codeAreaHL = CodeMirror.fromTextArea(document.getElementById("codeArea"), {
lineNumbers: true,
matchBrackets: true,
lineWrapping: true,
continueComments: "Enter",
extraKeys: {"Ctrl-Q": "toggleComment"}
});
editor_blockly.showXML = function () {
var xml = Blockly.Xml.workspaceToDom(editor_blockly.workspace);
var xml_text = Blockly.Xml.domToPrettyText(xml);
@ -293,7 +301,7 @@ editor_blockly.runCode = function () {
editor_blockly.parse = function () {
MotaActionFunctions.parse(
eval('obj=' + document.getElementById('codeArea').value.replace(/[<>&]/g,function(c){return {'<':'&lt;','>':'&gt;','&':'&amp;'}[c];})),
eval('obj=' + codeAreaHL.getValue().replace(/[<>&]/g,function(c){return {'<':'&lt;','>':'&gt;','&':'&amp;'}[c];})),
document.getElementById('entryType').value
);
}
@ -322,7 +330,7 @@ editor_blockly.import = function(id_){
}[field];
if(!type)return false;
editor_blockly.id=id_;
document.getElementById('codeArea').value = input.value;
codeAreaHL.setValue(input.value);
document.getElementById('entryType').value = type;
editor_blockly.parse();
editor_blockly.show();
@ -350,7 +358,7 @@ editor_blockly.confirm = function (){
editor_blockly.hide();
input.onchange();
}
if(document.getElementById('codeArea').value===''){
if(codeAreaHL.getValue()===''){
setvalue('null');
return;
}

View File

@ -322,6 +322,10 @@ editor_file = function(editor, callback){
else */
locObj[v]=null;
});
Object.keys(editor_file.comment.floors.loc).forEach(function(v){
delete(locObj[v]);
});
delete(locObj.map);
return locObj;
})(),
editor_file.comment.floors.floor,
@ -337,6 +341,10 @@ editor_file = function(editor, callback){
else */
locObj[v]=null;
});
Object.keys(editor_file.comment.floors.loc).forEach(function(v){
delete(locObj[v]);
});
delete(locObj.map);
return locObj;
})(),
editor_file.comment.floors.floor,

View File

@ -219,6 +219,7 @@ tip_in_showMode = [
'涉及图片的更改需要F5刷新浏览器来生效',
'文本域可以通过双击,在文本编辑器或事件编辑器中编辑',
'事件编辑器中的显示文本和自定义脚本的方块也可以双击',
"画出的地图要点击\"保存地图\"才会写入到文件中",
];
var tip = new Vue({
el: '#tip',

View File

@ -17,10 +17,9 @@
<p class="warnText" v-if="error">{{ errors[error-1] }}</p>
</div>
<div id="editTip" v-cloak>
<select id="selectFloor"></select><br>
<br>
<input type="button" value="当前地图另存为" id='saveFloorAs'/>
<input id='saveAsName' placeholder="输入新楼层id"/>
<input class='btn' type="button" value="save" id='saveFloor'/>
<input class='btn' type="button" value="saveAs" id='saveFloorAs'/>
<input class='btn' type="button" value="复制地图" v-on:click="copyMap"/>
</div>
<div style="position: absolute;right: 10px;bottom:70px;">
@ -128,7 +127,7 @@
<category name="template"></category>
</xml>
</h3>
<div>
<div style="position: relative;">
<div id="blocklyDiv"></div>
<textarea id="codeArea" spellcheck="false"></textarea>
</div>
@ -183,6 +182,9 @@
<option value="functions">脚本编辑</option>
<option value="appendpic">追加素材</option>
</select>
<br><br><br><br>
<select id="selectFloor"></select>
<input type="button" value="保存地图" id='saveFloor'/>
<!-- -->
<div id="bgSelect" v-cloak style="display:none">
<span>当前地板: </span>
@ -337,7 +339,7 @@
<script>
//所有全局量
__all__=['Vue','fs','editor_file','editor_mode','main','core','hasOwnProp','printf','printe','editor','converter','ActionParser','MotaActionFunctions','MotaActionBlocks'];
__id__=['editArea','arrRowMark','mapRowMark','data','bg','dataSelection','blocklyDiv','codeArea','entryType'];
__id__=['editArea','arrRowMark','mapRowMark','data','bg','dataSelection','blocklyDiv','codeAreaHL','entryType'];
__Vue__=['exportM','editArea','editTip','clear','tip','selectBox'];
//var event = document.getElementById('event');
@ -357,7 +359,7 @@ main.init('editor', function() {
editor.mode.floor();
editor.mode.tower();
editor.mode.functions();
editor.mode.showMode('loc');
editor.mode.showMode('floor');
editor.mode.listen();
editor_multi=editor_multi();
editor_blockly=editor_blockly();