@codemirror/view 6.31.0 → 6.32.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,13 @@
1
+ ## 6.32.0 (2024-08-12)
2
+
3
+ ### Bug fixes
4
+
5
+ Fix a bug where the editor could draw way too big a viewport when not managing its own scrollbar.
6
+
7
+ ### New features
8
+
9
+ The new `gutterWidgetClass` facet makes it possible to add a class to gutter elements next to widgets.
10
+
1
11
  ## 6.31.0 (2024-08-11)
2
12
 
3
13
  ### Bug fixes
package/dist/index.cjs CHANGED
@@ -5740,7 +5740,7 @@ function visiblePixelRange(dom, paddingTop) {
5740
5740
  left = Math.max(left, parentRect.left);
5741
5741
  right = Math.min(right, parentRect.right);
5742
5742
  top = Math.max(top, parentRect.top);
5743
- bottom = parent == dom.parentNode ? parentRect.bottom : Math.min(bottom, parentRect.bottom);
5743
+ bottom = Math.min(parent == dom.parentNode ? win.innerHeight : bottom, parentRect.bottom);
5744
5744
  }
5745
5745
  parent = style.position == "absolute" || style.position == "fixed" ? elt.offsetParent : elt.parentNode;
5746
5746
  }
@@ -10552,6 +10552,11 @@ Markers given to this facet should _only_ define an
10552
10552
  in all gutters for the line).
10553
10553
  */
10554
10554
  const gutterLineClass = state.Facet.define();
10555
+ /**
10556
+ Facet used to add a class to all gutter elements next to a widget.
10557
+ Should not provide widgets with a `toDOM` method.
10558
+ */
10559
+ const gutterWidgetClass = state.Facet.define();
10555
10560
  const defaults = {
10556
10561
  class: "",
10557
10562
  renderEmptyElements: false,
@@ -10762,9 +10767,14 @@ class UpdateContext {
10762
10767
  this.addElement(view, line, localMarkers);
10763
10768
  }
10764
10769
  widget(view, block) {
10765
- let marker = this.gutter.config.widgetMarker(view, block.widget, block);
10766
- if (marker)
10767
- this.addElement(view, block, [marker]);
10770
+ let marker = this.gutter.config.widgetMarker(view, block.widget, block), markers = marker ? [marker] : null;
10771
+ for (let cls of view.state.facet(gutterWidgetClass)) {
10772
+ let marker = cls(view, block.widget, block);
10773
+ if (marker)
10774
+ (markers || (markers = [])).push(marker);
10775
+ }
10776
+ if (markers)
10777
+ this.addElement(view, block, markers);
10768
10778
  }
10769
10779
  finish() {
10770
10780
  let gutter = this.gutter;
@@ -11075,6 +11085,7 @@ exports.getPanel = getPanel;
11075
11085
  exports.getTooltip = getTooltip;
11076
11086
  exports.gutter = gutter;
11077
11087
  exports.gutterLineClass = gutterLineClass;
11088
+ exports.gutterWidgetClass = gutterWidgetClass;
11078
11089
  exports.gutters = gutters;
11079
11090
  exports.hasHoverTooltips = hasHoverTooltips;
11080
11091
  exports.highlightActiveLine = highlightActiveLine;
package/dist/index.d.cts CHANGED
@@ -2088,6 +2088,11 @@ Markers given to this facet should _only_ define an
2088
2088
  in all gutters for the line).
2089
2089
  */
2090
2090
  declare const gutterLineClass: Facet<RangeSet<GutterMarker>, readonly RangeSet<GutterMarker>[]>;
2091
+ /**
2092
+ Facet used to add a class to all gutter elements next to a widget.
2093
+ Should not provide widgets with a `toDOM` method.
2094
+ */
2095
+ declare const gutterWidgetClass: Facet<(view: EditorView, widget: WidgetType, block: BlockInfo) => GutterMarker | null, readonly ((view: EditorView, widget: WidgetType, block: BlockInfo) => GutterMarker | null)[]>;
2091
2096
  type Handlers = {
2092
2097
  [event: string]: (view: EditorView, line: BlockInfo, event: Event) => boolean;
2093
2098
  };
@@ -2195,4 +2200,4 @@ trailing whitespace.
2195
2200
  */
2196
2201
  declare function highlightTrailingWhitespace(): Extension;
2197
2202
 
2198
- export { BidiSpan, BlockInfo, BlockType, type Command, type DOMEventHandlers, type DOMEventMap, Decoration, type DecorationSet, Direction, EditorView, type EditorViewConfig, GutterMarker, type HoverTooltipSource, type KeyBinding, type LayerMarker, MatchDecorator, type MouseSelectionStyle, type Panel, type PanelConstructor, type PluginSpec, type PluginValue, type Rect, RectangleMarker, type Tooltip, type TooltipView, ViewPlugin, ViewUpdate, WidgetType, closeHoverTooltips, crosshairCursor, drawSelection, dropCursor, getDrawSelectionConfig, getPanel, getTooltip, gutter, gutterLineClass, gutters, hasHoverTooltips, highlightActiveLine, highlightActiveLineGutter, highlightSpecialChars, highlightTrailingWhitespace, highlightWhitespace, hoverTooltip, keymap, layer, lineNumberMarkers, lineNumberWidgetMarker, lineNumbers, logException, panels, placeholder, rectangularSelection, repositionTooltips, runScopeHandlers, scrollPastEnd, showPanel, showTooltip, tooltips };
2203
+ export { BidiSpan, BlockInfo, BlockType, type Command, type DOMEventHandlers, type DOMEventMap, Decoration, type DecorationSet, Direction, EditorView, type EditorViewConfig, GutterMarker, type HoverTooltipSource, type KeyBinding, type LayerMarker, MatchDecorator, type MouseSelectionStyle, type Panel, type PanelConstructor, type PluginSpec, type PluginValue, type Rect, RectangleMarker, type Tooltip, type TooltipView, ViewPlugin, ViewUpdate, WidgetType, closeHoverTooltips, crosshairCursor, drawSelection, dropCursor, getDrawSelectionConfig, getPanel, getTooltip, gutter, gutterLineClass, gutterWidgetClass, gutters, hasHoverTooltips, highlightActiveLine, highlightActiveLineGutter, highlightSpecialChars, highlightTrailingWhitespace, highlightWhitespace, hoverTooltip, keymap, layer, lineNumberMarkers, lineNumberWidgetMarker, lineNumbers, logException, panels, placeholder, rectangularSelection, repositionTooltips, runScopeHandlers, scrollPastEnd, showPanel, showTooltip, tooltips };
package/dist/index.d.ts CHANGED
@@ -2088,6 +2088,11 @@ Markers given to this facet should _only_ define an
2088
2088
  in all gutters for the line).
