@codemirror/lint 6.5.0 → 6.7.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.
- package/CHANGELOG.md +12 -0
- package/dist/index.cjs +8 -3
- package/dist/index.d.cts +10 -2
- package/dist/index.d.ts +10 -2
- package/dist/index.js +8 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
## 6.7.0 (2024-04-30)
|
|
2
|
+
|
|
3
|
+
### New features
|
|
4
|
+
|
|
5
|
+
The `renderMessage` function is now called with the editor view as first argument.
|
|
6
|
+
|
|
7
|
+
## 6.6.0 (2024-04-29)
|
|
8
|
+
|
|
9
|
+
### New features
|
|
10
|
+
|
|
11
|
+
The new `hideOn` configuration option can be used to control in what circumstances lint tooltips get hidden by state changes.
|
|
12
|
+
|
|
1
13
|
## 6.5.0 (2024-01-30)
|
|
2
14
|
|
|
3
15
|
### Bug fixes
|
package/dist/index.cjs
CHANGED
|
@@ -50,8 +50,12 @@ function findDiagnostic(diagnostics, diagnostic = null, after = 0) {
|
|
|
50
50
|
return found;
|
|
51
51
|
}
|
|
52
52
|
function hideTooltip(tr, tooltip) {
|
|
53
|
+
let from = tooltip.pos, to = tooltip.end || from;
|
|
54
|
+
let result = tr.state.facet(lintConfig).hideOn(tr, from, to);
|
|
55
|
+
if (result != null)
|
|
56
|
+
return result;
|
|
53
57
|
let line = tr.startState.doc.lineAt(tooltip.pos);
|
|
54
|
-
return !!(tr.effects.some(e => e.is(setDiagnosticsEffect)) || tr.changes.touchesRange(line.from, line.to));
|
|
58
|
+
return !!(tr.effects.some(e => e.is(setDiagnosticsEffect)) || tr.changes.touchesRange(line.from, Math.max(line.to, to)));
|
|
55
59
|
}
|
|
56
60
|
function maybeEnableLint(state$1, effects) {
|
|
57
61
|
return state$1.field(lintState, false) ? effects : effects.concat(state.StateEffect.appendConfig.of(lintExtensions));
|
|
@@ -263,7 +267,8 @@ const lintConfig = state.Facet.define({
|
|
|
263
267
|
delay: 750,
|
|
264
268
|
markerFilter: null,
|
|
265
269
|
tooltipFilter: null,
|
|
266
|
-
needsRefresh: null
|
|
270
|
+
needsRefresh: null,
|
|
271
|
+
hideOn: () => null,
|
|
267
272
|
}, {
|
|
268
273
|
needsRefresh: (a, b) => !a ? b : !b ? a : u => a(u) || b(u)
|
|
269
274
|
}));
|
|
@@ -309,7 +314,7 @@ function assignKeys(actions) {
|
|
|
309
314
|
function renderDiagnostic(view, diagnostic, inPanel) {
|
|
310
315
|
var _a;
|
|
311
316
|
let keys = inPanel ? assignKeys(diagnostic.actions) : [];
|
|
312
|
-
return elt("li", { class: "cm-diagnostic cm-diagnostic-" + diagnostic.severity }, elt("span", { class: "cm-diagnosticText" }, diagnostic.renderMessage ? diagnostic.renderMessage() : diagnostic.message), (_a = diagnostic.actions) === null || _a === void 0 ? void 0 : _a.map((action, i) => {
|
|
317
|
+
return elt("li", { class: "cm-diagnostic cm-diagnostic-" + diagnostic.severity }, elt("span", { class: "cm-diagnosticText" }, diagnostic.renderMessage ? diagnostic.renderMessage(view) : diagnostic.message), (_a = diagnostic.actions) === null || _a === void 0 ? void 0 : _a.map((action, i) => {
|
|
313
318
|
let fired = false, click = (e) => {
|
|
314
319
|
e.preventDefault();
|
|
315
320
|
if (fired)
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _codemirror_state from '@codemirror/state';
|
|
2
|
-
import { EditorState, TransactionSpec, Extension } from '@codemirror/state';
|
|
2
|
+
import { EditorState, TransactionSpec, Extension, Transaction } from '@codemirror/state';
|
|
3
3
|
import { EditorView, Command, KeyBinding, ViewUpdate } from '@codemirror/view';
|
|
4
4
|
|
|
5
5
|
type Severity = "hint" | "info" | "warning" | "error";
|
|
@@ -40,7 +40,7 @@ interface Diagnostic {
|
|
|
40
40
|
An optional custom rendering function that displays the message
|
|
41
41
|
as a DOM node.
|
|
42
42
|
*/
|
|
43
|
-
renderMessage?: () => Node;
|
|
43
|
+
renderMessage?: (view: EditorView) => Node;
|
|
44
44
|
/**
|
|
45
45
|
An optional array of actions that can be taken on this
|
|
46
46
|
diagnostic.
|
|
@@ -85,6 +85,14 @@ interface LintConfig {
|
|
|
85
85
|
tooltip will appear if the empty set is returned.
|
|
86
86
|
*/
|
|
87
87
|
tooltipFilter?: null | DiagnosticFilter;
|
|
88
|
+
/**
|
|
89
|
+
Can be used to control what kind of transactions cause lint
|
|
90
|
+
hover tooltips associated with the given document range to be
|
|
91
|
+
hidden. By default any transactions that changes the line
|
|
92
|
+
around the range will hide it. Returning null falls back to this
|
|
93
|
+
behavior.
|
|
94
|
+
*/
|
|
95
|
+
hideOn?: (tr: Transaction, from: number, to: number) => boolean | null;
|
|
88
96
|
}
|
|
89
97
|
interface LintGutterConfig {
|
|
90
98
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _codemirror_state from '@codemirror/state';
|
|
2
|
-
import { EditorState, TransactionSpec, Extension } from '@codemirror/state';
|
|
2
|
+
import { EditorState, TransactionSpec, Extension, Transaction } from '@codemirror/state';
|
|
3
3
|
import { EditorView, Command, KeyBinding, ViewUpdate } from '@codemirror/view';
|
|
4
4
|
|
|
5
5
|
type Severity = "hint" | "info" | "warning" | "error";
|
|
@@ -40,7 +40,7 @@ interface Diagnostic {
|
|
|
40
40
|
An optional custom rendering function that displays the message
|
|
41
41
|
as a DOM node.
|
|
42
42
|
*/
|
|
43
|
-
renderMessage?: () => Node;
|
|
43
|
+
renderMessage?: (view: EditorView) => Node;
|
|
44
44
|
/**
|
|
45
45
|
An optional array of actions that can be taken on this
|
|
46
46
|
diagnostic.
|
|
@@ -85,6 +85,14 @@ interface LintConfig {
|
|
|
85
85
|
tooltip will appear if the empty set is returned.
|
|
86
86
|
*/
|
|
87
87
|
tooltipFilter?: null | DiagnosticFilter;
|
|
88
|
+
/**
|
|
89
|
+
Can be used to control what kind of transactions cause lint
|
|
90
|
+
hover tooltips associated with the given document range to be
|
|
91
|
+
hidden. By default any transactions that changes the line
|
|
92
|
+
around the range will hide it. Returning null falls back to this
|
|
93
|
+
behavior.
|
|
94
|
+
*/
|
|
95
|
+
hideOn?: (tr: Transaction, from: number, to: number) => boolean | null;
|
|
88
96
|
}
|
|
89
97
|
interface LintGutterConfig {
|
|
90
98
|
/**
|
package/dist/index.js
CHANGED
|
@@ -48,8 +48,12 @@ function findDiagnostic(diagnostics, diagnostic = null, after = 0) {
|
|
|
48
48
|
return found;
|
|
49
49
|
}
|
|
50
50
|
function hideTooltip(tr, tooltip) {
|
|
51
|
+
let from = tooltip.pos, to = tooltip.end || from;
|
|
52
|
+
let result = tr.state.facet(lintConfig).hideOn(tr, from, to);
|
|
53
|
+
if (result != null)
|
|
54
|
+
return result;
|
|
51
55
|
let line = tr.startState.doc.lineAt(tooltip.pos);
|
|
52
|
-
return !!(tr.effects.some(e => e.is(setDiagnosticsEffect)) || tr.changes.touchesRange(line.from, line.to));
|
|
56
|
+
return !!(tr.effects.some(e => e.is(setDiagnosticsEffect)) || tr.changes.touchesRange(line.from, Math.max(line.to, to)));
|
|
53
57
|
}
|
|
54
58
|
function maybeEnableLint(state, effects) {
|
|
55
59
|
return state.field(lintState, false) ? effects : effects.concat(StateEffect.appendConfig.of(lintExtensions));
|
|
@@ -261,7 +265,8 @@ const lintConfig = /*@__PURE__*/Facet.define({
|
|
|
261
265
|
delay: 750,
|
|
262
266
|
markerFilter: null,
|
|
263
267
|
tooltipFilter: null,
|
|
264
|
-
needsRefresh: null
|
|
268
|
+
needsRefresh: null,
|
|
269
|
+
hideOn: () => null,
|
|
265
270
|
}, {
|
|
266
271
|
needsRefresh: (a, b) => !a ? b : !b ? a : u => a(u) || b(u)
|
|
267
272
|
}));
|
|
@@ -307,7 +312,7 @@ function assignKeys(actions) {
|
|
|
307
312
|
function renderDiagnostic(view, diagnostic, inPanel) {
|
|
308
313
|
var _a;
|
|
309
314
|
let keys = inPanel ? assignKeys(diagnostic.actions) : [];
|
|
310
|
-
return elt("li", { class: "cm-diagnostic cm-diagnostic-" + diagnostic.severity }, elt("span", { class: "cm-diagnosticText" }, diagnostic.renderMessage ? diagnostic.renderMessage() : diagnostic.message), (_a = diagnostic.actions) === null || _a === void 0 ? void 0 : _a.map((action, i) => {
|
|
315
|
+
return elt("li", { class: "cm-diagnostic cm-diagnostic-" + diagnostic.severity }, elt("span", { class: "cm-diagnosticText" }, diagnostic.renderMessage ? diagnostic.renderMessage(view) : diagnostic.message), (_a = diagnostic.actions) === null || _a === void 0 ? void 0 : _a.map((action, i) => {
|
|
311
316
|
let fired = false, click = (e) => {
|
|
312
317
|
e.preventDefault();
|
|
313
318
|
if (fired)
|