Compress CodeMirror
This commit is contained in:
parent
3282aba011
commit
a64f80414a
@ -32,3 +32,26 @@ The above copyright notice and this permission notice shall be included in all c
|
||||
|
||||
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.
|
||||
|
||||
----------------------------------------------------------------
|
||||
|
||||
MIT License
|
||||
|
||||
Copyright (C) 2013 by Marijn Haverbeke and others <marijnh@gmail.com>
|
||||
|
||||
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.
|
||||
@ -1051,11 +1051,33 @@
|
||||
}
|
||||
if (hiding) hiding.style.opacity = 1
|
||||
findNext(cm, event.shiftKey, function(_, to) {
|
||||
var dialog
|
||||
if (to.line < 3 && document.querySelector &&
|
||||
(dialog = cm.display.wrapper.querySelector(".CodeMirror-dialog")) &&
|
||||
dialog.getBoundingClientRect().bottom - 4 > cm.cursorCoords(to, "window").top)
|
||||
(hiding = dialog).style.opacity = .4
|
||||
// --- Add count
|
||||
var text = document.getElementById('CodeMirror-search-count');
|
||||
if (text) {
|
||||
if (to) {
|
||||
var query = state.query;
|
||||
if (typeof query === 'string') {
|
||||
query = new RegExp(query.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), queryCaseInsensitive(query) ? "gi": "g");
|
||||
} else if (query instanceof RegExp) {
|
||||
query = new RegExp(query.source, query.flags + "g");
|
||||
} else { query = null; }
|
||||
if (query) {
|
||||
text.innerText = (cm.getRange({line: 0, ch: 0}, to).match(query) || []).length
|
||||
+ "/" + (cm.getValue().match(query) || []).length;
|
||||
} else {
|
||||
text.innerText = '0/0';
|
||||
}
|
||||
} else {
|
||||
text.innerText = '0/0';
|
||||
}
|
||||
}
|
||||
if (to) {
|
||||
var dialog
|
||||
if (to.line < 3 && document.querySelector &&
|
||||
(dialog = cm.display.wrapper.querySelector(".CodeMirror-dialog")) &&
|
||||
dialog.getBoundingClientRect().bottom - 4 > cm.cursorCoords(to, "window").top)
|
||||
(hiding = dialog).style.opacity = .4
|
||||
}
|
||||
})
|
||||
};
|
||||
persistentDialog(cm, getQueryDialog(cm), q, searchNext, function(event, query) {
|
||||
@ -1091,7 +1113,7 @@
|
||||
var cursor = getSearchCursor(cm, state.query, rev ? state.posFrom : state.posTo);
|
||||
if (!cursor.find(rev)) {
|
||||
cursor = getSearchCursor(cm, state.query, rev ? CodeMirror.Pos(cm.lastLine()) : CodeMirror.Pos(cm.firstLine(), 0));
|
||||
if (!cursor.find(rev)) return;
|
||||
if (!cursor.find(rev)) return callback && callback(null, null);
|
||||
}
|
||||
cm.setSelection(cursor.from(), cursor.to());
|
||||
cm.scrollIntoView({from: cursor.from(), to: cursor.to()}, 20);
|
||||
@ -1100,6 +1122,8 @@
|
||||
});}
|
||||
|
||||
function clearSearch(cm) {cm.operation(function() {
|
||||
var text = document.getElementById('CodeMirror-search-count');
|
||||
if (text) text.innerText = '';
|
||||
var state = getSearchState(cm);
|
||||
state.lastQuery = state.query;
|
||||
if (!state.query) return;
|
||||
@ -1110,16 +1134,16 @@
|
||||
|
||||
|
||||
function getQueryDialog(cm) {
|
||||
return '<span class="CodeMirror-search-label">' + "搜索: " + '</span> <input type="text" style="width: 10em" class="CodeMirror-search-field"/> <span style="color: #888" class="CodeMirror-search-hint">' + "使用/re/语法正则搜索" + '</span>';
|
||||
return '<span class="CodeMirror-search-label">搜索: </span> <input type="text" style="width: 10em" class="CodeMirror-search-field"/> <span class="CodeMirror-search-label" id="CodeMirror-search-count">0/0</span> <span style="color: #888" class="CodeMirror-search-hint">使用/re/语法正则搜索</span>';
|
||||
}
|
||||
function getReplaceQueryDialog(cm) {
|
||||
return ' <input type="text" style="width: 10em" class="CodeMirror-search-field"/> <span style="color: #888" class="CodeMirror-search-hint">' + "使用/re/语法正则搜索" + '</span>';
|
||||
return ' <input type="text" style="width: 10em" class="CodeMirror-search-field"/> <span style="color: #888" class="CodeMirror-search-hint">使用/re/语法正则搜索</span>';
|
||||
}
|
||||
function getReplacementQueryDialog(cm) {
|
||||
return '<span class="CodeMirror-search-label">' + "替换为: " + '</span> <input type="text" style="width: 10em" class="CodeMirror-search-field"/>';
|
||||
return '<span class="CodeMirror-search-label">替换为: </span> <input type="text" style="width: 10em" class="CodeMirror-search-field"/>';
|
||||
}
|
||||
function getDoReplaceConfirm(cm) {
|
||||
return '<span class="CodeMirror-search-label">' + "确认替换?" + '</span> <button>' + "确定" + '</button> <button>' + "取消" + '</button> <button>' + "全部替换" + '</button> <button>' + "停止搜索" + '</button> ';
|
||||
return '<span class="CodeMirror-search-label">确认替换?</span> <button>确定</button> <button>取消</button> <button>全部替换</button> <button>停止搜索</button> ';
|
||||
}
|
||||
|
||||
function replaceAll(cm, query, text) {
|
||||
|
||||
1
_server/CodeMirror/codeMirror.plugin.min.js
vendored
Normal file
1
_server/CodeMirror/codeMirror.plugin.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
1
_server/CodeMirror/tern.min.js
vendored
Normal file
1
_server/CodeMirror/tern.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -470,10 +470,10 @@
|
||||
<script src="_server/CodeMirror/codeMirror.bundle.min.js"></script>
|
||||
<script src="_server/CodeMirror/beautify.min.js"></script>
|
||||
<script src="_server/CodeMirror/jshint.min.js"></script>
|
||||
<script src="_server/CodeMirror/codeMirror.plugin.js"></script>
|
||||
<script src="_server/CodeMirror/codeMirror.plugin.min.js"></script>
|
||||
<script src="_server/CodeMirror/acorn.min.js"></script>
|
||||
<script src="_server/CodeMirror/defs.js"></script>
|
||||
<script src="_server/CodeMirror/tern.js"></script>
|
||||
<script src="_server/CodeMirror/tern.min.js"></script>
|
||||
<!-- thirdparty -->
|
||||
<script src="_server/thirdparty/color.all.min.js"></script>
|
||||
<script src="_server/thirdparty/awesomplete.min.js"></script>
|
||||
|
||||
@ -453,10 +453,10 @@
|
||||
<script src="_server/CodeMirror/codeMirror.bundle.min.js"></script>
|
||||
<script src="_server/CodeMirror/beautify.min.js"></script>
|
||||
<script src="_server/CodeMirror/jshint.min.js"></script>
|
||||
<script src="_server/CodeMirror/codeMirror.plugin.js"></script>
|
||||
<script src="_server/CodeMirror/codeMirror.plugin.min.js"></script>
|
||||
<script src="_server/CodeMirror/acorn.min.js"></script>
|
||||
<script src="_server/CodeMirror/defs.js"></script>
|
||||
<script src="_server/CodeMirror/tern.js"></script>
|
||||
<script src="_server/CodeMirror/tern.min.js"></script>
|
||||
<!-- thirdparty -->
|
||||
<script src="_server/thirdparty/color.all.min.js"></script>
|
||||
<script src="_server/thirdparty/awesomplete.min.js"></script>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user