2089
2089
  */
2090
2090
  declare const gutterLineClass: Facet<RangeSet<GutterMarker>, readonly RangeSet<GutterMarker>[]>;
2091
+ /**
2092
+ Facet used to add a class to all gutter elements next to a widget.
2093
+ Should not provide widgets with a `toDOM` method.
2094
+ */
2095
+ declare const gutterWidgetClass: Facet<(view: EditorView, widget: WidgetType, block: BlockInfo) => GutterMarker | null, readonly ((view: EditorView, widget: WidgetType, block: BlockInfo) => GutterMarker | null)[]>;
2091
2096
  type Handlers = {
2092
2097
  [event: string]: (view: EditorView, line: BlockInfo, event: Event) => boolean;
2093
2098
  };
@@ -2195,4 +2200,4 @@ trailing whitespace.
2195
2200
  */
2196
2201
  declare function highlightTrailingWhitespace(): Extension;
2197
2202
 
2198
- export { BidiSpan, BlockInfo, BlockType, type Command, type DOMEventHandlers, type DOMEventMap, Decoration, type DecorationSet, Direction, EditorView, type EditorViewConfig, GutterMarker, type HoverTooltipSource, type KeyBinding, type LayerMarker, MatchDecorator, type MouseSelectionStyle, type Panel, type PanelConstructor, type PluginSpec, type PluginValue, type Rect, RectangleMarker, type Tooltip, type TooltipView, ViewPlugin, ViewUpdate, WidgetType, closeHoverTooltips, crosshairCursor, drawSelection, dropCursor, getDrawSelectionConfig, getPanel, getTooltip, gutter, gutterLineClass, gutters, hasHoverTooltips, highlightActiveLine, highlightActiveLineGutter, highlightSpecialChars, highlightTrailingWhitespace, highlightWhitespace, hoverTooltip, keymap, layer, lineNumberMarkers, lineNumberWidgetMarker, lineNumbers, logException, panels, placeholder, rectangularSelection, repositionTooltips, runScopeHandlers, scrollPastEnd, showPanel, showTooltip, tooltips };
2203
+ export { BidiSpan, BlockInfo, BlockType, type Command, type DOMEventHandlers, type DOMEventMap, Decoration, type DecorationSet, Direction, EditorView, type EditorViewConfig, GutterMarker, type HoverTooltipSource, type KeyBinding, type LayerMarker, MatchDecorator, type MouseSelectionStyle, type Panel, type PanelConstructor, type PluginSpec, type PluginValue, type Rect, RectangleMarker, type Tooltip, type TooltipView, ViewPlugin, ViewUpdate, WidgetType, closeHoverTooltips, crosshairCursor, drawSelection, dropCursor, getDrawSelectionConfig, getPanel, getTooltip, gutter, gutterLineClass, gutterWidgetClass, gutters, hasHoverTooltips, highlightActiveLine, highlightActiveLineGutter, highlightSpecialChars, highlightTrailingWhitespace, highlightWhitespace, hoverTooltip, keymap, layer, lineNumberMarkers, lineNumberWidgetMarker, lineNumbers, logException, panels, placeholder, rectangularSelection, repositionTooltips, runScopeHandlers, scrollPastEnd, showPanel, showTooltip, tooltips };
package/dist/index.js CHANGED
@@ -5735,7 +5735,7 @@ function visiblePixelRange(dom, paddingTop) {
5735
5735
  left = Math.max(left, parentRect.left);
5736
5736
  right = Math.min(right, parentRect.right);
5737
5737
  top = Math.max(top, parentRect.top);
5738
- bottom = parent == dom.parentNode ? parentRect.bottom : Math.min(bottom, parentRect.bottom);
5738
+ bottom = Math.min(parent == dom.parentNode ? win.innerHeight : bottom, parentRect.bottom);
5739
5739
  }
