UNPKG

@discoveryjs/discovery

Version:

Frontend framework for rapid data (JSON) analysis, shareable serverless reports and dashboards

55 lines (54 loc) 1.81 kB
import type { ViewModel } from '../../main/view-model.js'; import type { Suggestion } from '../../main/query-suggestions.js'; import { Emitter } from '../../core/emitter.js'; import CodeMirror from 'codemirror'; import 'codemirror/mode/javascript/javascript.js'; import './editors-hint.js'; export type EditorOptions = { mode: string | { name: string; isDiscoveryViewDefined?: (name: string) => boolean; }; placeholder: string; hint: EditorHintOptions['hint']; }; export type EditorHintOptions = { closeOnUnfocus: boolean; container: HTMLElement; hint(cm: CodeMirror): null | EditorHintResult; }; export type EditorHintResult = { list: EditorHintSuggestion[]; }; export type EditorHintSuggestion = { entry: Suggestion; text: string; render(el: HTMLElement, result: EditorHintResult, suggestion: EditorHintSuggestion): void; from: number; to: number; }; export declare class Editor extends Emitter<{ change: [newValue: string]; }> { static CodeMirror: any; el: HTMLElement; cm: CodeMirror; get container(): HTMLElement | null; constructor({ hint, mode, placeholder }: Partial<EditorOptions>); getValue(): any; setValue(value: string | undefined): boolean; focus(): void; } export declare class QueryEditor extends Editor { private queryData; private queryContext; inputPanelEl: HTMLElement; outputPanelEl: HTMLElement; constructor(getSuggestions: (value: string, offset: number, data: unknown, context: unknown) => Suggestion[] | null); setValue(value: string | undefined, data?: unknown, context?: unknown): boolean; } export declare class ViewEditor extends Editor { constructor(); isViewDefined(name: string): boolean; } export default function (host: ViewModel): void;