编辑器保存不退出
This commit is contained in:
parent
0a49409863
commit
e3940a4c70
@ -422,7 +422,7 @@ table.row {
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -60%);
|
||||
width: 436px;
|
||||
width: 540px;
|
||||
}
|
||||
|
||||
#uieventHead {
|
||||
@ -444,8 +444,8 @@ table.row {
|
||||
}
|
||||
|
||||
#uieventBody {
|
||||
width: 416px;
|
||||
height: 416px;
|
||||
width: 520px;
|
||||
height: 520px;
|
||||
position: relative;
|
||||
margin-left: 10px;
|
||||
margin-bottom: 5px;
|
||||
|
||||
@ -163,7 +163,7 @@ editor_blockly = function () {
|
||||
editor_blockly.hide();
|
||||
}
|
||||
|
||||
editor_blockly.confirm = function () {
|
||||
editor_blockly.confirm = function (keep) {
|
||||
if (!editor_blockly.id) {
|
||||
editor_blockly.id = '';
|
||||
return;
|
||||
@ -186,10 +186,13 @@ editor_blockly = function () {
|
||||
}
|
||||
var setvalue = function (value) {
|
||||
var thisTr = document.getElementById(editor_blockly.id);
|
||||
editor_blockly.id = '';
|
||||
var input = thisTr.children[2].children[0].children[0];
|
||||
input.value = value;
|
||||
editor_blockly.hide();
|
||||
if (!keep) {
|
||||
editor_blockly.id = '';
|
||||
editor_blockly.hide();
|
||||
}
|
||||
else alert('保存成功!');
|
||||
input.onchange();
|
||||
}
|
||||
if (codeAreaHL.getValue() === '') {
|
||||
|
||||
@ -345,7 +345,7 @@ editor_multi = function () {
|
||||
multiLineArgs = [null, null, null];
|
||||
}
|
||||
|
||||
editor_multi.confirm = function () {
|
||||
editor_multi.confirm = function (keep) {
|
||||
if (editor_multi.hasError()) {
|
||||
alert("当前好像存在严重的语法错误,请处理后再保存。\n严重的语法错误可能会导致整个编辑器的崩溃。");
|
||||
return;
|
||||
@ -359,21 +359,18 @@ editor_multi = function () {
|
||||
if (editor_multi.id === 'callFromBlockly') {
|
||||
// ----- 自动格式化
|
||||
_format();
|
||||
editor_multi.id = '';
|
||||
editor_multi.multiLineDone();
|
||||
editor_multi.multiLineDone(keep);
|
||||
return;
|
||||
}
|
||||
|
||||
if (editor_multi.id === 'importFile') {
|
||||
_format();
|
||||
editor_multi.id = '';
|
||||
editor_multi.writeFileDone();
|
||||
editor_multi.writeFileDone(keep);
|
||||
return;
|
||||
}
|
||||
|
||||
var setvalue = function (value) {
|
||||
var thisTr = document.getElementById(editor_multi.id);
|
||||
editor_multi.id = '';
|
||||
var input = thisTr.children[2].children[0].children[0];
|
||||
if (editor_multi.isString) {
|
||||
input.value = JSON.stringify(value);
|
||||
@ -392,7 +389,12 @@ editor_multi = function () {
|
||||
}
|
||||
input.value = tstr;
|
||||
}
|
||||
editor_multi.hide();
|
||||
if (!keep) {
|
||||
editor_multi.id = '';
|
||||
editor_multi.hide();
|
||||
} else {
|
||||
alert('写入成功!');
|
||||
}
|
||||
input.onchange();
|
||||
}
|
||||
lastOffset[editor_multi.id] = (codeEditor.getScrollInfo() || {}).top;
|
||||
@ -424,11 +426,16 @@ editor_multi = function () {
|
||||
editor_multi.lintAutocomplete = Boolean(args.lint);
|
||||
editor_multi.show();
|
||||
}
|
||||
editor_multi.multiLineDone = function () {
|
||||
editor_multi.hide();
|
||||
editor_multi.multiLineDone = function (keep) {
|
||||
if (!multiLineArgs[0] || !multiLineArgs[1] || !multiLineArgs[2]) return;
|
||||
var newvalue = codeEditor.getValue() || '';
|
||||
multiLineArgs[2](newvalue, multiLineArgs[0], multiLineArgs[1])
|
||||
if (!keep) {
|
||||
editor_multi.id = '';
|
||||
editor_multi.hide();
|
||||
} else {
|
||||
alert('写入成功!');
|
||||
}
|
||||
}
|
||||
|
||||
var _fileValues = ['']
|
||||
@ -453,7 +460,12 @@ editor_multi = function () {
|
||||
fs.writeFile(_fileValues[0], editor.util.encode64(codeEditor.getValue() || ''), 'base64', function (err, data) {
|
||||
if (err) printe('文件写入失败,请手动粘贴至' + _fileValues[0] + '\n' + err);
|
||||
else {
|
||||
editor_multi.hide();
|
||||
if (!keep) {
|
||||
editor_multi.id = '';
|
||||
editor_multi.hide();
|
||||
} else {
|
||||
alert('写入成功!');
|
||||
}
|
||||
printf(_fileValues[0] + " 写入成功,F5刷新后生效");
|
||||
}
|
||||
});
|
||||
|
||||
@ -108,7 +108,7 @@ editor_uievent_wrapper = function (editor) {
|
||||
|
||||
uievent.selectPoint = function (floorId, x, y, bigmap, callback) {
|
||||
uievent.values.bigmap = bigmap;
|
||||
uievent.values.size = editor.isMobile ? window.innerWidth / core.__SIZE__ : 32;
|
||||
uievent.values.size = editor.isMobile ? window.innerWidth / core.__SIZE__ : 32 * 1.25;
|
||||
|
||||
uievent.isOpen = true;
|
||||
uievent.elements.div.style.display = 'block';
|
||||
|
||||
@ -212,6 +212,7 @@
|
||||
<button onclick="editor_blockly.runCode()">console.log(obj=code)</button>
|
||||
-->
|
||||
<button onclick="editor_blockly.confirm()">确认</button>
|
||||
<button onclick="editor_blockly.confirm(true)">应用</button>
|
||||
<button id='blocklyParse' onclick="editor_blockly.parse()">解析</button>
|
||||
<button onclick="editor_blockly.cancel()">取消</button>
|
||||
<!-- 手机端放不下,因此不显示搜索框 -->
|
||||
@ -243,6 +244,7 @@
|
||||
<div id="left7" style="z-index:-1;opacity: 0;"><!-- 多行文本编辑器 -->
|
||||
<button onclick="editor_multi.confirm()">确认</button>
|
||||
<button onclick="editor_multi.cancel()">取消</button>
|
||||
<button onclick="editor_multi.confirm(true)">应用</button>
|
||||
<button onclick="editor_multi.format()">格式化</button>
|
||||
<button id="editor_multi_preview" style="display: none;">预览</button>
|
||||
<input type="checkbox" onclick="editor_multi.toggerLint()" id="lintCheckbox"
|
||||
|
||||
@ -209,6 +209,7 @@
|
||||
<button onclick="editor_blockly.runCode()">console.log(obj=code)</button>
|
||||
-->
|
||||
<button onclick="editor_blockly.confirm()">确认</button>
|
||||
<button onclick="editor_blockly.confirm(true)">应用</button>
|
||||
<button id='blocklyParse' onclick="editor_blockly.parse()">解析</button>
|
||||
<button onclick="editor_blockly.cancel()">取消</button>
|
||||
<div style="position: relative; display: inline-block; margin-left: 10px">
|
||||
@ -239,6 +240,7 @@
|
||||
<div id="left7" style="z-index:-1;opacity: 0;"><!-- 多行文本编辑器 -->
|
||||
<button onclick="editor_multi.confirm()">确认</button>
|
||||
<button onclick="editor_multi.cancel()">取消</button>
|
||||
<button onclick="editor_multi.confirm(true)">应用</button>
|
||||
<button onclick="editor_multi.format()">格式化</button>
|
||||
<button id="editor_multi_preview" style="display: none;">预览</button>
|
||||
<input type="checkbox" onclick="editor_multi.toggerLint()" id="lintCheckbox"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user