From 45f27530a025dc4a6e40f4b953db102a1d33748c Mon Sep 17 00:00:00 2001 From: YouWei Zhao Date: Mon, 12 Mar 2018 00:02:28 +0800 Subject: [PATCH] =?UTF-8?q?editor:=E6=9B=B4=E6=94=B9=E9=83=A8=E5=88=86?= =?UTF-8?q?=E5=86=85=E5=AE=B9=E6=98=BE=E7=A4=BA=E7=9A=84=E7=BC=A9=E8=BF=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _server/editor_mode.js | 15 ++++++++++++--- _server/editor_multi.js | 7 ++++++- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/_server/editor_mode.js b/_server/editor_mode.js index d48e222e..2782652f 100644 --- a/_server/editor_mode.js +++ b/_server/editor_mode.js @@ -126,12 +126,12 @@ editor_mode.prototype.objToTr = function(obj,commentObj,field){ var outstr=['',shortField,'', '',shortCommentHTMLescape,'', - '
',editor_mode.objToTd(thiseval,comment),'
\n', + '
',editor_mode.objToTd(thiseval,comment,field),'
\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 ["\n"].join(''); } else { //rows='",rows,"' - return ["\n'].join(''); + var num = 0;//editor_mode.indent(field); + return ["\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); } diff --git a/_server/editor_multi.js b/_server/editor_multi.js index e536d17e..3d6100a0 100644 --- a/_server/editor_multi.js +++ b/_server/editor_multi.js @@ -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_]) }