How to use the codemirror.findModeByName function in codemirror

To help you get started, we’ve selected a few codemirror 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 spring-projects / spring-flo / src / controllers / code-editor.js View on Github external
function updateMode() {
                var language = $scope.language && typeof $scope.language === 'string' ? $scope.language : defaultLanguage;
                if (language) {
                    var info = CodeMirror.findModeByName(language);

                    // Set proper editor mode
                    doc.setOption('mode', info.mime);
                    CodeMirror.autoLoadMode(doc, info.mode);

                    // Set proper Lint mode
                    doc.setOption('lint', getLintOption(info.name));
                }
            }
github ZeroX-DG / SnippetStore / browser / render / components / code-editor / index.jsx View on Github external
applyEditorStyleSingleFile (props) {
    const { config, snippet } = props || this.props
    const {
      theme,
      showLineNumber,
      fontFamily,
      fontSize,
      tabSize,
      indentUsingTab,
      highlightCurrentLine
    } = config.editor
    // only update codemirror mode if new props is passed
    if (props) {
      const snippetMode = CodeMirror.findModeByName(snippet.lang).mode
      if (snippetMode && snippetMode !== 'null') {
        require(`codemirror/mode/${snippetMode}/${snippetMode}`)
      }
    }
    const gutters = showLineNumber
      ? ['CodeMirror-linenumbers', 'CodeMirror-foldgutter']
      : []
    this.editor.getWrapperElement().style.fontSize = `${fontSize}px`
    this.editor.setOption('lineNumbers', showLineNumber)
    this.editor.setOption('foldGutter', showLineNumber)
    this.editor.setOption('theme', theme)
    this.editor.setOption('gutters', gutters)

    this.editor.setOption('indentUnit', tabSize)
    this.editor.setOption('tabSize', tabSize)
    this.editor.setOption('indentWithTabs', indentUsingTab)
github ZeroX-DG / SnippetStore / browser / render / layouts / list-and-detail / snippet-detail / index.jsx View on Github external
const descripChanged = snippet.description !== description.value
    if (
      valueChanged ||
      langChanged ||
      nameChanged ||
      tagChanged ||
      descripChanged
    ) {
      const newSnippet = _.clone(snippet)
      newSnippet.value = editor.getValue()
      newSnippet.lang = lang.value
      newSnippet.name = name.value
      newSnippet.tags = newTags
      newSnippet.description = description.value
      if (langChanged) {
        const snippetMode = CodeMirror.findModeByName(newSnippet.lang).mode
        require(`codemirror/mode/${snippetMode}/${snippetMode}`)
        editor.setOption('mode', snippetMode)
      }
      store.updateSnippet(newSnippet)
    }
    this.setState({ isEditing: false }, () => {
      eventEmitter.emit('snippet-detail:edit-end')
    })
    editor.setOption('readOnly', true)
  }
github BoostIO / Boostnote / browser / components / CodeEditor.js View on Github external
setMode (mode) {
    let syntax = CodeMirror.findModeByName(convertModeName(mode))
    if (syntax == null) syntax = CodeMirror.findModeByName('Plain Text')

    this.editor.setOption('mode', syntax.mime)
    CodeMirror.autoLoadMode(this.editor, syntax.mode)
  }
github BoostIO / Boostnote / browser / components / CodeEditor.js View on Github external
setMode (mode) {
    let syntax = CodeMirror.findModeByName(pass(mode))
    if (syntax == null) syntax = CodeMirror.findModeByName('Plain Text')

    this.editor.setOption('mode', syntax.mime)
    CodeMirror.autoLoadMode(this.editor, syntax.mode)
  }
github BoostIO / BoostNote.next / src / components / CodeEditor.js View on Github external
setSyntaxMode (mode) {
    let syntax = CodeMirror.findModeByName(mode)
    if (syntax == null) syntax = CodeMirror.findModeByName('Plain Text')

    this.codemirror.setOption('mode', syntax.mime)
    CodeMirror.autoLoadMode(this.codemirror, syntax.mode)
  }
github BoostIO / Boostnote / browser / components / CodeEditor.js View on Github external
setMode (mode) {
    let syntax = CodeMirror.findModeByName(pass(mode))
    if (syntax == null) syntax = CodeMirror.findModeByName('Plain Text')

    this.editor.setOption('mode', syntax.mime)
    CodeMirror.autoLoadMode(this.editor, syntax.mode)
  }
github BoostIO / Boostnote / browser / finder / NoteDetail.js View on Github external
const viewList = note.snippets.map((snippet, index) => {
        const isActive = this.state.snippetIndex === index

        let syntax = CodeMirror.findModeByName(pass(snippet.mode))
        if (syntax == null) syntax = CodeMirror.findModeByName('Plain Text')

        return <div style="{{zIndex:">
          {snippet.mode === 'markdown'
            ? 
            : </div>
github BoostIO / BoostNote.next / src / components / CodeEditor.js View on Github external
setSyntaxMode (mode) {
    let syntax = CodeMirror.findModeByName(mode)
    if (syntax == null) syntax = CodeMirror.findModeByName('Plain Text')

    this.codemirror.setOption('mode', syntax.mime)
    CodeMirror.autoLoadMode(this.codemirror, syntax.mode)
  }