5740
5740
  parent = style.position == "absolute" || style.position == "fixed" ? elt.offsetParent : elt.parentNode;
5741
5741
  }
@@ -10547,6 +10547,11 @@ Markers given to this facet should _only_ define an
10547
10547
  in all gutters for the line).
10548
10548
  */
10549
10549
  const gutterLineClass = /*@__PURE__*/Facet.define();
10550
+ /**
10551
+ Facet used to add a class to all gutter elements next to a widget.
10552
+ Should not provide widgets with a `toDOM` method.
10553
+ */
10554
+ const gutterWidgetClass = /*@__PURE__*/Facet.define();
10550
10555
  const defaults = {
10551
10556
  class: "",
10552
10557
  renderEmptyElements: false,
@@ -10757,9 +10762,14 @@ class UpdateContext {
10757
10762
  this.addElement(view, line, localMarkers);
10758
10763
  }
10759
10764
  widget(view, block) {
10760
- let marker = this.gutter.config.widgetMarker(view, block.widget, block);
10761
- if (marker)
10762
- this.addElement(view, block, [marker]);
10765
+ let marker = this.gutter.config.widgetMarker(view, block.widget, block), markers = marker ? [marker] : null;
10766
+ for (let cls of view.state.facet(gutterWidgetClass)) {
10767
+ let marker = cls(view, block.widget, block);
10768
+ if (marker)
10769
+ (markers || (markers = [])).push(marker);
10770
+ }
10771
+ if (markers)
10772
+ this.addElement(view, block, markers);
10763
10773
  }
10764
10774
  finish() {
10765
10775
  let gutter = this.gutter;
@@ -11050,4 +11060,4 @@ function highlightTrailingWhitespace() {
11050
11060
  const __test = { HeightMap, HeightOracle, MeasuredHeights, QueryType, ChangedRange, computeOrder,
11051
11061
  moveVisually, clearHeightChangeFlag, getHeightChangeFlag: () => heightChangeFlag };
11052
11062
 
11053
- export { BidiSpan, BlockInfo, BlockType, Decoration, Direction, EditorView, GutterMarker, MatchDecorator, RectangleMarker, ViewPlugin, ViewUpdate, WidgetType, __test, closeHoverTooltips, crosshairCursor, drawSelection, dropCursor, getDrawSelectionConfig, getPanel, getTooltip, gutter, gutterLineClass, gutters, hasHoverTooltips, highlightActiveLine, highlightActiveLineGutter, highlightSpecialChars, highlightTrailingWhitespace, highlightWhitespace, hoverTooltip, keymap, layer, lineNumberMarkers, lineNumberWidgetMarker, lineNumbers, logException, panels, placeholder, rectangularSelection, repositionTooltips, runScopeHandlers, scrollPastEnd, showPanel, showTooltip, tooltips };
11063
+ export { BidiSpan, BlockInfo, BlockType, Decoration, Direction, EditorView, GutterMarker, MatchDecorator, RectangleMarker, ViewPlugin, ViewUpdate, WidgetType, __test, closeHoverTooltips, crosshairCursor, drawSelection, dropCursor, getDrawSelectionConfig, getPanel, getTooltip, gutter, gutterLineClass, gutterWidgetClass, gutters, hasHoverTooltips, highlightActiveLine, highlightActiveLineGutter, highlightSpecialChars, highlightTrailingWhitespace, highlightWhitespace, hoverTooltip, keymap, layer, lineNumberMarkers, lineNumberWidgetMarker, lineNumbers, logException, panels, placeholder, rectangularSelection, repositionTooltips, runScopeHandlers, scrollPastEnd, showPanel, showTooltip, tooltips };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codemirror/view",
3
- "version": "6.31.0",
3
+ "version": "6.32.0",
4
4
  "description": "DOM view component for the CodeMirror code editor",
5
5
  "scripts": {
6
6
  "test": "cm-runtests",