UNPKG

prong-editor

Version:

Prong (PRojectional jsON Gui) is an editor framework for creating bespoke in-browser editors for JSON-based domain-specific languages (such as [Vega](https://vega.github.io/vega/), [Vega-Lite](https://vega.github.io/vega-lite/), [Tracery](https://tracery.

53 lines (52 loc) 1.74 kB
import { DecorationSet, ViewPlugin, ViewUpdate } from "@codemirror/view"; import { StateField, Extension } from "@codemirror/state"; import { SyntaxNode } from "@lezer/common"; import { ProjectionQuery } from "./query"; import { Diagnostic } from "@codemirror/lint"; export interface ProjectionProps { currentValue: any; cursorPositions: any[]; diagnosticErrors: Diagnostic[]; fullCode: string; keyPath: (string | number)[]; node: SyntaxNode; setCode: (code: string) => void; typings: any[]; } interface ProjectionBase { name: string; query: ProjectionQuery; projection: (props: ProjectionProps) => JSX.Element; } export interface ProjectionTooltip extends ProjectionBase { type: "tooltip"; group: string; takeOverMenu?: boolean; } export interface ProjectionInline extends ProjectionBase { type: "inline"; hasInternalState: boolean; mode: "replace" | "prefix" | "suffix" | "replace-multiline"; } export interface ProjectionHighlight { type: "highlight"; query: ProjectionQuery; class: string; } export declare type Projection = ProjectionInline | ProjectionTooltip | ProjectionHighlight; export declare const getInUseRanges: (projectionsInUse: ProjectionMaterialization[]) => Set<`${number}-${number}`>; export declare const projectionView: ViewPlugin<{ decorations: DecorationSet; update(update: ViewUpdate): void; }>; declare type ProjectionMaterialization = { from: number; to: number; projection: Projection; }; export interface ProjectionState { projectionsInUse: ProjectionMaterialization[]; } export declare const projectionState: StateField<ProjectionState>; export default function projectionPlugin(): Extension; export {};