-
Notifications
You must be signed in to change notification settings - Fork 4k
/
Copy pathindex.ts
33 lines (28 loc) · 907 Bytes
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { EditorView, ViewPlugin, Decoration } from '@uiw/react-codemirror';
import type { PluginState } from './types';
import { VariablePluginView } from './plugin-view';
export function createVariablePlugin({ viewRef, lastCompletionRef, onSelect }: PluginState) {
return ViewPlugin.fromClass(
class {
private view: VariablePluginView;
constructor(view: EditorView) {
this.view = new VariablePluginView(view, viewRef, lastCompletionRef, onSelect);
}
update(update: any) {
this.view.update(update);
}
get decorations() {
return this.view.decorations;
}
},
{
decorations: (v) => v.decorations,
provide: (plugin) =>
EditorView.atomicRanges.of((view) => {
return view.plugin(plugin)?.decorations || Decoration.none;
}),
}
);
}
export * from './types';
export * from './constants';