@codemirror/lint 0.19.4 → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,21 @@
1
+ ## 0.20.0 (2022-04-20)
2
+
3
+ ### Breaking changes
4
+
5
+ Update dependencies to 0.20.0
6
+
7
+ ## 0.19.6 (2022-03-04)
8
+
9
+ ### Bug fixes
10
+
11
+ Fix a bug where hovering over the icons in the lint gutter would sometimes fail to show a tooltip or show the tooltip for another line.
12
+
13
+ ## 0.19.5 (2022-02-25)
14
+
15
+ ### Bug fixes
16
+
17
+ Make sure the lint gutter tooltips are positioned under their icon, even when the line is wrapped.
18
+
1
19
  ## 0.19.4 (2022-02-25)
2
20
 
3
21
  ### Bug fixes
package/dist/index.cjs CHANGED
@@ -4,10 +4,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var view = require('@codemirror/view');
6
6
  var state = require('@codemirror/state');
7
- var tooltip = require('@codemirror/tooltip');
8
- var panel = require('@codemirror/panel');
9
- var gutter = require('@codemirror/gutter');
10
- var rangeset = require('@codemirror/rangeset');
11
7
  var elt = require('crelt');
12
8
 
13
9
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
@@ -62,7 +58,7 @@ function maybeEnableLint(state$1, effects) {
62
58
  activeMark.range(selected.from, selected.to)
63
59
  ]);
64
60
  }),
65
- tooltip.hoverTooltip(lintTooltip),
61
+ view.hoverTooltip(lintTooltip),
66
62
  baseTheme
67
63
  ]));
68
64
  }
@@ -109,7 +105,7 @@ const lintState = state.StateField.define({
109
105
  }
110
106
  return value;
111
107
  },
112
- provide: f => [panel.showPanel.from(f, val => val.panel),
108
+ provide: f => [view.showPanel.from(f, val => val.panel),
113
109
  view.EditorView.decorations.from(f, s => s.diagnostics)]
114
110
  });
115
111
  /**
@@ -148,13 +144,13 @@ function diagnosticsTooltip(view, diagnostics) {
148
144
  /**
149
145
  Command to open and focus the lint panel.
150
146
  */
151
- const openLintPanel = (view) => {
152
- let field = view.state.field(lintState, false);
147
+ const openLintPanel = (view$1) => {
148
+ let field = view$1.state.field(lintState, false);
153
149
  if (!field || !field.panel)
154
- view.dispatch({ effects: maybeEnableLint(view.state, [togglePanel.of(true)]) });
155
- let panel$1 = panel.getPanel(view, LintPanel.open);
156
- if (panel$1)
157
- panel$1.dom.querySelector(".cm-panel-lint ul").focus();
150
+ view$1.dispatch({ effects: maybeEnableLint(view$1.state, [togglePanel.of(true)]) });
151
+ let panel = view.getPanel(view$1, LintPanel.open);
152
+ if (panel)
153
+ panel.dom.querySelector(".cm-panel-lint ul").focus();
158
154
  return true;
159
155
  };
160
156
  /**
@@ -577,7 +573,7 @@ const baseTheme = view.EditorView.baseTheme({
577
573
  }
578
574
  }
579
575
  });
580
- class LintGutterMarker extends gutter.GutterMarker {
576
+ class LintGutterMarker extends view.GutterMarker {
581
577
  constructor(diagnostics) {
582
578
  super();
583
579
  this.diagnostics = diagnostics;
@@ -611,8 +607,8 @@ function trackHoverOn(view, marker) {
611
607
  }
612
608
  function gutterMarkerMouseOver(view, marker, diagnostics) {
613
609
  function hovered() {
614
- let line = view.visualLineAtHeight(marker.getBoundingClientRect().top + 5 - view.documentTop);
615
- const linePos = view.coordsAtPos(line.from), markerRect = marker.getBoundingClientRect();
610
+ let line = view.elementAtHeight(marker.getBoundingClientRect().top + 5 - view.documentTop);
611
+ const linePos = view.coordsAtPos(line.from);
616
612
  if (linePos) {
617
613
  view.dispatch({ effects: setLintGutterTooltip.of({
618
614
  pos: line.from,
@@ -620,7 +616,7 @@ function gutterMarkerMouseOver(view, marker, diagnostics) {
620
616
  create() {
621
617
  return {
622
618
  dom: diagnosticsTooltip(view, diagnostics),
623
- offset: { x: markerRect.left - linePos.left, y: 0 }
619
+ getCoords: () => marker.getBoundingClientRect()
624
620
  };
625
621
  }
626
622
  }) });
@@ -649,15 +645,15 @@ function markersForDiagnostics(doc, diagnostics) {
649
645
  for (let line in byLine) {
650
646
  markers.push(new LintGutterMarker(byLine[line]).range(+line));
651
647
  }
652
- return rangeset.RangeSet.of(markers, true);
648
+ return state.RangeSet.of(markers, true);
653
649
  }
654
- const lintGutterExtension = gutter.gutter({
650
+ const lintGutterExtension = view.gutter({
655
651
  class: "cm-gutter-lint",
656
652
  markers: view => view.state.field(lintGutterMarkers),
657
653
  });
658
654
  const lintGutterMarkers = state.StateField.define({
659
655
  create() {
660
- return rangeset.RangeSet.empty;
656
+ return state.RangeSet.empty;
661
657
  },
662
658
  update(markers, tr) {
663
659
  markers = markers.map(tr.changes);
@@ -676,21 +672,18 @@ const lintGutterTooltip = state.StateField.define({
676
672
  tooltip = Object.assign(Object.assign({}, tooltip), { pos: tr.changes.mapPos(tooltip.pos) });
677
673
  return tr.effects.reduce((t, e) => e.is(setLintGutterTooltip) ? e.value : t, tooltip);
678
674
  },
679
- provide: field => tooltip.showTooltip.from(field)
675
+ provide: field => view.showTooltip.from(field)
680
676
  });
681
677
  const lintGutterTheme = view.EditorView.baseTheme({
682
678
  ".cm-gutter-lint": {
683
679
  width: "1.4em",
684
680
  "& .cm-gutterElement": {
685
- padding: "0 .2em",
686
- display: "flex",
687
- flexDirection: "column",
688
- justifyContent: "center",
681
+ padding: ".2em"
689
682
  }
690
683
  },
691
684
  ".cm-lint-marker": {
692
685
  width: "1em",
693
- height: "1em",
686
+ height: "1em"
694
687
  },
695
688
  ".cm-lint-marker-info": {
696
689
  content: svg(`<path fill="#aaf" stroke="#77e" stroke-width="6" stroke-linejoin="round" d="M5 5L35 5L35 35L5 35Z"/>`)
package/dist/index.d.ts CHANGED
@@ -47,7 +47,7 @@ interface Action {
47
47
  /**
48
48
  The function to call when the user activates this action. Is
49
49
  given the diagnostic's _current_ position, which may have
50
- changed since the creation of the diagnostic due to editing.
50
+ changed since the creation of the diagnostic, due to editing.
51
51
  */
52
52
  apply: (view: EditorView, from: number, to: number) => void;
53
53
  }
