@codemirror/lint
Advanced tools
Comparing version 6.0.0 to 6.1.0
@@ -0,1 +1,7 @@ | ||
## 6.1.0 (2022-11-15) | ||
### New features | ||
The new `forEachDiagnostic` function can be used to iterate over the diagnostics in an editor state. | ||
## 6.0.0 (2022-06-08) | ||
@@ -2,0 +8,0 @@ |
@@ -148,3 +148,11 @@ import * as _codemirror_state from '@codemirror/state'; | ||
declare function lintGutter(config?: LintGutterConfig): Extension; | ||
/** | ||
Iterate over the marked diagnostics for the given editor state, | ||
calling `f` for each of them. Note that, if the document changed | ||
since the diagnostics werecreated, the `Diagnostic` object will | ||
hold the original outdated position, whereas the `to` and `from` | ||
arguments hold the diagnostic's current position. | ||
*/ | ||
declare function forEachDiagnostic(state: EditorState, f: (d: Diagnostic, from: number, to: number) => void): void; | ||
export { Action, Diagnostic, LintSource, closeLintPanel, diagnosticCount, forceLinting, lintGutter, lintKeymap, linter, nextDiagnostic, openLintPanel, setDiagnostics, setDiagnosticsEffect }; | ||
export { Action, Diagnostic, LintSource, closeLintPanel, diagnosticCount, forEachDiagnostic, forceLinting, lintGutter, lintKeymap, linter, nextDiagnostic, openLintPanel, setDiagnostics, setDiagnosticsEffect }; |
@@ -1,2 +0,2 @@ | ||
import { Decoration, showPanel, EditorView, ViewPlugin, hoverTooltip, logException, gutter, showTooltip, getPanel, WidgetType, GutterMarker } from '@codemirror/view'; | ||
import { Decoration, showPanel, EditorView, ViewPlugin, logException, gutter, showTooltip, getPanel, WidgetType, hoverTooltip, GutterMarker } from '@codemirror/view'; | ||
import { StateEffect, StateField, Facet, combineConfig, RangeSet } from '@codemirror/state'; | ||
@@ -192,3 +192,3 @@ import elt from 'crelt'; | ||
const lintKeymap = [ | ||
{ key: "Mod-Shift-m", run: openLintPanel }, | ||
{ key: "Mod-Shift-m", run: openLintPanel, preventDefault: true }, | ||
{ key: "F8", run: nextDiagnostic } | ||
@@ -607,4 +607,4 @@ ]; | ||
let rect = marker.getBoundingClientRect(); | ||
if (event.clientX > rect.left - 10 /* Margin */ && event.clientX < rect.right + 10 /* Margin */ && | ||
event.clientY > rect.top - 10 /* Margin */ && event.clientY < rect.bottom + 10 /* Margin */) | ||
if (event.clientX > rect.left - 10 /* Hover.Margin */ && event.clientX < rect.right + 10 /* Hover.Margin */ && | ||
event.clientY > rect.top - 10 /* Hover.Margin */ && event.clientY < rect.bottom + 10 /* Hover.Margin */) | ||
return; | ||
@@ -712,3 +712,3 @@ for (let target = event.target; target; target = target.parentNode) { | ||
}, | ||
".cm-lint-marker-error:before": { | ||
".cm-lint-marker-error": { | ||
content: /*@__PURE__*/svg(`<circle cx="20" cy="20" r="15" fill="#f87" stroke="#f43" stroke-width="6"/>`) | ||
@@ -720,3 +720,3 @@ }, | ||
return combineConfig(configs, { | ||
hoverTime: 300 /* Time */, | ||
hoverTime: 300 /* Hover.Time */, | ||
markerFilter: null, | ||
@@ -735,3 +735,16 @@ tooltipFilter: null | ||
} | ||
/** | ||
Iterate over the marked diagnostics for the given editor state, | ||
calling `f` for each of them. Note that, if the document changed | ||
since the diagnostics werecreated, the `Diagnostic` object will | ||
hold the original outdated position, whereas the `to` and `from` | ||
arguments hold the diagnostic's current position. | ||
*/ | ||
function forEachDiagnostic(state, f) { | ||
let lState = state.field(lintState, false); | ||
if (lState && lState.diagnostics.size) | ||
for (let iter = RangeSet.iter([lState.diagnostics]); iter.value; iter.next()) | ||
f(iter.value.spec.diagnostic, iter.from, iter.to); | ||
} | ||
export { closeLintPanel, diagnosticCount, forceLinting, lintGutter, lintKeymap, linter, nextDiagnostic, openLintPanel, setDiagnostics, setDiagnosticsEffect }; | ||
export { closeLintPanel, diagnosticCount, forEachDiagnostic, forceLinting, lintGutter, lintKeymap, linter, nextDiagnostic, openLintPanel, setDiagnostics, setDiagnosticsEffect }; |
{ | ||
"name": "@codemirror/lint", | ||
"version": "6.0.0", | ||
"version": "6.1.0", | ||
"description": "Linting support for the CodeMirror code editor", | ||
@@ -5,0 +5,0 @@ "scripts": { |
# @codemirror/lint [![NPM version](https://img.shields.io/npm/v/@codemirror/lint.svg)](https://www.npmjs.org/package/@codemirror/lint) | ||
[ [**WEBSITE**](https://codemirror.net/6/) | [**DOCS**](https://codemirror.net/6/docs/ref/#lint) | [**ISSUES**](https://github.com/codemirror/codemirror.next/issues) | [**FORUM**](https://discuss.codemirror.net/c/next/) | [**CHANGELOG**](https://github.com/codemirror/lint/blob/main/CHANGELOG.md) ] | ||
[ [**WEBSITE**](https://codemirror.net/) | [**DOCS**](https://codemirror.net/docs/ref/#lint) | [**ISSUES**](https://github.com/codemirror/dev/issues) | [**FORUM**](https://discuss.codemirror.net/c/next/) | [**CHANGELOG**](https://github.com/codemirror/lint/blob/main/CHANGELOG.md) ] | ||
This package implements linting support for the | ||
[CodeMirror](https://codemirror.net/6/) code editor. | ||
[CodeMirror](https://codemirror.net/) code editor. | ||
The [project page](https://codemirror.net/6/) has more information, a | ||
number of [examples](https://codemirror.net/6/examples/) and the | ||
[documentation](https://codemirror.net/6/docs/). | ||
The [project page](https://codemirror.net/) has more information, a | ||
number of [examples](https://codemirror.net/examples/) and the | ||
[documentation](https://codemirror.net/docs/). | ||
@@ -12,0 +12,0 @@ This code is released under an |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
69561
1653