How to use the monaco-editor/esm/vs/editor/editor.main.editor function in monaco-editor

To help you get started, we’ve selected a few monaco-editor 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 satya164 / monaco-editor-boilerplate / src / Editor.js View on Github external
case 'typescript':
      case 'javascript':
        /* $FlowFixMe */
        MonacoWorker = require('worker-loader!monaco-editor/esm/vs/language/typescript/ts.worker');
        break;
      default:
        /* $FlowFixMe */
        MonacoWorker = require('worker-loader!monaco-editor/esm/vs/editor/editor.worker');
    }

    return new MonacoWorker();
  },
};

monaco.editor.defineTheme('ayu-light', light);
monaco.editor.defineTheme('ayu-dark', dark);

/**
 * Disable typescript's diagnostics for JavaScript files.
 * This suppresses errors when using Flow syntax.
 * It's also unnecessary since we use ESLint for error checking.
 */
monaco.languages.typescript.javascriptDefaults.setDiagnosticsOptions({
  noSemanticValidation: true,
  noSyntaxValidation: true,
});

/**
 * Use prettier to format JavaScript code.
 * This will replace the default formatter.
 */
monaco.languages.registerDocumentFormattingEditProvider('javascript', {
github satya164 / monaco-editor-boilerplate / src / Editor.js View on Github external
break;
      case 'typescript':
      case 'javascript':
        /* $FlowFixMe */
        MonacoWorker = require('worker-loader!monaco-editor/esm/vs/language/typescript/ts.worker');
        break;
      default:
        /* $FlowFixMe */
        MonacoWorker = require('worker-loader!monaco-editor/esm/vs/editor/editor.worker');
    }

    return new MonacoWorker();
  },
};

monaco.editor.defineTheme('ayu-light', light);
monaco.editor.defineTheme('ayu-dark', dark);

/**
 * Disable typescript's diagnostics for JavaScript files.
 * This suppresses errors when using Flow syntax.
 * It's also unnecessary since we use ESLint for error checking.
 */
monaco.languages.typescript.javascriptDefaults.setDiagnosticsOptions({
  noSemanticValidation: true,
  noSyntaxValidation: true,
});

/**
 * Use prettier to format JavaScript code.
 * This will replace the default formatter.
 */
github expo / snack-web / snack / components / Editor / MonacoEditor.js View on Github external
break;
      case 'typescript':
      case 'javascript':
        /* $FlowFixMe */
        MonacoWorker = require('worker-loader!monaco-editor/esm/vs/language/typescript/ts.worker');
        break;
      default:
        /* $FlowFixMe */
        MonacoWorker = require('worker-loader!monaco-editor/esm/vs/editor/editor.worker');
    }

    return new MonacoWorker();
  },
};

monaco.editor.defineTheme('light', light);
monaco.editor.defineTheme('dark', dark);

/**
 * Disable typescript's diagnostics for JavaScript files.
 * This suppresses errors when using Flow syntax.
 * It's also unnecessary since we use ESLint for error checking.
 */
monaco.languages.typescript.javascriptDefaults.setDiagnosticsOptions({
  noSemanticValidation: true,
  noSyntaxValidation: true,
});

/**
 * Use prettier to format JavaScript code.
 * This will replace the default formatter.
 */
github expo / snack-web / snack / components / Editor / MonacoEditor.js View on Github external
componentDidMount() {
    // Spawn a worker to fetch type definitions for dependencies
    /* $FlowFixMe */
    this._typingsWorker = new TypingsWorker();
    this._typingsWorker.addEventListener('message', ({ data }: any) => this._addTypings(data));

    const { path, value, annotations, autoFocus, ...rest } = this.props;

    this._editor = monaco.editor.create(this._node, rest, {
      codeEditorService: {
        addCodeEditor: () => {},
        removeCodeEditor: () => {},
        listCodeEditors: () => [this._editor],

        getFocusedCodeEditor: () => this._editor,

        registerDecorationType: () => {},
        removeDecorationType: () => {},
        resolveDecorationOptions: () => {},

        setTransientModelProperty: () => {},
        getTransientModelProperty: () => {},

        getActiveCodeEditor: () => this._editor,
        openCodeEditor: async ({ resource, options }, editor) => {
github expo / snack-web / src / client / components / Editor / MonacoEditor.tsx View on Github external
const findModel = (path: string) =>
  monaco.editor.getModels().find(model => model.uri.path === `/${path}`);
github expo / snack-web / src / client / components / Editor / MonacoEditor.tsx View on Github external
SimpleEditorModelResolverService.prototype.findModel = function(_: any, resource: any) {
  return monaco.editor.getModels().find(model => model.uri.toString() === resource.toString());
};