@teipublisher/pb-components 1.40.1 → 1.41.0

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.
Files changed (93) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/demo/pb-code-editor.html +12 -9
  3. package/dist/{iron-form-f540b15b.js → iron-form-9e72ac45.js} +1 -1
  4. package/dist/jinn-codemirror-c1a4b755.js +1 -0
  5. package/dist/{paper-checkbox-f6a70487.js → paper-checkbox-102e3b43.js} +120 -120
  6. package/dist/pb-code-editor.js +22 -0
  7. package/dist/pb-components-bundle.js +234 -234
  8. package/dist/pb-edit-app.js +33 -33
  9. package/dist/pb-elements.json +100 -16
  10. package/dist/pb-i18n-6ad23bcf.js +1 -0
  11. package/dist/pb-message-0fb0b538.js +911 -0
  12. package/dist/pb-odd-editor.js +110 -82
  13. package/package.json +4 -5
  14. package/pb-elements.json +100 -16
  15. package/src/pb-code-editor.js +51 -663
  16. package/src/pb-components.js +0 -1
  17. package/src/pb-load.js +11 -0
  18. package/src/pb-odd-model-editor.js +33 -23
  19. package/src/pb-odd-parameter-editor.js +17 -9
  20. package/src/pb-odd-rendition-editor.js +19 -9
  21. package/css/codemirror/3024-day.css +0 -41
  22. package/css/codemirror/3024-night.css +0 -39
  23. package/css/codemirror/abbott.css +0 -268
  24. package/css/codemirror/abcdef.css +0 -32
  25. package/css/codemirror/ambiance-mobile.css +0 -5
  26. package/css/codemirror/ambiance.css +0 -74
  27. package/css/codemirror/ayu-dark.css +0 -44
  28. package/css/codemirror/ayu-mirage.css +0 -45
  29. package/css/codemirror/base16-dark.css +0 -40
  30. package/css/codemirror/base16-light.css +0 -38
  31. package/css/codemirror/bespin.css +0 -34
  32. package/css/codemirror/blackboard.css +0 -32
  33. package/css/codemirror/cobalt.css +0 -25
  34. package/css/codemirror/colorforth.css +0 -33
  35. package/css/codemirror/darcula.css +0 -53
  36. package/css/codemirror/dracula.css +0 -40
  37. package/css/codemirror/duotone-dark.css +0 -35
  38. package/css/codemirror/duotone-light.css +0 -36
  39. package/css/codemirror/eclipse.css +0 -23
  40. package/css/codemirror/elegant.css +0 -13
  41. package/css/codemirror/erlang-dark.css +0 -34
  42. package/css/codemirror/gruvbox-dark.css +0 -39
  43. package/css/codemirror/hopscotch.css +0 -34
  44. package/css/codemirror/icecoder.css +0 -43
  45. package/css/codemirror/idea.css +0 -42
  46. package/css/codemirror/isotope.css +0 -34
  47. package/css/codemirror/juejin.css +0 -30
  48. package/css/codemirror/lesser-dark.css +0 -47
  49. package/css/codemirror/liquibyte.css +0 -95
  50. package/css/codemirror/lucario.css +0 -37
  51. package/css/codemirror/material-darker.css +0 -135
  52. package/css/codemirror/material-ocean.css +0 -141
  53. package/css/codemirror/material-palenight.css +0 -141
  54. package/css/codemirror/material.css +0 -141
  55. package/css/codemirror/mbo.css +0 -37
  56. package/css/codemirror/mdn-like.css +0 -46
  57. package/css/codemirror/midnight.css +0 -39
  58. package/css/codemirror/monokai.css +0 -41
  59. package/css/codemirror/moxer.css +0 -143
  60. package/css/codemirror/neat.css +0 -12
  61. package/css/codemirror/neo.css +0 -43
  62. package/css/codemirror/night.css +0 -27
  63. package/css/codemirror/nord.css +0 -42
  64. package/css/codemirror/oceanic-next.css +0 -46
  65. package/css/codemirror/panda-syntax.css +0 -85
  66. package/css/codemirror/paraiso-dark.css +0 -38
  67. package/css/codemirror/paraiso-light.css +0 -38
  68. package/css/codemirror/pastel-on-dark.css +0 -52
  69. package/css/codemirror/railscasts.css +0 -34
  70. package/css/codemirror/rubyblue.css +0 -25
  71. package/css/codemirror/seti.css +0 -44
  72. package/css/codemirror/shadowfox.css +0 -52
  73. package/css/codemirror/solarized.css +0 -168
  74. package/css/codemirror/ssms.css +0 -16
  75. package/css/codemirror/the-matrix.css +0 -30
  76. package/css/codemirror/tomorrow-night-bright.css +0 -35
  77. package/css/codemirror/tomorrow-night-eighties.css +0 -38
  78. package/css/codemirror/ttcn.css +0 -64
  79. package/css/codemirror/twilight.css +0 -32
  80. package/css/codemirror/vibrant-ink.css +0 -34
  81. package/css/codemirror/xq-dark.css +0 -53
  82. package/css/codemirror/xq-light.css +0 -43
  83. package/css/codemirror/yeti.css +0 -44
  84. package/css/codemirror/yonce.css +0 -59
  85. package/css/codemirror/zenburn.css +0 -37
  86. package/dist/pb-message-1a0c0c52.js +0 -1360
  87. package/lib/codemirror/addon/display/placeholder.js +0 -70
  88. package/lib/codemirror/addon/edit/matchbrackets.js +0 -152
  89. package/lib/codemirror/addon/lint/lint.js +0 -282
  90. package/lib/codemirror/mode/css/css.js +0 -855
  91. package/lib/codemirror/mode/stex/stex.js +0 -249
  92. package/lib/codemirror/mode/xml/xml.js +0 -404
  93. package/lib/codemirror/mode/xquery/xquery.js +0 -434
