@veltra/desktop 1.2.16 → 1.2.18
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/dist/components/action/action-group.vue.d.ts +2 -2
- package/dist/components/action/action.vue.d.ts +1 -1
- package/dist/components/auto-complete/auto-complete.vue.d.ts +2 -2
- package/dist/components/cascade/cascade.vue.d.ts +3 -3
- package/dist/components/checkbox/checkbox-button.vue.d.ts +1 -1
- package/dist/components/checkbox-group/checkbox-group.vue.d.ts +2 -2
- package/dist/components/code-editor/basic-setup.js +7 -7
- package/dist/components/code-editor/code-editor.js +15 -10
- package/dist/components/code-editor/code-editor.js.map +1 -1
- package/dist/components/date-picker/date-picker.vue.d.ts +2 -2
- package/dist/components/date-range-picker/date-range-picker.vue.d.ts +2 -2
- package/dist/components/empty/empty.vue.d.ts +1 -1
- package/dist/components/file-picker/file-picker.vue.d.ts +1 -1
- package/dist/components/input/input.vue.d.ts +2 -2
- package/dist/components/multi-select/multi-select.vue.d.ts +3 -3
- package/dist/components/multi-tree-select/multi-tree-select.vue.d.ts +3 -3
- package/dist/components/number-input/number-input.vue.d.ts +2 -2
- package/dist/components/number-range-input/number-range-input.vue.d.ts +1 -1
- package/dist/components/password-input/password-input.vue.d.ts +1 -1
- package/dist/components/pop-confirm/pop-confirm.vue.d.ts +1 -1
- package/dist/components/radio-group/radio-group.vue.d.ts +2 -2
- package/dist/components/rich-text-editor/rich-text-editor.vue.d.ts +1 -1
- package/dist/components/select/select.vue.d.ts +2 -2
- package/dist/components/textarea/textarea.vue.d.ts +2 -2
- package/dist/components/tip/tip.vue.d.ts +1 -1
- package/dist/components/tree-select/tree-select.vue.d.ts +3 -3
- package/dist/node_modules/.bun/@codemirror_autocomplete@6.20.3/node_modules/@codemirror/autocomplete/dist/index.js +1750 -0
- package/dist/node_modules/.bun/@codemirror_autocomplete@6.20.3/node_modules/@codemirror/autocomplete/dist/index.js.map +1 -0
- package/dist/node_modules/.bun/@codemirror_commands@6.10.4/node_modules/@codemirror/commands/dist/index.js +1719 -0
- package/dist/node_modules/.bun/@codemirror_commands@6.10.4/node_modules/@codemirror/commands/dist/index.js.map +1 -0
- package/dist/node_modules/.bun/@codemirror_lang-java@6.0.2/node_modules/@codemirror/lang-java/dist/index.js +51 -0
- package/dist/node_modules/.bun/@codemirror_lang-java@6.0.2/node_modules/@codemirror/lang-java/dist/index.js.map +1 -0
- package/dist/node_modules/.bun/@codemirror_lang-javascript@6.2.5/node_modules/@codemirror/lang-javascript/dist/index.js +378 -0
- package/dist/node_modules/.bun/@codemirror_lang-javascript@6.2.5/node_modules/@codemirror/lang-javascript/dist/index.js.map +1 -0
- package/dist/node_modules/.bun/@codemirror_lang-json@6.0.2/node_modules/@codemirror/lang-json/dist/index.js +31 -0
- package/dist/node_modules/.bun/@codemirror_lang-json@6.0.2/node_modules/@codemirror/lang-json/dist/index.js.map +1 -0
- package/dist/node_modules/.bun/@codemirror_lang-sql@6.10.0/node_modules/@codemirror/lang-sql/dist/index.js +601 -0
- package/dist/node_modules/.bun/@codemirror_lang-sql@6.10.0/node_modules/@codemirror/lang-sql/dist/index.js.map +1 -0
- package/dist/node_modules/.bun/@codemirror_language@6.12.4/node_modules/@codemirror/language/dist/index.js +1767 -0
- package/dist/node_modules/.bun/@codemirror_language@6.12.4/node_modules/@codemirror/language/dist/index.js.map +1 -0
- package/dist/node_modules/.bun/@codemirror_lint@6.9.7/node_modules/@codemirror/lint/dist/index.js +569 -0
- package/dist/node_modules/.bun/@codemirror_lint@6.9.7/node_modules/@codemirror/lint/dist/index.js.map +1 -0
- package/dist/node_modules/.bun/@codemirror_search@6.7.1/node_modules/@codemirror/search/dist/index.js +1142 -0
- package/dist/node_modules/.bun/@codemirror_search@6.7.1/node_modules/@codemirror/search/dist/index.js.map +1 -0
- package/dist/node_modules/.bun/@codemirror_state@6.7.0/node_modules/@codemirror/state/dist/index.js +3372 -0
- package/dist/node_modules/.bun/@codemirror_state@6.7.0/node_modules/@codemirror/state/dist/index.js.map +1 -0
- package/dist/node_modules/.bun/@codemirror_theme-one-dark@6.1.3/node_modules/@codemirror/theme-one-dark/dist/index.js +165 -0
- package/dist/node_modules/.bun/@codemirror_theme-one-dark@6.1.3/node_modules/@codemirror/theme-one-dark/dist/index.js.map +1 -0
- package/dist/node_modules/.bun/@codemirror_view@6.43.4/node_modules/@codemirror/view/dist/index.js +9770 -0
- package/dist/node_modules/.bun/@codemirror_view@6.43.4/node_modules/@codemirror/view/dist/index.js.map +1 -0
- package/dist/node_modules/.bun/@lezer_common@1.5.2/node_modules/@lezer/common/dist/index.js +1567 -0
- package/dist/node_modules/.bun/@lezer_common@1.5.2/node_modules/@lezer/common/dist/index.js.map +1 -0
- package/dist/node_modules/.bun/@lezer_highlight@1.2.3/node_modules/@lezer/highlight/dist/index.js +864 -0
- package/dist/node_modules/.bun/@lezer_highlight@1.2.3/node_modules/@lezer/highlight/dist/index.js.map +1 -0
- package/dist/node_modules/.bun/@lezer_java@1.1.3/node_modules/@lezer/java/dist/index.js +235 -0
- package/dist/node_modules/.bun/@lezer_java@1.1.3/node_modules/@lezer/java/dist/index.js.map +1 -0
- package/dist/node_modules/.bun/@lezer_javascript@1.5.4/node_modules/@lezer/javascript/dist/index.js +470 -0
- package/dist/node_modules/.bun/@lezer_javascript@1.5.4/node_modules/@lezer/javascript/dist/index.js.map +1 -0
- package/dist/node_modules/.bun/@lezer_json@1.0.3/node_modules/@lezer/json/dist/index.js +55 -0
- package/dist/node_modules/.bun/@lezer_json@1.0.3/node_modules/@lezer/json/dist/index.js.map +1 -0
- package/dist/node_modules/.bun/@lezer_lr@1.4.10/node_modules/@lezer/lr/dist/index.js +1485 -0
- package/dist/node_modules/.bun/@lezer_lr@1.4.10/node_modules/@lezer/lr/dist/index.js.map +1 -0
- package/dist/node_modules/.bun/@marijn_find-cluster-break@1.0.2/node_modules/@marijn/find-cluster-break/src/index.js +73 -0
- package/dist/node_modules/.bun/@marijn_find-cluster-break@1.0.2/node_modules/@marijn/find-cluster-break/src/index.js.map +1 -0
- package/dist/node_modules/.bun/crelt@1.0.6/node_modules/crelt/index.js +26 -0
- package/dist/node_modules/.bun/crelt@1.0.6/node_modules/crelt/index.js.map +1 -0
- package/dist/node_modules/.bun/style-mod@4.1.3/node_modules/style-mod/src/style-mod.js +95 -0
- package/dist/node_modules/.bun/style-mod@4.1.3/node_modules/style-mod/src/style-mod.js.map +1 -0
- package/dist/node_modules/.bun/w3c-keyname@2.2.8/node_modules/w3c-keyname/index.js +104 -0
- package/dist/node_modules/.bun/w3c-keyname@2.2.8/node_modules/w3c-keyname/index.js.map +1 -0
- package/package.json +20 -18
- package/src/components/code-editor/code-editor.vue +12 -7
package/dist/node_modules/.bun/@codemirror_lint@6.9.7/node_modules/@codemirror/lint/dist/index.js
ADDED
|
@@ -0,0 +1,569 @@
|
|
|
1
|
+
import { Facet, RangeSetBuilder, StateEffect, StateField, combineConfig } from "../../../../../@codemirror_state@6.7.0/node_modules/@codemirror/state/dist/index.js";
|
|
2
|
+
import crelt from "../../../../../crelt@1.0.6/node_modules/crelt/index.js";
|
|
3
|
+
import { Decoration, EditorView, WidgetType, activateHover, getPanel, hoverTooltip, showPanel } from "../../../../../@codemirror_view@6.43.4/node_modules/@codemirror/view/dist/index.js";
|
|
4
|
+
//#region ../../node_modules/.bun/@codemirror+lint@6.9.7/node_modules/@codemirror/lint/dist/index.js
|
|
5
|
+
var SelectedDiagnostic = class {
|
|
6
|
+
constructor(from, to, diagnostic) {
|
|
7
|
+
this.from = from;
|
|
8
|
+
this.to = to;
|
|
9
|
+
this.diagnostic = diagnostic;
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
var LintState = class LintState {
|
|
13
|
+
constructor(diagnostics, panel, selected) {
|
|
14
|
+
this.diagnostics = diagnostics;
|
|
15
|
+
this.panel = panel;
|
|
16
|
+
this.selected = selected;
|
|
17
|
+
}
|
|
18
|
+
static init(diagnostics, panel, state) {
|
|
19
|
+
let diagnosticFilter = state.facet(lintConfig).markerFilter;
|
|
20
|
+
if (diagnosticFilter) diagnostics = diagnosticFilter(diagnostics, state);
|
|
21
|
+
let sorted = diagnostics.slice().sort((a, b) => a.from - b.from || a.to - b.to);
|
|
22
|
+
let deco = new RangeSetBuilder(), active = [], pos = 0;
|
|
23
|
+
let scan = state.doc.iter(), scanPos = 0, docLen = state.doc.length;
|
|
24
|
+
for (let i = 0;;) {
|
|
25
|
+
let next = i == sorted.length ? null : sorted[i];
|
|
26
|
+
if (!next && !active.length) break;
|
|
27
|
+
let from, to;
|
|
28
|
+
if (active.length) {
|
|
29
|
+
from = pos;
|
|
30
|
+
to = active.reduce((p, d) => Math.min(p, d.to), next && next.from > from ? next.from : 1e8);
|
|
31
|
+
} else {
|
|
32
|
+
from = next.from;
|
|
33
|
+
if (from > docLen) break;
|
|
34
|
+
to = next.to;
|
|
35
|
+
active.push(next);
|
|
36
|
+
i++;
|
|
37
|
+
}
|
|
38
|
+
while (i < sorted.length) {
|
|
39
|
+
let next = sorted[i];
|
|
40
|
+
if (next.from == from && (next.to > next.from || next.to == from)) {
|
|
41
|
+
active.push(next);
|
|
42
|
+
i++;
|
|
43
|
+
to = Math.min(next.to, to);
|
|
44
|
+
} else {
|
|
45
|
+
to = Math.min(next.from, to);
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
to = Math.min(to, docLen);
|
|
50
|
+
let widget = false;
|
|
51
|
+
if (active.some((d) => d.from == from && (d.to == to || to == docLen))) {
|
|
52
|
+
widget = from == to;
|
|
53
|
+
if (!widget && to - from < 10) {
|
|
54
|
+
let behind = from - (scanPos + scan.value.length);
|
|
55
|
+
if (behind > 0) {
|
|
56
|
+
scan.next(behind);
|
|
57
|
+
scanPos = from;
|
|
58
|
+
}
|
|
59
|
+
for (let check = from;;) {
|
|
60
|
+
if (check >= to) {
|
|
61
|
+
widget = true;
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
if (!scan.lineBreak && scanPos + scan.value.length > check) break;
|
|
65
|
+
check = scanPos + scan.value.length;
|
|
66
|
+
scanPos += scan.value.length;
|
|
67
|
+
scan.next();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
let sev = maxSeverity(active);
|
|
72
|
+
if (widget) deco.add(from, from, Decoration.widget({
|
|
73
|
+
widget: new DiagnosticWidget(sev),
|
|
74
|
+
diagnostics: active.slice()
|
|
75
|
+
}));
|
|
76
|
+
else {
|
|
77
|
+
let markClass = active.reduce((c, d) => d.markClass ? c + " " + d.markClass : c, "");
|
|
78
|
+
deco.add(from, to, Decoration.mark({
|
|
79
|
+
class: "cm-lintRange cm-lintRange-" + sev + markClass,
|
|
80
|
+
diagnostics: active.slice(),
|
|
81
|
+
inclusiveEnd: active.some((a) => a.to > to)
|
|
82
|
+
}));
|
|
83
|
+
}
|
|
84
|
+
pos = to;
|
|
85
|
+
if (pos == docLen) break;
|
|
86
|
+
for (let i = 0; i < active.length; i++) if (active[i].to <= pos) active.splice(i--, 1);
|
|
87
|
+
}
|
|
88
|
+
let set = deco.finish();
|
|
89
|
+
return new LintState(set, panel, findDiagnostic(set));
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
function findDiagnostic(diagnostics, diagnostic = null, after = 0) {
|
|
93
|
+
let found = null;
|
|
94
|
+
diagnostics.between(after, 1e9, (from, to, { spec }) => {
|
|
95
|
+
if (diagnostic && spec.diagnostics.indexOf(diagnostic) < 0) return;
|
|
96
|
+
if (!found) found = new SelectedDiagnostic(from, to, diagnostic || spec.diagnostics[0]);
|
|
97
|
+
else if (spec.diagnostics.indexOf(found.diagnostic) < 0) return false;
|
|
98
|
+
else found = new SelectedDiagnostic(found.from, to, found.diagnostic);
|
|
99
|
+
});
|
|
100
|
+
return found;
|
|
101
|
+
}
|
|
102
|
+
function hideTooltip(tr, tooltip) {
|
|
103
|
+
let from = tooltip.pos, to = tooltip.end || from;
|
|
104
|
+
let result = tr.state.facet(lintConfig).hideOn(tr, from, to);
|
|
105
|
+
if (result != null) return result;
|
|
106
|
+
let line = tr.startState.doc.lineAt(tooltip.pos);
|
|
107
|
+
return !!(tr.effects.some((e) => e.is(setDiagnosticsEffect)) || tr.changes.touchesRange(line.from, Math.max(line.to, to)));
|
|
108
|
+
}
|
|
109
|
+
function maybeEnableLint(state, effects) {
|
|
110
|
+
return state.field(lintState, false) ? effects : effects.concat(StateEffect.appendConfig.of(lintExtensions));
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
The state effect that updates the set of active diagnostics. Can
|
|
114
|
+
be useful when writing an extension that needs to track these.
|
|
115
|
+
*/
|
|
116
|
+
const setDiagnosticsEffect = /*@__PURE__*/ StateEffect.define();
|
|
117
|
+
const togglePanel = /*@__PURE__*/ StateEffect.define();
|
|
118
|
+
const movePanelSelection = /*@__PURE__*/ StateEffect.define();
|
|
119
|
+
const lintState = /*@__PURE__*/ StateField.define({
|
|
120
|
+
create() {
|
|
121
|
+
return new LintState(Decoration.none, null, null);
|
|
122
|
+
},
|
|
123
|
+
update(value, tr) {
|
|
124
|
+
if (tr.docChanged && value.diagnostics.size) {
|
|
125
|
+
let mapped = value.diagnostics.map(tr.changes), selected = null, panel = value.panel;
|
|
126
|
+
if (value.selected) {
|
|
127
|
+
let selPos = tr.changes.mapPos(value.selected.from, 1);
|
|
128
|
+
selected = findDiagnostic(mapped, value.selected.diagnostic, selPos) || findDiagnostic(mapped, null, selPos);
|
|
129
|
+
}
|
|
130
|
+
if (!mapped.size && panel && tr.state.facet(lintConfig).autoPanel) panel = null;
|
|
131
|
+
value = new LintState(mapped, panel, selected);
|
|
132
|
+
}
|
|
133
|
+
for (let effect of tr.effects) if (effect.is(setDiagnosticsEffect)) {
|
|
134
|
+
let panel = !tr.state.facet(lintConfig).autoPanel ? value.panel : effect.value.length ? LintPanel.open : null;
|
|
135
|
+
value = LintState.init(effect.value, panel, tr.state);
|
|
136
|
+
} else if (effect.is(togglePanel)) value = new LintState(value.diagnostics, effect.value ? LintPanel.open : null, value.selected);
|
|
137
|
+
else if (effect.is(movePanelSelection)) value = new LintState(value.diagnostics, value.panel, effect.value);
|
|
138
|
+
return value;
|
|
139
|
+
},
|
|
140
|
+
provide: (f) => [showPanel.from(f, (val) => val.panel), EditorView.decorations.from(f, (s) => s.diagnostics)]
|
|
141
|
+
});
|
|
142
|
+
const activeMark = /*@__PURE__*/ Decoration.mark({ class: "cm-lintRange cm-lintRange-active" });
|
|
143
|
+
function lintTooltip(view, pos, side) {
|
|
144
|
+
let { diagnostics } = view.state.field(lintState);
|
|
145
|
+
let found, start = -1, end = -1;
|
|
146
|
+
diagnostics.between(pos - (side < 0 ? 1 : 0), pos + (side > 0 ? 1 : 0), (from, to, { spec }) => {
|
|
147
|
+
if (pos >= from && pos <= to && (from == to || (pos > from || side > 0) && (pos < to || side < 0))) {
|
|
148
|
+
found = spec.diagnostics;
|
|
149
|
+
start = from;
|
|
150
|
+
end = to;
|
|
151
|
+
return false;
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
let diagnosticFilter = view.state.facet(lintConfig).tooltipFilter;
|
|
155
|
+
if (found && diagnosticFilter) found = diagnosticFilter(found, view.state);
|
|
156
|
+
if (!found) return null;
|
|
157
|
+
return {
|
|
158
|
+
pos: start,
|
|
159
|
+
end,
|
|
160
|
+
above: true,
|
|
161
|
+
create() {
|
|
162
|
+
return { dom: diagnosticsTooltip(view, found) };
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
function diagnosticsTooltip(view, diagnostics) {
|
|
167
|
+
return crelt("ul", { class: "cm-tooltip-lint" }, diagnostics.map((d) => renderDiagnostic(view, d, false)));
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
Command to open and focus the lint panel.
|
|
171
|
+
*/
|
|
172
|
+
const openLintPanel = (view) => {
|
|
173
|
+
let field = view.state.field(lintState, false);
|
|
174
|
+
if (!field || !field.panel) view.dispatch({ effects: maybeEnableLint(view.state, [togglePanel.of(true)]) });
|
|
175
|
+
let panel = getPanel(view, LintPanel.open);
|
|
176
|
+
if (panel) panel.dom.querySelector(".cm-panel-lint ul").focus();
|
|
177
|
+
return true;
|
|
178
|
+
};
|
|
179
|
+
/**
|
|
180
|
+
Command to close the lint panel, when open.
|
|
181
|
+
*/
|
|
182
|
+
const closeLintPanel = (view) => {
|
|
183
|
+
let field = view.state.field(lintState, false);
|
|
184
|
+
if (!field || !field.panel) return false;
|
|
185
|
+
view.dispatch({ effects: togglePanel.of(false) });
|
|
186
|
+
return true;
|
|
187
|
+
};
|
|
188
|
+
/**
|
|
189
|
+
Move the selection to the next diagnostic.
|
|
190
|
+
*/
|
|
191
|
+
const nextDiagnostic = (view) => {
|
|
192
|
+
let field = view.state.field(lintState, false);
|
|
193
|
+
if (!field) return false;
|
|
194
|
+
let sel = view.state.selection.main, next = findDiagnostic(field.diagnostics, null, sel.to + 1);
|
|
195
|
+
if (!next) {
|
|
196
|
+
next = findDiagnostic(field.diagnostics, null, 0);
|
|
197
|
+
if (!next || next.from == sel.from && next.to == sel.to) return false;
|
|
198
|
+
}
|
|
199
|
+
view.dispatch({
|
|
200
|
+
selection: {
|
|
201
|
+
anchor: next.from,
|
|
202
|
+
head: next.to
|
|
203
|
+
},
|
|
204
|
+
scrollIntoView: true
|
|
205
|
+
});
|
|
206
|
+
activateHover(view, next.from, 1, {
|
|
207
|
+
tooltip: lintHover,
|
|
208
|
+
until: (tr) => tr.docChanged || tr.newSelection.main.head < next.from || tr.newSelection.main.head > next.to
|
|
209
|
+
});
|
|
210
|
+
return true;
|
|
211
|
+
};
|
|
212
|
+
/**
|
|
213
|
+
A set of default key bindings for the lint functionality.
|
|
214
|
+
|
|
215
|
+
- Ctrl-Shift-m (Cmd-Shift-m on macOS): [`openLintPanel`](https://codemirror.net/6/docs/ref/#lint.openLintPanel)
|
|
216
|
+
- F8: [`nextDiagnostic`](https://codemirror.net/6/docs/ref/#lint.nextDiagnostic)
|
|
217
|
+
*/
|
|
218
|
+
const lintKeymap = [{
|
|
219
|
+
key: "Mod-Shift-m",
|
|
220
|
+
run: openLintPanel,
|
|
221
|
+
preventDefault: true
|
|
222
|
+
}, {
|
|
223
|
+
key: "F8",
|
|
224
|
+
run: nextDiagnostic
|
|
225
|
+
}];
|
|
226
|
+
const lintConfig = /*@__PURE__*/ Facet.define({ combine(input) {
|
|
227
|
+
return {
|
|
228
|
+
sources: input.map((i) => i.source).filter((x) => x != null),
|
|
229
|
+
...combineConfig(input.map((i) => i.config), {
|
|
230
|
+
delay: 750,
|
|
231
|
+
markerFilter: null,
|
|
232
|
+
tooltipFilter: null,
|
|
233
|
+
needsRefresh: null,
|
|
234
|
+
hideOn: () => null
|
|
235
|
+
}, {
|
|
236
|
+
delay: Math.max,
|
|
237
|
+
markerFilter: combineFilter,
|
|
238
|
+
tooltipFilter: combineFilter,
|
|
239
|
+
needsRefresh: (a, b) => !a ? b : !b ? a : (u) => a(u) || b(u),
|
|
240
|
+
hideOn: (a, b) => !a ? b : !b ? a : (t, x, y) => a(t, x, y) || b(t, x, y),
|
|
241
|
+
autoPanel: (a, b) => a || b
|
|
242
|
+
})
|
|
243
|
+
};
|
|
244
|
+
} });
|
|
245
|
+
function combineFilter(a, b) {
|
|
246
|
+
return !a ? b : !b ? a : (d, s) => b(a(d, s), s);
|
|
247
|
+
}
|
|
248
|
+
function assignKeys(actions) {
|
|
249
|
+
let assigned = [];
|
|
250
|
+
if (actions) actions: for (let { name } of actions) {
|
|
251
|
+
for (let i = 0; i < name.length; i++) {
|
|
252
|
+
let ch = name[i];
|
|
253
|
+
if (/[a-zA-Z]/.test(ch) && !assigned.some((c) => c.toLowerCase() == ch.toLowerCase())) {
|
|
254
|
+
assigned.push(ch);
|
|
255
|
+
continue actions;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
assigned.push("");
|
|
259
|
+
}
|
|
260
|
+
return assigned;
|
|
261
|
+
}
|
|
262
|
+
function renderDiagnostic(view, diagnostic, inPanel) {
|
|
263
|
+
var _a;
|
|
264
|
+
let keys = inPanel ? assignKeys(diagnostic.actions) : [];
|
|
265
|
+
return crelt("li", { class: "cm-diagnostic cm-diagnostic-" + diagnostic.severity }, crelt("span", { class: "cm-diagnosticText" }, diagnostic.renderMessage ? diagnostic.renderMessage(view) : diagnostic.message), (_a = diagnostic.actions) === null || _a === void 0 ? void 0 : _a.map((action, i) => {
|
|
266
|
+
let fired = false, click = (e) => {
|
|
267
|
+
e.preventDefault();
|
|
268
|
+
if (fired) return;
|
|
269
|
+
fired = true;
|
|
270
|
+
let found = findDiagnostic(view.state.field(lintState).diagnostics, diagnostic);
|
|
271
|
+
if (found) action.apply(view, found.from, found.to);
|
|
272
|
+
};
|
|
273
|
+
let { name } = action, keyIndex = keys[i] ? name.indexOf(keys[i]) : -1;
|
|
274
|
+
let nameElt = keyIndex < 0 ? name : [
|
|
275
|
+
name.slice(0, keyIndex),
|
|
276
|
+
crelt("u", name.slice(keyIndex, keyIndex + 1)),
|
|
277
|
+
name.slice(keyIndex + 1)
|
|
278
|
+
];
|
|
279
|
+
return crelt("button", {
|
|
280
|
+
type: "button",
|
|
281
|
+
class: "cm-diagnosticAction" + (action.markClass ? " " + action.markClass : ""),
|
|
282
|
+
onclick: click,
|
|
283
|
+
onmousedown: click,
|
|
284
|
+
"aria-label": ` Action: ${name}${keyIndex < 0 ? "" : ` (access key "${keys[i]})"`}.`
|
|
285
|
+
}, nameElt);
|
|
286
|
+
}), diagnostic.source && crelt("div", { class: "cm-diagnosticSource" }, diagnostic.source));
|
|
287
|
+
}
|
|
288
|
+
var DiagnosticWidget = class extends WidgetType {
|
|
289
|
+
constructor(sev) {
|
|
290
|
+
super();
|
|
291
|
+
this.sev = sev;
|
|
292
|
+
}
|
|
293
|
+
eq(other) {
|
|
294
|
+
return other.sev == this.sev;
|
|
295
|
+
}
|
|
296
|
+
toDOM() {
|
|
297
|
+
return crelt("span", { class: "cm-lintPoint cm-lintPoint-" + this.sev });
|
|
298
|
+
}
|
|
299
|
+
};
|
|
300
|
+
var PanelItem = class {
|
|
301
|
+
constructor(view, diagnostic) {
|
|
302
|
+
this.diagnostic = diagnostic;
|
|
303
|
+
this.id = "item_" + Math.floor(Math.random() * 4294967295).toString(16);
|
|
304
|
+
this.dom = renderDiagnostic(view, diagnostic, true);
|
|
305
|
+
this.dom.id = this.id;
|
|
306
|
+
this.dom.setAttribute("role", "option");
|
|
307
|
+
}
|
|
308
|
+
};
|
|
309
|
+
var LintPanel = class LintPanel {
|
|
310
|
+
constructor(view) {
|
|
311
|
+
this.view = view;
|
|
312
|
+
this.items = [];
|
|
313
|
+
let onkeydown = (event) => {
|
|
314
|
+
if (event.ctrlKey || event.altKey || event.metaKey) return;
|
|
315
|
+
if (event.keyCode == 27) {
|
|
316
|
+
closeLintPanel(this.view);
|
|
317
|
+
this.view.focus();
|
|
318
|
+
} else if (event.keyCode == 38 || event.keyCode == 33) this.moveSelection((this.selectedIndex - 1 + this.items.length) % this.items.length);
|
|
319
|
+
else if (event.keyCode == 40 || event.keyCode == 34) this.moveSelection((this.selectedIndex + 1) % this.items.length);
|
|
320
|
+
else if (event.keyCode == 36) this.moveSelection(0);
|
|
321
|
+
else if (event.keyCode == 35) this.moveSelection(this.items.length - 1);
|
|
322
|
+
else if (event.keyCode == 13) this.view.focus();
|
|
323
|
+
else if (event.keyCode >= 65 && event.keyCode <= 90 && this.selectedIndex >= 0) {
|
|
324
|
+
let { diagnostic } = this.items[this.selectedIndex], keys = assignKeys(diagnostic.actions);
|
|
325
|
+
for (let i = 0; i < keys.length; i++) if (keys[i].toUpperCase().charCodeAt(0) == event.keyCode) {
|
|
326
|
+
let found = findDiagnostic(this.view.state.field(lintState).diagnostics, diagnostic);
|
|
327
|
+
if (found) diagnostic.actions[i].apply(view, found.from, found.to);
|
|
328
|
+
}
|
|
329
|
+
} else return;
|
|
330
|
+
event.preventDefault();
|
|
331
|
+
};
|
|
332
|
+
let onclick = (event) => {
|
|
333
|
+
for (let i = 0; i < this.items.length; i++) if (this.items[i].dom.contains(event.target)) this.moveSelection(i);
|
|
334
|
+
};
|
|
335
|
+
this.list = crelt("ul", {
|
|
336
|
+
tabIndex: 0,
|
|
337
|
+
role: "listbox",
|
|
338
|
+
"aria-label": this.view.state.phrase("Diagnostics"),
|
|
339
|
+
onkeydown,
|
|
340
|
+
onclick
|
|
341
|
+
});
|
|
342
|
+
this.dom = crelt("div", { class: "cm-panel-lint" }, this.list, crelt("button", {
|
|
343
|
+
type: "button",
|
|
344
|
+
name: "close",
|
|
345
|
+
"aria-label": this.view.state.phrase("close"),
|
|
346
|
+
onclick: () => closeLintPanel(this.view)
|
|
347
|
+
}, "×"));
|
|
348
|
+
this.update();
|
|
349
|
+
}
|
|
350
|
+
get selectedIndex() {
|
|
351
|
+
let selected = this.view.state.field(lintState).selected;
|
|
352
|
+
if (!selected) return -1;
|
|
353
|
+
for (let i = 0; i < this.items.length; i++) if (this.items[i].diagnostic == selected.diagnostic) return i;
|
|
354
|
+
return -1;
|
|
355
|
+
}
|
|
356
|
+
update() {
|
|
357
|
+
let { diagnostics, selected } = this.view.state.field(lintState);
|
|
358
|
+
let i = 0, needsSync = false, newSelectedItem = null;
|
|
359
|
+
let seen = /* @__PURE__ */ new Set();
|
|
360
|
+
diagnostics.between(0, this.view.state.doc.length, (_start, _end, { spec }) => {
|
|
361
|
+
for (let diagnostic of spec.diagnostics) {
|
|
362
|
+
if (seen.has(diagnostic)) continue;
|
|
363
|
+
seen.add(diagnostic);
|
|
364
|
+
let found = -1, item;
|
|
365
|
+
for (let j = i; j < this.items.length; j++) if (this.items[j].diagnostic == diagnostic) {
|
|
366
|
+
found = j;
|
|
367
|
+
break;
|
|
368
|
+
}
|
|
369
|
+
if (found < 0) {
|
|
370
|
+
item = new PanelItem(this.view, diagnostic);
|
|
371
|
+
this.items.splice(i, 0, item);
|
|
372
|
+
needsSync = true;
|
|
373
|
+
} else {
|
|
374
|
+
item = this.items[found];
|
|
375
|
+
if (found > i) {
|
|
376
|
+
this.items.splice(i, found - i);
|
|
377
|
+
needsSync = true;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
if (selected && item.diagnostic == selected.diagnostic) {
|
|
381
|
+
if (!item.dom.hasAttribute("aria-selected")) {
|
|
382
|
+
item.dom.setAttribute("aria-selected", "true");
|
|
383
|
+
newSelectedItem = item;
|
|
384
|
+
}
|
|
385
|
+
} else if (item.dom.hasAttribute("aria-selected")) item.dom.removeAttribute("aria-selected");
|
|
386
|
+
i++;
|
|
387
|
+
}
|
|
388
|
+
});
|
|
389
|
+
while (i < this.items.length && !(this.items.length == 1 && this.items[0].diagnostic.from < 0)) {
|
|
390
|
+
needsSync = true;
|
|
391
|
+
this.items.pop();
|
|
392
|
+
}
|
|
393
|
+
if (this.items.length == 0) {
|
|
394
|
+
this.items.push(new PanelItem(this.view, {
|
|
395
|
+
from: -1,
|
|
396
|
+
to: -1,
|
|
397
|
+
severity: "info",
|
|
398
|
+
message: this.view.state.phrase("No diagnostics")
|
|
399
|
+
}));
|
|
400
|
+
needsSync = true;
|
|
401
|
+
}
|
|
402
|
+
if (newSelectedItem) {
|
|
403
|
+
this.list.setAttribute("aria-activedescendant", newSelectedItem.id);
|
|
404
|
+
this.view.requestMeasure({
|
|
405
|
+
key: this,
|
|
406
|
+
read: () => ({
|
|
407
|
+
sel: newSelectedItem.dom.getBoundingClientRect(),
|
|
408
|
+
panel: this.list.getBoundingClientRect()
|
|
409
|
+
}),
|
|
410
|
+
write: ({ sel, panel }) => {
|
|
411
|
+
let scaleY = panel.height / this.list.offsetHeight;
|
|
412
|
+
if (sel.top < panel.top) this.list.scrollTop -= (panel.top - sel.top) / scaleY;
|
|
413
|
+
else if (sel.bottom > panel.bottom) this.list.scrollTop += (sel.bottom - panel.bottom) / scaleY;
|
|
414
|
+
}
|
|
415
|
+
});
|
|
416
|
+
} else if (this.selectedIndex < 0) this.list.removeAttribute("aria-activedescendant");
|
|
417
|
+
if (needsSync) this.sync();
|
|
418
|
+
}
|
|
419
|
+
sync() {
|
|
420
|
+
let domPos = this.list.firstChild;
|
|
421
|
+
function rm() {
|
|
422
|
+
let prev = domPos;
|
|
423
|
+
domPos = prev.nextSibling;
|
|
424
|
+
prev.remove();
|
|
425
|
+
}
|
|
426
|
+
for (let item of this.items) if (item.dom.parentNode == this.list) {
|
|
427
|
+
while (domPos != item.dom) rm();
|
|
428
|
+
domPos = item.dom.nextSibling;
|
|
429
|
+
} else this.list.insertBefore(item.dom, domPos);
|
|
430
|
+
while (domPos) rm();
|
|
431
|
+
}
|
|
432
|
+
moveSelection(selectedIndex) {
|
|
433
|
+
if (this.selectedIndex < 0) return;
|
|
434
|
+
let selection = findDiagnostic(this.view.state.field(lintState).diagnostics, this.items[selectedIndex].diagnostic);
|
|
435
|
+
if (!selection) return;
|
|
436
|
+
this.view.dispatch({
|
|
437
|
+
selection: {
|
|
438
|
+
anchor: selection.from,
|
|
439
|
+
head: selection.to
|
|
440
|
+
},
|
|
441
|
+
scrollIntoView: true,
|
|
442
|
+
effects: movePanelSelection.of(selection)
|
|
443
|
+
});
|
|
444
|
+
}
|
|
445
|
+
static open(view) {
|
|
446
|
+
return new LintPanel(view);
|
|
447
|
+
}
|
|
448
|
+
};
|
|
449
|
+
function svg(content, attrs = `viewBox="0 0 40 40"`) {
|
|
450
|
+
return `url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${attrs}>${encodeURIComponent(content)}</svg>')`;
|
|
451
|
+
}
|
|
452
|
+
function underline(color) {
|
|
453
|
+
return svg(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${color}" fill="none" stroke-width=".7"/>`, `width="6" height="3"`);
|
|
454
|
+
}
|
|
455
|
+
const baseTheme = /*@__PURE__*/ EditorView.baseTheme({
|
|
456
|
+
".cm-diagnostic": {
|
|
457
|
+
padding: "3px 6px 3px 8px",
|
|
458
|
+
marginLeft: "-1px",
|
|
459
|
+
display: "block",
|
|
460
|
+
whiteSpace: "pre-wrap"
|
|
461
|
+
},
|
|
462
|
+
".cm-diagnostic-error": { borderLeft: "5px solid #d11" },
|
|
463
|
+
".cm-diagnostic-warning": { borderLeft: "5px solid orange" },
|
|
464
|
+
".cm-diagnostic-info": { borderLeft: "5px solid #999" },
|
|
465
|
+
".cm-diagnostic-hint": { borderLeft: "5px solid #66d" },
|
|
466
|
+
".cm-diagnosticAction": {
|
|
467
|
+
font: "inherit",
|
|
468
|
+
border: "none",
|
|
469
|
+
padding: "2px 4px",
|
|
470
|
+
backgroundColor: "#444",
|
|
471
|
+
color: "white",
|
|
472
|
+
borderRadius: "3px",
|
|
473
|
+
marginLeft: "8px",
|
|
474
|
+
cursor: "pointer"
|
|
475
|
+
},
|
|
476
|
+
".cm-diagnosticSource": {
|
|
477
|
+
fontSize: "70%",
|
|
478
|
+
opacity: .7
|
|
479
|
+
},
|
|
480
|
+
".cm-lintRange": {
|
|
481
|
+
backgroundPosition: "left bottom",
|
|
482
|
+
backgroundRepeat: "repeat-x",
|
|
483
|
+
paddingBottom: "0.7px"
|
|
484
|
+
},
|
|
485
|
+
".cm-lintRange-error": { backgroundImage: /*@__PURE__*/ underline("#f11") },
|
|
486
|
+
".cm-lintRange-warning": { backgroundImage: /*@__PURE__*/ underline("orange") },
|
|
487
|
+
".cm-lintRange-info": { backgroundImage: /*@__PURE__*/ underline("#999") },
|
|
488
|
+
".cm-lintRange-hint": { backgroundImage: /*@__PURE__*/ underline("#66d") },
|
|
489
|
+
".cm-lintRange-active": { backgroundColor: "#ffdd9980" },
|
|
490
|
+
".cm-tooltip-lint": {
|
|
491
|
+
padding: 0,
|
|
492
|
+
margin: 0
|
|
493
|
+
},
|
|
494
|
+
".cm-lintPoint": {
|
|
495
|
+
position: "relative",
|
|
496
|
+
"&:after": {
|
|
497
|
+
content: "\"\"",
|
|
498
|
+
position: "absolute",
|
|
499
|
+
bottom: 0,
|
|
500
|
+
left: "-2px",
|
|
501
|
+
borderLeft: "3px solid transparent",
|
|
502
|
+
borderRight: "3px solid transparent",
|
|
503
|
+
borderBottom: "4px solid #d11"
|
|
504
|
+
}
|
|
505
|
+
},
|
|
506
|
+
".cm-lintPoint-warning": { "&:after": { borderBottomColor: "orange" } },
|
|
507
|
+
".cm-lintPoint-info": { "&:after": { borderBottomColor: "#999" } },
|
|
508
|
+
".cm-lintPoint-hint": { "&:after": { borderBottomColor: "#66d" } },
|
|
509
|
+
".cm-panel.cm-panel-lint": {
|
|
510
|
+
position: "relative",
|
|
511
|
+
"& ul": {
|
|
512
|
+
maxHeight: "100px",
|
|
513
|
+
overflowY: "auto",
|
|
514
|
+
"& [aria-selected]": {
|
|
515
|
+
backgroundColor: "#ddd",
|
|
516
|
+
"& u": { textDecoration: "underline" }
|
|
517
|
+
},
|
|
518
|
+
"&:focus [aria-selected]": {
|
|
519
|
+
background_fallback: "#bdf",
|
|
520
|
+
backgroundColor: "Highlight",
|
|
521
|
+
color_fallback: "white",
|
|
522
|
+
color: "HighlightText"
|
|
523
|
+
},
|
|
524
|
+
"& u": { textDecoration: "none" },
|
|
525
|
+
padding: 0,
|
|
526
|
+
margin: 0
|
|
527
|
+
},
|
|
528
|
+
"& [name=close]": {
|
|
529
|
+
position: "absolute",
|
|
530
|
+
top: "0",
|
|
531
|
+
right: "2px",
|
|
532
|
+
background: "inherit",
|
|
533
|
+
border: "none",
|
|
534
|
+
font: "inherit",
|
|
535
|
+
padding: 0,
|
|
536
|
+
margin: 0
|
|
537
|
+
}
|
|
538
|
+
},
|
|
539
|
+
"&dark .cm-lintRange-active": { backgroundColor: "#86714a80" },
|
|
540
|
+
"&dark .cm-panel.cm-panel-lint ul": { "& [aria-selected]": { backgroundColor: "#2e343e" } }
|
|
541
|
+
});
|
|
542
|
+
function severityWeight(sev) {
|
|
543
|
+
return sev == "error" ? 4 : sev == "warning" ? 3 : sev == "info" ? 2 : 1;
|
|
544
|
+
}
|
|
545
|
+
function maxSeverity(diagnostics) {
|
|
546
|
+
let sev = "hint", weight = 1;
|
|
547
|
+
for (let d of diagnostics) {
|
|
548
|
+
let w = severityWeight(d.severity);
|
|
549
|
+
if (w > weight) {
|
|
550
|
+
weight = w;
|
|
551
|
+
sev = d.severity;
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
return sev;
|
|
555
|
+
}
|
|
556
|
+
const lintHover = /*@__PURE__*/ hoverTooltip(lintTooltip, { hideOn: hideTooltip });
|
|
557
|
+
const lintExtensions = [
|
|
558
|
+
lintState,
|
|
559
|
+
/*@__PURE__*/ EditorView.decorations.compute([lintState], (state) => {
|
|
560
|
+
let { selected, panel } = state.field(lintState);
|
|
561
|
+
return !selected || !panel || selected.from == selected.to ? Decoration.none : Decoration.set([activeMark.range(selected.from, selected.to)]);
|
|
562
|
+
}),
|
|
563
|
+
lintHover,
|
|
564
|
+
baseTheme
|
|
565
|
+
];
|
|
566
|
+
//#endregion
|
|
567
|
+
export { lintKeymap };
|
|
568
|
+
|
|
569
|
+
//# sourceMappingURL=index.js.map
|