editor format js
This commit is contained in:
parent
25bd2c5d72
commit
248b65834d
@ -19,3 +19,16 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
----------------------------------------------------------------
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
|
||||
1
_server/CodeMirror/beautify.min.js
vendored
Normal file
1
_server/CodeMirror/beautify.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -1,3 +1,5 @@
|
||||
|
||||
|
||||
editor_multi = function () {
|
||||
|
||||
var editor_multi = {};
|
||||
@ -19,6 +21,8 @@ editor_multi = function () {
|
||||
highlightSelectionMatches: {showToken: /\w/, annotateScrollbar: true}
|
||||
});
|
||||
|
||||
editor_multi.codeEditor = codeEditor;
|
||||
|
||||
codeEditor.on("keyup", function (cm, event) {
|
||||
if (codeEditor.getOption("autocomplete") && !event.ctrlKey && (
|
||||
(event.keyCode >= 65 && event.keyCode <= 90) ||
|
||||
@ -60,6 +64,18 @@ editor_multi = function () {
|
||||
return '\t';
|
||||
}
|
||||
|
||||
editor_multi.format = function () {
|
||||
if (!editor_multi.lintAutocomplete) {
|
||||
alert("只有代码才能进行格式化操作!");
|
||||
return;
|
||||
}
|
||||
codeEditor.setValue(js_beautify(codeEditor.getValue(), {
|
||||
brace_style: "collapse-preserve-inline",
|
||||
indent_with_tabs: true,
|
||||
jslint_happy: true
|
||||
}));
|
||||
}
|
||||
|
||||
editor_multi.import = function (id_, args) {
|
||||
var thisTr = document.getElementById(id_);
|
||||
if (!thisTr) return false;
|
||||
|
||||
@ -220,6 +220,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.format()">格式化</button>
|
||||
<input type="checkbox" onclick="editor_multi.toggerLint()" id="lintCheckbox"
|
||||
style="vertical-align: bottom;margin-left:6px"/>
|
||||
<span style="vertical-align: bottom; margin-left: -3px">语法检查</span>
|
||||
@ -554,6 +555,7 @@ if (location.protocol.indexOf("http")!=0) {
|
||||
<!-- codemirror -->
|
||||
<script src="_server/CodeMirror/codeMirror.bundle.min.js"></script>
|
||||
<script src="_server/CodeMirror/jshint.min.js"></script>
|
||||
<script src="_server/CodeMirror/beautify.min.js"></script>
|
||||
<script src="_server/CodeMirror/codeMirror.plugin.min.js"></script>
|
||||
<!-- colorPicker -->
|
||||
<script type="text/javascript" src="_server/colorPicker/color.all.min.js"></script>
|
||||
|
||||
@ -216,6 +216,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.format()">格式化</button>
|
||||
<input type="checkbox" onclick="editor_multi.toggerLint()" id="lintCheckbox"
|
||||
style="vertical-align: bottom;margin-left:6px"/>
|
||||
<span style="vertical-align: bottom; margin-left: -3px">语法检查</span>
|
||||
@ -535,6 +536,7 @@ if (location.protocol.indexOf("http")!=0) {
|
||||
<!-- codemirror -->
|
||||
<script src="_server/CodeMirror/codeMirror.bundle.min.js"></script>
|
||||
<script src="_server/CodeMirror/jshint.min.js"></script>
|
||||
<script src="_server/CodeMirror/beautify.min.js"></script>
|
||||
<script src="_server/CodeMirror/codeMirror.plugin.min.js"></script>
|
||||
<!-- colorPicker -->
|
||||
<script type="text/javascript" src="_server/colorPicker/color.all.min.js"></script>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user