monaco-azure-logic-app-lang
TypeScript icon, indicating that this package has built-in type declarations

0.4.0 • Public • Published

Azure logic app language

An azure logic app language module for monaco editor.

npm version Build Status Coverage Status Code style

This is a very early release, do not suggest using it in production till latter its stable version

A simple example explains the purpose of this module:

import * as monaco from 'monaco-editor/esm/vs/editor/editor.api';
import {
  default as AzLogicAppExpressionLang,
  IdentifierType,
  AzLgcExpDocument,
  AzLogicAppExpressionLangMonacoEditor,
  ValidateResult
} from 'monaco-azure-logic-app-lang';
import scannerPath from 'monaco-azure-logic-app-lang/scanner/scanner.wasm';

AzLogicAppExpressionLang.scannerOrItsPath = scannerPath;
AzLogicAppExpressionLang.monaco = monaco;
// AzLogicAppExpressionLang.emitBinaryTokens = true;
// AzLogicAppExpressionLang.inSyntaxDebugMode = true;
// AzLogicAppExpressionLang.inSemanticDebugMode = true;

const sampleCodes = "";

export const MONACO_EDITOR_ID = 'first-expression-monaco-editor';

function subscribeCodeDoc(azLgcExpDocument?: AzLgcExpDocument) {
  if (azLgcExpDocument) {
    (window as any).expCodeDocument = azLgcExpDocument.codeDocument;
    (window as any).expCodeDocumentText = azLgcExpDocument.codeDocument.text;
  }
}

function subscribeValidateResult(vr?: ValidateResult) {
  (window as any).expProblems = vr?.problems || [];
}

export const mount = (root:HTMLDivElement)=> {
  const theEditor = new AzLogicAppExpressionLangMonacoEditor(
    root,
    {
      theme: 'hc-black',
      contextmenu: false,
      value: sampleCodes,
      automaticLayout: true,
    },
    MONACO_EDITOR_ID
  )
  AzLogicAppExpressionLangMonacoEditor.init.then(()=>{
    theEditor.azLgcExpDocEventEmitter?.subscribe(subscribeCodeDoc);
    theEditor.validationResultEventEmitter?.subscribe(subscribeValidateResult);
  })
}

const rootEle = document.getElementById('root');

if (rootEle){
  const expressionEditorEle = document.createElement('div');
  expressionEditorEle.id = EXPRESSION_MONACO_EDITOR_ID
  expressionEditorEle.style.height = '100vh';
  expressionEditorEle.style.width = '100vw';
  rootEle.appendChild(expressionEditorEle);
  mount(expressionEditorEle);
}

Readme

Keywords

Package Sidebar

Install

npm i monaco-azure-logic-app-lang

Weekly Downloads

1,069

Version

0.4.0

License

LICENSE.md

Unpacked Size

482 kB

Total Files

39

Last publish

Collaborators

  • albertli90