2018-02-20 13:13:24 +00:00
|
|
|
import CodeMirror, { Doc } from 'codemirror'
|
2018-01-16 17:51:30 +00:00
|
|
|
|
2018-02-22 14:43:57 +00:00
|
|
|
import LatexMode from './ide/editor/codemirror/LatexMode'
|
2018-02-21 14:55:08 +00:00
|
|
|
|
2018-02-22 19:27:30 +00:00
|
|
|
export function init (rootEl) {
|
2018-02-22 14:43:57 +00:00
|
|
|
CodeMirror.defineMode('latex', () => new LatexMode())
|
2018-02-21 14:55:08 +00:00
|
|
|
CodeMirror.defineMIME('application/x-tex', 'latex')
|
|
|
|
CodeMirror.defineMIME('application/x-latex', 'latex')
|
|
|
|
|
|
|
|
return CodeMirror(rootEl, {
|
|
|
|
mode: 'latex'
|
|
|
|
})
|
2018-01-16 17:51:30 +00:00
|
|
|
}
|
2018-02-20 13:13:24 +00:00
|
|
|
|
2018-02-22 19:27:30 +00:00
|
|
|
export function openDoc (cm, content) {
|
2018-02-21 14:55:08 +00:00
|
|
|
const newDoc = Doc(content, 'latex')
|
2018-02-20 13:13:24 +00:00
|
|
|
cm.swapDoc(newDoc)
|
|
|
|
return newDoc
|
|
|
|
}
|