@onereach/ui-components-vue2 18.0.0 → 18.0.1

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.
Files changed (26) hide show
  1. package/dist/bundled/components/OrCode/OrCode.js +6 -7
  2. package/dist/bundled/components/OrCode/index.js +5 -5
  3. package/dist/bundled/components/OrCode/lang.js +5 -5
  4. package/dist/bundled/components/OrCode/libs.js +5 -5
  5. package/dist/bundled/components/OrCode/theme.js +1 -3
  6. package/dist/bundled/components/OrCodeV3/OrCode.js +8 -9
  7. package/dist/bundled/components/OrCodeV3/index.js +5 -6
  8. package/dist/bundled/components/OrCodeV3/libs.js +5 -6
  9. package/dist/bundled/components/OrRichTextEditorV3/OrRichTextEditor.js +1 -1
  10. package/dist/bundled/components/OrRichTextEditorV3/utils/codemirror/codemirrorNode.js +2 -2
  11. package/dist/bundled/components/OrRichTextEditorV3/utils/codemirror/codemirrorView.js +533 -4
  12. package/dist/bundled/components/OrRichTextEditorV3/utils/codemirror/theme.js +1 -3
  13. package/dist/bundled/components/OrRichTextEditorV3/utils/markdown.js +2 -2
  14. package/dist/bundled/components/index.js +6 -7
  15. package/dist/bundled/{index-36159e83.js → index-3db765e0.js} +1 -1
  16. package/dist/bundled/index-7d05cef5.js +737 -0
  17. package/dist/bundled/{index-97358457.js → index-984e3b2c.js} +2 -4
  18. package/dist/bundled/index-993c320e.js +3209 -0
  19. package/dist/bundled/{index-688b7f22.js → index-bf867a40.js} +3 -5
  20. package/dist/bundled/{index-4b377c87.js → index-e5fc608d.js} +1 -1
  21. package/dist/bundled/{index-0cb923e8.js → index-eb07705b.js} +1 -3
  22. package/dist/bundled/index-f2294f8e.js +17056 -0
  23. package/dist/bundled/{index-402ddb06.js → index-f680a6b7.js} +2 -4
  24. package/dist/bundled/index.js +6 -7
  25. package/dist/bundled/{markdown-88d482e0.js → markdown-0a4a3a38.js} +1 -1
  26. package/package.json +12 -12
