@muze-nl/simplystore 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/commands.mjs +2 -2
- package/src/share.mjs +22 -39
- package/.eslintrc.cjs +0 -15
- package/package.json~ +0 -33
- package/test/produce.mjs +0 -79
- package/test/share.mjs +0 -18
- package/test/test.jsontag +0 -20
- package/www/assets/css/style.css +0 -2296
- package/www/assets/feather-sprite.svg +0 -1
- package/www/assets/img/simplystore-narrow-white.svg +0 -138
- package/www/assets/img/simplystore-narrow.svg +0 -138
- package/www/assets/img/simplystore-white.svg +0 -153
- package/www/assets/img/simplystore.svg +0 -153
- package/www/codemirror/AUTHORS +0 -979
- package/www/codemirror/CHANGELOG.md +0 -2208
- package/www/codemirror/CONTRIBUTING.md +0 -92
- package/www/codemirror/LICENSE +0 -21
- package/www/codemirror/README.md +0 -47
- package/www/codemirror/addon/lint/javascript-lint.js +0 -65
- package/www/codemirror/addon/lint/lint.css +0 -79
- package/www/codemirror/addon/lint/lint.js +0 -291
- package/www/codemirror/lib/codemirror.css +0 -344
- package/www/codemirror/lib/codemirror.js +0 -9874
- package/www/codemirror/mode/javascript/javascript.js +0 -960
- package/www/codemirror/package.json +0 -52
- package/www/codemirror/theme/material-ocean.css +0 -141
- package/www/index.html +0 -359
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
# How to contribute
|
|
2
|
-
|
|
3
|
-
- [Getting help](#getting-help)
|
|
4
|
-
- [Submitting bug reports](#submitting-bug-reports)
|
|
5
|
-
- [Contributing code](#contributing-code)
|
|
6
|
-
|
|
7
|
-
## Getting help
|
|
8
|
-
|
|
9
|
-
Community discussion, questions, and informal bug reporting is done on the
|
|
10
|
-
[discuss.CodeMirror forum](http://discuss.codemirror.net).
|
|
11
|
-
|
|
12
|
-
## Submitting bug reports
|
|
13
|
-
|
|
14
|
-
The preferred way to report bugs is to use the
|
|
15
|
-
[GitHub issue tracker](http://github.com/codemirror/CodeMirror/issues). Before
|
|
16
|
-
reporting a bug, read these pointers.
|
|
17
|
-
|
|
18
|
-
**Note:** The issue tracker is for *bugs*, not requests for help. Questions
|
|
19
|
-
should be asked on the
|
|
20
|
-
[discuss.CodeMirror forum](http://discuss.codemirror.net) instead.
|
|
21
|
-
|
|
22
|
-
### Reporting bugs effectively
|
|
23
|
-
|
|
24
|
-
- CodeMirror is maintained by volunteers. They don't owe you anything, so be
|
|
25
|
-
polite. Reports with an indignant or belligerent tone tend to be moved to the
|
|
26
|
-
bottom of the pile.
|
|
27
|
-
|
|
28
|
-
- Include information about **the browser in which the problem occurred**. Even
|
|
29
|
-
if you tested several browsers, and the problem occurred in all of them,
|
|
30
|
-
mention this fact in the bug report. Also include browser version numbers and
|
|
31
|
-
the operating system that you're on.
|
|
32
|
-
|
|
33
|
-
- Mention which release of CodeMirror you're using. Preferably, try also with
|
|
34
|
-
the current development snapshot, to ensure the problem has not already been
|
|
35
|
-
fixed.
|
|
36
|
-
|
|
37
|
-
- Mention very precisely what went wrong. "X is broken" is not a good bug
|
|
38
|
-
report. What did you expect to happen? What happened instead? Describe the
|
|
39
|
-
exact steps a maintainer has to take to make the problem occur. We can not
|
|
40
|
-
fix something that we can not observe.
|
|
41
|
-
|
|
42
|
-
- If the problem can not be reproduced in any of the demos included in the
|
|
43
|
-
CodeMirror distribution, please provide an HTML document that demonstrates
|
|
44
|
-
the problem. The best way to do this is to go to
|
|
45
|
-
[jsbin.com](http://jsbin.com/ihunin/edit), enter it there, press save, and
|
|
46
|
-
include the resulting link in your bug report.
|
|
47
|
-
|
|
48
|
-
## Contributing code
|
|
49
|
-
|
|
50
|
-
Note that we are not accepting any new addons or modes into the main
|
|
51
|
-
distribution. If you've written such a module, please distribute it as
|
|
52
|
-
a separate NPM package.
|
|
53
|
-
|
|
54
|
-
- Make sure you have a [GitHub Account](https://github.com/signup/free)
|
|
55
|
-
- Fork [CodeMirror](https://github.com/codemirror/CodeMirror/)
|
|
56
|
-
([how to fork a repo](https://help.github.com/articles/fork-a-repo))
|
|
57
|
-
- Make your changes
|
|
58
|
-
- If your changes are easy to test or likely to regress, add tests.
|
|
59
|
-
Tests for the core go into `test/test.js`, some modes have their own
|
|
60
|
-
test suite under `mode/XXX/test.js`. Feel free to add new test
|
|
61
|
-
suites to modes that don't have one yet (be sure to link the new
|
|
62
|
-
tests into `test/index.html`).
|
|
63
|
-
- Follow the general code style of the rest of the project (see
|
|
64
|
-
below). Run `bin/lint` to verify that the linter is happy.
|
|
65
|
-
- Make sure all tests pass. Visit `test/index.html` in your browser to
|
|
66
|
-
run them.
|
|
67
|
-
- Submit a pull request
|
|
68
|
-
([how to create a pull request](https://help.github.com/articles/fork-a-repo)).
|
|
69
|
-
Don't put more than one feature/fix in a single pull request.
|
|
70
|
-
|
|
71
|
-
By contributing code to CodeMirror you
|
|
72
|
-
|
|
73
|
-
- agree to license the contributed code under CodeMirror's [MIT
|
|
74
|
-
license](https://codemirror.net/5/LICENSE).
|
|
75
|
-
|
|
76
|
-
- confirm that you have the right to contribute and license the code
|
|
77
|
-
in question. (Either you hold all rights on the code, or the rights
|
|
78
|
-
holder has explicitly granted the right to use it like this,
|
|
79
|
-
through a compatible open source license or through a direct
|
|
80
|
-
agreement with you.)
|
|
81
|
-
|
|
82
|
-
### Coding standards
|
|
83
|
-
|
|
84
|
-
- 2 spaces per indentation level, no tabs.
|
|
85
|
-
|
|
86
|
-
- Note that the linter (`bin/lint`) which is run after each commit
|
|
87
|
-
complains about unused variables and functions. Prefix their names
|
|
88
|
-
with an underscore to muffle it.
|
|
89
|
-
|
|
90
|
-
- CodeMirror does *not* follow JSHint or JSLint prescribed style.
|
|
91
|
-
Patches that try to 'fix' code to pass one of these linters will be
|
|
92
|
-
unceremoniously discarded.
|
package/www/codemirror/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (C) 2017 by Marijn Haverbeke <marijnh@gmail.com> and others
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in
|
|
13
|
-
all copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
-
THE SOFTWARE.
|
package/www/codemirror/README.md
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
# CodeMirror
|
|
2
|
-
|
|
3
|
-
[](https://github.com/codemirror/codemirror5/actions)
|
|
4
|
-
[](https://www.npmjs.org/package/codemirror)
|
|
5
|
-
|
|
6
|
-
CodeMirror is a versatile text editor implemented in JavaScript for
|
|
7
|
-
the browser. It is specialized for editing code, and comes with over
|
|
8
|
-
100 language modes and various addons that implement more advanced
|
|
9
|
-
editing functionality. Every language comes with fully-featured code
|
|
10
|
-
and syntax highlighting to help with reading and editing complex code.
|
|
11
|
-
|
|
12
|
-
A rich programming API and a CSS theming system are available for
|
|
13
|
-
customizing CodeMirror to fit your application, and extending it with
|
|
14
|
-
new functionality.
|
|
15
|
-
|
|
16
|
-
You can find more information (and the
|
|
17
|
-
[manual](https://codemirror.net/5/doc/manual.html)) on the [project
|
|
18
|
-
page](https://codemirror.net/5/). For questions and discussion, use the
|
|
19
|
-
[discussion forum](https://discuss.codemirror.net/).
|
|
20
|
-
|
|
21
|
-
See
|
|
22
|
-
[CONTRIBUTING.md](https://github.com/codemirror/CodeMirror/blob/master/CONTRIBUTING.md)
|
|
23
|
-
for contributing guidelines.
|
|
24
|
-
|
|
25
|
-
The CodeMirror community aims to be welcoming to everybody. We use the
|
|
26
|
-
[Contributor Covenant
|
|
27
|
-
(1.1)](http://contributor-covenant.org/version/1/1/0/) as our code of
|
|
28
|
-
conduct.
|
|
29
|
-
|
|
30
|
-
### Installation
|
|
31
|
-
|
|
32
|
-
Either get the [zip file](https://codemirror.net/5/codemirror.zip) with
|
|
33
|
-
the latest version, or make sure you have [Node](https://nodejs.org/)
|
|
34
|
-
installed and run:
|
|
35
|
-
|
|
36
|
-
npm install codemirror
|
|
37
|
-
|
|
38
|
-
**NOTE**: This is the source repository for the library, and not the
|
|
39
|
-
distribution channel. Cloning it is not the recommended way to install
|
|
40
|
-
the library, and will in fact not work unless you also run the build
|
|
41
|
-
step.
|
|
42
|
-
|
|
43
|
-
### Quickstart
|
|
44
|
-
|
|
45
|
-
To build the project, make sure you have Node.js installed (at least version 6)
|
|
46
|
-
and then `npm install`. To run, just open `index.html` in your
|
|
47
|
-
browser (you don't need to run a webserver). Run the tests with `npm test`.
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
|
2
|
-
// Distributed under an MIT license: https://codemirror.net/5/LICENSE
|
|
3
|
-
|
|
4
|
-
// Depends on jshint.js from https://github.com/jshint/jshint
|
|
5
|
-
|
|
6
|
-
(function(mod) {
|
|
7
|
-
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
|
8
|
-
mod(require("../../lib/codemirror"));
|
|
9
|
-
else if (typeof define == "function" && define.amd) // AMD
|
|
10
|
-
define(["../../lib/codemirror"], mod);
|
|
11
|
-
else // Plain browser env
|
|
12
|
-
mod(CodeMirror);
|
|
13
|
-
})(function(CodeMirror) {
|
|
14
|
-
"use strict";
|
|
15
|
-
// declare global: JSHINT
|
|
16
|
-
|
|
17
|
-
function validator(text, options) {
|
|
18
|
-
if (!window.JSHINT) {
|
|
19
|
-
if (window.console) {
|
|
20
|
-
window.console.error("Error: window.JSHINT not defined, CodeMirror JavaScript linting cannot run.");
|
|
21
|
-
}
|
|
22
|
-
return [];
|
|
23
|
-
}
|
|
24
|
-
if (!options.indent) // JSHint error.character actually is a column index, this fixes underlining on lines using tabs for indentation
|
|
25
|
-
options.indent = 1; // JSHint default value is 4
|
|
26
|
-
JSHINT(text, options, options.globals);
|
|
27
|
-
var errors = JSHINT.data().errors, result = [];
|
|
28
|
-
if (errors) parseErrors(errors, result);
|
|
29
|
-
return result;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
CodeMirror.registerHelper("lint", "javascript", validator);
|
|
33
|
-
|
|
34
|
-
function parseErrors(errors, output) {
|
|
35
|
-
for ( var i = 0; i < errors.length; i++) {
|
|
36
|
-
var error = errors[i];
|
|
37
|
-
if (error) {
|
|
38
|
-
if (error.line <= 0) {
|
|
39
|
-
if (window.console) {
|
|
40
|
-
window.console.warn("Cannot display JSHint error (invalid line " + error.line + ")", error);
|
|
41
|
-
}
|
|
42
|
-
continue;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
var start = error.character - 1, end = start + 1;
|
|
46
|
-
if (error.evidence) {
|
|
47
|
-
var index = error.evidence.substring(start).search(/.\b/);
|
|
48
|
-
if (index > -1) {
|
|
49
|
-
end += index;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// Convert to format expected by validation service
|
|
54
|
-
var hint = {
|
|
55
|
-
message: error.reason,
|
|
56
|
-
severity: error.code ? (error.code.startsWith('W') ? "warning" : "error") : "error",
|
|
57
|
-
from: CodeMirror.Pos(error.line - 1, start),
|
|
58
|
-
to: CodeMirror.Pos(error.line - 1, end)
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
output.push(hint);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
});
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
/* The lint marker gutter */
|
|
2
|
-
.CodeMirror-lint-markers {
|
|
3
|
-
width: 16px;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
.CodeMirror-lint-tooltip {
|
|
7
|
-
background-color: #ffd;
|
|
8
|
-
border: 1px solid black;
|
|
9
|
-
border-radius: 4px 4px 4px 4px;
|
|
10
|
-
color: black;
|
|
11
|
-
font-family: monospace;
|
|
12
|
-
font-size: 10pt;
|
|
13
|
-
overflow: hidden;
|
|
14
|
-
padding: 2px 5px;
|
|
15
|
-
position: fixed;
|
|
16
|
-
white-space: pre;
|
|
17
|
-
white-space: pre-wrap;
|
|
18
|
-
z-index: 100;
|
|
19
|
-
max-width: 600px;
|
|
20
|
-
opacity: 0;
|
|
21
|
-
transition: opacity .4s;
|
|
22
|
-
-moz-transition: opacity .4s;
|
|
23
|
-
-webkit-transition: opacity .4s;
|
|
24
|
-
-o-transition: opacity .4s;
|
|
25
|
-
-ms-transition: opacity .4s;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
.CodeMirror-lint-mark {
|
|
29
|
-
background-position: left bottom;
|
|
30
|
-
background-repeat: repeat-x;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
.CodeMirror-lint-mark-warning {
|
|
34
|
-
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAADCAYAAAC09K7GAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sJFhQXEbhTg7YAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAMklEQVQI12NkgIIvJ3QXMjAwdDN+OaEbysDA4MPAwNDNwMCwiOHLCd1zX07o6kBVGQEAKBANtobskNMAAAAASUVORK5CYII=");
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
.CodeMirror-lint-mark-error {
|
|
38
|
-
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAADCAYAAAC09K7GAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sJDw4cOCW1/KIAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAHElEQVQI12NggIL/DAz/GdA5/xkY/qPKMDAwAADLZwf5rvm+LQAAAABJRU5ErkJggg==");
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
.CodeMirror-lint-marker {
|
|
42
|
-
background-position: center center;
|
|
43
|
-
background-repeat: no-repeat;
|
|
44
|
-
cursor: pointer;
|
|
45
|
-
display: inline-block;
|
|
46
|
-
height: 16px;
|
|
47
|
-
width: 16px;
|
|
48
|
-
vertical-align: middle;
|
|
49
|
-
position: relative;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
.CodeMirror-lint-message {
|
|
53
|
-
padding-left: 18px;
|
|
54
|
-
background-position: top left;
|
|
55
|
-
background-repeat: no-repeat;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
.CodeMirror-lint-marker-warning, .CodeMirror-lint-message-warning {
|
|
59
|
-
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAANlBMVEX/uwDvrwD/uwD/uwD/uwD/uwD/uwD/uwD/uwD6twD/uwAAAADurwD2tQD7uAD+ugAAAAD/uwDhmeTRAAAADHRSTlMJ8mN1EYcbmiixgACm7WbuAAAAVklEQVR42n3PUQqAIBBFUU1LLc3u/jdbOJoW1P08DA9Gba8+YWJ6gNJoNYIBzAA2chBth5kLmG9YUoG0NHAUwFXwO9LuBQL1giCQb8gC9Oro2vp5rncCIY8L8uEx5ZkAAAAASUVORK5CYII=");
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
.CodeMirror-lint-marker-error, .CodeMirror-lint-message-error {
|
|
63
|
-
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAHlBMVEW7AAC7AACxAAC7AAC7AAAAAAC4AAC5AAD///+7AAAUdclpAAAABnRSTlMXnORSiwCK0ZKSAAAATUlEQVR42mWPOQ7AQAgDuQLx/z8csYRmPRIFIwRGnosRrpamvkKi0FTIiMASR3hhKW+hAN6/tIWhu9PDWiTGNEkTtIOucA5Oyr9ckPgAWm0GPBog6v4AAAAASUVORK5CYII=");
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
.CodeMirror-lint-marker-multiple {
|
|
67
|
-
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAHCAMAAADzjKfhAAAACVBMVEUAAAAAAAC/v7914kyHAAAAAXRSTlMAQObYZgAAACNJREFUeNo1ioEJAAAIwmz/H90iFFSGJgFMe3gaLZ0od+9/AQZ0ADosbYraAAAAAElFTkSuQmCC");
|
|
68
|
-
background-repeat: no-repeat;
|
|
69
|
-
background-position: right bottom;
|
|
70
|
-
width: 100%; height: 100%;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
.CodeMirror-lint-line-error {
|
|
74
|
-
background-color: rgba(183, 76, 81, 0.08);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
.CodeMirror-lint-line-warning {
|
|
78
|
-
background-color: rgba(255, 211, 0, 0.1);
|
|
79
|
-
}
|
|
@@ -1,291 +0,0 @@
|
|
|
1
|
-
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
|
2
|
-
// Distributed under an MIT license: https://codemirror.net/5/LICENSE
|
|
3
|
-
|
|
4
|
-
(function(mod) {
|
|
5
|
-
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
|
6
|
-
mod(require("../../lib/codemirror"));
|
|
7
|
-
else if (typeof define == "function" && define.amd) // AMD
|
|
8
|
-
define(["../../lib/codemirror"], mod);
|
|
9
|
-
else // Plain browser env
|
|
10
|
-
mod(CodeMirror);
|
|
11
|
-
})(function(CodeMirror) {
|
|
12
|
-
"use strict";
|
|
13
|
-
var GUTTER_ID = "CodeMirror-lint-markers";
|
|
14
|
-
var LINT_LINE_ID = "CodeMirror-lint-line-";
|
|
15
|
-
|
|
16
|
-
function showTooltip(cm, e, content) {
|
|
17
|
-
var tt = document.createElement("div");
|
|
18
|
-
tt.className = "CodeMirror-lint-tooltip cm-s-" + cm.options.theme;
|
|
19
|
-
tt.appendChild(content.cloneNode(true));
|
|
20
|
-
if (cm.state.lint.options.selfContain)
|
|
21
|
-
cm.getWrapperElement().appendChild(tt);
|
|
22
|
-
else
|
|
23
|
-
document.body.appendChild(tt);
|
|
24
|
-
|
|
25
|
-
function position(e) {
|
|
26
|
-
if (!tt.parentNode) return CodeMirror.off(document, "mousemove", position);
|
|
27
|
-
tt.style.top = Math.max(0, e.clientY - tt.offsetHeight - 5) + "px";
|
|
28
|
-
tt.style.left = (e.clientX + 5) + "px";
|
|
29
|
-
}
|
|
30
|
-
CodeMirror.on(document, "mousemove", position);
|
|
31
|
-
position(e);
|
|
32
|
-
if (tt.style.opacity != null) tt.style.opacity = 1;
|
|
33
|
-
return tt;
|
|
34
|
-
}
|
|
35
|
-
function rm(elt) {
|
|
36
|
-
if (elt.parentNode) elt.parentNode.removeChild(elt);
|
|
37
|
-
}
|
|
38
|
-
function hideTooltip(tt) {
|
|
39
|
-
if (!tt.parentNode) return;
|
|
40
|
-
if (tt.style.opacity == null) rm(tt);
|
|
41
|
-
tt.style.opacity = 0;
|
|
42
|
-
setTimeout(function() { rm(tt); }, 600);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function showTooltipFor(cm, e, content, node) {
|
|
46
|
-
var tooltip = showTooltip(cm, e, content);
|
|
47
|
-
function hide() {
|
|
48
|
-
CodeMirror.off(node, "mouseout", hide);
|
|
49
|
-
if (tooltip) { hideTooltip(tooltip); tooltip = null; }
|
|
50
|
-
}
|
|
51
|
-
var poll = setInterval(function() {
|
|
52
|
-
if (tooltip) for (var n = node;; n = n.parentNode) {
|
|
53
|
-
if (n && n.nodeType == 11) n = n.host;
|
|
54
|
-
if (n == document.body) return;
|
|
55
|
-
if (!n) { hide(); break; }
|
|
56
|
-
}
|
|
57
|
-
if (!tooltip) return clearInterval(poll);
|
|
58
|
-
}, 400);
|
|
59
|
-
CodeMirror.on(node, "mouseout", hide);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
function LintState(cm, conf, hasGutter) {
|
|
63
|
-
this.marked = [];
|
|
64
|
-
if (conf instanceof Function) conf = {getAnnotations: conf};
|
|
65
|
-
if (!conf || conf === true) conf = {};
|
|
66
|
-
this.options = {};
|
|
67
|
-
this.linterOptions = conf.options || {};
|
|
68
|
-
for (var prop in defaults) this.options[prop] = defaults[prop];
|
|
69
|
-
for (var prop in conf) {
|
|
70
|
-
if (defaults.hasOwnProperty(prop)) {
|
|
71
|
-
if (conf[prop] != null) this.options[prop] = conf[prop];
|
|
72
|
-
} else if (!conf.options) {
|
|
73
|
-
this.linterOptions[prop] = conf[prop];
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
this.timeout = null;
|
|
77
|
-
this.hasGutter = hasGutter;
|
|
78
|
-
this.onMouseOver = function(e) { onMouseOver(cm, e); };
|
|
79
|
-
this.waitingFor = 0
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
var defaults = {
|
|
83
|
-
highlightLines: false,
|
|
84
|
-
tooltips: true,
|
|
85
|
-
delay: 500,
|
|
86
|
-
lintOnChange: true,
|
|
87
|
-
getAnnotations: null,
|
|
88
|
-
async: false,
|
|
89
|
-
selfContain: null,
|
|
90
|
-
formatAnnotation: null,
|
|
91
|
-
onUpdateLinting: null
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
function clearMarks(cm) {
|
|
95
|
-
var state = cm.state.lint;
|
|
96
|
-
if (state.hasGutter) cm.clearGutter(GUTTER_ID);
|
|
97
|
-
if (state.options.highlightLines) clearErrorLines(cm);
|
|
98
|
-
for (var i = 0; i < state.marked.length; ++i)
|
|
99
|
-
state.marked[i].clear();
|
|
100
|
-
state.marked.length = 0;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
function clearErrorLines(cm) {
|
|
104
|
-
cm.eachLine(function(line) {
|
|
105
|
-
var has = line.wrapClass && /\bCodeMirror-lint-line-\w+\b/.exec(line.wrapClass);
|
|
106
|
-
if (has) cm.removeLineClass(line, "wrap", has[0]);
|
|
107
|
-
})
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
function makeMarker(cm, labels, severity, multiple, tooltips) {
|
|
111
|
-
var marker = document.createElement("div"), inner = marker;
|
|
112
|
-
marker.className = "CodeMirror-lint-marker CodeMirror-lint-marker-" + severity;
|
|
113
|
-
if (multiple) {
|
|
114
|
-
inner = marker.appendChild(document.createElement("div"));
|
|
115
|
-
inner.className = "CodeMirror-lint-marker CodeMirror-lint-marker-multiple";
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
if (tooltips != false) CodeMirror.on(inner, "mouseover", function(e) {
|
|
119
|
-
showTooltipFor(cm, e, labels, inner);
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
return marker;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
function getMaxSeverity(a, b) {
|
|
126
|
-
if (a == "error") return a;
|
|
127
|
-
else return b;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
function groupByLine(annotations) {
|
|
131
|
-
var lines = [];
|
|
132
|
-
for (var i = 0; i < annotations.length; ++i) {
|
|
133
|
-
var ann = annotations[i], line = ann.from.line;
|
|
134
|
-
(lines[line] || (lines[line] = [])).push(ann);
|
|
135
|
-
}
|
|
136
|
-
return lines;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
function annotationTooltip(ann) {
|
|
140
|
-
var severity = ann.severity;
|
|
141
|
-
if (!severity) severity = "error";
|
|
142
|
-
var tip = document.createElement("div");
|
|
143
|
-
tip.className = "CodeMirror-lint-message CodeMirror-lint-message-" + severity;
|
|
144
|
-
if (typeof ann.messageHTML != 'undefined') {
|
|
145
|
-
tip.innerHTML = ann.messageHTML;
|
|
146
|
-
} else {
|
|
147
|
-
tip.appendChild(document.createTextNode(ann.message));
|
|
148
|
-
}
|
|
149
|
-
return tip;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
function lintAsync(cm, getAnnotations) {
|
|
153
|
-
var state = cm.state.lint
|
|
154
|
-
var id = ++state.waitingFor
|
|
155
|
-
function abort() {
|
|
156
|
-
id = -1
|
|
157
|
-
cm.off("change", abort)
|
|
158
|
-
}
|
|
159
|
-
cm.on("change", abort)
|
|
160
|
-
getAnnotations(cm.getValue(), function(annotations, arg2) {
|
|
161
|
-
cm.off("change", abort)
|
|
162
|
-
if (state.waitingFor != id) return
|
|
163
|
-
if (arg2 && annotations instanceof CodeMirror) annotations = arg2
|
|
164
|
-
cm.operation(function() {updateLinting(cm, annotations)})
|
|
165
|
-
}, state.linterOptions, cm);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
function startLinting(cm) {
|
|
169
|
-
var state = cm.state.lint;
|
|
170
|
-
if (!state) return;
|
|
171
|
-
var options = state.options;
|
|
172
|
-
/*
|
|
173
|
-
* Passing rules in `options` property prevents JSHint (and other linters) from complaining
|
|
174
|
-
* about unrecognized rules like `onUpdateLinting`, `delay`, `lintOnChange`, etc.
|
|
175
|
-
*/
|
|
176
|
-
var getAnnotations = options.getAnnotations || cm.getHelper(CodeMirror.Pos(0, 0), "lint");
|
|
177
|
-
if (!getAnnotations) return;
|
|
178
|
-
if (options.async || getAnnotations.async) {
|
|
179
|
-
lintAsync(cm, getAnnotations)
|
|
180
|
-
} else {
|
|
181
|
-
var annotations = getAnnotations(cm.getValue(), state.linterOptions, cm);
|
|
182
|
-
if (!annotations) return;
|
|
183
|
-
if (annotations.then) annotations.then(function(issues) {
|
|
184
|
-
cm.operation(function() {updateLinting(cm, issues)})
|
|
185
|
-
});
|
|
186
|
-
else cm.operation(function() {updateLinting(cm, annotations)})
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
function updateLinting(cm, annotationsNotSorted) {
|
|
191
|
-
var state = cm.state.lint;
|
|
192
|
-
if (!state) return;
|
|
193
|
-
var options = state.options;
|
|
194
|
-
clearMarks(cm);
|
|
195
|
-
|
|
196
|
-
var annotations = groupByLine(annotationsNotSorted);
|
|
197
|
-
|
|
198
|
-
for (var line = 0; line < annotations.length; ++line) {
|
|
199
|
-
var anns = annotations[line];
|
|
200
|
-
if (!anns) continue;
|
|
201
|
-
|
|
202
|
-
// filter out duplicate messages
|
|
203
|
-
var message = [];
|
|
204
|
-
anns = anns.filter(function(item) { return message.indexOf(item.message) > -1 ? false : message.push(item.message) });
|
|
205
|
-
|
|
206
|
-
var maxSeverity = null;
|
|
207
|
-
var tipLabel = state.hasGutter && document.createDocumentFragment();
|
|
208
|
-
|
|
209
|
-
for (var i = 0; i < anns.length; ++i) {
|
|
210
|
-
var ann = anns[i];
|
|
211
|
-
var severity = ann.severity;
|
|
212
|
-
if (!severity) severity = "error";
|
|
213
|
-
maxSeverity = getMaxSeverity(maxSeverity, severity);
|
|
214
|
-
|
|
215
|
-
if (options.formatAnnotation) ann = options.formatAnnotation(ann);
|
|
216
|
-
if (state.hasGutter) tipLabel.appendChild(annotationTooltip(ann));
|
|
217
|
-
|
|
218
|
-
if (ann.to) state.marked.push(cm.markText(ann.from, ann.to, {
|
|
219
|
-
className: "CodeMirror-lint-mark CodeMirror-lint-mark-" + severity,
|
|
220
|
-
__annotation: ann
|
|
221
|
-
}));
|
|
222
|
-
}
|
|
223
|
-
// use original annotations[line] to show multiple messages
|
|
224
|
-
if (state.hasGutter)
|
|
225
|
-
cm.setGutterMarker(line, GUTTER_ID, makeMarker(cm, tipLabel, maxSeverity, annotations[line].length > 1,
|
|
226
|
-
options.tooltips));
|
|
227
|
-
|
|
228
|
-
if (options.highlightLines)
|
|
229
|
-
cm.addLineClass(line, "wrap", LINT_LINE_ID + maxSeverity);
|
|
230
|
-
}
|
|
231
|
-
if (options.onUpdateLinting) options.onUpdateLinting(annotationsNotSorted, annotations, cm);
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
function onChange(cm) {
|
|
235
|
-
var state = cm.state.lint;
|
|
236
|
-
if (!state) return;
|
|
237
|
-
clearTimeout(state.timeout);
|
|
238
|
-
state.timeout = setTimeout(function(){startLinting(cm);}, state.options.delay);
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
function popupTooltips(cm, annotations, e) {
|
|
242
|
-
var target = e.target || e.srcElement;
|
|
243
|
-
var tooltip = document.createDocumentFragment();
|
|
244
|
-
for (var i = 0; i < annotations.length; i++) {
|
|
245
|
-
var ann = annotations[i];
|
|
246
|
-
tooltip.appendChild(annotationTooltip(ann));
|
|
247
|
-
}
|
|
248
|
-
showTooltipFor(cm, e, tooltip, target);
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
function onMouseOver(cm, e) {
|
|
252
|
-
var target = e.target || e.srcElement;
|
|
253
|
-
if (!/\bCodeMirror-lint-mark-/.test(target.className)) return;
|
|
254
|
-
var box = target.getBoundingClientRect(), x = (box.left + box.right) / 2, y = (box.top + box.bottom) / 2;
|
|
255
|
-
var spans = cm.findMarksAt(cm.coordsChar({left: x, top: y}, "client"));
|
|
256
|
-
|
|
257
|
-
var annotations = [];
|
|
258
|
-
for (var i = 0; i < spans.length; ++i) {
|
|
259
|
-
var ann = spans[i].__annotation;
|
|
260
|
-
if (ann) annotations.push(ann);
|
|
261
|
-
}
|
|
262
|
-
if (annotations.length) popupTooltips(cm, annotations, e);
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
CodeMirror.defineOption("lint", false, function(cm, val, old) {
|
|
266
|
-
if (old && old != CodeMirror.Init) {
|
|
267
|
-
clearMarks(cm);
|
|
268
|
-
if (cm.state.lint.options.lintOnChange !== false)
|
|
269
|
-
cm.off("change", onChange);
|
|
270
|
-
CodeMirror.off(cm.getWrapperElement(), "mouseover", cm.state.lint.onMouseOver);
|
|
271
|
-
clearTimeout(cm.state.lint.timeout);
|
|
272
|
-
delete cm.state.lint;
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
if (val) {
|
|
276
|
-
var gutters = cm.getOption("gutters"), hasLintGutter = false;
|
|
277
|
-
for (var i = 0; i < gutters.length; ++i) if (gutters[i] == GUTTER_ID) hasLintGutter = true;
|
|
278
|
-
var state = cm.state.lint = new LintState(cm, val, hasLintGutter);
|
|
279
|
-
if (state.options.lintOnChange)
|
|
280
|
-
cm.on("change", onChange);
|
|
281
|
-
if (state.options.tooltips != false && state.options.tooltips != "gutter")
|
|
282
|
-
CodeMirror.on(cm.getWrapperElement(), "mouseover", state.onMouseOver);
|
|
283
|
-
|
|
284
|
-
startLinting(cm);
|
|
285
|
-
}
|
|
286
|
-
});
|
|
287
|
-
|
|
288
|
-
CodeMirror.defineExtension("performLint", function() {
|
|
289
|
-
startLinting(this);
|
|
290
|
-
});
|
|
291
|
-
});
|