فهرست منبع

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

CodeMirror syntax parsing
Alasdair Smith 8 سال پیش
والد
کامیت
67a78accbb

+ 4 - 1
services/web/.eslintrc

@@ -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",

+ 0 - 1
services/web/karma.conf.js

@@ -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: {

+ 10 - 2
services/web/public/es/rich-text.js

@@ -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
 }

+ 2 - 0
services/web/test/unit_frontend/coffee/ide/editor/directives/cmEditorTests.coffee

@@ -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)

+ 3 - 1
services/web/webpack.config.js

@@ -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