@codemirror/lint 0.19.3 → 0.19.6
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/CHANGELOG.md +22 -0
- package/dist/index.cjs +26 -23
- package/dist/index.d.ts +7 -1
- package/dist/index.js +19 -16
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,25 @@
|
|
|
1
|
+
## 0.19.6 (2022-03-04)
|
|
2
|
+
|
|
3
|
+
### Bug fixes
|
|
4
|
+
|
|
5
|
+
Fix a bug where hovering over the icons in the lint gutter would sometimes fail to show a tooltip or show the tooltip for another line.
|
|
6
|
+
|
|
7
|
+
## 0.19.5 (2022-02-25)
|
|
8
|
+
|
|
9
|
+
### Bug fixes
|
|
10
|
+
|
|
11
|
+
Make sure the lint gutter tooltips are positioned under their icon, even when the line is wrapped.
|
|
12
|
+
|
|
13
|
+
## 0.19.4 (2022-02-25)
|
|
14
|
+
|
|
15
|
+
### Bug fixes
|
|
16
|
+
|
|
17
|
+
Fix an issue where an outdated marker could stick around on the lint gutter after all diagnostics were removed.
|
|
18
|
+
|
|
19
|
+
### New features
|
|
20
|
+
|
|
21
|
+
Add a `hoverTime` option to the lint gutter. Change default hover time to 300
|
|
22
|
+
|
|
1
23
|
## 0.19.3 (2021-11-09)
|
|
2
24
|
|
|
3
25
|
### New features
|
package/dist/index.cjs
CHANGED
|
@@ -143,7 +143,7 @@ function lintTooltip(view, pos, side) {
|
|
|
143
143
|
};
|
|
144
144
|
}
|
|
145
145
|
function diagnosticsTooltip(view, diagnostics) {
|
|
146
|
-
return elt__default[
|
|
146
|
+
return elt__default["default"]("ul", { class: "cm-tooltip-lint" }, diagnostics.map(d => renderDiagnostic(view, d, false)));
|
|
147
147
|
}
|
|
148
148
|
/**
|
|
149
149
|
Command to open and focus the lint panel.
|
|
@@ -212,10 +212,8 @@ const lintPlugin = view.ViewPlugin.fromClass(class {
|
|
|
212
212
|
this.set = false;
|
|
213
213
|
let { state } = this.view, { sources } = state.facet(lintSource);
|
|
214
214
|
Promise.all(sources.map(source => Promise.resolve(source(this.view)))).then(annotations => {
|
|
215
|
-
var _a, _b;
|
|
216
215
|
let all = annotations.reduce((a, b) => a.concat(b));
|
|
217
|
-
if (this.view.state.doc == state.doc
|
|
218
|
-
(all.length || ((_b = (_a = this.view.state.field(lintState, false)) === null || _a === void 0 ? void 0 : _a.diagnostics) === null || _b === void 0 ? void 0 : _b.size)))
|
|
216
|
+
if (this.view.state.doc == state.doc)
|
|
219
217
|
this.view.dispatch(setDiagnostics(this.view.state, all));
|
|
220
218
|
}, error => { view.logException(this.view.state, error); });
|
|
221
219
|
}
|
|
@@ -282,7 +280,7 @@ function assignKeys(actions) {
|
|
|
282
280
|
function renderDiagnostic(view, diagnostic, inPanel) {
|
|
283
281
|
var _a;
|
|
284
282
|
let keys = inPanel ? assignKeys(diagnostic.actions) : [];
|
|
285
|
-
return elt__default[
|
|
283
|
+
return elt__default["default"]("li", { class: "cm-diagnostic cm-diagnostic-" + diagnostic.severity }, elt__default["default"]("span", { class: "cm-diagnosticText" }, diagnostic.message), (_a = diagnostic.actions) === null || _a === void 0 ? void 0 : _a.map((action, i) => {
|
|
286
284
|
let click = (e) => {
|
|
287
285
|
e.preventDefault();
|
|
288
286
|
let found = findDiagnostic(view.state.field(lintState).diagnostics, diagnostic);
|
|
@@ -291,16 +289,16 @@ function renderDiagnostic(view, diagnostic, inPanel) {
|
|
|
291
289
|
};
|
|
292
290
|
let { name } = action, keyIndex = keys[i] ? name.indexOf(keys[i]) : -1;
|
|
293
291
|
let nameElt = keyIndex < 0 ? name : [name.slice(0, keyIndex),
|
|
294
|
-
elt__default[
|
|
292
|
+
elt__default["default"]("u", name.slice(keyIndex, keyIndex + 1)),
|
|
295
293
|
name.slice(keyIndex + 1)];
|
|
296
|
-
return elt__default[
|
|
294
|
+
return elt__default["default"]("button", {
|
|
297
295
|
type: "button",
|
|
298
296
|
class: "cm-diagnosticAction",
|
|
299
297
|
onclick: click,
|
|
300
298
|
onmousedown: click,
|
|
301
299
|
"aria-label": ` Action: ${name}${keyIndex < 0 ? "" : ` (access key "${keys[i]})"`}.`
|
|
302
300
|
}, nameElt);
|
|
303
|
-
}), diagnostic.source && elt__default[
|
|
301
|
+
}), diagnostic.source && elt__default["default"]("div", { class: "cm-diagnosticSource" }, diagnostic.source));
|
|
304
302
|
}
|
|
305
303
|
class DiagnosticWidget extends view.WidgetType {
|
|
306
304
|
constructor(diagnostic) {
|
|
@@ -309,7 +307,7 @@ class DiagnosticWidget extends view.WidgetType {
|
|
|
309
307
|
}
|
|
310
308
|
eq(other) { return other.diagnostic == this.diagnostic; }
|
|
311
309
|
toDOM() {
|
|
312
|
-
return elt__default[
|
|
310
|
+
return elt__default["default"]("span", { class: "cm-lintPoint cm-lintPoint-" + this.diagnostic.severity });
|
|
313
311
|
}
|
|
314
312
|
}
|
|
315
313
|
class PanelItem {
|
|
@@ -365,14 +363,14 @@ class LintPanel {
|
|
|
365
363
|
this.moveSelection(i);
|
|
366
364
|
}
|
|
367
365
|
};
|
|
368
|
-
this.list = elt__default[
|
|
366
|
+
this.list = elt__default["default"]("ul", {
|
|
369
367
|
tabIndex: 0,
|
|
370
368
|
role: "listbox",
|
|
371
369
|
"aria-label": this.view.state.phrase("Diagnostics"),
|
|
372
370
|
onkeydown,
|
|
373
371
|
onclick
|
|
374
372
|
});
|
|
375
|
-
this.dom = elt__default[
|
|
373
|
+
this.dom = elt__default["default"]("div", { class: "cm-panel-lint" }, this.list, elt__default["default"]("button", {
|
|
376
374
|
type: "button",
|
|
377
375
|
name: "close",
|
|
378
376
|
"aria-label": this.view.state.phrase("close"),
|
|
@@ -613,8 +611,8 @@ function trackHoverOn(view, marker) {
|
|
|
613
611
|
}
|
|
614
612
|
function gutterMarkerMouseOver(view, marker, diagnostics) {
|
|
615
613
|
function hovered() {
|
|
616
|
-
let line = view.
|
|
617
|
-
const linePos = view.coordsAtPos(line.from)
|
|
614
|
+
let line = view.elementAtHeight(marker.getBoundingClientRect().top + 5 - view.documentTop);
|
|
615
|
+
const linePos = view.coordsAtPos(line.from);
|
|
618
616
|
if (linePos) {
|
|
619
617
|
view.dispatch({ effects: setLintGutterTooltip.of({
|
|
620
618
|
pos: line.from,
|
|
@@ -622,7 +620,7 @@ function gutterMarkerMouseOver(view, marker, diagnostics) {
|
|
|
622
620
|
create() {
|
|
623
621
|
return {
|
|
624
622
|
dom: diagnosticsTooltip(view, diagnostics),
|
|
625
|
-
|
|
623
|
+
getCoords: () => marker.getBoundingClientRect()
|
|
626
624
|
};
|
|
627
625
|
}
|
|
628
626
|
}) });
|
|
@@ -630,14 +628,15 @@ function gutterMarkerMouseOver(view, marker, diagnostics) {
|
|
|
630
628
|
marker.onmouseout = marker.onmousemove = null;
|
|
631
629
|
trackHoverOn(view, marker);
|
|
632
630
|
}
|
|
633
|
-
let
|
|
631
|
+
let { hoverTime } = view.state.facet(lintGutterConfig);
|
|
632
|
+
let hoverTimeout = setTimeout(hovered, hoverTime);
|
|
634
633
|
marker.onmouseout = () => {
|
|
635
634
|
clearTimeout(hoverTimeout);
|
|
636
635
|
marker.onmouseout = marker.onmousemove = null;
|
|
637
636
|
};
|
|
638
637
|
marker.onmousemove = () => {
|
|
639
638
|
clearTimeout(hoverTimeout);
|
|
640
|
-
hoverTimeout = setTimeout(hovered,
|
|
639
|
+
hoverTimeout = setTimeout(hovered, hoverTime);
|
|
641
640
|
};
|
|
642
641
|
}
|
|
643
642
|
function markersForDiagnostics(doc, diagnostics) {
|
|
@@ -683,15 +682,12 @@ const lintGutterTheme = view.EditorView.baseTheme({
|
|
|
683
682
|
".cm-gutter-lint": {
|
|
684
683
|
width: "1.4em",
|
|
685
684
|
"& .cm-gutterElement": {
|
|
686
|
-
padding: "
|
|
687
|
-
display: "flex",
|
|
688
|
-
flexDirection: "column",
|
|
689
|
-
justifyContent: "center",
|
|
685
|
+
padding: ".2em"
|
|
690
686
|
}
|
|
691
687
|
},
|
|
692
688
|
".cm-lint-marker": {
|
|
693
689
|
width: "1em",
|
|
694
|
-
height: "1em"
|
|
690
|
+
height: "1em"
|
|
695
691
|
},
|
|
696
692
|
".cm-lint-marker-info": {
|
|
697
693
|
content: svg(`<path fill="#aaf" stroke="#77e" stroke-width="6" stroke-linejoin="round" d="M5 5L35 5L35 35L5 35Z"/>`)
|
|
@@ -703,13 +699,20 @@ const lintGutterTheme = view.EditorView.baseTheme({
|
|
|
703
699
|
content: svg(`<circle cx="20" cy="20" r="15" fill="#f87" stroke="#f43" stroke-width="6"/>`)
|
|
704
700
|
},
|
|
705
701
|
});
|
|
702
|
+
const lintGutterConfig = state.Facet.define({
|
|
703
|
+
combine(configs) {
|
|
704
|
+
return state.combineConfig(configs, {
|
|
705
|
+
hoverTime: 300 /* Time */,
|
|
706
|
+
});
|
|
707
|
+
}
|
|
708
|
+
});
|
|
706
709
|
/**
|
|
707
710
|
Returns an extension that installs a gutter showing markers for
|
|
708
711
|
each line that has diagnostics, which can be hovered over to see
|
|
709
712
|
the diagnostics.
|
|
710
713
|
*/
|
|
711
|
-
function lintGutter() {
|
|
712
|
-
return [lintGutterMarkers, lintGutterExtension, lintGutterTheme, lintGutterTooltip];
|
|
714
|
+
function lintGutter(config = {}) {
|
|
715
|
+
return [lintGutterConfig.of(config), lintGutterMarkers, lintGutterExtension, lintGutterTheme, lintGutterTooltip];
|
|
713
716
|
}
|
|
714
717
|
|
|
715
718
|
exports.closeLintPanel = closeLintPanel;
|
package/dist/index.d.ts
CHANGED
|
@@ -51,6 +51,12 @@ interface Action {
|
|
|
51
51
|
*/
|
|
52
52
|
apply: (view: EditorView, from: number, to: number) => void;
|
|
53
53
|
}
|
|
54
|
+
interface LintGutterConfig {
|
|
55
|
+
/**
|
|
56
|
+
The delay before showing a tooltip when hovering over a lint gutter marker.
|
|
57
|
+
*/
|
|
58
|
+
hoverTime?: number;
|
|
59
|
+
}
|
|
54
60
|
/**
|
|
55
61
|
Returns a transaction spec which updates the current set of
|
|
56
62
|
diagnostics, and enables the lint extension if if wasn't already
|
|
@@ -108,6 +114,6 @@ Returns an extension that installs a gutter showing markers for
|
|
|
108
114
|
each line that has diagnostics, which can be hovered over to see
|
|
109
115
|
the diagnostics.
|
|
110
116
|
*/
|
|
111
|
-
declare function lintGutter(): Extension;
|
|
117
|
+
declare function lintGutter(config?: LintGutterConfig): Extension;
|
|
112
118
|
|
|
113
119
|
export { Action, Diagnostic, closeLintPanel, diagnosticCount, forceLinting, lintGutter, lintKeymap, linter, nextDiagnostic, openLintPanel, setDiagnostics, setDiagnosticsEffect };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Decoration, EditorView, ViewPlugin, logException, WidgetType } from '@codemirror/view';
|
|
2
|
-
import { StateEffect, StateField, Facet } from '@codemirror/state';
|
|
2
|
+
import { StateEffect, StateField, Facet, combineConfig } from '@codemirror/state';
|
|
3
3
|
import { hoverTooltip, showTooltip } from '@codemirror/tooltip';
|
|
4
4
|
import { showPanel, getPanel } from '@codemirror/panel';
|
|
5
5
|
import { gutter, GutterMarker } from '@codemirror/gutter';
|
|
@@ -204,10 +204,8 @@ const lintPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
|
|
|
204
204
|
this.set = false;
|
|
205
205
|
let { state } = this.view, { sources } = state.facet(lintSource);
|
|
206
206
|
Promise.all(sources.map(source => Promise.resolve(source(this.view)))).then(annotations => {
|
|
207
|
-
var _a, _b;
|
|
208
207
|
let all = annotations.reduce((a, b) => a.concat(b));
|
|
209
|
-
if (this.view.state.doc == state.doc
|
|
210
|
-
(all.length || ((_b = (_a = this.view.state.field(lintState, false)) === null || _a === void 0 ? void 0 : _a.diagnostics) === null || _b === void 0 ? void 0 : _b.size)))
|
|
208
|
+
if (this.view.state.doc == state.doc)
|
|
211
209
|
this.view.dispatch(setDiagnostics(this.view.state, all));
|
|
212
210
|
}, error => { logException(this.view.state, error); });
|
|
213
211
|
}
|
|
@@ -605,8 +603,8 @@ function trackHoverOn(view, marker) {
|
|
|
605
603
|
}
|
|
606
604
|
function gutterMarkerMouseOver(view, marker, diagnostics) {
|
|
607
605
|
function hovered() {
|
|
608
|
-
let line = view.
|
|
609
|
-
const linePos = view.coordsAtPos(line.from)
|
|
606
|
+
let line = view.elementAtHeight(marker.getBoundingClientRect().top + 5 - view.documentTop);
|
|
607
|
+
const linePos = view.coordsAtPos(line.from);
|
|
610
608
|
if (linePos) {
|
|
611
609
|
view.dispatch({ effects: setLintGutterTooltip.of({
|
|
612
610
|
pos: line.from,
|
|
@@ -614,7 +612,7 @@ function gutterMarkerMouseOver(view, marker, diagnostics) {
|
|
|
614
612
|
create() {
|
|
615
613
|
return {
|
|
616
614
|
dom: diagnosticsTooltip(view, diagnostics),
|
|
617
|
-
|
|
615
|
+
getCoords: () => marker.getBoundingClientRect()
|
|
618
616
|
};
|
|
619
617
|
}
|
|
620
618
|
}) });
|
|
@@ -622,14 +620,15 @@ function gutterMarkerMouseOver(view, marker, diagnostics) {
|
|
|
622
620
|
marker.onmouseout = marker.onmousemove = null;
|
|
623
621
|
trackHoverOn(view, marker);
|
|
624
622
|
}
|
|
625
|
-
let
|
|
623
|
+
let { hoverTime } = view.state.facet(lintGutterConfig);
|
|
624
|
+
let hoverTimeout = setTimeout(hovered, hoverTime);
|
|
626
625
|
marker.onmouseout = () => {
|
|
627
626
|
clearTimeout(hoverTimeout);
|
|
628
627
|
marker.onmouseout = marker.onmousemove = null;
|
|
629
628
|
};
|
|
630
629
|
marker.onmousemove = () => {
|
|
631
630
|
clearTimeout(hoverTimeout);
|
|
632
|
-
hoverTimeout = setTimeout(hovered,
|
|
631
|
+
hoverTimeout = setTimeout(hovered, hoverTime);
|
|
633
632
|
};
|
|
634
633
|
}
|
|
635
634
|
function markersForDiagnostics(doc, diagnostics) {
|
|
@@ -675,15 +674,12 @@ const lintGutterTheme = /*@__PURE__*/EditorView.baseTheme({
|
|
|
675
674
|
".cm-gutter-lint": {
|
|
676
675
|
width: "1.4em",
|
|
677
676
|
"& .cm-gutterElement": {
|
|
678
|
-
padding: "
|
|
679
|
-
display: "flex",
|
|
680
|
-
flexDirection: "column",
|
|
681
|
-
justifyContent: "center",
|
|
677
|
+
padding: ".2em"
|
|
682
678
|
}
|
|
683
679
|
},
|
|
684
680
|
".cm-lint-marker": {
|
|
685
681
|
width: "1em",
|
|
686
|
-
height: "1em"
|
|
682
|
+
height: "1em"
|
|
687
683
|
},
|
|
688
684
|
".cm-lint-marker-info": {
|
|
689
685
|
content: /*@__PURE__*/svg(`<path fill="#aaf" stroke="#77e" stroke-width="6" stroke-linejoin="round" d="M5 5L35 5L35 35L5 35Z"/>`)
|
|
@@ -695,13 +691,20 @@ const lintGutterTheme = /*@__PURE__*/EditorView.baseTheme({
|
|
|
695
691
|
content: /*@__PURE__*/svg(`<circle cx="20" cy="20" r="15" fill="#f87" stroke="#f43" stroke-width="6"/>`)
|
|
696
692
|
},
|
|
697
693
|
});
|
|
694
|
+
const lintGutterConfig = /*@__PURE__*/Facet.define({
|
|
695
|
+
combine(configs) {
|
|
696
|
+
return combineConfig(configs, {
|
|
697
|
+
hoverTime: 300 /* Time */,
|
|
698
|
+
});
|
|
699
|
+
}
|
|
700
|
+
});
|
|
698
701
|
/**
|
|
699
702
|
Returns an extension that installs a gutter showing markers for
|
|
700
703
|
each line that has diagnostics, which can be hovered over to see
|
|
701
704
|
the diagnostics.
|
|
702
705
|
*/
|
|
703
|
-
function lintGutter() {
|
|
704
|
-
return [lintGutterMarkers, lintGutterExtension, lintGutterTheme, lintGutterTooltip];
|
|
706
|
+
function lintGutter(config = {}) {
|
|
707
|
+
return [lintGutterConfig.of(config), lintGutterMarkers, lintGutterExtension, lintGutterTheme, lintGutterTooltip];
|
|
705
708
|
}
|
|
706
709
|
|
|
707
710
|
export { closeLintPanel, diagnosticCount, forceLinting, lintGutter, lintKeymap, linter, nextDiagnostic, openLintPanel, setDiagnostics, setDiagnosticsEffect };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codemirror/lint",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.6",
|
|
4
4
|
"description": "Linting support for the CodeMirror code editor",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "cm-runtests",
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"@codemirror/panel": "^0.19.0",
|
|
31
31
|
"@codemirror/rangeset": "^0.19.1",
|
|
32
32
|
"@codemirror/state": "^0.19.4",
|
|
33
|
-
"@codemirror/tooltip": "^0.19.
|
|
34
|
-
"@codemirror/view": "^0.19.
|
|
33
|
+
"@codemirror/tooltip": "^0.19.16",
|
|
34
|
+
"@codemirror/view": "^0.19.22",
|
|
35
35
|
"crelt": "^1.0.5"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|