Socket
Socket
Sign inDemoInstall

@codemirror/autocomplete

Package Overview
Dependencies
Maintainers
2
Versions
76
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@codemirror/autocomplete - npm Package Compare versions

Comparing version 0.19.14 to 0.19.15

10

CHANGELOG.md

@@ -0,1 +1,11 @@

## 0.19.15 (2022-03-23)
### New features
The `selectedCompletionIndex` function tells you the position of the currently selected completion.
The new `setSelectionCompletion` function creates a state effect that moves the selected completion to a given index.
A completion's `info` method may now return null to indicate that no further info is available.
## 0.19.14 (2022-03-10)

@@ -2,0 +12,0 @@

16

dist/index.d.ts
import * as _codemirror_state from '@codemirror/state';
import { EditorState, Transaction, StateCommand, Facet, Extension } from '@codemirror/state';
import { EditorState, Transaction, StateCommand, Facet, Extension, StateEffect } from '@codemirror/state';
import { EditorView, KeyBinding, Command } from '@codemirror/view';

@@ -84,3 +84,3 @@ import * as _lezer_common from '@lezer/common';

*/
info?: string | ((completion: Completion) => (Node | Promise<Node>));
info?: string | ((completion: Completion) => (Node | null | Promise<Node | null>));
/**

@@ -366,3 +366,13 @@ How to apply the completion. The default is to replace it with

declare function selectedCompletion(state: EditorState): Completion | null;
/**
Returns the currently selected position in the active completion
list, or null if no completions are active.
*/
declare function selectedCompletionIndex(state: EditorState): number | null;
/**
Create an effect that can be attached to a transaction to change
the currently selected completion.
*/
declare function setSelectedCompletion(index: number): StateEffect<unknown>;
export { Completion, CompletionContext, CompletionResult, CompletionSource, acceptCompletion, autocompletion, clearSnippet, closeCompletion, completeAnyWord, completeFromList, completionKeymap, completionStatus, currentCompletions, ifIn, ifNotIn, moveCompletionSelection, nextSnippetField, pickedCompletion, prevSnippetField, selectedCompletion, snippet, snippetCompletion, snippetKeymap, startCompletion };
export { Completion, CompletionContext, CompletionResult, CompletionSource, acceptCompletion, autocompletion, clearSnippet, closeCompletion, completeAnyWord, completeFromList, completionKeymap, completionStatus, currentCompletions, ifIn, ifNotIn, moveCompletionSelection, nextSnippetField, pickedCompletion, prevSnippetField, selectedCompletion, selectedCompletionIndex, setSelectedCompletion, snippet, snippetCompletion, snippetKeymap, startCompletion };

70

dist/index.js
import { Annotation, Facet, combineConfig, StateEffect, StateField, Prec, EditorSelection, Text, MapMode } from '@codemirror/state';
import { Direction, logException, EditorView, ViewPlugin, Decoration, WidgetType, keymap } from '@codemirror/view';
import { logException, Direction, EditorView, ViewPlugin, Decoration, WidgetType, keymap } from '@codemirror/view';
import { showTooltip, getTooltip } from '@codemirror/tooltip';

@@ -373,18 +373,2 @@ import { syntaxTree, indentUnit } from '@codemirror/language';

}
function createInfoDialog(option, view) {
let dom = document.createElement("div");
dom.className = "cm-tooltip cm-completionInfo";
let { info } = option.completion;
if (typeof info == "string") {
dom.textContent = info;
}
else {
let content = info(option.completion);
if (content.then)
content.then(node => dom.appendChild(node), e => logException(view.state, e, "completion info"));
else
dom.appendChild(content);
}
return dom;
}
function rangeAroundSelected(total, selected, max) {

@@ -458,9 +442,27 @@ if (total <= max)

}
let option = open.options[open.selected];
if (option.completion.info) {
this.info = this.dom.appendChild(createInfoDialog(option, this.view));
this.view.requestMeasure(this.placeInfo);
let { completion } = open.options[open.selected];
let { info } = completion;
if (!info)
return;
let infoResult = typeof info === 'string' ? document.createTextNode(info) : info(completion);
if (!infoResult)
return;
if ('then' in infoResult) {
infoResult.then(node => {
if (node && this.view.state.field(this.stateField, false) == cState)
this.addInfoPane(node);
}).catch(e => logException(this.view.state, e, "completion info"));
}
else {
this.addInfoPane(infoResult);
}
}
}
addInfoPane(content) {
let dom = this.info = document.createElement("div");
dom.className = "cm-tooltip cm-completionInfo";
dom.appendChild(content);
this.dom.appendChild(dom);
this.view.requestMeasure(this.placeInfo);
}
updateSelectedOption(selected) {

@@ -1436,2 +1438,3 @@ let set = null;

}
const completionArrayCache = /*@__PURE__*/new WeakMap;
/**

@@ -1443,3 +1446,8 @@ Returns the available completions as an array.

let open = (_a = state.field(completionState, false)) === null || _a === void 0 ? void 0 : _a.open;
return open ? open.options.map(o => o.completion) : [];
if (!open)
return [];
let completions = completionArrayCache.get(open.options);
if (!completions)
completionArrayCache.set(open.options, completions = open.options.map(o => o.completion));
return completions;
}

@@ -1454,3 +1462,19 @@ /**

}
/**
Returns the currently selected position in the active completion
list, or null if no completions are active.
*/
function selectedCompletionIndex(state) {
var _a;
let open = (_a = state.field(completionState, false)) === null || _a === void 0 ? void 0 : _a.open;
return open ? open.selected : null;
}
/**
Create an effect that can be attached to a transaction to change
the currently selected completion.
*/
function setSelectedCompletion(index) {
return setSelectedEffect.of(index);
}
export { CompletionContext, acceptCompletion, autocompletion, clearSnippet, closeCompletion, completeAnyWord, completeFromList, completionKeymap, completionStatus, currentCompletions, ifIn, ifNotIn, moveCompletionSelection, nextSnippetField, pickedCompletion, prevSnippetField, selectedCompletion, snippet, snippetCompletion, snippetKeymap, startCompletion };
export { CompletionContext, acceptCompletion, autocompletion, clearSnippet, closeCompletion, completeAnyWord, completeFromList, completionKeymap, completionStatus, currentCompletions, ifIn, ifNotIn, moveCompletionSelection, nextSnippetField, pickedCompletion, prevSnippetField, selectedCompletion, selectedCompletionIndex, setSelectedCompletion, snippet, snippetCompletion, snippetKeymap, startCompletion };
{
"name": "@codemirror/autocomplete",
"version": "0.19.14",
"version": "0.19.15",
"description": "Autocompletion for the CodeMirror code editor",

@@ -5,0 +5,0 @@ "scripts": {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc