-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5f6c34f
commit 87a5b71
Showing
10 changed files
with
674 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
.CodeMirror-hints { | ||
position: absolute; | ||
z-index: 10; | ||
overflow: hidden; | ||
list-style: none; | ||
|
||
margin: 0; | ||
padding: 2px; | ||
|
||
-webkit-box-shadow: 2px 3px 5px rgba(0,0,0,.2); | ||
-moz-box-shadow: 2px 3px 5px rgba(0,0,0,.2); | ||
box-shadow: 2px 3px 5px rgba(0,0,0,.2); | ||
border-radius: 3px; | ||
border: 1px solid silver; | ||
|
||
background: white; | ||
font-size: 90%; | ||
font-family: monospace; | ||
|
||
max-height: 20em; | ||
overflow-y: auto; | ||
} | ||
|
||
.CodeMirror-hint { | ||
margin: 0; | ||
padding: 0 4px; | ||
border-radius: 2px; | ||
white-space: pre; | ||
color: black; | ||
cursor: pointer; | ||
} | ||
|
||
li.CodeMirror-hint-active { | ||
background: #08f; | ||
color: white; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// CodeMirror, copyright (c) by Marijn Haverbeke and others | ||
// Distributed under an MIT license: https://codemirror.net/LICENSE | ||
|
||
(function(mod) { | ||
if (typeof exports == "object" && typeof module == "object") // CommonJS | ||
mod(require("../../lib/codemirror")); | ||
else if (typeof define == "function" && define.amd) // AMD | ||
define(["../../lib/codemirror"], mod); | ||
else // Plain browser env | ||
mod(CodeMirror); | ||
})(function(CodeMirror) { | ||
"use strict"; | ||
|
||
var WORD = /[\w$]+/, RANGE = 500; | ||
|
||
CodeMirror.registerHelper("hint", "anyword", function(editor, options) { | ||
|
||
var word = options && options.word || WORD; | ||
var range = options && options.range || RANGE; | ||
var cur = editor.getCursor(), curLine = editor.getLine(cur.line); | ||
var end = cur.ch, start = end; | ||
while (start && word.test(curLine.charAt(start - 1))) --start; | ||
var curWord = start != end && curLine.slice(start, end); | ||
|
||
options.list = MPG.mongoDBKeywords.concat(MPG.collectionFields); | ||
|
||
/** | ||
* Code block taken from Mongolo project. | ||
* @see https://github.com/tetreum/mongolo/blob/develop/htdocs/js/src/custom-hint.js | ||
*/ | ||
|
||
var list = [], | ||
suggestedWord, | ||
k; | ||
|
||
if (curWord) | ||
{ | ||
for (k in options.list) | ||
{ | ||
if (!options.list.hasOwnProperty(k)) {continue;} | ||
suggestedWord = options.list[k]; | ||
|
||
if (suggestedWord.toLowerCase().startsWith(curWord.toLowerCase()) && list.indexOf(suggestedWord) == -1) { | ||
list.push(suggestedWord); | ||
} | ||
} | ||
} | ||
|
||
return {list: list, from: CodeMirror.Pos(cur.line, start), to: CodeMirror.Pos(cur.line, end)}; | ||
}); | ||
}); |
Oops, something went wrong.