Merge pull request #370 from sharelatex/as-cm-parsing

CodeMirror syntax parsing
This commit is contained in:
Alasdair Smith 2018-03-02 10:57:06 +00:00 committed by GitHub
commit 67a78accbb
5 changed files with 19 additions and 5 deletions

View file

@ -11,7 +11,10 @@
"expect": true
},
"rules": {
"max-len": "error",
"max-len": ["error", {
// Ignore long describe/it test blocks
"ignorePattern": "^\\s*(it|describe)\\s*\\(['\"]"
}],
// Add some chai specific rules
"chai-expect/missing-assertion": "error",

View file

@ -33,7 +33,6 @@ module.exports = function (config) {
'test/unit_frontend/es/**/*.js': ['webpack']
},
frameworks: ['requirejs', 'mocha', 'chai-sinon'],
reporters: ['tap'],
// Configure webpack in the tests
webpack: {
resolve: {

View file

@ -1,11 +1,19 @@
import CodeMirror, { Doc } from 'codemirror'
import LatexMode from './ide/editor/codemirror/LatexMode'
export function init (rootEl) {
return CodeMirror(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)
const newDoc = Doc(content, 'latex')
cm.swapDoc(newDoc)
return newDoc
}

View file

@ -12,6 +12,8 @@ define ['ide/editor/directives/cmEditor'], () ->
}
}
afterEach () -> window.Frontend = null
it 'inits Rich Text', () ->
inject ($compile, $rootScope) =>
$compile('<div cm-editor></div>')($rootScope)

View file

@ -45,7 +45,9 @@ module.exports = {
use: [{
loader: 'babel-loader',
options: {
presets: ['env'],
presets: [
['env', { modules: false }]
],
// Configure babel-loader to cache compiled output so that subsequent
// compile runs are much faster
cacheDirectory: true