mirror of
https://github.com/DanielnetoDotCom/YouPHPTube
synced 2025-10-06 03:50:04 +02:00
npm update
This commit is contained in:
parent
0cdd3e9fee
commit
4696ba952f
1437 changed files with 32727 additions and 1248226 deletions
40
node_modules/@codemirror/lint/CHANGELOG.md
generated
vendored
40
node_modules/@codemirror/lint/CHANGELOG.md
generated
vendored
|
@ -1,3 +1,43 @@
|
|||
## 6.4.0 (2023-07-03)
|
||||
|
||||
### New features
|
||||
|
||||
Diagnostics can now use `"hint"` as a severity level.
|
||||
|
||||
Diagnostics can now set a `markClass` property to add an additional CSS class to the text marked by the diagnostic.
|
||||
|
||||
## 6.3.0 (2023-06-23)
|
||||
|
||||
### New features
|
||||
|
||||
A new `previousDiagnostic` command can be used to move back through the active diagnostics.
|
||||
|
||||
## 6.2.2 (2023-06-05)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Make sure lint gutter tooltips are properly closed when the content of their line changes.
|
||||
|
||||
## 6.2.1 (2023-04-13)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
The `linter` function now eagerly includes all lint-related extensions, rather than appending them to the configuration as-needed, so that turning off linting by clearing the compartment that contains it works properly.
|
||||
|
||||
## 6.2.0 (2023-02-27)
|
||||
|
||||
### New features
|
||||
|
||||
The new `needsRefresh` option to `linter` makes it possible to cause linting to be recalculated for non-document state changes.
|
||||
|
||||
## 6.1.1 (2023-02-15)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Give lint action buttons a pointer cursor style.
|
||||
|
||||
Fix a bug that caused diagnostic action callbacks to be called twice when their button was clicked.
|
||||
|
||||
## 6.1.0 (2022-11-15)
|
||||
|
||||
### New features
|
||||
|
|
2
node_modules/@codemirror/lint/LICENSE
generated
vendored
2
node_modules/@codemirror/lint/LICENSE
generated
vendored
|
@ -1,6 +1,6 @@
|
|||
MIT License
|
||||
|
||||
Copyright (C) 2018-2021 by Marijn Haverbeke <marijnh@gmail.com> and others
|
||||
Copyright (C) 2018-2021 by Marijn Haverbeke <marijn@haverbeke.berlin> and others
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
99
node_modules/@codemirror/lint/dist/index.cjs
generated
vendored
99
node_modules/@codemirror/lint/dist/index.cjs
generated
vendored
|
@ -37,7 +37,7 @@ class LintState {
|
|||
diagnostic: d
|
||||
}).range(d.from)
|
||||
: view.Decoration.mark({
|
||||
attributes: { class: "cm-lintRange cm-lintRange-" + d.severity },
|
||||
attributes: { class: "cm-lintRange cm-lintRange-" + d.severity + (d.markClass ? " " + d.markClass : "") },
|
||||
diagnostic: d
|
||||
}).range(d.from, d.to);
|
||||
}), true);
|
||||
|
@ -55,20 +55,11 @@ function findDiagnostic(diagnostics, diagnostic = null, after = 0) {
|
|||
return found;
|
||||
}
|
||||
function hideTooltip(tr, tooltip) {
|
||||
return !!(tr.effects.some(e => e.is(setDiagnosticsEffect)) || tr.changes.touchesRange(tooltip.pos));
|
||||
let line = tr.startState.doc.lineAt(tooltip.pos);
|
||||
return !!(tr.effects.some(e => e.is(setDiagnosticsEffect)) || tr.changes.touchesRange(line.from, line.to));
|
||||
}
|
||||
function maybeEnableLint(state$1, effects) {
|
||||
return state$1.field(lintState, false) ? effects : effects.concat(state.StateEffect.appendConfig.of([
|
||||
lintState,
|
||||
view.EditorView.decorations.compute([lintState], state => {
|
||||
let { selected, panel } = state.field(lintState);
|
||||
return !selected || !panel || selected.from == selected.to ? view.Decoration.none : view.Decoration.set([
|
||||
activeMark.range(selected.from, selected.to)
|
||||
]);
|
||||
}),
|
||||
view.hoverTooltip(lintTooltip, { hideOn: hideTooltip }),
|
||||
baseTheme
|
||||
]));
|
||||
return state$1.field(lintState, false) ? effects : effects.concat(state.StateEffect.appendConfig.of(lintExtensions));
|
||||
}
|
||||
/**
|
||||
Returns a transaction spec which updates the current set of
|
||||
|
@ -191,6 +182,30 @@ const nextDiagnostic = (view) => {
|
|||
return true;
|
||||
};
|
||||
/**
|
||||
Move the selection to the previous diagnostic.
|
||||
*/
|
||||
const previousDiagnostic = (view) => {
|
||||
let { state } = view, field = state.field(lintState, false);
|
||||
if (!field)
|
||||
return false;
|
||||
let sel = state.selection.main;
|
||||
let prevFrom, prevTo, lastFrom, lastTo;
|
||||
field.diagnostics.between(0, state.doc.length, (from, to) => {
|
||||
if (to < sel.to && (prevFrom == null || prevFrom < from)) {
|
||||
prevFrom = from;
|
||||
prevTo = to;
|
||||
}
|
||||
if (lastFrom == null || from > lastFrom) {
|
||||
lastFrom = from;
|
||||
lastTo = to;
|
||||
}
|
||||
});
|
||||
if (lastFrom == null || prevFrom == null && lastFrom == sel.from)
|
||||
return false;
|
||||
view.dispatch({ selection: { anchor: prevFrom !== null && prevFrom !== void 0 ? prevFrom : lastFrom, head: prevTo !== null && prevTo !== void 0 ? prevTo : lastTo }, scrollIntoView: true });
|
||||
return true;
|
||||
};
|
||||
/**
|
||||
A set of default key bindings for the lint functionality.
|
||||
|
||||
- Ctrl-Shift-m (Cmd-Shift-m on macOS): [`openLintPanel`](https://codemirror.net/6/docs/ref/#lint.openLintPanel)
|
||||
|
@ -227,7 +242,8 @@ const lintPlugin = view.ViewPlugin.fromClass(class {
|
|||
}
|
||||
update(update) {
|
||||
let config = update.state.facet(lintConfig);
|
||||
if (update.docChanged || config != update.startState.facet(lintConfig)) {
|
||||
if (update.docChanged || config != update.startState.facet(lintConfig) ||
|
||||
config.needsRefresh && config.needsRefresh(update)) {
|
||||
this.lintTime = Date.now() + config.delay;
|
||||
if (!this.set) {
|
||||
this.set = true;
|
||||
|
@ -250,10 +266,12 @@ const lintConfig = state.Facet.define({
|
|||
return Object.assign({ sources: input.map(i => i.source) }, state.combineConfig(input.map(i => i.config), {
|
||||
delay: 750,
|
||||
markerFilter: null,
|
||||
tooltipFilter: null
|
||||
tooltipFilter: null,
|
||||
needsRefresh: null
|
||||
}, {
|
||||
needsRefresh: (a, b) => !a ? b : !b ? a : u => a(u) || b(u)
|
||||
}));
|
||||
},
|
||||
enables: lintPlugin
|
||||
}
|
||||
});
|
||||
/**
|
||||
Given a diagnostic source, this function returns an extension that
|
||||
|
@ -261,7 +279,11 @@ enables linting with that source. It will be called whenever the
|
|||
editor is idle (after its content changed).
|
||||
*/
|
||||
function linter(source, config = {}) {
|
||||
return lintConfig.of({ source, config });
|
||||
return [
|
||||
lintConfig.of({ source, config }),
|
||||
lintPlugin,
|
||||
lintExtensions
|
||||
];
|
||||
}
|
||||
/**
|
||||
Forces any linters [configured](https://codemirror.net/6/docs/ref/#lint.linter) to run when the
|
||||
|
@ -291,8 +313,11 @@ function renderDiagnostic(view, diagnostic, inPanel) {
|
|||
var _a;
|
||||
let keys = inPanel ? assignKeys(diagnostic.actions) : [];
|
||||
return elt__default["default"]("li", { class: "cm-diagnostic cm-diagnostic-" + diagnostic.severity }, elt__default["default"]("span", { class: "cm-diagnosticText" }, diagnostic.renderMessage ? diagnostic.renderMessage() : diagnostic.message), (_a = diagnostic.actions) === null || _a === void 0 ? void 0 : _a.map((action, i) => {
|
||||
let click = (e) => {
|
||||
let fired = false, click = (e) => {
|
||||
e.preventDefault();
|
||||
if (fired)
|
||||
return;
|
||||
fired = true;
|
||||
let found = findDiagnostic(view.state.field(lintState).diagnostics, diagnostic);
|
||||
if (found)
|
||||
action.apply(view, found.from, found.to);
|
||||
|
@ -512,6 +537,7 @@ const baseTheme = view.EditorView.baseTheme({
|
|||
".cm-diagnostic-error": { borderLeft: "5px solid #d11" },
|
||||
".cm-diagnostic-warning": { borderLeft: "5px solid orange" },
|
||||
".cm-diagnostic-info": { borderLeft: "5px solid #999" },
|
||||
".cm-diagnostic-hint": { borderLeft: "5px solid #66d" },
|
||||
".cm-diagnosticAction": {
|
||||
font: "inherit",
|
||||
border: "none",
|
||||
|
@ -519,7 +545,8 @@ const baseTheme = view.EditorView.baseTheme({
|
|||
backgroundColor: "#444",
|
||||
color: "white",
|
||||
borderRadius: "3px",
|
||||
marginLeft: "8px"
|
||||
marginLeft: "8px",
|
||||
cursor: "pointer"
|
||||
},
|
||||
".cm-diagnosticSource": {
|
||||
fontSize: "70%",
|
||||
|
@ -533,6 +560,7 @@ const baseTheme = view.EditorView.baseTheme({
|
|||
".cm-lintRange-error": { backgroundImage: underline("#d11") },
|
||||
".cm-lintRange-warning": { backgroundImage: underline("orange") },
|
||||
".cm-lintRange-info": { backgroundImage: underline("#999") },
|
||||
".cm-lintRange-hint": { backgroundImage: underline("#66d") },
|
||||
".cm-lintRange-active": { backgroundColor: "#ffdd9980" },
|
||||
".cm-tooltip-lint": {
|
||||
padding: 0,
|
||||
|
@ -556,6 +584,9 @@ const baseTheme = view.EditorView.baseTheme({
|
|||
".cm-lintPoint-info": {
|
||||
"&:after": { borderBottomColor: "#999" }
|
||||
},
|
||||
".cm-lintPoint-hint": {
|
||||
"&:after": { borderBottomColor: "#66d" }
|
||||
},
|
||||
".cm-panel.cm-panel-lint": {
|
||||
position: "relative",
|
||||
"& ul": {
|
||||
|
@ -587,14 +618,14 @@ const baseTheme = view.EditorView.baseTheme({
|
|||
}
|
||||
}
|
||||
});
|
||||
function severityWeight(sev) {
|
||||
return sev == "error" ? 4 : sev == "warning" ? 3 : sev == "info" ? 2 : 1;
|
||||
}
|
||||
class LintGutterMarker extends view.GutterMarker {
|
||||
constructor(diagnostics) {
|
||||
super();
|
||||
this.diagnostics = diagnostics;
|
||||
this.severity = diagnostics.reduce((max, d) => {
|
||||
let s = d.severity;
|
||||
return s == "error" || s == "warning" && max == "info" ? s : max;
|
||||
}, "info");
|
||||
this.severity = diagnostics.reduce((max, d) => severityWeight(max) < severityWeight(d.severity) ? d.severity : max, "hint");
|
||||
}
|
||||
toDOM(view) {
|
||||
let elt = document.createElement("div");
|
||||
|
@ -611,8 +642,8 @@ class LintGutterMarker extends view.GutterMarker {
|
|||
function trackHoverOn(view, marker) {
|
||||
let mousemove = (event) => {
|
||||
let rect = marker.getBoundingClientRect();
|
||||
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 */)
|
||||
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 */)
|
||||
return;
|
||||
for (let target = event.target; target; target = target.parentNode) {
|
||||
if (target.nodeType == 1 && target.classList.contains("cm-tooltip-lint"))
|
||||
|
@ -719,10 +750,21 @@ const lintGutterTheme = view.EditorView.baseTheme({
|
|||
content: svg(`<circle cx="20" cy="20" r="15" fill="#f87" stroke="#f43" stroke-width="6"/>`)
|
||||
},
|
||||
});
|
||||
const lintExtensions = [
|
||||
lintState,
|
||||
view.EditorView.decorations.compute([lintState], state => {
|
||||
let { selected, panel } = state.field(lintState);
|
||||
return !selected || !panel || selected.from == selected.to ? view.Decoration.none : view.Decoration.set([
|
||||
activeMark.range(selected.from, selected.to)
|
||||
]);
|
||||
}),
|
||||
view.hoverTooltip(lintTooltip, { hideOn: hideTooltip }),
|
||||
baseTheme
|
||||
];
|
||||
const lintGutterConfig = state.Facet.define({
|
||||
combine(configs) {
|
||||
return state.combineConfig(configs, {
|
||||
hoverTime: 300 /* Hover.Time */,
|
||||
hoverTime: 300 /* Time */,
|
||||
markerFilter: null,
|
||||
tooltipFilter: null
|
||||
});
|
||||
|
@ -739,7 +781,7 @@ function lintGutter(config = {}) {
|
|||
/**
|
||||
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
|
||||
since the diagnostics were created, the `Diagnostic` object will
|
||||
hold the original outdated position, whereas the `to` and `from`
|
||||
arguments hold the diagnostic's current position.
|
||||
*/
|
||||
|
@ -759,5 +801,6 @@ exports.lintKeymap = lintKeymap;
|
|||
exports.linter = linter;
|
||||
exports.nextDiagnostic = nextDiagnostic;
|
||||
exports.openLintPanel = openLintPanel;
|
||||
exports.previousDiagnostic = previousDiagnostic;
|
||||
exports.setDiagnostics = setDiagnostics;
|
||||
exports.setDiagnosticsEffect = setDiagnosticsEffect;
|
||||
|
|
173
node_modules/@codemirror/lint/dist/index.d.cts
generated
vendored
Normal file
173
node_modules/@codemirror/lint/dist/index.d.cts
generated
vendored
Normal file
|
@ -0,0 +1,173 @@
|
|||
import * as _codemirror_state from '@codemirror/state';
|
||||
import { EditorState, TransactionSpec, Extension } from '@codemirror/state';
|
||||
import { EditorView, Command, KeyBinding, ViewUpdate } from '@codemirror/view';
|
||||
|
||||
declare type Severity = "hint" | "info" | "warning" | "error";
|
||||
/**
|
||||
Describes a problem or hint for a piece of code.
|
||||
*/
|
||||
interface Diagnostic {
|
||||
/**
|
||||
The start position of the relevant text.
|
||||
*/
|
||||
from: number;
|
||||
/**
|
||||
The end position. May be equal to `from`, though actually
|
||||
covering text is preferable.
|
||||
*/
|
||||
to: number;
|
||||
/**
|
||||
The severity of the problem. This will influence how it is
|
||||
displayed.
|
||||
*/
|
||||
severity: Severity;
|
||||
/**
|
||||
When given, add an extra CSS class to parts of the code that
|
||||
this diagnostic applies to.
|
||||
*/
|
||||
markClass?: string;
|
||||
/**
|
||||
An optional source string indicating where the diagnostic is
|
||||
coming from. You can put the name of your linter here, if
|
||||
applicable.
|
||||
*/
|
||||
source?: string;
|
||||
/**
|
||||
The message associated with this diagnostic.
|
||||
*/
|
||||
message: string;
|
||||
/**
|
||||
An optional custom rendering function that displays the message
|
||||
as a DOM node.
|
||||
*/
|
||||
renderMessage?: () => Node;
|
||||
/**
|
||||
An optional array of actions that can be taken on this
|
||||
diagnostic.
|
||||
*/
|
||||
actions?: readonly Action[];
|
||||
}
|
||||
/**
|
||||
An action associated with a diagnostic.
|
||||
*/
|
||||
interface Action {
|
||||
/**
|
||||
The label to show to the user. Should be relatively short.
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
The function to call when the user activates this action. Is
|
||||
given the diagnostic's _current_ position, which may have
|
||||
changed since the creation of the diagnostic, due to editing.
|
||||
*/
|
||||
apply: (view: EditorView, from: number, to: number) => void;
|
||||
}
|
||||
declare type DiagnosticFilter = (diagnostics: readonly Diagnostic[]) => Diagnostic[];
|
||||
interface LintConfig {
|
||||
/**
|
||||
Time to wait (in milliseconds) after a change before running
|
||||
the linter. Defaults to 750ms.
|
||||
*/
|
||||
delay?: number;
|
||||
/**
|
||||
Optional predicate that can be used to indicate when diagnostics
|
||||
need to be recomputed. Linting is always re-done on document
|
||||
changes.
|
||||
*/
|
||||
needsRefresh?: null | ((update: ViewUpdate) => boolean);
|
||||
/**
|
||||
Optional filter to determine which diagnostics produce markers
|
||||
in the content.
|
||||
*/
|
||||
markerFilter?: null | DiagnosticFilter;
|
||||
/**
|
||||
Filter applied to a set of diagnostics shown in a tooltip. No
|
||||
tooltip will appear if the empty set is returned.
|
||||
*/
|
||||
tooltipFilter?: null | DiagnosticFilter;
|
||||
}
|
||||
interface LintGutterConfig {
|
||||
/**
|
||||
The delay before showing a tooltip when hovering over a lint gutter marker.
|
||||
*/
|
||||
hoverTime?: number;
|
||||
/**
|
||||
Optional filter determining which diagnostics show a marker in
|
||||
the gutter.
|
||||
*/
|
||||
markerFilter?: null | DiagnosticFilter;
|
||||
/**
|
||||
Optional filter for diagnostics displayed in a tooltip, which
|
||||
can also be used to prevent a tooltip appearing.
|
||||
*/
|
||||
tooltipFilter?: null | DiagnosticFilter;
|
||||
}
|
||||
/**
|
||||
Returns a transaction spec which updates the current set of
|
||||
diagnostics, and enables the lint extension if if wasn't already
|
||||
active.
|
||||
*/
|
||||
declare function setDiagnostics(state: EditorState, diagnostics: readonly Diagnostic[]): TransactionSpec;
|
||||
/**
|
||||
The state effect that updates the set of active diagnostics. Can
|
||||
be useful when writing an extension that needs to track these.
|
||||
*/
|
||||
declare const setDiagnosticsEffect: _codemirror_state.StateEffectType<readonly Diagnostic[]>;
|
||||
/**
|
||||
Returns the number of active lint diagnostics in the given state.
|
||||
*/
|
||||
declare function diagnosticCount(state: EditorState): number;
|
||||
/**
|
||||
Command to open and focus the lint panel.
|
||||
*/
|
||||
declare const openLintPanel: Command;
|
||||
/**
|
||||
Command to close the lint panel, when open.
|
||||
*/
|
||||
declare const closeLintPanel: Command;
|
||||
/**
|
||||
Move the selection to the next diagnostic.
|
||||
*/
|
||||
declare const nextDiagnostic: Command;
|
||||
/**
|
||||
Move the selection to the previous diagnostic.
|
||||
*/
|
||||
declare const previousDiagnostic: Command;
|
||||
/**
|
||||
A set of default key bindings for the lint functionality.
|
||||
|
||||
- Ctrl-Shift-m (Cmd-Shift-m on macOS): [`openLintPanel`](https://codemirror.net/6/docs/ref/#lint.openLintPanel)
|
||||
- F8: [`nextDiagnostic`](https://codemirror.net/6/docs/ref/#lint.nextDiagnostic)
|
||||
*/
|
||||
declare const lintKeymap: readonly KeyBinding[];
|
||||
/**
|
||||
The type of a function that produces diagnostics.
|
||||
*/
|
||||
declare type LintSource = (view: EditorView) => readonly Diagnostic[] | Promise<readonly Diagnostic[]>;
|
||||
/**
|
||||
Given a diagnostic source, this function returns an extension that
|
||||
enables linting with that source. It will be called whenever the
|
||||
editor is idle (after its content changed).
|
||||
*/
|
||||
declare function linter(source: LintSource, config?: LintConfig): Extension;
|
||||
/**
|
||||
Forces any linters [configured](https://codemirror.net/6/docs/ref/#lint.linter) to run when the
|
||||
editor is idle to run right away.
|
||||
*/
|
||||
declare function forceLinting(view: EditorView): void;
|
||||
/**
|
||||
Returns an extension that installs a gutter showing markers for
|
||||
each line that has diagnostics, which can be hovered over to see
|
||||
the diagnostics.
|
||||
*/
|
||||
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 were created, 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, forEachDiagnostic, forceLinting, lintGutter, lintKeymap, linter, nextDiagnostic, openLintPanel, previousDiagnostic, setDiagnostics, setDiagnosticsEffect };
|
24
node_modules/@codemirror/lint/dist/index.d.ts
generated
vendored
24
node_modules/@codemirror/lint/dist/index.d.ts
generated
vendored
|
@ -1,7 +1,8 @@
|
|||
import * as _codemirror_state from '@codemirror/state';
|
||||
import { EditorState, TransactionSpec, Extension } from '@codemirror/state';
|
||||
import { EditorView, Command, KeyBinding } from '@codemirror/view';
|
||||
import { EditorView, Command, KeyBinding, ViewUpdate } from '@codemirror/view';
|
||||
|
||||
declare type Severity = "hint" | "info" | "warning" | "error";
|
||||
/**
|
||||
Describes a problem or hint for a piece of code.
|
||||
*/
|
||||
|
@ -19,7 +20,12 @@ interface Diagnostic {
|
|||
The severity of the problem. This will influence how it is
|
||||
displayed.
|
||||
*/
|
||||
severity: "info" | "warning" | "error";
|
||||
severity: Severity;
|
||||
/**
|
||||
When given, add an extra CSS class to parts of the code that
|
||||
this diagnostic applies to.
|
||||
*/
|
||||
markClass?: string;
|
||||
/**
|
||||
An optional source string indicating where the diagnostic is
|
||||
coming from. You can put the name of your linter here, if
|
||||
|
@ -64,6 +70,12 @@ interface LintConfig {
|
|||
*/
|
||||
delay?: number;
|
||||
/**
|
||||
Optional predicate that can be used to indicate when diagnostics
|
||||
need to be recomputed. Linting is always re-done on document
|
||||
changes.
|
||||
*/
|
||||
needsRefresh?: null | ((update: ViewUpdate) => boolean);
|
||||
/**
|
||||
Optional filter to determine which diagnostics produce markers
|
||||
in the content.
|
||||
*/
|
||||
|
@ -118,6 +130,10 @@ Move the selection to the next diagnostic.
|
|||
*/
|
||||
declare const nextDiagnostic: Command;
|
||||
/**
|
||||
Move the selection to the previous diagnostic.
|
||||
*/
|
||||
declare const previousDiagnostic: Command;
|
||||
/**
|
||||
A set of default key bindings for the lint functionality.
|
||||
|
||||
- Ctrl-Shift-m (Cmd-Shift-m on macOS): [`openLintPanel`](https://codemirror.net/6/docs/ref/#lint.openLintPanel)
|
||||
|
@ -148,10 +164,10 @@ 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
|
||||
since the diagnostics were created, 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, forEachDiagnostic, forceLinting, lintGutter, lintKeymap, linter, nextDiagnostic, openLintPanel, setDiagnostics, setDiagnosticsEffect };
|
||||
export { Action, Diagnostic, LintSource, closeLintPanel, diagnosticCount, forEachDiagnostic, forceLinting, lintGutter, lintKeymap, linter, nextDiagnostic, openLintPanel, previousDiagnostic, setDiagnostics, setDiagnosticsEffect };
|
||||
|
|
102
node_modules/@codemirror/lint/dist/index.js
generated
vendored
102
node_modules/@codemirror/lint/dist/index.js
generated
vendored
|
@ -1,4 +1,4 @@
|
|||
import { Decoration, showPanel, EditorView, ViewPlugin, logException, gutter, showTooltip, getPanel, WidgetType, hoverTooltip, GutterMarker } from '@codemirror/view';
|
||||
import { Decoration, showPanel, EditorView, ViewPlugin, logException, gutter, showTooltip, hoverTooltip, getPanel, WidgetType, GutterMarker } from '@codemirror/view';
|
||||
import { StateEffect, StateField, Facet, combineConfig, RangeSet } from '@codemirror/state';
|
||||
import elt from 'crelt';
|
||||
|
||||
|
@ -29,7 +29,7 @@ class LintState {
|
|||
diagnostic: d
|
||||
}).range(d.from)
|
||||
: Decoration.mark({
|
||||
attributes: { class: "cm-lintRange cm-lintRange-" + d.severity },
|
||||
attributes: { class: "cm-lintRange cm-lintRange-" + d.severity + (d.markClass ? " " + d.markClass : "") },
|
||||
diagnostic: d
|
||||
}).range(d.from, d.to);
|
||||
}), true);
|
||||
|
@ -47,20 +47,11 @@ function findDiagnostic(diagnostics, diagnostic = null, after = 0) {
|
|||
return found;
|
||||
}
|
||||
function hideTooltip(tr, tooltip) {
|
||||
return !!(tr.effects.some(e => e.is(setDiagnosticsEffect)) || tr.changes.touchesRange(tooltip.pos));
|
||||
let line = tr.startState.doc.lineAt(tooltip.pos);
|
||||
return !!(tr.effects.some(e => e.is(setDiagnosticsEffect)) || tr.changes.touchesRange(line.from, line.to));
|
||||
}
|
||||
function maybeEnableLint(state, effects) {
|
||||
return state.field(lintState, false) ? effects : effects.concat(StateEffect.appendConfig.of([
|
||||
lintState,
|
||||
EditorView.decorations.compute([lintState], state => {
|
||||
let { selected, panel } = state.field(lintState);
|
||||
return !selected || !panel || selected.from == selected.to ? Decoration.none : Decoration.set([
|
||||
activeMark.range(selected.from, selected.to)
|
||||
]);
|
||||
}),
|
||||
hoverTooltip(lintTooltip, { hideOn: hideTooltip }),
|
||||
baseTheme
|
||||
]));
|
||||
return state.field(lintState, false) ? effects : effects.concat(StateEffect.appendConfig.of(lintExtensions));
|
||||
}
|
||||
/**
|
||||
Returns a transaction spec which updates the current set of
|
||||
|
@ -183,6 +174,30 @@ const nextDiagnostic = (view) => {
|
|||
return true;
|
||||
};
|
||||
/**
|
||||
Move the selection to the previous diagnostic.
|
||||
*/
|
||||
const previousDiagnostic = (view) => {
|
||||
let { state } = view, field = state.field(lintState, false);
|
||||
if (!field)
|
||||
return false;
|
||||
let sel = state.selection.main;
|
||||
let prevFrom, prevTo, lastFrom, lastTo;
|
||||
field.diagnostics.between(0, state.doc.length, (from, to) => {
|
||||
if (to < sel.to && (prevFrom == null || prevFrom < from)) {
|
||||
prevFrom = from;
|
||||
prevTo = to;
|
||||
}
|
||||
if (lastFrom == null || from > lastFrom) {
|
||||
lastFrom = from;
|
||||
lastTo = to;
|
||||
}
|
||||
});
|
||||
if (lastFrom == null || prevFrom == null && lastFrom == sel.from)
|
||||
return false;
|
||||
view.dispatch({ selection: { anchor: prevFrom !== null && prevFrom !== void 0 ? prevFrom : lastFrom, head: prevTo !== null && prevTo !== void 0 ? prevTo : lastTo }, scrollIntoView: true });
|
||||
return true;
|
||||
};
|
||||
/**
|
||||
A set of default key bindings for the lint functionality.
|
||||
|
||||
- Ctrl-Shift-m (Cmd-Shift-m on macOS): [`openLintPanel`](https://codemirror.net/6/docs/ref/#lint.openLintPanel)
|
||||
|
@ -219,7 +234,8 @@ const lintPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
|
|||
}
|
||||
update(update) {
|
||||
let config = update.state.facet(lintConfig);
|
||||
if (update.docChanged || config != update.startState.facet(lintConfig)) {
|
||||
if (update.docChanged || config != update.startState.facet(lintConfig) ||
|
||||
config.needsRefresh && config.needsRefresh(update)) {
|
||||
this.lintTime = Date.now() + config.delay;
|
||||
if (!this.set) {
|
||||
this.set = true;
|
||||
|
@ -242,10 +258,12 @@ const lintConfig = /*@__PURE__*/Facet.define({
|
|||
return Object.assign({ sources: input.map(i => i.source) }, combineConfig(input.map(i => i.config), {
|
||||
delay: 750,
|
||||
markerFilter: null,
|
||||
tooltipFilter: null
|
||||
tooltipFilter: null,
|
||||
needsRefresh: null
|
||||
}, {
|
||||
needsRefresh: (a, b) => !a ? b : !b ? a : u => a(u) || b(u)
|
||||
}));
|
||||
},
|
||||
enables: lintPlugin
|
||||
}
|
||||
});
|
||||
/**
|
||||
Given a diagnostic source, this function returns an extension that
|
||||
|
@ -253,7 +271,11 @@ enables linting with that source. It will be called whenever the
|
|||
editor is idle (after its content changed).
|
||||
*/
|
||||
function linter(source, config = {}) {
|
||||
return lintConfig.of({ source, config });
|
||||
return [
|
||||
lintConfig.of({ source, config }),
|
||||
lintPlugin,
|
||||
lintExtensions
|
||||
];
|
||||
}
|
||||
/**
|
||||
Forces any linters [configured](https://codemirror.net/6/docs/ref/#lint.linter) to run when the
|
||||
|
@ -283,8 +305,11 @@ function renderDiagnostic(view, diagnostic, inPanel) {
|
|||
var _a;
|
||||
let keys = inPanel ? assignKeys(diagnostic.actions) : [];
|
||||
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) => {
|
||||
let click = (e) => {
|
||||
let fired = false, click = (e) => {
|
||||
e.preventDefault();
|
||||
if (fired)
|
||||
return;
|
||||
fired = true;
|
||||
let found = findDiagnostic(view.state.field(lintState).diagnostics, diagnostic);
|
||||
if (found)
|
||||
action.apply(view, found.from, found.to);
|
||||
|
@ -504,6 +529,7 @@ const baseTheme = /*@__PURE__*/EditorView.baseTheme({
|
|||
".cm-diagnostic-error": { borderLeft: "5px solid #d11" },
|
||||
".cm-diagnostic-warning": { borderLeft: "5px solid orange" },
|
||||
".cm-diagnostic-info": { borderLeft: "5px solid #999" },
|
||||
".cm-diagnostic-hint": { borderLeft: "5px solid #66d" },
|
||||
".cm-diagnosticAction": {
|
||||
font: "inherit",
|
||||
border: "none",
|
||||
|
@ -511,7 +537,8 @@ const baseTheme = /*@__PURE__*/EditorView.baseTheme({
|
|||
backgroundColor: "#444",
|
||||
color: "white",
|
||||
borderRadius: "3px",
|
||||
marginLeft: "8px"
|
||||
marginLeft: "8px",
|
||||
cursor: "pointer"
|
||||
},
|
||||
".cm-diagnosticSource": {
|
||||
fontSize: "70%",
|
||||
|
@ -525,6 +552,7 @@ const baseTheme = /*@__PURE__*/EditorView.baseTheme({
|
|||
".cm-lintRange-error": { backgroundImage: /*@__PURE__*/underline("#d11") },
|
||||
".cm-lintRange-warning": { backgroundImage: /*@__PURE__*/underline("orange") },
|
||||
".cm-lintRange-info": { backgroundImage: /*@__PURE__*/underline("#999") },
|
||||
".cm-lintRange-hint": { backgroundImage: /*@__PURE__*/underline("#66d") },
|
||||
".cm-lintRange-active": { backgroundColor: "#ffdd9980" },
|
||||
".cm-tooltip-lint": {
|
||||
padding: 0,
|
||||
|
@ -548,6 +576,9 @@ const baseTheme = /*@__PURE__*/EditorView.baseTheme({
|
|||
".cm-lintPoint-info": {
|
||||
"&:after": { borderBottomColor: "#999" }
|
||||
},
|
||||
".cm-lintPoint-hint": {
|
||||
"&:after": { borderBottomColor: "#66d" }
|
||||
},
|
||||
".cm-panel.cm-panel-lint": {
|
||||
position: "relative",
|
||||
"& ul": {
|
||||
|
@ -579,14 +610,14 @@ const baseTheme = /*@__PURE__*/EditorView.baseTheme({
|
|||
}
|
||||
}
|
||||
});
|
||||
function severityWeight(sev) {
|
||||
return sev == "error" ? 4 : sev == "warning" ? 3 : sev == "info" ? 2 : 1;
|
||||
}
|
||||
class LintGutterMarker extends GutterMarker {
|
||||
constructor(diagnostics) {
|
||||
super();
|
||||
this.diagnostics = diagnostics;
|
||||
this.severity = diagnostics.reduce((max, d) => {
|
||||
let s = d.severity;
|
||||
return s == "error" || s == "warning" && max == "info" ? s : max;
|
||||
}, "info");
|
||||
this.severity = diagnostics.reduce((max, d) => severityWeight(max) < severityWeight(d.severity) ? d.severity : max, "hint");
|
||||
}
|
||||
toDOM(view) {
|
||||
let elt = document.createElement("div");
|
||||
|
@ -603,8 +634,8 @@ class LintGutterMarker extends GutterMarker {
|
|||
function trackHoverOn(view, marker) {
|
||||
let mousemove = (event) => {
|
||||
let rect = marker.getBoundingClientRect();
|
||||
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 */)
|
||||
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 */)
|
||||
return;
|
||||
for (let target = event.target; target; target = target.parentNode) {
|
||||
if (target.nodeType == 1 && target.classList.contains("cm-tooltip-lint"))
|
||||
|
@ -711,10 +742,21 @@ const lintGutterTheme = /*@__PURE__*/EditorView.baseTheme({
|
|||
content: /*@__PURE__*/svg(`<circle cx="20" cy="20" r="15" fill="#f87" stroke="#f43" stroke-width="6"/>`)
|
||||
},
|
||||
});
|
||||
const lintExtensions = [
|
||||
lintState,
|
||||
/*@__PURE__*/EditorView.decorations.compute([lintState], state => {
|
||||
let { selected, panel } = state.field(lintState);
|
||||
return !selected || !panel || selected.from == selected.to ? Decoration.none : Decoration.set([
|
||||
activeMark.range(selected.from, selected.to)
|
||||
]);
|
||||
}),
|
||||
/*@__PURE__*/hoverTooltip(lintTooltip, { hideOn: hideTooltip }),
|
||||
baseTheme
|
||||
];
|
||||
const lintGutterConfig = /*@__PURE__*/Facet.define({
|
||||
combine(configs) {
|
||||
return combineConfig(configs, {
|
||||
hoverTime: 300 /* Hover.Time */,
|
||||
hoverTime: 300 /* Time */,
|
||||
markerFilter: null,
|
||||
tooltipFilter: null
|
||||
});
|
||||
|
@ -731,7 +773,7 @@ function lintGutter(config = {}) {
|
|||
/**
|
||||
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
|
||||
since the diagnostics were created, the `Diagnostic` object will
|
||||
hold the original outdated position, whereas the `to` and `from`
|
||||
arguments hold the diagnostic's current position.
|
||||
*/
|
||||
|
@ -742,4 +784,4 @@ function forEachDiagnostic(state, f) {
|
|||
f(iter.value.spec.diagnostic, iter.from, iter.to);
|
||||
}
|
||||
|
||||
export { closeLintPanel, diagnosticCount, forEachDiagnostic, forceLinting, lintGutter, lintKeymap, linter, nextDiagnostic, openLintPanel, setDiagnostics, setDiagnosticsEffect };
|
||||
export { closeLintPanel, diagnosticCount, forEachDiagnostic, forceLinting, lintGutter, lintKeymap, linter, nextDiagnostic, openLintPanel, previousDiagnostic, setDiagnostics, setDiagnosticsEffect };
|
||||
|
|
6
node_modules/@codemirror/lint/package.json
generated
vendored
6
node_modules/@codemirror/lint/package.json
generated
vendored
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@codemirror/lint",
|
||||
"version": "6.1.0",
|
||||
"version": "6.4.0",
|
||||
"description": "Linting support for the CodeMirror code editor",
|
||||
"scripts": {
|
||||
"test": "cm-runtests",
|
||||
|
@ -12,7 +12,7 @@
|
|||
],
|
||||
"author": {
|
||||
"name": "Marijn Haverbeke",
|
||||
"email": "marijnh@gmail.com",
|
||||
"email": "marijn@haverbeke.berlin",
|
||||
"url": "http://marijnhaverbeke.nl"
|
||||
},
|
||||
"type": "module",
|
||||
|
@ -31,7 +31,7 @@
|
|||
"crelt": "^1.0.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@codemirror/buildhelper": "^0.1.0"
|
||||
"@codemirror/buildhelper": "^1.0.0"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue