How to use monaco-editor-core - 10 common examples

To help you get started, we’ve selected a few monaco-editor-core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github microsoft / BotFramework-Composer / Composer / packages / tools / language-servers / language-understanding / demo / src / client.ts View on Github external
});

monaco.editor.defineTheme('lutheme', {
  base: 'vs',
  inherit: false,
  colors: {},
  rules: [],
});

// create Monaco editor
const value = `@  ml a
@  composite la = [a, b]
 `;

const editor = monaco.editor.create(document.getElementById('container')!, {
  model: monaco.editor.createModel(value, 'bflu', monaco.Uri.parse('inmemory://model.json')),
  glyphMargin: true,
  autoClosingBrackets: 'always',
  wordBasedSuggestions: false,
  autoIndent: true,
  formatOnType: true,
  lightbulb: {
    enabled: true,
  },
  theme: 'lutheme',
});

// install Monaco language client services
MonacoServices.install(editor);

// create the web socket
const url = createUrl('/luServer');
github microsoft / BotFramework-Composer / Composer / packages / tools / language-servers / language-understanding / demo / src / client.ts View on Github external
monaco.languages.register({
  id: 'bflu',
  extensions: ['.lu'],
  aliases: ['LU', 'language-understanding'],
  mimetypes: ['application/lu'],
});

monaco.languages.setLanguageConfiguration('bflu', {
  autoClosingPairs: [
    { open: '{', close: '}' },
    { open: '[', close: ']' },
    { open: '(', close: ')' },
  ],
});

monaco.editor.defineTheme('lutheme', {
  base: 'vs',
  inherit: false,
  colors: {},
  rules: [],
});

// create Monaco editor
const value = `@  ml a
@  composite la = [a, b]
 `;

const editor = monaco.editor.create(document.getElementById('container')!, {
  model: monaco.editor.createModel(value, 'bflu', monaco.Uri.parse('inmemory://model.json')),
  glyphMargin: true,
  autoClosingBrackets: 'always',
  wordBasedSuggestions: false,
github microsoft / BotFramework-Composer / Composer / packages / tools / language-servers / language-generation / demo / src / client.ts View on Github external
[/^\s*@\{/, { token: 'expression', next: '@expression' }],
      [/=\s*[\s\S]+\s*$/, { token: 'structure-property' }],
      [/\s*[a-zA-Z0-9_-]+\s*$/, { token: 'structure-name' }],
      [/./, 'structure-lg.content'],
    ],
  },
});

monaco.languages.register({
  id: 'botbuilderlg',
  extensions: ['.lg'],
  aliases: ['LG', 'language-generation'],
  mimetypes: ['application/lg'],
});

monaco.editor.defineTheme('lgtheme', {
  base: 'vs',
  inherit: false,
  colors: {},
  rules: [
    { token: 'template-name', foreground: '0000FF' },
    { token: 'function-name', foreground: '79571E' },
    { token: 'keywords', foreground: '0000FF' },
    { token: 'comments', foreground: '7A7574' },
    { token: 'number', foreground: '00A32B' },
    { token: 'string', foreground: 'DF2C2C' },
    { token: 'structure-name', foreground: '00B7C3' },
  ],
});

// create Monaco editor
const value = `#ted
github microsoft / BotFramework-Composer / Composer / packages / tools / language-servers / language-generation / demo / src / client.ts View on Github external
{ token: 'keywords', foreground: '0000FF' },
    { token: 'comments', foreground: '7A7574' },
    { token: 'number', foreground: '00A32B' },
    { token: 'string', foreground: 'DF2C2C' },
    { token: 'structure-name', foreground: '00B7C3' },
  ],
});

// create Monaco editor
const value = `#ted
- hello hello
- range
- great 
- ted hello `;
const editor = monaco.editor.create(document.getElementById('container')!, {
  model: monaco.editor.createModel(value, 'botbuilderlg', monaco.Uri.parse('inmemory://model.json')),
  glyphMargin: true,
  lightbulb: {
    enabled: true,
  },
  theme: 'lgtheme',
});

// install Monaco language client services
MonacoServices.install(editor);

// create the web socket
const url = createUrl('/lgServer');
const webSocket = createWebSocket(url);
// listen when the web socket is opened
listen({
  webSocket,
github microsoft / BotFramework-Composer / Composer / packages / tools / language-servers / language-understanding / demo / src / client.ts View on Github external
monaco.languages.setMonarchTokensProvider('botframeworklu', {
  ignoreCase: true,
  tokenizer: {
    root: [],
  },
});

monaco.languages.register({
  id: 'bflu',
  extensions: ['.lu'],
  aliases: ['LU', 'language-understanding'],
  mimetypes: ['application/lu'],
});

monaco.languages.setLanguageConfiguration('bflu', {
  autoClosingPairs: [
    { open: '{', close: '}' },
    { open: '[', close: ']' },
    { open: '(', close: ')' },
  ],
});

monaco.editor.defineTheme('lutheme', {
  base: 'vs',
  inherit: false,
  colors: {},
  rules: [],
});

// create Monaco editor
const value = `@  ml a
github microsoft / BotFramework-Composer / Composer / packages / tools / language-servers / language-understanding / demo / src / client.ts View on Github external
import * as monaco from 'monaco-editor-core';
import { listen, MessageConnection, Disposable } from 'vscode-ws-jsonrpc';
import {
  MonacoLanguageClient,
  CloseAction,
  ErrorAction,
  MonacoServices,
  createConnection,
} from 'monaco-languageclient';

