feat:样板编辑器升级
This commit is contained in:
parent
a04069b0ee
commit
00addfcbf3
2
_server/CodeMirror/beautify.min.js
vendored
2
_server/CodeMirror/beautify.min.js
vendored
File diff suppressed because one or more lines are too long
2
_server/CodeMirror/jshint.min.js
vendored
2
_server/CodeMirror/jshint.min.js
vendored
File diff suppressed because one or more lines are too long
BIN
_server/css/FiraCode.ttf
Normal file
BIN
_server/css/FiraCode.ttf
Normal file
Binary file not shown.
@ -699,3 +699,12 @@ div.checkboxSet {
|
|||||||
.etableInputDiv textarea:hover {
|
.etableInputDiv textarea:hover {
|
||||||
margin: -5px;
|
margin: -5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@font-face {
|
||||||
|
font-family: code;
|
||||||
|
src: url(./FiraCode.ttf);
|
||||||
|
}
|
||||||
|
|
||||||
|
.main .CodeMirror {
|
||||||
|
font-family: code, 微软雅黑, 黑体, 新宋体, Verdana;
|
||||||
|
}
|
||||||
|
|||||||
@ -710,3 +710,11 @@ div.checkboxSet {
|
|||||||
margin: -5px;
|
margin: -5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@font-face {
|
||||||
|
font-family: Fira;
|
||||||
|
src: url(./FiraCode.ttf);
|
||||||
|
}
|
||||||
|
|
||||||
|
.main .CodeMirror {
|
||||||
|
font-family: Fira, Menlo, Consolas, 'Courier New', Courier, monospace;
|
||||||
|
}
|
||||||
|
|||||||
@ -7,11 +7,11 @@ editor_multi = function () {
|
|||||||
var extraKeys = {
|
var extraKeys = {
|
||||||
"Ctrl-/": function (cm) { cm.toggleComment(); },
|
"Ctrl-/": function (cm) { cm.toggleComment(); },
|
||||||
"Ctrl-B": function (cm) { ternServer.jumpToDef(cm); },
|
"Ctrl-B": function (cm) { ternServer.jumpToDef(cm); },
|
||||||
"Ctrl-Q": function(cm) { ternServer.rename(cm); },
|
"Ctrl-Q": function (cm) { ternServer.rename(cm); },
|
||||||
"Cmd-F": CodeMirror.commands.findPersistent,
|
"Cmd-F": CodeMirror.commands.findPersistent,
|
||||||
"Ctrl-F": CodeMirror.commands.findPersistent,
|
"Ctrl-F": CodeMirror.commands.findPersistent,
|
||||||
"Ctrl-R": CodeMirror.commands.replaceAll,
|
"Ctrl-R": CodeMirror.commands.replaceAll,
|
||||||
"Ctrl-D": function(cm){ cm.foldCode(cm.getCursor()); },
|
"Ctrl-D": function (cm) { cm.foldCode(cm.getCursor()); },
|
||||||
"Ctrl-O": function () { editor_multi.openUrl('/_docs/#/api'); },
|
"Ctrl-O": function () { editor_multi.openUrl('/_docs/#/api'); },
|
||||||
"Ctrl-P": function () { editor_multi.openUrl('https://h5mota.com/plugins/'); }
|
"Ctrl-P": function () { editor_multi.openUrl('https://h5mota.com/plugins/'); }
|
||||||
};
|
};
|
||||||
@ -48,14 +48,14 @@ editor_multi = function () {
|
|||||||
'Ctrl-P': '打开在线插件列表(Ctrl+P)'
|
'Ctrl-P': '打开在线插件列表(Ctrl+P)'
|
||||||
};
|
};
|
||||||
|
|
||||||
document.getElementById('codemirrorCommands').innerHTML =
|
document.getElementById('codemirrorCommands').innerHTML =
|
||||||
"<option value='' selected>执行操作...</option>" +
|
"<option value='' selected>执行操作...</option>" +
|
||||||
Object.keys(commandsName).map(function (name) {
|
Object.keys(commandsName).map(function (name) {
|
||||||
return "<option value='" + name + "'>" + commandsName[name] + "</option>"
|
return "<option value='" + name + "'>" + commandsName[name] + "</option>"
|
||||||
}).join('');
|
}).join('');
|
||||||
|
|
||||||
var coredef = terndefs_f6783a0a_522d_417e_8407_94c67b692e50[2];
|
var coredef = terndefs_f6783a0a_522d_417e_8407_94c67b692e50[2];
|
||||||
Object.keys(core.material.enemys).forEach(function (name){
|
Object.keys(core.material.enemys).forEach(function (name) {
|
||||||
coredef.core.material.enemys[name] = {
|
coredef.core.material.enemys[name] = {
|
||||||
"!type": "enemy",
|
"!type": "enemy",
|
||||||
"!doc": core.material.enemys[name].name || "怪物"
|
"!doc": core.material.enemys[name].name || "怪物"
|
||||||
@ -236,7 +236,15 @@ editor_multi = function () {
|
|||||||
document.getElementById('left7').style = 'z-index:-1;opacity: 0;';
|
document.getElementById('left7').style = 'z-index:-1;opacity: 0;';
|
||||||
}
|
}
|
||||||
editor_multi.setLint = function () {
|
editor_multi.setLint = function () {
|
||||||
codeEditor.setOption("lint", editor_multi.lintAutocomplete);
|
if (editor_multi.lintAutocomplete) {
|
||||||
|
codeEditor.setOption("lint", {
|
||||||
|
options: {
|
||||||
|
esversion: 2021
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
codeEditor.setOption("lint", false);
|
||||||
|
}
|
||||||
codeEditor.setOption("autocomplete", editor_multi.lintAutocomplete);
|
codeEditor.setOption("autocomplete", editor_multi.lintAutocomplete);
|
||||||
document.getElementById("lintCheckbox").checked = editor_multi.lintAutocomplete;
|
document.getElementById("lintCheckbox").checked = editor_multi.lintAutocomplete;
|
||||||
}
|
}
|
||||||
@ -253,7 +261,7 @@ editor_multi = function () {
|
|||||||
var _format = function () {
|
var _format = function () {
|
||||||
if (!editor_multi.lintAutocomplete) return;
|
if (!editor_multi.lintAutocomplete) return;
|
||||||
var offset = (codeEditor.getScrollInfo() || {}).top || 0;
|
var offset = (codeEditor.getScrollInfo() || {}).top || 0;
|
||||||
_setValue(js_beautify(codeEditor.getValue(), {
|
_setValue(beautifier.js(codeEditor.getValue(), {
|
||||||
brace_style: "collapse-preserve-inline",
|
brace_style: "collapse-preserve-inline",
|
||||||
indent_with_tabs: true,
|
indent_with_tabs: true,
|
||||||
jslint_happy: true
|
jslint_happy: true
|
||||||
@ -486,6 +494,22 @@ editor_multi = function () {
|
|||||||
editor_multi.importFile(dict[mod])
|
editor_multi.importFile(dict[mod])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 字体大小
|
||||||
|
{
|
||||||
|
const CONFIG_KEY = "editor_multi.fontSize";
|
||||||
|
let fontsize = editor.config.get(CONFIG_KEY, 14);
|
||||||
|
const input = document.getElementById("editor_multi_fontsize");
|
||||||
|
const check = document.getElementById("editor_multi_fontweight")
|
||||||
|
input.value = fontsize;
|
||||||
|
editor_multi.setFontSize = function () {
|
||||||
|
const value = Number(input.value);
|
||||||
|
editor.config.set(CONFIG_KEY, value);
|
||||||
|
const ele = codeEditor.getWrapperElement()
|
||||||
|
ele.style.fontSize = `${value}px`;
|
||||||
|
ele.style.fontWeight = `${check.checked ? 'bold' : 'normal'}`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return editor_multi;
|
return editor_multi;
|
||||||
}
|
}
|
||||||
//editor_multi=editor_multi();
|
//editor_multi=editor_multi();
|
||||||
@ -242,15 +242,21 @@
|
|||||||
<button onclick="confirmColor()">确定</button>
|
<button onclick="confirmColor()">确定</button>
|
||||||
</div>
|
</div>
|
||||||
<div id="left7" style="z-index:-1;opacity: 0;"><!-- 多行文本编辑器 -->
|
<div id="left7" style="z-index:-1;opacity: 0;"><!-- 多行文本编辑器 -->
|
||||||
<button onclick="editor_multi.confirm()">确认</button>
|
<div>
|
||||||
<button onclick="editor_multi.cancel()">取消</button>
|
<button onclick="editor_multi.confirm()">确认</button>
|
||||||
<button onclick="editor_multi.confirm(true)">应用</button>
|
<button onclick="editor_multi.cancel()">取消</button>
|
||||||
<button onclick="editor_multi.format()">格式化</button>
|
<button onclick="editor_multi.confirm(true)">应用</button>
|
||||||
<button id="editor_multi_preview" style="display: none;">预览</button>
|
<button onclick="editor_multi.format()">格式化</button>
|
||||||
<input type="checkbox" onclick="editor_multi.toggerLint()" id="lintCheckbox"
|
<button id="editor_multi_preview" style="display: none;">预览</button>
|
||||||
style="vertical-align: middle;margin-left:6px"/>
|
<input type="checkbox" onclick="editor_multi.toggerLint()" id="lintCheckbox"
|
||||||
<span style="vertical-align: middle; margin-left: -3px">语法检查</span>
|
style="vertical-align: middle;margin-left:6px"/>
|
||||||
<select id="codemirrorCommands" onchange="editor_multi.doCommand(this)" style="vertical-align: middle; margin-left: 6px;"></select>
|
<span style="vertical-align: middle; margin-left: -3px">语法检查</span>
|
||||||
|
<select id="codemirrorCommands" onchange="editor_multi.doCommand(this)" style="vertical-align: middle; margin-left: 6px;"></select>
|
||||||
|
<span>字体大小</span>
|
||||||
|
<input style="width: 40px" type="number" onchange="editor_multi.setFontSize()" id="editor_multi_fontsize" />
|
||||||
|
<span>字体加粗</span>
|
||||||
|
<input style="width: 40px" type="checkbox" onchange="editor_multi.setFontSize()" id="editor_multi_fontweight" />
|
||||||
|
</div>
|
||||||
<textarea id="multiLineCode" name="multiLineCode"></textarea>
|
<textarea id="multiLineCode" name="multiLineCode"></textarea>
|
||||||
</div>
|
</div>
|
||||||
<div id="left8" class='leftTab' style="z-index:-1;opacity: 0;"><!-- functions -->
|
<div id="left8" class='leftTab' style="z-index:-1;opacity: 0;"><!-- functions -->
|
||||||
|
|||||||
24
editor.html
24
editor.html
@ -238,15 +238,21 @@
|
|||||||
<button onclick="confirmColor()">确定</button>
|
<button onclick="confirmColor()">确定</button>
|
||||||
</div>
|
</div>
|
||||||
<div id="left7" style="z-index:-1;opacity: 0;"><!-- 多行文本编辑器 -->
|
<div id="left7" style="z-index:-1;opacity: 0;"><!-- 多行文本编辑器 -->
|
||||||
<button onclick="editor_multi.confirm()">确认</button>
|
<div>
|
||||||
<button onclick="editor_multi.cancel()">取消</button>
|
<button onclick="editor_multi.confirm()">确认</button>
|
||||||
<button onclick="editor_multi.confirm(true)">应用</button>
|
<button onclick="editor_multi.cancel()">取消</button>
|
||||||
<button onclick="editor_multi.format()">格式化</button>
|
<button onclick="editor_multi.confirm(true)">应用</button>
|
||||||
<button id="editor_multi_preview" style="display: none;">预览</button>
|
<button onclick="editor_multi.format()">格式化</button>
|
||||||
<input type="checkbox" onclick="editor_multi.toggerLint()" id="lintCheckbox"
|
<button id="editor_multi_preview" style="display: none;">预览</button>
|
||||||
style="vertical-align: middle;margin-left:6px"/>
|
<input type="checkbox" onclick="editor_multi.toggerLint()" id="lintCheckbox"
|
||||||
<span style="vertical-align: middle; margin-left: -3px">语法检查</span>
|
style="vertical-align: middle;margin-left:6px"/>
|
||||||
<select id="codemirrorCommands" onchange="editor_multi.doCommand(this)" style="vertical-align: middle; margin-left: 6px;"></select>
|
<span style="vertical-align: middle; margin-left: -3px">语法检查</span>
|
||||||
|
<select id="codemirrorCommands" onchange="editor_multi.doCommand(this)" style="vertical-align: middle; margin-left: 6px;"></select>
|
||||||
|
<span>字体大小</span>
|
||||||
|
<input style="width: 40px" type="number" onchange="editor_multi.setFontSize()" id="editor_multi_fontsize" />
|
||||||
|
<span>字体加粗</span>
|
||||||
|
<input style="width: 40px" type="checkbox" onchange="editor_multi.setFontSize()" id="editor_multi_fontweight" />
|
||||||
|
</div>
|
||||||
<textarea id="multiLineCode" name="multiLineCode"></textarea>
|
<textarea id="multiLineCode" name="multiLineCode"></textarea>
|
||||||
</div>
|
</div>
|
||||||
<div id="left8" class='leftTab' style="z-index:-1;opacity: 0;"><!-- functions -->
|
<div id="left8" class='leftTab' style="z-index:-1;opacity: 0;"><!-- functions -->
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user