How to use the monaco-editor/esm/vs/editor/editor.api.KeyCode 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 mimic-sussex / sema / src / index.js View on Github external
//       readOnly: false,
//       theme: "vs-dark"
//     }
//   );
//
//   var editor2 = monaco.editor.create(document.getElementById('editor2'), {
//     value: [
//       '\tconsole.log("MaxiLib Output");'
//     ].join('\n'),
//     language: 'javascript'
//   });

  var myCondition1 = editor1.createContextKey(/*key name*/'myCondition1', /*default value*/false);
  var myCondition2 = editor1.createContextKey(/*key name*/'myCondition2', /*default value*/false);

  editor1.addCommand(monaco.KeyMod.Shift | monaco.KeyCode.Enter, function() {
      // services available in `ctx`

      var text = editor1.getValue();

      var selection = editor1.getSelection(); //[2,1 -> 2,34]
      var valueInSelection = editor1.getModel().getValueInRange(selection); //[2,1 -> 2,34]

      // const parser = new nearley.Parser(nearley.Grammar.fromCompiled(processor));
      //
      // parser.feed(input);
      //
      //


      alert("Text: " + text + '\n\n'
            + "Selection: " + selection +  '\n\n'
github exercism / website / app / javascript / components / editor / FileEditor.tsx View on Github external
const handleEditorDidMount = (
    editor: monacoEditor.editor.IStandaloneCodeEditor
  ) => {
    editorRef.current = editor

    editor.addAction({
      id: 'runTests',
      label: 'Run tests',
      keybindings: [monacoEditor.KeyCode.F2],
      run: onRunTests,
    })

    editor.addAction({
      id: 'submit',
      label: 'Submit',
      keybindings: [monacoEditor.KeyCode.F3],
      run: onSubmit,
    })

    MonacoServices.install(editor)

    editor.setModel(filesRef.current[0].model)

    // Fix a custom code font rendering bug
    // See https://github.com/exercism/website/issues/742#issuecomment-816806513
github DonJayamanne / pythonVSCode / src / datascience-ui / interactive-common / editor.tsx View on Github external
private onKeyUp = (e: monacoEditor.IKeyboardEvent) => {
        if (e.shiftKey && e.keyCode === monacoEditor.KeyCode.Enter) {
            // Shift enter was hit
            e.stopPropagation();
            e.preventDefault();
        }
    }
github exercism / website / app / javascript / components / editor / FileEditor.tsx View on Github external
const handleEditorDidMount = (
    editor: monacoEditor.editor.IStandaloneCodeEditor
  ) => {
    editorRef.current = editor

    editor.addAction({
      id: 'runTests',
      label: 'Run tests',
      keybindings: [monacoEditor.KeyCode.F2],
      run: onRunTests,
    })

    editor.addAction({
      id: 'submit',
      label: 'Submit',
      keybindings: [monacoEditor.KeyCode.F3],
      run: onSubmit,
    })

    MonacoServices.install(editor)

    editor.setModel(filesRef.current[0].model)

    // Fix a custom code font rendering bug
    // See https://github.com/exercism/website/issues/742#issuecomment-816806513
    document.fonts.ready.then(() => monacoEditor.editor.remeasureFonts())

    editorDidMount({ getFiles, setFiles, openPalette })
  }
github sourcegraph / sourcegraph / cmd / management-console / web / src / MonacoEditor.tsx View on Github external
setTimeout(() => {
            this.editor!.addCommand(monaco.KeyMod.CtrlCmd | monaco.KeyCode.KEY_S, () => this.props.onDidSave(), '')
        })
github sourcegraph / sourcegraph / web / src / settings / MonacoSettingsEditor.tsx View on Github external
setTimeout(() => {
            if (MonacoSettingsEditor.isStandaloneCodeEditor(editor)) {
                editor.addCommand(
                    monaco.KeyMod.CtrlCmd | monaco.KeyCode.KEY_S,
                    () => {
                        if (this.props.onDidSave) {
                            this.props.onDidSave()
                        }
                    },
                    ''
                )
            }
        })
    }
github ttu / lego-boost-app / src / components / CodeControl.tsx View on Github external
editor.onKeyDown(e => {
      if (e.keyCode === monacoEditor.KeyCode.Enter) {
        editor.updateOptions({ readOnly: false });
      }
    });
    editor.getAction('editor.action.formatDocument').run();
github exercism / website / app / javascript / components / student / editor / ExercismMonacoEditor.tsx View on Github external
const handleEditorDidMount = (
    editor: monacoEditor.editor.IStandaloneCodeEditor
  ) => {
    editorRef.current = editor

    editor.addAction({
      id: 'runTests',
      label: 'Run tests',
      keybindings: [monacoEditor.KeyCode.F2],
      run: onRunTests,
    })

    MonacoServices.install(editor)

    editorDidMount(editor)
  }