2.0.1 • Published 10 months ago

@making-sense/antlr-editor v2.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

ANTLR Editor

ANTLR Editor CI NPM version Storybook

ANTLR Typescript editor.

Usage

Install

yarn add @making-sense/antlr-editor

Example: VTLEditor

yarn add @making-sense/antlr-editor @making-sense/vtl-2-0-antlr-tools-ts @making-sense/vtl-2-0-monaco-tools-ts
import { AntlrEditor as VTLEditor } from "@making-sense/antlr-editor";
import * as VTLTools from "@making-sense/vtl-2-0-antlr-tools-ts";
import { getSuggestionsFromRange, monarchDefinition } from "@making-sense/vtl-2-0-monaco-tools-ts";

const customTools = { ...VTLTools, getSuggestionsFromRange, monarchDefinition };

const Editor = () => {
    return <VTLEditor tools={customTools} />;
};

export default Editor;

Developement mode

Storybook

yarn storybook

Linked app

git clone https://github.com/Making-Sense-Info/ANTLR-Editor
cd ANTLR-Editor
yarn

# Start the test app in watch mode
yarn start-test-app

# Link in an external project in watch mode
yarn link-in-app test-app # ../YOUR-APP is supposed to exist

AntlrEditor Props

NameTypeDefault value
scriptstring-
setScriptFunction-
customFetcherFunction *-
toolsTools *-
variablesVariables *{ }
variablesInputURLsVariableURLs *
onListErrorsFunctionundefined
heightstring"50vh"
widthstring"100%"
themestring"vs-dark"
optionsIStandaloneEditorConstructionOptions{}

See details about * props below

Props details

tools

tools has to be Antlr4 auto-generated Lexer & Parser.

NameTypeDefault value
idstring-
initialRulestring-
grammarstring-
LexerAntlr4 Lexer-
ParserAntlr4 Parser-

Have a look to VTL 2.0 Antlr Tools for example.

getSuggestionsFromRange & monarchDefinition

Have a look to VTL 2.0 Monaco Tools for autosuggestion & highlighting example.

customFetcher

customFetcher enable to provide a custom fetch, adding Authorization header for instance:

u => fetch(u, headers:{ Authorization: 'Bearer XXX'})

This function will be used to fetch variableURLs & sdmxResultURL props.

variables

variables enable to pass an object to provide auto-suggestion.

The shape of this object is:

const obj = {
    "var1": {"type": "STRING", "role": "IDENTIFIER"},
    "var2": {"type": "INTEGER", "role": "MEASURE"},
}

variableURLs

variableURLs enable to pass an array of string to fetch to provide auto-suggestion:

["http://metadata/1", "http://metadata/2"]

The shape of each fetched resources has to be:

[
    { "name": "var1", "type": "STRING", "role": "IDENTIFIER" },
    { "name": "var2", "type": "INTEGER", "role": "MEASURE" }
]
2.0.1

10 months ago

2.0.0

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago

0.3.2

1 year ago

0.3.0

2 years ago

0.3.1

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.1.0

2 years ago