How to use the monaco-editor.editor.setTheme 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 nteract / nteract / packages / monaco-editor / src / index.tsx View on Github external
if (!this.monaco) {
      return;
    }

    if (this.monaco.getValue() !== this.props.value) {
      // FIXME: calling setValue resets cursor position in monaco. It shouldn't!
      this.monaco.setValue(this.props.value);
    }

    const model = this.monaco.getModel();
    if (model && this.props.mode && model.getModeId() !== this.props.mode) {
      editor.setModelLanguage(model, this.props.mode);
    }

    if (this.props.theme) {
      editor.setTheme(this.props.theme);
    }
  }
github ritz078 / transform / components / Monaco.tsx View on Github external
initMonaco() {
    const { value, language, theme, options } = this.props;

    if (this.containerElement.current) {
      this.editor = editor.create(this.containerElement.current, {
        value,
        language,
        ...options
      });

      editor.defineTheme("light", lightEditor);

      if (theme) {
        editor.setTheme(theme);
      }
      // After initializing monaco editor
      this.editorDidMount(this.editor);
    }
  }
github brijeshb42 / monaco-vim / src / cm_adapter.js View on Github external
setOption(key, value) {
    this.state[key] = value;

    if (key === 'theme') {
      monacoEditor.setTheme(value);
    }
  }
github ritz078 / transform / components / Monaco.tsx View on Github external
componentDidUpdate(prevProps: MonacoProps) {
    const { value, language, theme, width, height, options } = this.props;

    if (value !== prevProps.value) {
      this.__prevent_trigger_change_event = true;
      this.editor.setValue(typeof value === "string" ? value : "");
      this.__prevent_trigger_change_event = false;
    }

    if (prevProps.language !== language) {
      editor.setModelLanguage(this.editor.getModel(), language);
    }
    if (prevProps.theme !== theme) {
      editor.setTheme(theme);
    }
    if (
      this.editor &&
      (width !== prevProps.width || height !== prevProps.height)
    ) {
      this.reLayout();
    }
    if (prevProps.options !== options) {
      this.editor.updateOptions(options);
    }
  }
github gitlabhq / gitlabhq / app / assets / javascripts / editor / editor_lite.js View on Github external
static setupMonacoTheme() {
    const themeName = window.gon?.user_color_scheme || DEFAULT_THEME;
    const theme = themes.find((t) => t.name === themeName);
    if (theme) monacoEditor.defineTheme(themeName, theme.data);
    monacoEditor.setTheme(theme ? themeName : DEFAULT_THEME);
  }