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