@@ -1,70 +0,0 @@
1
- function placeholder(CodeMirror) {
2
- CodeMirror.defineOption("placeholder", "", function(cm, val, old) {
3
- var prev = old && old != CodeMirror.Init;
4
- if (val && !prev) {
5
- cm.on("blur", onBlur);
6
- cm.on("change", onChange);
7
- cm.on("swapDoc", onChange);
8
- CodeMirror.on(cm.getInputField(), "compositionupdate", cm.state.placeholderCompose = function() { onComposition(cm); });
9
- onChange(cm);
10
- } else if (!val && prev) {
11
- cm.off("blur", onBlur);
12
- cm.off("change", onChange);
13
- cm.off("swapDoc", onChange);
14
- CodeMirror.off(cm.getInputField(), "compositionupdate", cm.state.placeholderCompose);
15
- clearPlaceholder(cm);
16
- var wrapper = cm.getWrapperElement();
17
- wrapper.className = wrapper.className.replace(" CodeMirror-empty", "");
18
- }
19
-
20
- if (val && !cm.hasFocus()) onBlur(cm);
21
- });
22
-
23
- function clearPlaceholder(cm) {
24
- if (cm.state.placeholder) {
25
- cm.state.placeholder.parentNode.removeChild(cm.state.placeholder);
26
- cm.state.placeholder = null;
27
- }
28
- }
29
- function setPlaceholder(cm) {
30
- clearPlaceholder(cm);
31
- var elt = cm.state.placeholder = document.createElement("pre");
32
- elt.style.cssText = "height: 0; overflow: visible";
33
- elt.style.direction = cm.getOption("direction");
34
- elt.className = "CodeMirror-placeholder CodeMirror-line-like";
35
- var placeHolder = cm.getOption("placeholder");
36
- if (typeof placeHolder == "string") placeHolder = document.createTextNode(placeHolder);
37
- elt.appendChild(placeHolder);
38
- cm.display.lineSpace.insertBefore(elt, cm.display.lineSpace.firstChild);
39
- }
40
-
41
- function onComposition(cm) {
42
- setTimeout(function() {
43
- var empty = false;
44
- if (cm.lineCount() == 1) {
45
- var input = cm.getInputField();
46
- empty = input.nodeName == "TEXTAREA" ? !cm.getLine(0).length
47
- : !/[^\u200b]/.test(input.querySelector(".CodeMirror-line").textContent);
48
- }
49
- if (empty) setPlaceholder(cm);
50
- else clearPlaceholder(cm);
51
- }, 20);
52
- }
53
-
54
- function onBlur(cm) {
55
- if (isEmpty(cm)) setPlaceholder(cm);
56
- }
57
- function onChange(cm) {
58
- var wrapper = cm.getWrapperElement(), empty = isEmpty(cm);
59
- wrapper.className = wrapper.className.replace(" CodeMirror-empty", "") + (empty ? " CodeMirror-empty" : "");
60
-
61
- if (empty) setPlaceholder(cm);
62
- else clearPlaceholder(cm);
63
- }
64
-
65
- function isEmpty(cm) {
66
- return (cm.lineCount() === 1) && (cm.getLine(0) === "");
67
- }
68
- }
69
-
70
- export default placeholder;
@@ -1,152 +0,0 @@
1
- function matchbrackets(CodeMirror) {
2
- var ie_lt8 = /MSIE \d/.test(navigator.userAgent) &&
3
- (document.documentMode == null || document.documentMode < 8);
4
-
5
- var Pos = CodeMirror.Pos;
6
-
7
- var matching = {"(": ")>", ")": "(<", "[": "]>", "]": "[<", "{": "}>", "}": "{<", "<": ">>", ">": "<<"};
8
-
9
- function bracketRegex(config) {
10
- return config && config.bracketRegex || /[(){}[\]]/
11
- }
12
-
13
- function findMatchingBracket(cm, where, config) {
14
- var line = cm.getLineHandle(where.line), pos = where.ch - 1;
15
- var afterCursor = config && config.afterCursor;
16
- if (afterCursor == null)
17
- afterCursor = /(^| )cm-fat-cursor($| )/.test(cm.getWrapperElement().className);
18
- var re = bracketRegex(config);
19
-
20
- // A cursor is defined as between two characters, but in in vim command mode
21
- // (i.e. not insert mode), the cursor is visually represented as a
22
- // highlighted box on top of the 2nd character. Otherwise, we allow matches
23
- // from before or after the cursor.
24
- var match = (!afterCursor && pos >= 0 && re.test(line.text.charAt(pos)) && matching[line.text.charAt(pos)]) ||
25
- re.test(line.text.charAt(pos + 1)) && matching[line.text.charAt(++pos)];
26
- if (!match) return null;
27
- var dir = match.charAt(1) == ">" ? 1 : -1;
28
- if (config && config.strict && (dir > 0) != (pos == where.ch)) return null;
29
- var style = cm.getTokenTypeAt(Pos(where.line, pos + 1));
30
-
31
- var found = scanForBracket(cm, Pos(where.line, pos + (dir > 0 ? 1 : 0)), dir, style, config);
32
- if (found == null) return null;
33
- return {from: Pos(where.line, pos), to: found && found.pos,
34
- match: found && found.ch == match.charAt(0), forward: dir > 0};
35
- }
36
-
37
- // bracketRegex is used to specify which type of bracket to scan
38
- // should be a regexp, e.g. /[[\]]/
39
- //
40
- // Note: If "where" is on an open bracket, then this bracket is ignored.
41
- //
42
- // Returns false when no bracket was found, null when it reached
43
- // maxScanLines and gave up
44
- function scanForBracket(cm, where, dir, style, config) {
45
- var maxScanLen = (config && config.maxScanLineLength) || 10000;
46
- var maxScanLines = (config && config.maxScanLines) || 1000;
47
-
48
- var stack = [];
49
- var re = bracketRegex(config);
50
- var lineEnd = dir > 0 ? Math.min(where.line + maxScanLines, cm.lastLine() + 1)
51
- : Math.max(cm.firstLine() - 1, where.line - maxScanLines);
52
- for (var lineNo = where.line; lineNo != lineEnd; lineNo += dir) {
53
- var line = cm.getLine(lineNo);
54
- if (!line) continue;
55
- var pos = dir > 0 ? 0 : line.length - 1, end = dir > 0 ? line.length : -1;
56
- if (line.length > maxScanLen) continue;
57
- if (lineNo == where.line) pos = where.ch - (dir < 0 ? 1 : 0);
58
- for (; pos != end; pos += dir) {
59
- var ch = line.charAt(pos);
60
- if (re.test(ch) && (style === undefined ||
61
- (cm.getTokenTypeAt(Pos(lineNo, pos + 1)) || "") == (style || ""))) {
62
- var match = matching[ch];
63
- if (match && (match.charAt(1) == ">") == (dir > 0)) stack.push(ch);
64
- else if (!stack.length) return {pos: Pos(lineNo, pos), ch: ch};
65
- else stack.pop();
66
- }
67
- }
68
- }
69
- return lineNo - dir == (dir > 0 ? cm.lastLine() : cm.firstLine()) ? false : null;
70
- }
71
-
72
- function matchBrackets(cm, autoclear, config) {
73
- // Disable brace matching in long lines, since it'll cause hugely slow updates
74
- var maxHighlightLen = cm.state.matchBrackets.maxHighlightLineLength || 1000,
75
- highlightNonMatching = config && config.highlightNonMatching;
76
- var marks = [], ranges = cm.listSelections();
77
- for (var i = 0; i < ranges.length; i++) {
78
- var match = ranges[i].empty() && findMatchingBracket(cm, ranges[i].head, config);
79
- if (match && (match.match || highlightNonMatching !== false) && cm.getLine(match.from.line).length <= maxHighlightLen) {
80
- var style = match.match ? "CodeMirror-matchingbracket" : "CodeMirror-nonmatchingbracket";
81
- marks.push(cm.markText(match.from, Pos(match.from.line, match.from.ch + 1), {className: style}));
82
- if (match.to && cm.getLine(match.to.line).length <= maxHighlightLen)
83
- marks.push(cm.markText(match.to, Pos(match.to.line, match.to.ch + 1), {className: style}));
84
- }
85
- }
86
-
87
- if (marks.length) {
88
- // Kludge to work around the IE bug from issue #1193, where text
89
- // input stops going to the textarea whenever this fires.
90
- if (ie_lt8 && cm.state.focused) cm.focus();
91
-
92
- var clear = function() {
93
- cm.operation(function() {
94
- for (var i = 0; i < marks.length; i++) marks[i].clear();
95
- });
96
- };
97
- if (autoclear) setTimeout(clear, 800);
98
- else return clear;
99
- }
100
- }
101
-
102
- function doMatchBrackets(cm) {
103
- cm.operation(function() {
104
- if (cm.state.matchBrackets.currentlyHighlighted) {
105
- cm.state.matchBrackets.currentlyHighlighted();
106
- cm.state.matchBrackets.currentlyHighlighted = null;
107
- }
108
- cm.state.matchBrackets.currentlyHighlighted = matchBrackets(cm, false, cm.state.matchBrackets);
109
- });
110
- }
111
-
112
- function clearHighlighted(cm) {
113
- if (cm.state.matchBrackets && cm.state.matchBrackets.currentlyHighlighted) {
114
- cm.state.matchBrackets.currentlyHighlighted();
115
- cm.state.matchBrackets.currentlyHighlighted = null;
116
- }
117
- }
118
-
119
- CodeMirror.defineOption("matchBrackets", false, function(cm, val, old) {
120
- if (old && old != CodeMirror.Init) {
121
- cm.off("cursorActivity", doMatchBrackets);
122
- cm.off("focus", doMatchBrackets);
123
- cm.off("blur", clearHighlighted);
124
- clearHighlighted(cm);
125
- }
126
- if (val) {
127
- cm.state.matchBrackets = typeof val == "object" ? val : {};
128
- cm.on("cursorActivity", doMatchBrackets);
129
- cm.on("focus", doMatchBrackets);
130
- cm.on("blur", clearHighlighted);
131
- }
132
- });
133
-
134
- CodeMirror.defineExtension("matchBrackets", function() {matchBrackets(this, true);});
135
- CodeMirror.defineExtension("findMatchingBracket", function(pos, config, oldConfig){
136
- // Backwards-compatibility kludge
137
- if (oldConfig || typeof config == "boolean") {
138
- if (!oldConfig) {
139
- config = config ? {strict: true} : null;
140
- } else {
141
- oldConfig.strict = config;
142
- config = oldConfig;
143
- }
144
- }
145
- return findMatchingBracket(this, pos, config)
146
- });
147
- CodeMirror.defineExtension("scanForBracket", function(pos, dir, style, config){
148
- return scanForBracket(this, pos, dir, style, config);
149
- });
150
- }
151
-
152
- export default matchbrackets;
@@ -1,282 +0,0 @@
1
- function lint(CodeMirror) {
2
- var GUTTER_ID = "CodeMirror-lint-markers";
3
- var LINT_LINE_ID = "CodeMirror-lint-line-";
4
-
5
- function showTooltip(cm, e, content) {
6
- var tt = document.createElement("div");
7
- tt.className = "CodeMirror-lint-tooltip cm-s-" + cm.options.theme;
8
- tt.appendChild(content.cloneNode(true));
9
- if (cm.state.lint.options.selfContain)
10
- cm.getWrapperElement().appendChild(tt);
11
- else
12
- document.body.appendChild(tt);
13
-
14
- function position(e) {
15
- if (!tt.parentNode) return CodeMirror.off(document, "mousemove", position);
16
- tt.style.top = Math.max(0, e.clientY - tt.offsetHeight - 5) + "px";
17
- tt.style.left = (e.clientX + 5) + "px";
18
- }
19
- CodeMirror.on(document, "mousemove", position);
20
- position(e);
21
- if (tt.style.opacity != null) tt.style.opacity = 1;
22
- return tt;
23
- }
24
- function rm(elt) {
25
- if (elt.parentNode) elt.parentNode.removeChild(elt);
26
- }
27
- function hideTooltip(tt) {
28
- if (!tt.parentNode) return;
29
- if (tt.style.opacity == null) rm(tt);
30
- tt.style.opacity = 0;
31
- setTimeout(function() { rm(tt); }, 600);
32
- }
33
-
34
- function showTooltipFor(cm, e, content, node) {
35
- var tooltip = showTooltip(cm, e, content);
36
- function hide() {
37
- CodeMirror.off(node, "mouseout", hide);
38
- if (tooltip) { hideTooltip(tooltip); tooltip = null; }
39
- }
40
- var poll = setInterval(function() {
41
- if (tooltip) for (var n = node;; n = n.parentNode) {
42
- if (n && n.nodeType == 11) n = n.host;
43
- if (n == document.body) return;
44
- if (!n) { hide(); break; }
45
- }
46
- if (!tooltip) return clearInterval(poll);
47
- }, 400);
48
- CodeMirror.on(node, "mouseout", hide);
49
- }
50
-
51
- function LintState(cm, conf, hasGutter) {
52
- this.marked = [];
53
- if (conf instanceof Function) conf = {getAnnotations: conf};
54
- if (!conf || conf === true) conf = {};
55
- this.options = {};
56
- this.linterOptions = conf.options || {};
57
- for (var prop in defaults) this.options[prop] = defaults[prop];
58
- for (var prop in conf) {
59
- if (defaults.hasOwnProperty(prop)) {
60
- if (conf[prop] != null) this.options[prop] = conf[prop];
61
- } else if (!conf.options) {
62
- this.linterOptions[prop] = conf[prop];
63
- }
64
- }
65
- this.timeout = null;
66
- this.hasGutter = hasGutter;
67
- this.onMouseOver = function(e) { onMouseOver(cm, e); };
68
- this.waitingFor = 0;
69
- }
70
-
71
- var defaults = {
72
- highlightLines: false,
73
- tooltips: true,
74
- delay: 500,
75
- lintOnChange: true,
76
- getAnnotations: null,
77
- async: false,
78
- selfContain: null,
79
- formatAnnotation: null,
80
- onUpdateLinting: null
81
- };
82
-
83
- function clearMarks(cm) {
84
- var state = cm.state.lint;
85
- if (state.hasGutter) cm.clearGutter(GUTTER_ID);
86
- if (state.options.highlightLines) clearErrorLines(cm);
87
- for (var i = 0; i < state.marked.length; ++i)
88
- state.marked[i].clear();
89
- state.marked.length = 0;
90
- }
91
-
92
- function clearErrorLines(cm) {
93
- cm.eachLine(function(line) {
94
- var has = line.wrapClass && /\bCodeMirror-lint-line-\w+\b/.exec(line.wrapClass);
95
- if (has) cm.removeLineClass(line, "wrap", has[0]);
96
- });
97
- }
98
-
99
- function makeMarker(cm, labels, severity, multiple, tooltips) {
100
- var marker = document.createElement("div"), inner = marker;
101
- marker.className = "CodeMirror-lint-marker CodeMirror-lint-marker-" + severity;
102
- if (multiple) {
103
- inner = marker.appendChild(document.createElement("div"));
104
- inner.className = "CodeMirror-lint-marker CodeMirror-lint-marker-multiple";
105
- }
106
-
107
- if (tooltips != false) CodeMirror.on(inner, "mouseover", function(e) {
108
- showTooltipFor(cm, e, labels, inner);
109
- });
110
-
111
- return marker;
112
- }
113
-
114
- function getMaxSeverity(a, b) {
115
- if (a == "error") return a;
116
- else return b;
117
- }
118
-
119
- function groupByLine(annotations) {
120
- var lines = [];
121
- for (var i = 0; i < annotations.length; ++i) {
122
- var ann = annotations[i], line = ann.from.line;
123
- (lines[line] || (lines[line] = [])).push(ann);
124
- }
125
- return lines;
126
- }
127
-
128
- function annotationTooltip(ann) {
129
- var severity = ann.severity;
130
- if (!severity) severity = "error";
131
- var tip = document.createElement("div");
132
- tip.className = "CodeMirror-lint-message CodeMirror-lint-message-" + severity;
133
- if (typeof ann.messageHTML != 'undefined') {
134
- tip.innerHTML = ann.messageHTML;
135
- } else {
136
- tip.appendChild(document.createTextNode(ann.message));
137
- }
138
- return tip;
139
- }
140
-
141
- function lintAsync(cm, getAnnotations) {
142
- var state = cm.state.lint;
143
- var id = ++state.waitingFor;
144
- function abort() {
145
- id = -1;
146
- cm.off("change", abort);
147
- }
148
- cm.on("change", abort);
149
- getAnnotations(cm.getValue(), function(annotations, arg2) {
150
- cm.off("change", abort);
151
- if (state.waitingFor != id) return
152
- if (arg2 && annotations instanceof CodeMirror) annotations = arg2;
153
- cm.operation(function() {updateLinting(cm, annotations);});
154
- }, state.linterOptions, cm);
155
- }
156
-
157
- function startLinting(cm) {
158
- var state = cm.state.lint;
159
- if (!state) return;
160
- var options = state.options;
161
- /*
162
- * Passing rules in `options` property prevents JSHint (and other linters) from complaining
163
- * about unrecognized rules like `onUpdateLinting`, `delay`, `lintOnChange`, etc.
164
- */
165
- var getAnnotations = options.getAnnotations || cm.getHelper(CodeMirror.Pos(0, 0), "lint");
166
- if (!getAnnotations) return;
167
- if (options.async || getAnnotations.async) {
168
- lintAsync(cm, getAnnotations);
169
- } else {
170
- var annotations = getAnnotations(cm.getValue(), state.linterOptions, cm);
171
- if (!annotations) return;
172
- if (annotations.then) annotations.then(function(issues) {
173
- cm.operation(function() {updateLinting(cm, issues);});
174
- });
175
- else cm.operation(function() {updateLinting(cm, annotations);});
176
- }
177
- }
178
-
179
- function updateLinting(cm, annotationsNotSorted) {
180
- var state = cm.state.lint;
181
- if (!state) return;
182
- var options = state.options;
183
- clearMarks(cm);
184
-
185
- var annotations = groupByLine(annotationsNotSorted);
186
-
187
- for (var line = 0; line < annotations.length; ++line) {
188
- var anns = annotations[line];
189
- if (!anns) continue;
190
-
191
- // filter out duplicate messages
192
- var message = [];
193
- anns = anns.filter(function(item) { return message.indexOf(item.message) > -1 ? false : message.push(item.message) });
194
-
195
- var maxSeverity = null;
196
- var tipLabel = state.hasGutter && document.createDocumentFragment();
197
-
198
- for (var i = 0; i < anns.length; ++i) {
199
- var ann = anns[i];
200
- var severity = ann.severity;
201
- if (!severity) severity = "error";
202
- maxSeverity = getMaxSeverity(maxSeverity, severity);
203
-
204
- if (options.formatAnnotation) ann = options.formatAnnotation(ann);
205
- if (state.hasGutter) tipLabel.appendChild(annotationTooltip(ann));
206
-
207
- if (ann.to) state.marked.push(cm.markText(ann.from, ann.to, {
208
- className: "CodeMirror-lint-mark CodeMirror-lint-mark-" + severity,
209
- __annotation: ann
210
- }));
211
- }
212
- // use original annotations[line] to show multiple messages
213
- if (state.hasGutter)
214
- cm.setGutterMarker(line, GUTTER_ID, makeMarker(cm, tipLabel, maxSeverity, annotations[line].length > 1,
215
- options.tooltips));
216
-
217
- if (options.highlightLines)
218
- cm.addLineClass(line, "wrap", LINT_LINE_ID + maxSeverity);
219
- }
220
- if (options.onUpdateLinting) options.onUpdateLinting(annotationsNotSorted, annotations, cm);
221
- }
222
-
223
- function onChange(cm) {
224
- var state = cm.state.lint;
225
- if (!state) return;
226
- clearTimeout(state.timeout);
227
- state.timeout = setTimeout(function(){startLinting(cm);}, state.options.delay);
228
- }
229
-
230
- function popupTooltips(cm, annotations, e) {
231
- var target = e.target || e.srcElement;
232
- var tooltip = document.createDocumentFragment();
233
- for (var i = 0; i < annotations.length; i++) {
234
- var ann = annotations[i];
235
- tooltip.appendChild(annotationTooltip(ann));
236
- }
237
- showTooltipFor(cm, e, tooltip, target);
238
- }
239
-
240
- function onMouseOver(cm, e) {
241
- var target = e.target || e.srcElement;
242
- if (!/\bCodeMirror-lint-mark-/.test(target.className)) return;
243
- var box = target.getBoundingClientRect(), x = (box.left + box.right) / 2, y = (box.top + box.bottom) / 2;
244
- var spans = cm.findMarksAt(cm.coordsChar({left: x, top: y}, "client"));
245
-
246
- var annotations = [];
247
- for (var i = 0; i < spans.length; ++i) {
248
- var ann = spans[i].__annotation;
249
- if (ann) annotations.push(ann);
250
- }
251
- if (annotations.length) popupTooltips(cm, annotations, e);
252
- }
253
-
254
- CodeMirror.defineOption("lint", false, function(cm, val, old) {
255
- if (old && old != CodeMirror.Init) {
256
- clearMarks(cm);
257
- if (cm.state.lint.options.lintOnChange !== false)
258
- cm.off("change", onChange);
259
- CodeMirror.off(cm.getWrapperElement(), "mouseover", cm.state.lint.onMouseOver);
260
- clearTimeout(cm.state.lint.timeout);
261
- delete cm.state.lint;
262
- }
263
-
264
- if (val) {
265
- var gutters = cm.getOption("gutters"), hasLintGutter = false;
266
- for (var i = 0; i < gutters.length; ++i) if (gutters[i] == GUTTER_ID) hasLintGutter = true;
267
- var state = cm.state.lint = new LintState(cm, val, hasLintGutter);
268
- if (state.options.lintOnChange)
269
- cm.on("change", onChange);
270
- if (state.options.tooltips != false && state.options.tooltips != "gutter")
271
- CodeMirror.on(cm.getWrapperElement(), "mouseover", state.onMouseOver);
272
-
273
- startLinting(cm);
274
- }
275
- });
276
-
277
- CodeMirror.defineExtension("performLint", function() {
278
- startLinting(this);
279
- });
280
- }
281
-
282
- export default lint;