package/dist/index.js CHANGED
@@ -1,9 +1,5 @@
1
- import { Decoration, EditorView, ViewPlugin, logException, WidgetType } from '@codemirror/view';
2
- import { StateEffect, StateField, Facet, combineConfig } from '@codemirror/state';
3
- import { hoverTooltip, showTooltip } from '@codemirror/tooltip';
4
- import { showPanel, getPanel } from '@codemirror/panel';
5
- import { gutter, GutterMarker } from '@codemirror/gutter';
6
- import { RangeSet } from '@codemirror/rangeset';
1
+ import { Decoration, showPanel, EditorView, ViewPlugin, hoverTooltip, logException, gutter, showTooltip, getPanel, WidgetType, GutterMarker } from '@codemirror/view';
2
+ import { StateEffect, StateField, Facet, RangeSet, combineConfig } from '@codemirror/state';
7
3
  import elt from 'crelt';
8
4
 
9
5
  class SelectedDiagnostic {
@@ -603,8 +599,8 @@ function trackHoverOn(view, marker) {
603
599
  }
604
600
  function gutterMarkerMouseOver(view, marker, diagnostics) {
605
601
  function hovered() {
606
- let line = view.visualLineAtHeight(marker.getBoundingClientRect().top + 5 - view.documentTop);
607
- const linePos = view.coordsAtPos(line.from), markerRect = marker.getBoundingClientRect();
602
+ let line = view.elementAtHeight(marker.getBoundingClientRect().top + 5 - view.documentTop);
603
+ const linePos = view.coordsAtPos(line.from);
608
604
  if (linePos) {
609
605
  view.dispatch({ effects: setLintGutterTooltip.of({
610
606
  pos: line.from,
@@ -612,7 +608,7 @@ function gutterMarkerMouseOver(view, marker, diagnostics) {
612
608
  create() {
613
609
  return {
614
610
  dom: diagnosticsTooltip(view, diagnostics),
615
- offset: { x: markerRect.left - linePos.left, y: 0 }
611
+ getCoords: () => marker.getBoundingClientRect()
616
612
  };
617
613
  }
618
614
  }) });
@@ -674,15 +670,12 @@ const lintGutterTheme = /*@__PURE__*/EditorView.baseTheme({
674
670
  ".cm-gutter-lint": {
675
671
  width: "1.4em",
676
672
  "& .cm-gutterElement": {
677
- padding: "0 .2em",
678
- display: "flex",
679
- flexDirection: "column",
680
- justifyContent: "center",
673
+ padding: ".2em"
681
674
  }
682
675
  },
683
676
  ".cm-lint-marker": {
684
677
  width: "1em",
685
- height: "1em",
678
+ height: "1em"
686
679
  },
687
680
  ".cm-lint-marker-info": {
688
681
  content: /*@__PURE__*/svg(`<path fill="#aaf" stroke="#77e" stroke-width="6" stroke-linejoin="round" d="M5 5L35 5L35 35L5 35Z"/>`)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codemirror/lint",
3
- "version": "0.19.4",
3
+ "version": "0.20.0",
4
4
  "description": "Linting support for the CodeMirror code editor",
5
5
  "scripts": {
6
6
  "test": "cm-runtests",
@@ -26,12 +26,8 @@
26
26
  "sideEffects": false,
27
27
  "license": "MIT",
28
28
  "dependencies": {
29
- "@codemirror/gutter": "^0.19.4",
30
- "@codemirror/panel": "^0.19.0",
31
- "@codemirror/rangeset": "^0.19.1",
32
- "@codemirror/state": "^0.19.4",
33
- "@codemirror/tooltip": "^0.19.5",
34
- "@codemirror/view": "^0.19.22",
29
+ "@codemirror/state": "^0.20.0",
30
+ "@codemirror/view": "^0.20.0",
35
31
  "crelt": "^1.0.5"
36
32
  },
37
33
  "devDependencies": {