import CodeMirror, { Doc } from 'codemirror'

import LatexParser from './ide/editor/codemirror/parser'

export function init (rootEl) {
  CodeMirror.defineMode('latex', () => new LatexParser())
  CodeMirror.defineMIME('application/x-tex', 'latex')
  CodeMirror.defineMIME('application/x-latex', 'latex')

  return CodeMirror(rootEl, {
    mode: 'latex'
  })
}

export function openDoc (cm, content) {
  const newDoc = Doc(content, 'latex')
  cm.swapDoc(newDoc)
  return newDoc
}

import CodeMirror, { Doc } from 'codemirror'

import LatexMode from './ide/editor/codemirror/LatexMode'

export function init (rootEl) {
  CodeMirror.defineMode('latex', () => new LatexMode())
  CodeMirror.defineMIME('application/x-tex', 'latex')
  CodeMirror.defineMIME('application/x-latex', 'latex')

  return CodeMirror(rootEl, {
    mode: 'latex'
  })
}

export function openDoc (cm, content) {
  const newDoc = Doc(content, 'latex')
  cm.swapDoc(newDoc)
  return newDoc
}

Rename to use CM naming consistently
Rename to use CM naming consistently
