@codemirror/lint 6.8.5 → 6.9.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 +10 -0
- package/dist/index.cjs +28 -13
- package/dist/index.d.cts +9 -2
- package/dist/index.d.ts +9 -2
- package/dist/index.js +28 -13
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
## 6.9.0 (2025-10-02)
|
|
2
|
+
|
|
3
|
+
### Bug fixes
|
|
4
|
+
|
|
5
|
+
Multiple configurations to `linter` will now be merged without raising an error.
|
|
6
|
+
|
|
7
|
+
### New features
|
|
8
|
+
|
|
9
|
+
The new `markClass` option to actions makes it possible to style action buttons.
|
|
10
|
+
|
|
1
11
|
## 6.8.5 (2025-03-26)
|
|
2
12
|
|
|
3
13
|
### Bug fixes
|
package/dist/index.cjs
CHANGED
|
@@ -319,22 +319,36 @@ function batchResults(promises, sink, error) {
|
|
|
319
319
|
}
|
|
320
320
|
const lintConfig = state.Facet.define({
|
|
321
321
|
combine(input) {
|
|
322
|
-
return
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
322
|
+
return {
|
|
323
|
+
sources: input.map(i => i.source).filter(x => x != null),
|
|
324
|
+
...state.combineConfig(input.map(i => i.config), {
|
|
325
|
+
delay: 750,
|
|
326
|
+
markerFilter: null,
|
|
327
|
+
tooltipFilter: null,
|
|
328
|
+
needsRefresh: null,
|
|
329
|
+
hideOn: () => null,
|
|
330
|
+
}, {
|
|
331
|
+
delay: Math.max,
|
|
332
|
+
markerFilter: combineFilter,
|
|
333
|
+
tooltipFilter: combineFilter,
|
|
334
|
+
needsRefresh: (a, b) => !a ? b : !b ? a : u => a(u) || b(u),
|
|
335
|
+
hideOn: (a, b) => !a ? b : !b ? a : (t, x, y) => a(t, x, y) || b(t, x, y),
|
|
336
|
+
autoPanel: (a, b) => a || b
|
|
337
|
+
})
|
|
338
|
+
};
|
|
331
339
|
}
|
|
332
340
|
});
|
|
341
|
+
function combineFilter(a, b) {
|
|
342
|
+
return !a ? b : !b ? a : (d, s) => b(a(d, s), s);
|
|
343
|
+
}
|
|
333
344
|
/**
|
|
334
345
|
Given a diagnostic source, this function returns an extension that
|
|
335
346
|
enables linting with that source. It will be called whenever the
|
|
336
|
-
editor is idle (after its content changed).
|
|
337
|
-
|
|
347
|
+
editor is idle (after its content changed).
|
|
348
|
+
|
|
349
|
+
Note that settings given here will apply to all linters active in
|
|
350
|
+
the editor. If `null` is given as source, this only configures the
|
|
351
|
+
lint extension.
|
|
338
352
|
*/
|
|
339
353
|
function linter(source, config = {}) {
|
|
340
354
|
return [
|
|
@@ -384,9 +398,10 @@ function renderDiagnostic(view, diagnostic, inPanel) {
|
|
|
384
398
|
let nameElt = keyIndex < 0 ? name : [name.slice(0, keyIndex),
|
|
385
399
|
elt("u", name.slice(keyIndex, keyIndex + 1)),
|
|
386
400
|
name.slice(keyIndex + 1)];
|
|
401
|
+
let markClass = action.markClass ? " " + action.markClass : "";
|
|
387
402
|
return elt("button", {
|
|
388
403
|
type: "button",
|
|
389
|
-
class: "cm-diagnosticAction",
|
|
404
|
+
class: "cm-diagnosticAction" + markClass,
|
|
390
405
|
onclick: click,
|
|
391
406
|
onmousedown: click,
|
|
392
407
|
"aria-label": ` Action: ${name}${keyIndex < 0 ? "" : ` (access key "${keys[i]})"`}.`
|
|
@@ -809,7 +824,7 @@ const lintGutterTooltip = state.StateField.define({
|
|
|
809
824
|
create() { return null; },
|
|
810
825
|
update(tooltip, tr) {
|
|
811
826
|
if (tooltip && tr.docChanged)
|
|
812
|
-
tooltip = hideTooltip(tr, tooltip) ? null :
|
|
827
|
+
tooltip = hideTooltip(tr, tooltip) ? null : { ...tooltip, pos: tr.changes.mapPos(tooltip.pos) };
|
|
813
828
|
return tr.effects.reduce((t, e) => e.is(setLintGutterTooltip) ? e.value : t, tooltip);
|
|
814
829
|
},
|
|
815
830
|
provide: field => view.showTooltip.from(field)
|
package/dist/index.d.cts
CHANGED
|
@@ -56,6 +56,10 @@ interface Action {
|
|
|
56
56
|
*/
|
|
57
57
|
name: string;
|
|
58
58
|
/**
|
|
59
|
+
When given, add an extra CSS class to the action button.
|
|
60
|
+
*/
|
|
61
|
+
markClass?: string;
|
|
62
|
+
/**
|
|
59
63
|
The function to call when the user activates this action. Is
|
|
60
64
|
given the diagnostic's _current_ position, which may have
|
|
61
65
|
changed since the creation of the diagnostic, due to editing.
|
|
@@ -161,8 +165,11 @@ type LintSource = (view: EditorView) => readonly Diagnostic[] | Promise<readonly
|
|
|
161
165
|
/**
|
|
162
166
|
Given a diagnostic source, this function returns an extension that
|
|
163
167
|
enables linting with that source. It will be called whenever the
|
|
164
|
-
editor is idle (after its content changed).
|
|
165
|
-
|
|
168
|
+
editor is idle (after its content changed).
|
|
169
|
+
|
|
170
|
+
Note that settings given here will apply to all linters active in
|
|
171
|
+
the editor. If `null` is given as source, this only configures the
|
|
172
|
+
lint extension.
|
|
166
173
|
*/
|
|
167
174
|
declare function linter(source: LintSource | null, config?: LintConfig): Extension;
|
|
168
175
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -56,6 +56,10 @@ interface Action {
|
|
|
56
56
|
*/
|
|
57
57
|
name: string;
|
|
58
58
|
/**
|
|
59
|
+
When given, add an extra CSS class to the action button.
|
|
60
|
+
*/
|
|
61
|
+
markClass?: string;
|
|
62
|
+
/**
|
|
59
63
|
The function to call when the user activates this action. Is
|
|
60
64
|
given the diagnostic's _current_ position, which may have
|
|
61
65
|
changed since the creation of the diagnostic, due to editing.
|
|
@@ -161,8 +165,11 @@ type LintSource = (view: EditorView) => readonly Diagnostic[] | Promise<readonly
|
|
|
161
165
|
/**
|
|
162
166
|
Given a diagnostic source, this function returns an extension that
|
|
163
167
|
enables linting with that source. It will be called whenever the
|
|
164
|
-
editor is idle (after its content changed).
|
|
165
|
-
|
|
168
|
+
editor is idle (after its content changed).
|
|
169
|
+
|
|
170
|
+
Note that settings given here will apply to all linters active in
|
|
171
|
+
the editor. If `null` is given as source, this only configures the
|
|
172
|
+
lint extension.
|
|
166
173
|
*/
|
|
167
174
|
declare function linter(source: LintSource | null, config?: LintConfig): Extension;
|
|
168
175
|
/**
|
package/dist/index.js
CHANGED
|
@@ -317,22 +317,36 @@ function batchResults(promises, sink, error) {
|
|
|
317
317
|
}
|
|
318
318
|
const lintConfig = /*@__PURE__*/Facet.define({
|
|
319
319
|
combine(input) {
|
|
320
|
-
return
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
320
|
+
return {
|
|
321
|
+
sources: input.map(i => i.source).filter(x => x != null),
|
|
322
|
+
...combineConfig(input.map(i => i.config), {
|
|
323
|
+
delay: 750,
|
|
324
|
+
markerFilter: null,
|
|
325
|
+
tooltipFilter: null,
|
|
326
|
+
needsRefresh: null,
|
|
327
|
+
hideOn: () => null,
|
|
328
|
+
}, {
|
|
329
|
+
delay: Math.max,
|
|
330
|
+
markerFilter: combineFilter,
|
|
331
|
+
tooltipFilter: combineFilter,
|
|
332
|
+
needsRefresh: (a, b) => !a ? b : !b ? a : u => a(u) || b(u),
|
|
333
|
+
hideOn: (a, b) => !a ? b : !b ? a : (t, x, y) => a(t, x, y) || b(t, x, y),
|
|
334
|
+
autoPanel: (a, b) => a || b
|
|
335
|
+
})
|
|
336
|
+
};
|
|
329
337
|
}
|
|
330
338
|
});
|
|
339
|
+
function combineFilter(a, b) {
|
|
340
|
+
return !a ? b : !b ? a : (d, s) => b(a(d, s), s);
|
|
341
|
+
}
|
|
331
342
|
/**
|
|
332
343
|
Given a diagnostic source, this function returns an extension that
|
|
333
344
|
enables linting with that source. It will be called whenever the
|
|
334
|
-
editor is idle (after its content changed).
|
|
335
|
-
|
|
345
|
+
editor is idle (after its content changed).
|
|
346
|
+
|
|
347
|
+
Note that settings given here will apply to all linters active in
|
|
348
|
+
the editor. If `null` is given as source, this only configures the
|
|
349
|
+
lint extension.
|
|
336
350
|
*/
|
|
337
351
|
function linter(source, config = {}) {
|
|
338
352
|
return [
|
|
@@ -382,9 +396,10 @@ function renderDiagnostic(view, diagnostic, inPanel) {
|
|
|
382
396
|
let nameElt = keyIndex < 0 ? name : [name.slice(0, keyIndex),
|
|
383
397
|
elt("u", name.slice(keyIndex, keyIndex + 1)),
|
|
384
398
|
name.slice(keyIndex + 1)];
|
|
399
|
+
let markClass = action.markClass ? " " + action.markClass : "";
|
|
385
400
|
return elt("button", {
|
|
386
401
|
type: "button",
|
|
387
|
-
class: "cm-diagnosticAction",
|
|
402
|
+
class: "cm-diagnosticAction" + markClass,
|
|
388
403
|
onclick: click,
|
|
389
404
|
onmousedown: click,
|
|
390
405
|
"aria-label": ` Action: ${name}${keyIndex < 0 ? "" : ` (access key "${keys[i]})"`}.`
|
|
@@ -807,7 +822,7 @@ const lintGutterTooltip = /*@__PURE__*/StateField.define({
|
|
|
807
822
|
create() { return null; },
|
|
808
823
|
update(tooltip, tr) {
|
|
809
824
|
if (tooltip && tr.docChanged)
|
|
810
|
-
tooltip = hideTooltip(tr, tooltip) ? null :
|
|
825
|
+
tooltip = hideTooltip(tr, tooltip) ? null : { ...tooltip, pos: tr.changes.mapPos(tooltip.pos) };
|
|
811
826
|
return tr.effects.reduce((t, e) => e.is(setLintGutterTooltip) ? e.value : t, tooltip);
|
|
812
827
|
},
|
|
813
828
|
provide: field => showTooltip.from(field)
|