import normalizeUrl = require('normalize-url');
const ReconnectingWebSocket = require('reconnecting-websocket');

// register Monaco languages

monaco.languages.setMonarchTokensProvider('botframeworklu', {
  ignoreCase: true,
  tokenizer: {
    root: [],
  },
});

monaco.languages.register({
  id: 'bflu',
  extensions: ['.lu'],
  aliases: ['LU', 'language-understanding'],
  mimetypes: ['application/lu'],
});

monaco.languages.setLanguageConfiguration('bflu', {
  autoClosingPairs: [
    { open: '{', close: '}' },
github microsoft / BotFramework-Composer / Composer / packages / tools / language-servers / language-generation / demo / src / client.ts View on Github external
import * as monaco from 'monaco-editor-core';
import { listen, MessageConnection } from 'vscode-ws-jsonrpc';
import {
  MonacoLanguageClient,
  CloseAction,
  ErrorAction,
  MonacoServices,
  createConnection,
} from 'monaco-languageclient';
import normalizeUrl = require('normalize-url');
const ReconnectingWebSocket = require('reconnecting-websocket');

// register Monaco languages

monaco.languages.setMonarchTokensProvider('botbuilderlg', {
  ignoreCase: true,
  brackets: [
    { open: '{', close: '}', token: 'delimiter.curly' },
    { open: '[', close: ']', token: 'delimiter.bracket' },
    { open: '(', close: ')', token: 'delimiter.parenthesis' },
  ],
  tokenizer: {
    root: [
      // template name line
      [/^\s*#/, { token: 'template-name', next: '@template_name' }],
      // template body
      [/^\s*-/, { token: 'template-body-identifier', goBack: 1, next: '@template_body' }],
      //comments
      [/^\s*>/, { token: 'comments', next: '@comments' }],
      // import statement in lg
      [/\[.*\]/, 'imports'],
github microsoft / monaco-json / src / json.worker.ts View on Github external
self.onmessage = () => {
	// ignore the first message
	worker.initialize((ctx, createData) => {
		return new JSONWorker(ctx, createData)
	});
};
github microsoft / monaco-typescript / src / ts.worker.ts View on Github external
self.onmessage = () => {
	// ignore the first message
	worker.initialize((ctx: monaco.worker.IWorkerContext, createData: ICreateData) => {
		return new TypeScriptWorker(ctx, createData)
	});
};
github microsoft / BotFramework-Composer / Composer / packages / tools / language-servers / language-understanding / demo / src / client.ts View on Github external
const webSocket = createWebSocket(url);
// listen when the web socket is opened
listen({
  webSocket,
  onConnection: connection => {
    // create and start the language client
    const languageClient = createLanguageClient(connection);
    const disposable: Disposable = languageClient.start();
    connection.onClose(() => disposable.dispose());
    // editor.addCommand(monaco.KeyMod.Alt | monaco.KeyCode.F9, function () {
    //   connection.sendRequest(DocumentOnTypeFormattingRequest.type );
    // });
  },
});

const keybinding = editor.addCommand(monaco.KeyMod.Alt | monaco.KeyCode.F9, function() {
  if (webSocket.OPEN) {
  }
});

function createLanguageClient(connection: MessageConnection): MonacoLanguageClient {
  return new MonacoLanguageClient({
    name: 'LU Language Client',
    clientOptions: {
      // use a language id as a document selector
      documentSelector: ['bflu'],
      // disable the default error handler
      errorHandler: {
        error: () => ErrorAction.Continue,
        closed: () => CloseAction.DoNotRestart,
      },
      //middleware

monaco-editor-core

A browser based code editor

MIT
Latest version published 2 months ago

Package Health Score

95 / 100
Full package analysis

Similar packages

Popular JavaScript code snippets

Find secure code to use in your application or website