@codemirror/autocomplete 0.19.11 → 0.19.12

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,9 @@
1
+ ## 0.19.12 (2022-01-11)
2
+
3
+ ### Bug fixes
4
+
5
+ Fix completion navigation with PageUp/Down when the completion tooltip isn't part of the view DOM.
6
+
1
7
  ## 0.19.11 (2022-01-11)
2
8
 
3
9
  ### Bug fixes
package/dist/index.cjs CHANGED
@@ -781,9 +781,10 @@ function moveCompletionSelection(forward, by = "option") {
781
781
  let cState = view.state.field(completionState, false);
782
782
  if (!cState || !cState.open || Date.now() - cState.open.timestamp < CompletionInteractMargin)
783
783
  return false;
784
- let step = 1, tooltip;
785
- if (by == "page" && (tooltip = view.dom.querySelector(".cm-tooltip-autocomplete")))
786
- step = Math.max(2, Math.floor(tooltip.offsetHeight / tooltip.querySelector("li").offsetHeight) - 1);
784
+ let step = 1, tooltip$1;
785
+ if (by == "page" && (tooltip$1 = tooltip.getTooltip(view, cState.open.tooltip)))
786
+ step = Math.max(2, Math.floor(tooltip$1.dom.offsetHeight /
787
+ tooltip$1.dom.querySelector("li").offsetHeight) - 1);
787
788
  let selected = cState.open.selected + step * (forward ? 1 : -1), { length } = cState.open.options;
788
789
  if (selected < 0)
789
790
  selected = by == "page" ? 0 : length - 1;
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Annotation, Facet, combineConfig, StateEffect, StateField, Prec, EditorSelection, Text } from '@codemirror/state';
2
2
  import { Direction, logException, EditorView, ViewPlugin, Decoration, WidgetType, keymap } from '@codemirror/view';
3
- import { showTooltip } from '@codemirror/tooltip';
3
+ import { showTooltip, getTooltip } from '@codemirror/tooltip';
4
4
  import { syntaxTree, indentUnit } from '@codemirror/language';
5
5
  import { codePointAt, codePointSize, fromCodePoint } from '@codemirror/text';
6
6
 
@@ -778,8 +778,9 @@ function moveCompletionSelection(forward, by = "option") {
778
778
  if (!cState || !cState.open || Date.now() - cState.open.timestamp < CompletionInteractMargin)
779
779
  return false;
780
780
  let step = 1, tooltip;
781
- if (by == "page" && (tooltip = view.dom.querySelector(".cm-tooltip-autocomplete")))
782
- step = Math.max(2, Math.floor(tooltip.offsetHeight / tooltip.querySelector("li").offsetHeight) - 1);
781
+ if (by == "page" && (tooltip = getTooltip(view, cState.open.tooltip)))
782
+ step = Math.max(2, Math.floor(tooltip.dom.offsetHeight /
783
+ tooltip.dom.querySelector("li").offsetHeight) - 1);
783
784
  let selected = cState.open.selected + step * (forward ? 1 : -1), { length } = cState.open.options;
784
785
  if (selected < 0)
785
786
  selected = by == "page" ? 0 : length - 1;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codemirror/autocomplete",
3
- "version": "0.19.11",
3
+ "version": "0.19.12",
4
4
  "description": "Autocompletion for the CodeMirror code editor",
5
5
  "scripts": {
6
6
  "test": "cm-runtests",
@@ -29,7 +29,7 @@
29
29
  "@codemirror/language": "^0.19.0",
30
30
  "@codemirror/state": "^0.19.4",
31
31
  "@codemirror/text": "^0.19.2",
32
- "@codemirror/tooltip": "^0.19.0",
32
+ "@codemirror/tooltip": "^0.19.12",
33
33
  "@codemirror/view": "^0.19.0",
34
34
  "@lezer/common": "^0.15.0"
35
35
  },