function snippet(template) {
    let snippet = Snippet.parse(template);
    return (editor, _completion, from, to) => {
        let { text, ranges } = snippet.instantiate(editor.state, from);
        let spec = { changes: { from, to, insert: Text.of(text) } };
        if (ranges.length)
            spec.selection = fieldSelection(ranges, 0);
        if (ranges.length > 1) {
            let active = new ActiveSnippet(ranges, 0);
            let effects = spec.effects = [setActive.of(active)];
            if (editor.state.field(snippetState, false) === undefined)
                effects.push(StateEffect.appendConfig.of([snippetState, addSnippetKeymap, snippetPointerHandler, baseTheme]));
        }
        editor.dispatch(editor.state.update(spec));
    };
}
/**
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.
*/
Convert a snippet template to a function that can apply it.
Snippets are written using syntax like this.



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] 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 . 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 ] 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) {
    let snippet = Snippet.parse(template);
    return (editor, _completion, from, to) => {
        let { text, ranges } = snippet.instantiate(editor.state, from);
        let spec = { changes: { from, to, insert: Text.of(text) } };
        if (ranges.length)
            spec.selection = fieldSelection(ranges, 0);
        if (ranges.length > 1) {
            let active = new ActiveSnippet(ranges, 0);
            let effects = spec.effects = [setActive.of(active)];
            if (editor.state.field(snippetState, false) === undefined)
                effects.push(StateEffect.appendConfig.of([snippetState, addSnippetKeymap, snippetPointerHandler, baseTheme]));
        }
        editor.dispatch(editor.state.update(spec));
    };
}
function snippet ( template ) { let snippet = Snippet . parse ( template ) ; return ( editor , _completion , from , to ) => { let { text , ranges } = snippet . instantiate ( editor . state , from ) ; let spec = { changes : { from , to , insert : Text . of ( text ) } } ; if ( ranges . length ) spec . selection = fieldSelection ( ranges , 0 ) ; if ( ranges . length > 1 ) { let active = new ActiveSnippet ( ranges , 0 ) ; let effects = spec . effects = [ setActive . of ( active ) ] ; if ( editor . state . field ( snippetState , false ) === undefined ) effects . push ( StateEffect . appendConfig . of ( [ snippetState , addSnippetKeymap , snippetPointerHandler , baseTheme ] ) ) ; } editor . dispatch ( editor . state . update ( spec ) ) ; } ; }
Convert a snippet template to a function that can apply it.
Convert a snippet template to a function that can apply it .