Socket
Socket
Sign inDemoInstall

@codemirror/autocomplete

Package Overview
Dependencies
Maintainers
2
Versions
77
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.18.0 to 0.18.1

10

CHANGELOG.md

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

## 0.18.1 (2021-03-11)
### Bug fixes
Stop active completion when all sources resolve without producing any matches.
### New features
`Completion.info` may now return a promise.
## 0.18.0 (2021-03-03)

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

240

dist/index.d.ts

@@ -6,21 +6,119 @@ import { EditorState, Transaction, StateCommand, Facet, Extension } from '@codemirror/state';

interface CompletionConfig {
/**
When enabled (defaults to true), autocompletion will start
whenever the user types something that can be completed.
*/
activateOnTyping?: boolean;
/**
Override the completion sources used. By default, they will be
taken from the `"autocomplete"` [language
data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt) (which should hold
[completion sources](https://codemirror.net/6/docs/ref/#autocomplete.CompletionSource)).
*/
override?: readonly CompletionSource[] | null;
/**
The maximum number of options to render to the DOM.
*/
maxRenderedOptions?: number;
/**
Set this to false to disable the [default completion
keymap](https://codemirror.net/6/docs/ref/#autocomplete.completionKeymap). (This requires you to
add bindings to control completion yourself. The bindings should
probably have a higher precedence than other bindings for the
same keys.)
*/
defaultKeymap?: boolean;
}
/**
Objects type used to represent individual completions.
*/
interface Completion {
/**
The label to show in the completion picker. This is what input
is matched agains to determine whether a completion matches (and
how well it matches).
*/
label: string;
/**
An optional short piece of information to show (with a different
style) after the label.
*/
detail?: string;
info?: string | ((completion: Completion) => Node);
/**
Additional info to show when the completion is selected. Can be
a plain string or a function that'll render the DOM structure to
show when invoked.
*/
info?: string | ((completion: Completion) => (Node | Promise<Node>));
/**
How to apply the completion. The default is to replace it with
its [label](https://codemirror.net/6/docs/ref/#autocomplete.Completion.label). When this holds a
string, the completion range is replaced by that string. When it
is a function, that function is called to perform the
completion.
*/
apply?: string | ((view: EditorView, completion: Completion, from: number, to: number) => void);
/**
The type of the completion. This is used to pick an icon to show
for the completion. Icons are styled with a CSS class created by
appending the type name to `"cm-completionIcon-"`. You can
define or restyle icons by defining these selectors. The base
library defines simple icons for `class`, `constant`, `enum`,
`function`, `interface`, `keyword`, `method`, `namespace`,
`property`, `text`, `type`, and `variable`.
*/
type?: string;
/**
When given, should be a number from -99 to 99 that adjusts how
this completion is ranked compared to other completions that
match the input as well as this one. A negative number moves it
down the list, a positive number moves it up.
*/
boost?: number;
}
/**
An instance of this is passed to completion source functions.
*/
declare class CompletionContext {
/**
The editor state that the completion happens in.
*/
readonly state: EditorState;
/**
The position at which the completion is happening.
*/
readonly pos: number;
/**
Indicates whether completion was activated explicitly, or
implicitly by typing. The usual way to respond to this is to
only return completions when either there is part of a
completable entity before the cursor, or `explicit` is true.
*/
readonly explicit: boolean;
constructor(state: EditorState, pos: number, explicit: boolean);
/**
Create a new completion context. (Mostly useful for testing
completion sources—in the editor, the extension will create
these for you.)
*/
constructor(
/**
The editor state that the completion happens in.
*/
state: EditorState,
/**
The position at which the completion is happening.
*/
pos: number,
/**
Indicates whether completion was activated explicitly, or
implicitly by typing. The usual way to respond to this is to
only return completions when either there is part of a
completable entity before the cursor, or `explicit` is true.
*/
explicit: boolean);
/**
Get the extent, content, and (if there is a token) type of the
token before `this.pos`.
*/
tokenBefore(types: readonly string[]): {

@@ -32,2 +130,6 @@ from: number;

} | null;
/**
Get the match of the given expression directly before the
cursor.
*/
matchBefore(expr: RegExp): {

@@ -38,15 +140,87 @@ from: number;

} | null;
/**
Yields true when the query has been aborted. Can be useful in
asynchronous queries to avoid doing work that will be ignored.
*/
get aborted(): boolean;
/**
Allows you to register abort handlers, which will be called when
the query is
[aborted](https://codemirror.net/6/docs/ref/#autocomplete.CompletionContext.aborted).
*/
addEventListener(type: "abort", listener: () => void): void;
}
/**
Given a a fixed array of options, return an autocompleter that
completes them.
*/
declare function completeFromList(list: readonly (string | Completion)[]): CompletionSource;
/**
Wrap the given completion source so that it will not fire when the
cursor is in a syntax node with one of the given names.
*/
declare function ifNotIn(nodes: readonly string[], source: CompletionSource): CompletionSource;
/**
The function signature for a completion source. Such a function
may return its [result](https://codemirror.net/6/docs/ref/#autocomplete.CompletionResult)
synchronously or as a promise. Returning null indicates no
completions are available.
*/
declare type CompletionSource = (context: CompletionContext) => CompletionResult | null | Promise<CompletionResult | null>;
/**
Interface for objects returned by completion sources.
*/
interface CompletionResult {
/**
The start of the range that is being completed.
*/
from: number;
/**
The end of the range that is being completed. Defaults to the
main cursor position.
*/
to?: number;
/**
The completions returned. These don't have to be compared with
the input by the source—the autocompletion system will do its
own matching (against the text between `from` and `to`) and
sorting.
*/
options: readonly Completion[];
/**
When given, further input that causes the part of the document
between ([mapped](https://codemirror.net/6/docs/ref/#state.ChangeDesc.mapPos)) `from` and `to` to
match this regular expression will not query the completion
source again, but continue with this list of options. This can
help a lot with responsiveness, since it allows the completion
list to be updated synchronously.
*/
span?: RegExp;
}
/**
Convert a snippet template to a function that can apply it.
Snippets are written using syntax like this:
"for (let ${index} = 0; ${index} < ${end}; ${index}++) {\n\t${}\n}"
Each `${}` placeholder (you may also use `#{}`) indicates a field
that the user can fill in. Its name, if any, will be the default
content for the field.
When the snippet is activated by calling the returned function,
the code is inserted at the given position. Newlines in the
template are indented by the indentation of the start line, plus
one [indent unit](https://codemirror.net/6/docs/ref/#language.indentUnit) per tab character after
the newline.
On activation, (all instances of) the first field are selected.
The user can move between fields with Tab and Shift-Tab as long as
the fields are active. Moving to the last field or moving the
cursor out of the current field deactivates the fields.
The order of fields defaults to textual order, but you can add
numbers to placeholders (`${1}` or `${1:defaultText}`) to provide
a custom order.
*/
declare function snippet(template: string): (editor: {

@@ -56,20 +230,82 @@ state: EditorState;

}, _completion: Completion, from: number, to: number) => void;
/**
A command that clears the active snippet, if any.
*/
declare const clearSnippet: StateCommand;
/**
Move to the next snippet field, if available.
*/
declare const nextSnippetField: StateCommand;
/**
Move to the previous snippet field, if available.
*/
declare const prevSnippetField: StateCommand;
/**
A facet that can be used to configure the key bindings used by
snippets. The default binds Tab to
[`nextSnippetField`](https://codemirror.net/6/docs/ref/#autocomplete.nextSnippetField), Shift-Tab to
[`prevSnippetField`](https://codemirror.net/6/docs/ref/#autocomplete.prevSnippetField), and Escape
to [`clearSnippet`](https://codemirror.net/6/docs/ref/#autocomplete.clearSnippet).
*/
declare const snippetKeymap: Facet<readonly KeyBinding[], readonly KeyBinding[]>;
/**
Create a completion from a snippet. Returns an object with the
properties from `completion`, plus an `apply` function that
applies the snippet.
*/
declare function snippetCompletion(template: string, completion: Completion): Completion;
/**
Returns a command that moves the completion selection forward or
backward by the given amount.
*/
declare function moveCompletionSelection(forward: boolean, by?: "option" | "page"): Command;
/**
Accept the current completion.
*/
declare const acceptCompletion: Command;
/**
Explicitly start autocompletion.
*/
declare const startCompletion: Command;
/**
Close the currently active completion.
*/
declare const closeCompletion: Command;
/**
A completion source that will scan the document for words (using a
[character categorizer](https://codemirror.net/6/docs/ref/#state.EditorState.charCategorizer)), and
return those as completions.
*/
declare const completeAnyWord: CompletionSource;
/**
Returns an extension that enables autocompletion.
*/
declare function autocompletion(config?: CompletionConfig): Extension;
/**
Basic keybindings for autocompletion.
- Ctrl-Space: [`startCompletion`](https://codemirror.net/6/docs/ref/#autocomplete.startCompletion)
- Escape: [`closeCompletion`](https://codemirror.net/6/docs/ref/#autocomplete.closeCompletion)
- ArrowDown: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(true)`
- ArrowUp: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(false)`
- PageDown: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(true, "page")`
- PageDown: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(true, "page")`
- Enter: [`acceptCompletion`](https://codemirror.net/6/docs/ref/#autocomplete.acceptCompletion)
*/
declare const completionKeymap: readonly KeyBinding[];
/**
Get the current completion status. When completions are available,
this will return `"active"`. When completions are pending (in the
process of being queried), this returns `"pending"`. Otherwise, it
returns `null`.
*/
declare function completionStatus(state: EditorState): null | "active" | "pending";
/**
Returns the available completions as an array.
*/
declare function currentCompletions(state: EditorState): readonly Completion[];
export { Completion, CompletionContext, CompletionResult, CompletionSource, acceptCompletion, autocompletion, clearSnippet, closeCompletion, completeAnyWord, completeFromList, completionKeymap, completionStatus, currentCompletions, ifNotIn, moveCompletionSelection, nextSnippetField, prevSnippetField, snippet, snippetCompletion, snippetKeymap, startCompletion };

