overleaf/services/web/public/es/rich-text.js

20 lines
478 B
JavaScript
Raw Normal View History

import CodeMirror, { Doc } from 'codemirror'
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-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')
cm.swapDoc(newDoc)
return newDoc
}