Merge pull request #75 from zhaouv/v2.0-editor-20180304

editor:更改部分内容显示的缩进
This commit is contained in:
Zhang Chen 2018-03-12 00:25:45 +08:00 committed by GitHub
commit 7ad578a2a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 4 deletions

View File

@ -126,12 +126,12 @@ editor_mode.prototype.objToTr = function(obj,commentObj,field){
var outstr=['<tr id="',guid,'"><td title="',field,'">',shortField,'</td>',
'<td title="',commentHTMLescape,'">',shortCommentHTMLescape,'</td>',
'<td><div class="etableInputDiv">',editor_mode.objToTd(thiseval,comment),'</div></td></tr>\n',
'<td><div class="etableInputDiv">',editor_mode.objToTd(thiseval,comment,field),'</div></td></tr>\n',
];
return [outstr.join(''),guid];
}
editor_mode.prototype.objToTd = function(thiseval,comment){
editor_mode.prototype.objToTd = function(thiseval,comment,field){
if( comment.indexOf('$select') != -1){
var evalstr = comment.split('$select')[1].split('$end')[0];
var values = eval(evalstr)['values'];
@ -145,10 +145,19 @@ editor_mode.prototype.objToTd = function(thiseval,comment){
return ["<input spellcheck='false' value='",JSON.stringify(thiseval),"'/>\n"].join('');
} else {
//rows='",rows,"'
return ["<textarea spellcheck='false' >",JSON.stringify(thiseval,null,4),'</textarea>\n'].join('');
var num = 0;//editor_mode.indent(field);
return ["<textarea spellcheck='false' >",JSON.stringify(thiseval,null,num),'</textarea>\n'].join('');
}
}
editor_mode.prototype.indent = function(field){
var num = 4;
if(field.indexOf("['main']")===0)return 0;
if(field.indexOf("['flyRange']")!==-1)return 0;
if(field==="['special']")return 0;
return num;
}
editor_mode.prototype.addAction = function(action){
editor_mode.actionList.push(action);
}

View File

@ -16,6 +16,10 @@ editor_multi.isString=false;
editor_multi.show = function(){document.getElementById('left7').style='';}
editor_multi.hide = function(){document.getElementById('left7').style='z-index:-1;opacity: 0;';}
editor_multi.indent = function(field){
if(editor && editor.mode && editor.mode.indent)return editor.mode.indent(field);
return 4;
}
editor_multi.import = function(id_){
var thisTr = document.getElementById(id_);
@ -29,9 +33,10 @@ editor_multi.import = function(id_){
editor_multi.isString=true;
codeEditor.setValue(JSON.parse(input.value)||'');
} else {
var num = editor_multi.indent(field);
eval('var tobj='+(input.value||'null'));
var tmap={};
var tstr = JSON.stringify(tobj,function(k,v){if(typeof(v)===typeof('') && v.slice(0,8)==='function'){var id_ = editor.guid();tmap[id_]=v.toString();return id_;}else return v},4);
var tstr = JSON.stringify(tobj,function(k,v){if(typeof(v)===typeof('') && v.slice(0,8)==='function'){var id_ = editor.guid();tmap[id_]=v.toString();return id_;}else return v},num);
for(var id_ in tmap){
tstr = tstr.replace('"'+id_+'"',tmap[id_])
}