253

dist/index.js
import { showTooltip, tooltips } from '@codemirror/tooltip';
import { Facet, combineConfig, StateEffect, StateField, Transaction, Text, EditorSelection, Prec, CharCategory } from '@codemirror/state';
import { EditorView, Direction, ViewPlugin, logException, Decoration, WidgetType, keymap } from '@codemirror/view';
import { EditorView, Direction, logException, ViewPlugin, Decoration, WidgetType, keymap } from '@codemirror/view';
import { syntaxTree, indentUnit } from '@codemirror/language';
import { codePointAt, codePointSize, fromCodePoint } from '@codemirror/text';
/// An instance of this is passed to completion source functions.
/**
An instance of this is passed to completion source functions.
*/
class CompletionContext {
/// Create a new completion context. (Mostly useful for testing
/// completion sources—in the editor, the extension will create
/// these for you.)
/**
Create a new completion context. (Mostly useful for testing
completion sources—in the editor, the extension will create
these for you.)
*/
constructor(
/// The editor state that the completion happens in.
/**
The editor state that the completion happens in.
*/
state,
/// The position at which the completion is happening.
/**
The position at which the completion is happening.
*/
pos,
/// Indicates whether completion was activated explicitly, or
/// implicitly by typing. The usual way to respond to this is to
/// only return completions when either there is part of a
/// completable entity before the cursor, or `explicit` is true.
/**
Indicates whether completion was activated explicitly, or
implicitly by typing. The usual way to respond to this is to
only return completions when either there is part of a
completable entity before the cursor, or `explicit` is true.
*/
explicit) {

@@ -25,7 +35,11 @@ this.state = state;

this.explicit = explicit;
/// @internal
/**
@internal
*/
this.abortListeners = [];
}
/// Get the extent, content, and (if there is a token) type of the
/// token before `this.pos`.
/**
Get the extent, content, and (if there is a token) type of the
token before `this.pos`.
*/
tokenBefore(types) {

@@ -39,4 +53,6 @@ let token = syntaxTree(this.state).resolve(this.pos, -1);

}
/// Get the match of the given expression directly before the
/// cursor.
/**
Get the match of the given expression directly before the
cursor.
*/
matchBefore(expr) {

@@ -49,8 +65,12 @@ let line = this.state.doc.lineAt(this.pos);

}
/// Yields true when the query has been aborted. Can be useful in
/// asynchronous queries to avoid doing work that will be ignored.
/**
Yields true when the query has been aborted. Can be useful in
asynchronous queries to avoid doing work that will be ignored.
*/
get aborted() { return this.abortListeners == null; }
/// Allows you to register abort handlers, which will be called when
/// the query is
/// [aborted](#autocomplete.CompletionContext.aborted).
/**
Allows you to register abort handlers, which will be called when
the query is
[aborted](https://codemirror.net/6/docs/ref/#autocomplete.CompletionContext.aborted).
*/
addEventListener(type, listener) {

@@ -78,4 +98,6 @@ if (type == "abort" && this.abortListeners)

}
/// Given a a fixed array of options, return an autocompleter that
/// completes them.
/**
Given a a fixed array of options, return an autocompleter that
completes them.
*/
function completeFromList(list) {

@@ -89,4 +111,6 @@ let options = list.map(o => typeof o == "string" ? { label: o } : o);

}
/// Wrap the given completion source so that it will not fire when the
/// cursor is in a syntax node with one of the given names.
/**
Wrap the given completion source so that it will not fire when the
cursor is in a syntax node with one of the given names.
*/
function ifNotIn(nodes, source) {

@@ -111,3 +135,2 @@ return (context) => {

function ensureAnchor(expr, start) {
var _a;
let { source } = expr;

@@ -117,3 +140,3 @@ let addStart = start && source[0] != "^", addEnd = source[source.length - 1] != "$";

return expr;
return new RegExp(`${addStart ? "^" : ""}(?:${source})${addEnd ? "$" : ""}`, (_a = expr.flags) !== null && _a !== void 0 ? _a : (expr.ignoreCase ? "i" : ""));
return new RegExp(`${addStart ? "^" : ""}(?:${source})${addEnd ? "$" : ""}`, expr.flags ?? (expr.ignoreCase ? "i" : ""));
}

@@ -282,4 +305,6 @@ function applyCompletion(view, option) {

fontFamily: "monospace",
overflowY: "auto",
whiteSpace: "nowrap",
overflow: "auto",
maxWidth_fallback: "700px",
maxWidth: "min(700px, 95vw)",
maxHeight: "10em",

@@ -416,10 +441,16 @@ listStyle: "none",

}
function createInfoDialog(option) {
function createInfoDialog(option, view) {
let dom = document.createElement("div");
dom.className = "cm-tooltip cm-completionInfo";
let { info } = option.completion;
if (typeof info == "string")
if (typeof info == "string") {
dom.textContent = info;
else
dom.appendChild(info(option.completion));
}
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;

@@ -494,3 +525,3 @@ }

if (option.completion.info) {
this.info = this.dom.appendChild(createInfoDialog(option));
this.info = this.dom.appendChild(createInfoDialog(option, this.view));
this.view.requestMeasure(this.placeInfo);

@@ -619,3 +650,3 @@ }

map(changes) {
return new CompletionDialog(this.options, this.attrs, [Object.assign(Object.assign({}, this.tooltip[0]), { pos: changes.mapPos(this.tooltip[0].pos) })], this.timestamp, this.selected);
return new CompletionDialog(this.options, this.attrs, [{ ...this.tooltip[0], pos: changes.mapPos(this.tooltip[0].pos) }], this.timestamp, this.selected);
}

@@ -645,2 +676,4 @@ }

: this.open && tr.docChanged ? this.open.map(tr.changes) : this.open;
if (!open && active.every(a => a.state != 1 /* Pending */) && active.some(a => a.hasResult()))
active = active.map(a => a.hasResult() ? new ActiveSource(a.source, 0 /* Inactive */, false) : a);
for (let effect of tr.effects)

@@ -761,4 +794,6 @@ if (effect.is(setSelectedEffect))

const CompletionInteractMargin = 75;
/// Returns a command that moves the completion selection forward or
/// backward by the given amount.
/**
Returns a command that moves the completion selection forward or
backward by the given amount.
*/
function moveCompletionSelection(forward, by = "option") {

@@ -781,3 +816,5 @@ return (view) => {

}
/// Accept the current completion.
/**
Accept the current completion.
*/
const acceptCompletion = (view) => {

@@ -790,3 +827,5 @@ let cState = view.state.field(completionState, false);

};
/// Explicitly start autocompletion.
/**
Explicitly start autocompletion.
*/
const startCompletion = (view) => {

@@ -799,3 +838,5 @@ let cState = view.state.field(completionState, false);

};
/// Close the currently active completion.
/**
Close the currently active completion.
*/
const closeCompletion = (view) => {

@@ -902,3 +943,2 @@ let cState = view.state.field(completionState, false);

accept() {
var _a;
if (this.debounceAccept > -1)

@@ -915,3 +955,3 @@ clearTimeout(this.debounceAccept);

if (query.done) {
let active = new ActiveResult(query.source, query.context.explicit, query.done, query.done.from, (_a = query.done.to) !== null && _a !== void 0 ? _a : cur(query.updates.length ? query.updates[0].startState : this.view.state), query.done.span ? ensureAnchor(query.done.span, true) : null);
let active = new ActiveResult(query.source, query.context.explicit, query.done, query.done.from, query.done.to ?? cur(query.updates.length ? query.updates[0].startState : this.view.state), query.done.span ? ensureAnchor(query.done.span, true) : null);
// Replay the transactions that happened since the start of

@@ -1070,25 +1110,27 @@ // the request and see if that preserves the result

}
/// Convert a snippet template to a function that can apply it.
/// Snippets are written using syntax like this:
///
/// "for (let ${index} = 0; ${index} < ${end}; ${index}++) {\n\t${}\n}"
///
/// Each `${}` placeholder (you may also use `#{}`) indicates a field
/// that the user can fill in. Its name, if any, will be the default
/// content for the field.
///
/// When the snippet is activated by calling the returned function,
/// the code is inserted at the given position. Newlines in the
/// template are indented by the indentation of the start line, plus
/// one [indent unit](#language.indentUnit) per tab character after
/// the newline.
///
/// On activation, (all instances of) the first field are selected.
/// The user can move between fields with Tab and Shift-Tab as long as
/// the fields are active. Moving to the last field or moving the
/// cursor out of the current field deactivates the fields.
///
/// The order of fields defaults to textual order, but you can add
/// numbers to placeholders (`${1}` or `${1:defaultText}`) to provide
/// a custom order.
/**
Convert a snippet template to a function that can apply it.
Snippets are written using syntax like this:
"for (let ${index} = 0; ${index} < ${end}; ${index}++) {\n\t${}\n}"
Each `${}` placeholder (you may also use `#{}`) indicates a field
that the user can fill in. Its name, if any, will be the default
content for the field.
When the snippet is activated by calling the returned function,
the code is inserted at the given position. Newlines in the
template are indented by the indentation of the start line, plus
one [indent unit](https://codemirror.net/6/docs/ref/#language.indentUnit) per tab character after
the newline.
On activation, (all instances of) the first field are selected.
The user can move between fields with Tab and Shift-Tab as long as
the fields are active. Moving to the last field or moving the
cursor out of the current field deactivates the fields.
The order of fields defaults to textual order, but you can add
numbers to placeholders (`${1}` or `${1:defaultText}`) to provide
a custom order.
*/
function snippet(template) {

@@ -1122,3 +1164,5 @@ let snippet = Snippet.parse(template);

}
/// A command that clears the active snippet, if any.
/**
A command that clears the active snippet, if any.
*/
const clearSnippet = ({ state, dispatch }) => {

@@ -1131,5 +1175,9 @@ let active = state.field(snippetState, false);

};
/// Move to the next snippet field, if available.
/**
Move to the next snippet field, if available.
*/
const nextSnippetField = moveField(1);
/// Move to the previous snippet field, if available.
/**
Move to the previous snippet field, if available.
*/
const prevSnippetField = moveField(-1);

@@ -1140,7 +1188,9 @@ const defaultSnippetKeymap = [

];
/// A facet that can be used to configure the key bindings used by
/// snippets. The default binds Tab to
/// [`nextSnippetField`](#autocomplete.nextSnippetField), Shift-Tab to
/// [`prevSnippetField`](#autocomplete.prevSnippetField), and Escape
/// to [`clearSnippet`](#autocomplete.clearSnippet).
/**
A facet that can be used to configure the key bindings used by
snippets. The default binds Tab to
[`nextSnippetField`](https://codemirror.net/6/docs/ref/#autocomplete.nextSnippetField), Shift-Tab to
[`prevSnippetField`](https://codemirror.net/6/docs/ref/#autocomplete.prevSnippetField), and Escape
to [`clearSnippet`](https://codemirror.net/6/docs/ref/#autocomplete.clearSnippet).
*/
const snippetKeymap = Facet.define({

@@ -1150,7 +1200,9 @@ combine(maps) { return maps.length ? maps[0] : defaultSnippetKeymap; }

const addSnippetKeymap = Prec.override(keymap.compute([snippetKeymap], state => state.facet(snippetKeymap)));
/// Create a completion from a snippet. Returns an object with the
/// properties from `completion`, plus an `apply` function that
/// applies the snippet.
/**
Create a completion from a snippet. Returns an object with the
properties from `completion`, plus an `apply` function that
applies the snippet.
*/
function snippetCompletion(template, completion) {
return Object.assign(Object.assign({}, completion), { apply: snippet(template) });
return { ...completion, apply: snippet(template) };
}

@@ -1173,5 +1225,7 @@ const snippetPointerHandler = EditorView.domEventHandlers({

/// A completion source that will scan the document for words (using a
/// [character categorizer](#state.EditorState.charCategorizer)), and
/// return those as completions.
/**
A completion source that will scan the document for words (using a
[character categorizer](https://codemirror.net/6/docs/ref/#state.EditorState.charCategorizer)), and
return those as completions.
*/
const completeAnyWord = context => {

@@ -1210,3 +1264,5 @@ let options = [], seen = Object.create(null);

/// Returns an extension that enables autocompletion.
/**
Returns an extension that enables autocompletion.
*/
function autocompletion(config = {}) {

@@ -1222,11 +1278,13 @@ return [

}
/// Basic keybindings for autocompletion.
///
/// - Ctrl-Space: [`startCompletion`](#autocomplete.startCompletion)
/// - Escape: [`closeCompletion`](#autocomplete.closeCompletion)
/// - ArrowDown: [`moveCompletionSelection`](#autocomplete.moveCompletionSelection)`(true)`
/// - ArrowUp: [`moveCompletionSelection`](#autocomplete.moveCompletionSelection)`(false)`
/// - PageDown: [`moveCompletionSelection`](#autocomplete.moveCompletionSelection)`(true, "page")`
/// - PageDown: [`moveCompletionSelection`](#autocomplete.moveCompletionSelection)`(true, "page")`
/// - Enter: [`acceptCompletion`](#autocomplete.acceptCompletion)
/**
Basic keybindings for autocompletion.
- Ctrl-Space: [`startCompletion`](https://codemirror.net/6/docs/ref/#autocomplete.startCompletion)
- Escape: [`closeCompletion`](https://codemirror.net/6/docs/ref/#autocomplete.closeCompletion)
- ArrowDown: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(true)`
- ArrowUp: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(false)`
- PageDown: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(true, "page")`
- PageDown: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(true, "page")`
- Enter: [`acceptCompletion`](https://codemirror.net/6/docs/ref/#autocomplete.acceptCompletion)
*/
const completionKeymap = [

@@ -1242,6 +1300,8 @@ { key: "Ctrl-Space", run: startCompletion },

const completionKeymapExt = Prec.override(keymap.computeN([completionConfig], state => state.facet(completionConfig).defaultKeymap ? [completionKeymap] : []));
/// Get the current completion status. When completions are available,
/// this will return `"active"`. When completions are pending (in the
/// process of being queried), this returns `"pending"`. Otherwise, it
/// returns `null`.
/**
Get the current completion status. When completions are available,
this will return `"active"`. When completions are pending (in the
process of being queried), this returns `"pending"`. Otherwise, it
returns `null`.
*/
function completionStatus(state) {

@@ -1252,6 +1312,7 @@ let cState = state.field(completionState, false);

}
/// Returns the available completions as an array.
/**
Returns the available completions as an array.
*/
function currentCompletions(state) {
var _a;
let open = (_a = state.field(completionState, false)) === null || _a === void 0 ? void 0 : _a.open;
let open = state.field(completionState, false)?.open;
return open ? open.options.map(o => o.completion) : [];

@@ -1258,0 +1319,0 @@ }

{
"name": "@codemirror/autocomplete",
"version": "0.18.0",
"version": "0.18.1",
"description": "Autocompletion for the CodeMirror code editor",
"scripts": {
"test": "echo 'Test runner in wrapper package'",
"prepare": "tsc -p tsconfig.local.json && rollup -c"
"prepare": "cm-buildhelper src/index.ts"
},

@@ -37,5 +37,3 @@ "keywords": [

"devDependencies": {
"rollup": "^2.35.1",
"rollup-plugin-dts": "^2.0.1",
"typescript": "^4.1.3",
"@codemirror/buildhelper": "^0.1.0",
"@types/mocha": "^5.2.0",

@@ -42,0 +40,0 @@ "ist": "^1.1.6",

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