@@ -0,0 +1,737 @@
1
+ import { E as EditorView, D as Decoration, h as hoverTooltip, S as StateField, s as showPanel, V as ViewPlugin, l as logException, F as Facet, c as combineConfig, g as gutter, R as RangeSet, b as showTooltip, d as StateEffect, e as getPanel, W as WidgetType, G as GutterMarker } from './index-f2294f8e.js';
2
+ import elt from 'crelt';
3
+
4
+ class SelectedDiagnostic {
5
+ constructor(from, to, diagnostic) {
6
+ this.from = from;
7
+ this.to = to;
8
+ this.diagnostic = diagnostic;
9
+ }
10
+ }
11
+ class LintState {
12
+ constructor(diagnostics, panel, selected) {
13
+ this.diagnostics = diagnostics;
14
+ this.panel = panel;
15
+ this.selected = selected;
16
+ }
17
+ static init(diagnostics, panel, state) {
18
+ // Filter the list of diagnostics for which to create markers
19
+ let markedDiagnostics = diagnostics;
20
+ let diagnosticFilter = state.facet(lintConfig).markerFilter;
21
+ if (diagnosticFilter)
22
+ markedDiagnostics = diagnosticFilter(markedDiagnostics, state);
23
+ let ranges = Decoration.set(markedDiagnostics.map((d) => {
24
+ // For zero-length ranges or ranges covering only a line break, create a widget
25
+ return d.from == d.to || (d.from == d.to - 1 && state.doc.lineAt(d.from).to == d.from)
26
+ ? Decoration.widget({
27
+ widget: new DiagnosticWidget(d),
28
+ diagnostic: d
29
+ }).range(d.from)
30
+ : Decoration.mark({
31
+ attributes: { class: "cm-lintRange cm-lintRange-" + d.severity + (d.markClass ? " " + d.markClass : "") },
32
+ diagnostic: d,
33
+ inclusive: true
34
+ }).range(d.from, d.to);
35
+ }), true);
36
+ return new LintState(ranges, panel, findDiagnostic(ranges));
37
+ }
38
+ }
39
+ function findDiagnostic(diagnostics, diagnostic = null, after = 0) {
40
+ let found = null;
41
+ diagnostics.between(after, 1e9, (from, to, { spec }) => {
42
+ if (diagnostic && spec.diagnostic != diagnostic)
43
+ return;
44
+ found = new SelectedDiagnostic(from, to, spec.diagnostic);
45
+ return false;
46
+ });
47
+ return found;
48
+ }
49
+ function hideTooltip(tr, tooltip) {
50
+ let line = tr.startState.doc.lineAt(tooltip.pos);
51
+ return !!(tr.effects.some(e => e.is(setDiagnosticsEffect)) || tr.changes.touchesRange(line.from, line.to));
52
+ }
53
+ function maybeEnableLint(state, effects) {
54
+ return state.field(lintState, false) ? effects : effects.concat(StateEffect.appendConfig.of(lintExtensions));
55
+ }
56
+ /**
57
+ Returns a transaction spec which updates the current set of
58
+ diagnostics, and enables the lint extension if if wasn't already
59
+ active.
60
+ */
61
+ function setDiagnostics(state, diagnostics) {
62
+ return {
63
+ effects: maybeEnableLint(state, [setDiagnosticsEffect.of(diagnostics)])
64
+ };
65
+ }
66
+ /**
67
+ The state effect that updates the set of active diagnostics. Can
68
+ be useful when writing an extension that needs to track these.
69
+ */
70
+ const setDiagnosticsEffect = /*@__PURE__*/StateEffect.define();
71
+ const togglePanel = /*@__PURE__*/StateEffect.define();
72
+ const movePanelSelection = /*@__PURE__*/StateEffect.define();
73
+ const lintState = /*@__PURE__*/StateField.define({
74
+ create() {
75
+ return new LintState(Decoration.none, null, null);
76
+ },
77
+ update(value, tr) {
78
+ if (tr.docChanged) {
79
+ let mapped = value.diagnostics.map(tr.changes), selected = null;
80
+ if (value.selected) {
81
+ let selPos = tr.changes.mapPos(value.selected.from, 1);
82
+ selected = findDiagnostic(mapped, value.selected.diagnostic, selPos) || findDiagnostic(mapped, null, selPos);
83
+ }
84
+ value = new LintState(mapped, value.panel, selected);
85
+ }
86
+ for (let effect of tr.effects) {
87
+ if (effect.is(setDiagnosticsEffect)) {
88
+ value = LintState.init(effect.value, value.panel, tr.state);
89
+ }
90
+ else if (effect.is(togglePanel)) {
91
+ value = new LintState(value.diagnostics, effect.value ? LintPanel.open : null, value.selected);
92
+ }
93
+ else if (effect.is(movePanelSelection)) {
94
+ value = new LintState(value.diagnostics, value.panel, effect.value);
95
+ }
96
+ }
97
+ return value;
98
+ },
99
+ provide: f => [showPanel.from(f, val => val.panel),
100
+ EditorView.decorations.from(f, s => s.diagnostics)]
101
+ });
102
+ const activeMark = /*@__PURE__*/Decoration.mark({ class: "cm-lintRange cm-lintRange-active", inclusive: true });
103
+ function lintTooltip(view, pos, side) {
104
+ let { diagnostics } = view.state.field(lintState);
105
+ let found = [], stackStart = 2e8, stackEnd = 0;
106
+ diagnostics.between(pos - (side < 0 ? 1 : 0), pos + (side > 0 ? 1 : 0), (from, to, { spec }) => {
107
+ if (pos >= from && pos <= to &&
108
+ (from == to || ((pos > from || side > 0) && (pos < to || side < 0)))) {
109
+ found.push(spec.diagnostic);
110
+ stackStart = Math.min(from, stackStart);
111
+ stackEnd = Math.max(to, stackEnd);
112
+ }
113
+ });
114
+ let diagnosticFilter = view.state.facet(lintConfig).tooltipFilter;
115
+ if (diagnosticFilter)
116
+ found = diagnosticFilter(found, view.state);
117
+ if (!found.length)
118
+ return null;
119
+ return {
120
+ pos: stackStart,
121
+ end: stackEnd,
122
+ above: view.state.doc.lineAt(stackStart).to < stackEnd,
123
+ create() {
124
+ return { dom: diagnosticsTooltip(view, found) };
125
+ }
126
+ };
127
+ }
128
+ function diagnosticsTooltip(view, diagnostics) {
129
+ return elt("ul", { class: "cm-tooltip-lint" }, diagnostics.map(d => renderDiagnostic(view, d, false)));
130
+ }
131
+ /**
132
+ Command to open and focus the lint panel.
133
+ */
134
+ const openLintPanel = (view) => {
135
+ let field = view.state.field(lintState, false);
136
+ if (!field || !field.panel)
137
+ view.dispatch({ effects: maybeEnableLint(view.state, [togglePanel.of(true)]) });
138
+ let panel = getPanel(view, LintPanel.open);
139
+ if (panel)
140
+ panel.dom.querySelector(".cm-panel-lint ul").focus();
141
+ return true;
142
+ };
143
+ /**
144
+ Command to close the lint panel, when open.
145
+ */
146
+ const closeLintPanel = (view) => {
147
+ let field = view.state.field(lintState, false);
148
+ if (!field || !field.panel)
149
+ return false;
150
+ view.dispatch({ effects: togglePanel.of(false) });
151
+ return true;
152
+ };
153
+ /**
154
+ Move the selection to the next diagnostic.
155
+ */
156
+ const nextDiagnostic = (view) => {
157
+ let field = view.state.field(lintState, false);
158
+ if (!field)
159
+ return false;
160
+ let sel = view.state.selection.main, next = field.diagnostics.iter(sel.to + 1);
161
+ if (!next.value) {
162
+ next = field.diagnostics.iter(0);
163
+ if (!next.value || next.from == sel.from && next.to == sel.to)
164
+ return false;
165
+ }
166
+ view.dispatch({ selection: { anchor: next.from, head: next.to }, scrollIntoView: true });
167
+ return true;
168
+ };
169
+ /**
170
+ A set of default key bindings for the lint functionality.
171
+
172
+ - Ctrl-Shift-m (Cmd-Shift-m on macOS): [`openLintPanel`](https://codemirror.net/6/docs/ref/#lint.openLintPanel)
173
+ - F8: [`nextDiagnostic`](https://codemirror.net/6/docs/ref/#lint.nextDiagnostic)
174
+ */
175
+ const lintKeymap = [
176
+ { key: "Mod-Shift-m", run: openLintPanel, preventDefault: true },
177
+ { key: "F8", run: nextDiagnostic }
178
+ ];
179
+ const lintPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
180
+ constructor(view) {
181
+ this.view = view;
182
+ this.timeout = -1;
183
+ this.set = true;
184
+ let { delay } = view.state.facet(lintConfig);
185
+ this.lintTime = Date.now() + delay;
186
+ this.run = this.run.bind(this);
187
+ this.timeout = setTimeout(this.run, delay);
188
+ }
189
+ run() {
190
+ let now = Date.now();
191
+ if (now < this.lintTime - 10) {
192
+ this.timeout = setTimeout(this.run, this.lintTime - now);
193
+ }
194
+ else {
195
+ this.set = false;
196
+ let { state } = this.view, { sources } = state.facet(lintConfig);
197
+ if (sources.length)
198
+ Promise.all(sources.map(source => Promise.resolve(source(this.view)))).then(annotations => {
199
+ let all = annotations.reduce((a, b) => a.concat(b));
200
+ if (this.view.state.doc == state.doc)
201
+ this.view.dispatch(setDiagnostics(this.view.state, all));
202
+ }, error => { logException(this.view.state, error); });
203
+ }
204
+ }
205
+ update(update) {
206
+ let config = update.state.facet(lintConfig);
207
+ if (update.docChanged || config != update.startState.facet(lintConfig) ||
208
+ config.needsRefresh && config.needsRefresh(update)) {
209
+ this.lintTime = Date.now() + config.delay;
210
+ if (!this.set) {
211
+ this.set = true;
212
+ this.timeout = setTimeout(this.run, config.delay);
213
+ }
214
+ }
215
+ }
216
+ force() {
217
+ if (this.set) {
218
+ this.lintTime = Date.now();
219
+ this.run();
220
+ }
221
+ }
222
+ destroy() {
223
+ clearTimeout(this.timeout);
224
+ }
225
+ });
226
+ const lintConfig = /*@__PURE__*/Facet.define({
227
+ combine(input) {
228
+ return Object.assign({ sources: input.map(i => i.source).filter(x => x != null) }, combineConfig(input.map(i => i.config), {
229
+ delay: 750,
230
+ markerFilter: null,
231
+ tooltipFilter: null,
232
+ needsRefresh: null
233
+ }, {
234
+ needsRefresh: (a, b) => !a ? b : !b ? a : u => a(u) || b(u)
235
+ }));
236
+ }
237
+ });
238
+ /**
239
+ Given a diagnostic source, this function returns an extension that
240
+ enables linting with that source. It will be called whenever the
241
+ editor is idle (after its content changed). If `null` is given as
242
+ source, this only configures the lint extension.
243
+ */
244
+ function linter(source, config = {}) {
245
+ return [
246
+ lintConfig.of({ source, config }),
247
+ lintPlugin,
248
+ lintExtensions
249
+ ];
250
+ }
251
+ function assignKeys(actions) {
252
+ let assigned = [];
253
+ if (actions)
254
+ actions: for (let { name } of actions) {
255
+ for (let i = 0; i < name.length; i++) {
256
+ let ch = name[i];
257
+ if (/[a-zA-Z]/.test(ch) && !assigned.some(c => c.toLowerCase() == ch.toLowerCase())) {
258
+ assigned.push(ch);
259
+ continue actions;
260
+ }
261
+ }
262
+ assigned.push("");
263
+ }
264
+ return assigned;
265
+ }
266
+ function renderDiagnostic(view, diagnostic, inPanel) {
267
+ var _a;
268
+ let keys = inPanel ? assignKeys(diagnostic.actions) : [];
269
+ 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) => {
270
+ let fired = false, click = (e) => {
271
+ e.preventDefault();
272
+ if (fired)
273
+ return;
274
+ fired = true;
275
+ let found = findDiagnostic(view.state.field(lintState).diagnostics, diagnostic);
276
+ if (found)
277
+ action.apply(view, found.from, found.to);
278
+ };
279
+ let { name } = action, keyIndex = keys[i] ? name.indexOf(keys[i]) : -1;
280
+ let nameElt = keyIndex < 0 ? name : [name.slice(0, keyIndex),
281
+ elt("u", name.slice(keyIndex, keyIndex + 1)),
282
+ name.slice(keyIndex + 1)];
283
+ return elt("button", {
284
+ type: "button",
285
+ class: "cm-diagnosticAction",
286
+ onclick: click,
287
+ onmousedown: click,
288
+ "aria-label": ` Action: ${name}${keyIndex < 0 ? "" : ` (access key "${keys[i]})"`}.`
289
+ }, nameElt);
290
+ }), diagnostic.source && elt("div", { class: "cm-diagnosticSource" }, diagnostic.source));
291
+ }
292
+ class DiagnosticWidget extends WidgetType {
293
+ constructor(diagnostic) {
294
+ super();
295
+ this.diagnostic = diagnostic;
296
+ }
297
+ eq(other) { return other.diagnostic == this.diagnostic; }
298
+ toDOM() {
299
+ return elt("span", { class: "cm-lintPoint cm-lintPoint-" + this.diagnostic.severity });
300
+ }
301
+ }
302
+ class PanelItem {
303
+ constructor(view, diagnostic) {
304
+ this.diagnostic = diagnostic;
305
+ this.id = "item_" + Math.floor(Math.random() * 0xffffffff).toString(16);
306
+ this.dom = renderDiagnostic(view, diagnostic, true);
307
+ this.dom.id = this.id;
308
+ this.dom.setAttribute("role", "option");
309
+ }
310
+ }
311
+ class LintPanel {
312
+ constructor(view) {
313
+ this.view = view;
314
+ this.items = [];
315
+ let onkeydown = (event) => {
316
+ if (event.keyCode == 27) { // Escape
317
+ closeLintPanel(this.view);
318
+ this.view.focus();
319
+ }
320
+ else if (event.keyCode == 38 || event.keyCode == 33) { // ArrowUp, PageUp
321
+ this.moveSelection((this.selectedIndex - 1 + this.items.length) % this.items.length);
322
+ }
323
+ else if (event.keyCode == 40 || event.keyCode == 34) { // ArrowDown, PageDown
324
+ this.moveSelection((this.selectedIndex + 1) % this.items.length);
325
+ }
326
+ else if (event.keyCode == 36) { // Home
327
+ this.moveSelection(0);
328
+ }
329
+ else if (event.keyCode == 35) { // End
330
+ this.moveSelection(this.items.length - 1);
331
+ }
332
+ else if (event.keyCode == 13) { // Enter
333
+ this.view.focus();
334
+ }
335
+ else if (event.keyCode >= 65 && event.keyCode <= 90 && this.selectedIndex >= 0) { // A-Z
336
+ let { diagnostic } = this.items[this.selectedIndex], keys = assignKeys(diagnostic.actions);
337
+ for (let i = 0; i < keys.length; i++)
338
+ if (keys[i].toUpperCase().charCodeAt(0) == event.keyCode) {
339
+ let found = findDiagnostic(this.view.state.field(lintState).diagnostics, diagnostic);
340
+ if (found)
341
+ diagnostic.actions[i].apply(view, found.from, found.to);
342
+ }
343
+ }
344
+ else {
345
+ return;
346
+ }
347
+ event.preventDefault();
348
+ };
349
+ let onclick = (event) => {
350
+ for (let i = 0; i < this.items.length; i++) {
351
+ if (this.items[i].dom.contains(event.target))
352
+ this.moveSelection(i);
353
+ }
354
+ };
355
+ this.list = elt("ul", {
356
+ tabIndex: 0,
357
+ role: "listbox",
358
+ "aria-label": this.view.state.phrase("Diagnostics"),
359
+ onkeydown,
360
+ onclick
361
+ });
362
+ this.dom = elt("div", { class: "cm-panel-lint" }, this.list, elt("button", {
363
+ type: "button",
364
+ name: "close",
365
+ "aria-label": this.view.state.phrase("close"),
366
+ onclick: () => closeLintPanel(this.view)
367
+ }, "×"));
368
+ this.update();
369
+ }
370
+ get selectedIndex() {
371
+ let selected = this.view.state.field(lintState).selected;
372
+ if (!selected)
373
+ return -1;
374
+ for (let i = 0; i < this.items.length; i++)
375
+ if (this.items[i].diagnostic == selected.diagnostic)
376
+ return i;
377
+ return -1;
378
+ }
379
+ update() {
380
+ let { diagnostics, selected } = this.view.state.field(lintState);
381
+ let i = 0, needsSync = false, newSelectedItem = null;
382
+ diagnostics.between(0, this.view.state.doc.length, (_start, _end, { spec }) => {
383
+ let found = -1, item;
384
+ for (let j = i; j < this.items.length; j++)
385
+ if (this.items[j].diagnostic == spec.diagnostic) {
386
+ found = j;
387
+ break;
388
+ }
389
+ if (found < 0) {
390
+ item = new PanelItem(this.view, spec.diagnostic);
391
+ this.items.splice(i, 0, item);
392
+ needsSync = true;
393
+ }
394
+ else {
395
+ item = this.items[found];
396
+ if (found > i) {
397
+ this.items.splice(i, found - i);
398
+ needsSync = true;
399
+ }
400
+ }
401
+ if (selected && item.diagnostic == selected.diagnostic) {
402
+ if (!item.dom.hasAttribute("aria-selected")) {
403
+ item.dom.setAttribute("aria-selected", "true");
404
+ newSelectedItem = item;
405
+ }
406
+ }
407
+ else if (item.dom.hasAttribute("aria-selected")) {
408
+ item.dom.removeAttribute("aria-selected");
409
+ }
410
+ i++;
411
+ });
412
+ while (i < this.items.length && !(this.items.length == 1 && this.items[0].diagnostic.from < 0)) {
413
+ needsSync = true;
414
+ this.items.pop();
415
+ }
416
+ if (this.items.length == 0) {
417
+ this.items.push(new PanelItem(this.view, {
418
+ from: -1, to: -1,
419
+ severity: "info",
420
+ message: this.view.state.phrase("No diagnostics")
421
+ }));
422
+ needsSync = true;
423
+ }
424
+ if (newSelectedItem) {
425
+ this.list.setAttribute("aria-activedescendant", newSelectedItem.id);
426
+ this.view.requestMeasure({
427
+ key: this,
428
+ read: () => ({ sel: newSelectedItem.dom.getBoundingClientRect(), panel: this.list.getBoundingClientRect() }),
429
+ write: ({ sel, panel }) => {
430
+ let scaleY = panel.height / this.list.offsetHeight;
431
+ if (sel.top < panel.top)
432
+ this.list.scrollTop -= (panel.top - sel.top) / scaleY;
433
+ else if (sel.bottom > panel.bottom)
434
+ this.list.scrollTop += (sel.bottom - panel.bottom) / scaleY;
435
+ }
436
+ });
437
+ }
438
+ else if (this.selectedIndex < 0) {
439
+ this.list.removeAttribute("aria-activedescendant");
440
+ }
441
+ if (needsSync)
442
+ this.sync();
443
+ }
444
+ sync() {
445
+ let domPos = this.list.firstChild;
446
+ function rm() {
447
+ let prev = domPos;
448
+ domPos = prev.nextSibling;
449
+ prev.remove();
450
+ }
451
+ for (let item of this.items) {
452
+ if (item.dom.parentNode == this.list) {
453
+ while (domPos != item.dom)
454
+ rm();
455
+ domPos = item.dom.nextSibling;
456
+ }
457
+ else {
458
+ this.list.insertBefore(item.dom, domPos);
459
+ }
460
+ }
461
+ while (domPos)
462
+ rm();
463
+ }
464
+ moveSelection(selectedIndex) {
465
+ if (this.selectedIndex < 0)
466
+ return;
467
+ let field = this.view.state.field(lintState);
468
+ let selection = findDiagnostic(field.diagnostics, this.items[selectedIndex].diagnostic);
469
+ if (!selection)
470
+ return;
471
+ this.view.dispatch({
472
+ selection: { anchor: selection.from, head: selection.to },
473
+ scrollIntoView: true,
474
+ effects: movePanelSelection.of(selection)
475
+ });
476
+ }
477
+ static open(view) { return new LintPanel(view); }
478
+ }
479
+ function svg(content, attrs = `viewBox="0 0 40 40"`) {
480
+ return `url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${attrs}>${encodeURIComponent(content)}</svg>')`;
481
+ }
482
+ function underline(color) {
483
+ 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"`);
484
+ }
485
+ const baseTheme = /*@__PURE__*/EditorView.baseTheme({
486
+ ".cm-diagnostic": {
487
+ padding: "3px 6px 3px 8px",
488
+ marginLeft: "-1px",
489
+ display: "block",
490
+ whiteSpace: "pre-wrap"
491
+ },
492
+ ".cm-diagnostic-error": { borderLeft: "5px solid #d11" },
493
+ ".cm-diagnostic-warning": { borderLeft: "5px solid orange" },
494
+ ".cm-diagnostic-info": { borderLeft: "5px solid #999" },
495
+ ".cm-diagnostic-hint": { borderLeft: "5px solid #66d" },
496
+ ".cm-diagnosticAction": {
497
+ font: "inherit",
498
+ border: "none",
499
+ padding: "2px 4px",
500
+ backgroundColor: "#444",
501
+ color: "white",
502
+ borderRadius: "3px",
503
+ marginLeft: "8px",
504
+ cursor: "pointer"
505
+ },
506
+ ".cm-diagnosticSource": {
507
+ fontSize: "70%",
508
+ opacity: .7
509
+ },
510
+ ".cm-lintRange": {
511
+ backgroundPosition: "left bottom",
512
+ backgroundRepeat: "repeat-x",
513
+ paddingBottom: "0.7px",
514
+ },
515
+ ".cm-lintRange-error": { backgroundImage: /*@__PURE__*/underline("#d11") },
516
+ ".cm-lintRange-warning": { backgroundImage: /*@__PURE__*/underline("orange") },
517
+ ".cm-lintRange-info": { backgroundImage: /*@__PURE__*/underline("#999") },
518
+ ".cm-lintRange-hint": { backgroundImage: /*@__PURE__*/underline("#66d") },
519
+ ".cm-lintRange-active": { backgroundColor: "#ffdd9980" },
520
+ ".cm-tooltip-lint": {
521
+ padding: 0,
522
+ margin: 0
523
+ },
524
+ ".cm-lintPoint": {
525
+ position: "relative",
526
+ "&:after": {
527
+ content: '""',
528
+ position: "absolute",
529
+ bottom: 0,
530
+ left: "-2px",
531
+ borderLeft: "3px solid transparent",
532
+ borderRight: "3px solid transparent",
533
+ borderBottom: "4px solid #d11"
534
+ }
535
+ },
536
+ ".cm-lintPoint-warning": {
537
+ "&:after": { borderBottomColor: "orange" }
538
+ },
539
+ ".cm-lintPoint-info": {
540
+ "&:after": { borderBottomColor: "#999" }
541
+ },
542
+ ".cm-lintPoint-hint": {
543
+ "&:after": { borderBottomColor: "#66d" }
544
+ },
545
+ ".cm-panel.cm-panel-lint": {
546
+ position: "relative",
547
+ "& ul": {
548
+ maxHeight: "100px",
549
+ overflowY: "auto",
550
+ "& [aria-selected]": {
551
+ backgroundColor: "#ddd",
552
+ "& u": { textDecoration: "underline" }
553
+ },
554
+ "&:focus [aria-selected]": {
555
+ background_fallback: "#bdf",
556
+ backgroundColor: "Highlight",
557
+ color_fallback: "white",
558
+ color: "HighlightText"
559
+ },
560
+ "& u": { textDecoration: "none" },
561
+ padding: 0,
562
+ margin: 0
563
+ },
564
+ "& [name=close]": {
565
+ position: "absolute",
566
+ top: "0",
567
+ right: "2px",
568
+ background: "inherit",
569
+ border: "none",
570
+ font: "inherit",
571
+ padding: 0,
572
+ margin: 0
573
+ }
574
+ }
575
+ });
576
+ function severityWeight(sev) {
577
+ return sev == "error" ? 4 : sev == "warning" ? 3 : sev == "info" ? 2 : 1;
578
+ }
579
+ class LintGutterMarker extends GutterMarker {
580
+ constructor(diagnostics) {
581
+ super();
582
+ this.diagnostics = diagnostics;
583
+ this.severity = diagnostics.reduce((max, d) => severityWeight(max) < severityWeight(d.severity) ? d.severity : max, "hint");
584
+ }
585
+ toDOM(view) {
586
+ let elt = document.createElement("div");
587
+ elt.className = "cm-lint-marker cm-lint-marker-" + this.severity;
588
+ let diagnostics = this.diagnostics;
589
+ let diagnosticsFilter = view.state.facet(lintGutterConfig).tooltipFilter;
590
+ if (diagnosticsFilter)
591
+ diagnostics = diagnosticsFilter(diagnostics, view.state);
592
+ if (diagnostics.length)
593
+ elt.onmouseover = () => gutterMarkerMouseOver(view, elt, diagnostics);
594
+ return elt;
595
+ }
596
+ }
597
+ function trackHoverOn(view, marker) {
598
+ let mousemove = (event) => {
599
+ let rect = marker.getBoundingClientRect();
600
+ if (event.clientX > rect.left - 10 /* Hover.Margin */ && event.clientX < rect.right + 10 /* Hover.Margin */ &&
601
+ event.clientY > rect.top - 10 /* Hover.Margin */ && event.clientY < rect.bottom + 10 /* Hover.Margin */)
602
+ return;
603
+ for (let target = event.target; target; target = target.parentNode) {
604
+ if (target.nodeType == 1 && target.classList.contains("cm-tooltip-lint"))
605
+ return;
606
+ }
607
+ window.removeEventListener("mousemove", mousemove);
608
+ if (view.state.field(lintGutterTooltip))
609
+ view.dispatch({ effects: setLintGutterTooltip.of(null) });
610
+ };
611
+ window.addEventListener("mousemove", mousemove);
612
+ }
613
+ function gutterMarkerMouseOver(view, marker, diagnostics) {
614
+ function hovered() {
615
+ let line = view.elementAtHeight(marker.getBoundingClientRect().top + 5 - view.documentTop);
616
+ const linePos = view.coordsAtPos(line.from);
617
+ if (linePos) {
618
+ view.dispatch({ effects: setLintGutterTooltip.of({
619
+ pos: line.from,
620
+ above: false,
621
+ create() {
622
+ return {
623
+ dom: diagnosticsTooltip(view, diagnostics),
624
+ getCoords: () => marker.getBoundingClientRect()
625
+ };
626
+ }
627
+ }) });
628
+ }
629
+ marker.onmouseout = marker.onmousemove = null;
630
+ trackHoverOn(view, marker);
631
+ }
632
+ let { hoverTime } = view.state.facet(lintGutterConfig);
633
+ let hoverTimeout = setTimeout(hovered, hoverTime);
634
+ marker.onmouseout = () => {
635
+ clearTimeout(hoverTimeout);
636
+ marker.onmouseout = marker.onmousemove = null;
637
+ };
638
+ marker.onmousemove = () => {
639
+ clearTimeout(hoverTimeout);
640
+ hoverTimeout = setTimeout(hovered, hoverTime);
641
+ };
642
+ }
643
+ function markersForDiagnostics(doc, diagnostics) {
644
+ let byLine = Object.create(null);
645
+ for (let diagnostic of diagnostics) {
646
+ let line = doc.lineAt(diagnostic.from);
647
+ (byLine[line.from] || (byLine[line.from] = [])).push(diagnostic);
648
+ }
649
+ let markers = [];
650
+ for (let line in byLine) {
651
+ markers.push(new LintGutterMarker(byLine[line]).range(+line));
652
+ }
653
+ return RangeSet.of(markers, true);
654
+ }
655
+ const lintGutterExtension = /*@__PURE__*/gutter({
656
+ class: "cm-gutter-lint",
657
+ markers: view => view.state.field(lintGutterMarkers),
658
+ });
659
+ const lintGutterMarkers = /*@__PURE__*/StateField.define({
660
+ create() {
661
+ return RangeSet.empty;
662
+ },
663
+ update(markers, tr) {
664
+ markers = markers.map(tr.changes);
665
+ let diagnosticFilter = tr.state.facet(lintGutterConfig).markerFilter;
666
+ for (let effect of tr.effects) {
667
+ if (effect.is(setDiagnosticsEffect)) {
668
+ let diagnostics = effect.value;
669
+ if (diagnosticFilter)
670
+ diagnostics = diagnosticFilter(diagnostics || [], tr.state);
671
+ markers = markersForDiagnostics(tr.state.doc, diagnostics.slice(0));
672
+ }
673
+ }
674
+ return markers;
675
+ }
676
+ });
677
+ const setLintGutterTooltip = /*@__PURE__*/StateEffect.define();
678
+ const lintGutterTooltip = /*@__PURE__*/StateField.define({
679
+ create() { return null; },
680
+ update(tooltip, tr) {
681
+ if (tooltip && tr.docChanged)
682
+ tooltip = hideTooltip(tr, tooltip) ? null : Object.assign(Object.assign({}, tooltip), { pos: tr.changes.mapPos(tooltip.pos) });
683
+ return tr.effects.reduce((t, e) => e.is(setLintGutterTooltip) ? e.value : t, tooltip);
684
+ },
685
+ provide: field => showTooltip.from(field)
686
+ });
687
+ const lintGutterTheme = /*@__PURE__*/EditorView.baseTheme({
688
+ ".cm-gutter-lint": {
689
+ width: "1.4em",
690
+ "& .cm-gutterElement": {
691
+ padding: ".2em"
692
+ }
693
+ },
694
+ ".cm-lint-marker": {
695
+ width: "1em",
696
+ height: "1em"
697
+ },
698
+ ".cm-lint-marker-info": {
699
+ content: /*@__PURE__*/svg(`<path fill="#aaf" stroke="#77e" stroke-width="6" stroke-linejoin="round" d="M5 5L35 5L35 35L5 35Z"/>`)
700
+ },
701
+ ".cm-lint-marker-warning": {
702
+ content: /*@__PURE__*/svg(`<path fill="#fe8" stroke="#fd7" stroke-width="6" stroke-linejoin="round" d="M20 6L37 35L3 35Z"/>`),
703
+ },
704
+ ".cm-lint-marker-error": {
705
+ content: /*@__PURE__*/svg(`<circle cx="20" cy="20" r="15" fill="#f87" stroke="#f43" stroke-width="6"/>`)
706
+ },
707
+ });
708
+ const lintExtensions = [
709
+ lintState,
710
+ /*@__PURE__*/EditorView.decorations.compute([lintState], state => {
711
+ let { selected, panel } = state.field(lintState);
712
+ return !selected || !panel || selected.from == selected.to ? Decoration.none : Decoration.set([
713
+ activeMark.range(selected.from, selected.to)
714
+ ]);
715
+ }),
716
+ /*@__PURE__*/hoverTooltip(lintTooltip, { hideOn: hideTooltip }),
717
+ baseTheme
718
+ ];
719
+ const lintGutterConfig = /*@__PURE__*/Facet.define({
720
+ combine(configs) {
721
+ return combineConfig(configs, {
722
+ hoverTime: 300 /* Hover.Time */,
723
+ markerFilter: null,
724
+ tooltipFilter: null
725
+ });
726
+ }
727
+ });
728
+ /**
729
+ Returns an extension that installs a gutter showing markers for
730
+ each line that has diagnostics, which can be hovered over to see
731
+ the diagnostics.
732
+ */
733
+ function lintGutter(config = {}) {
734
+ return [lintGutterConfig.of(config), lintGutterMarkers, lintGutterExtension, lintGutterTheme, lintGutterTooltip];
735
+ }
736
+
737
+ export { lintGutter as a, lintKeymap as b, linter as l };