From 9cc34c8af637097552f56fa02a3bd5c6898ab4b1 Mon Sep 17 00:00:00 2001 From: Alasdair Smith Date: Wed, 21 Feb 2018 14:17:32 +0000 Subject: [PATCH 01/10] Copy paste latex parser from v1 with rich comment parsing Rich comments are not being ported over to v2 as they are superseded by track changes From 47588880b91fad26bac49718d14b76309a212ceb Mon Sep 17 00:00:00 2001 From: Alasdair Smith Date: Wed, 21 Feb 2018 14:54:38 +0000 Subject: [PATCH 02/10] Extract Mark to separate module From cdd4d6aaa6c5c65a6460e288f44e2e18021a1c19 Mon Sep 17 00:00:00 2001 From: Alasdair Smith Date: Wed, 21 Feb 2018 15:42:45 +0000 Subject: [PATCH 03/10] Reduce some of the meta programming From 027ab1250aee3dc4981d3b34ffa013565b135ab4 Mon Sep 17 00:00:00 2001 From: Alasdair Smith Date: Wed, 21 Feb 2018 14:55:08 +0000 Subject: [PATCH 04/10] Configure CM with latex parser --- services/web/public/es/rich-text.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/services/web/public/es/rich-text.js b/services/web/public/es/rich-text.js index f87cb46339..3ed3236702 100644 --- a/services/web/public/es/rich-text.js +++ b/services/web/public/es/rich-text.js @@ -1,11 +1,19 @@ import CodeMirror, { Doc } from 'codemirror' +import LatexParser from './ide/editor/codemirror/parser' + export function init (rootEl) { - return CodeMirror(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) + const newDoc = Doc(content, 'latex') cm.swapDoc(newDoc) return newDoc } From 3677dc9a8b5b5d2572d8eaba621360afa94df7e3 Mon Sep 17 00:00:00 2001 From: Alasdair Smith Date: Thu, 22 Feb 2018 14:43:57 +0000 Subject: [PATCH 05/10] Rename to use CM naming consistently --- services/web/public/es/rich-text.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/web/public/es/rich-text.js b/services/web/public/es/rich-text.js index 3ed3236702..55de7d8fb1 100644 --- a/services/web/public/es/rich-text.js +++ b/services/web/public/es/rich-text.js @@ -1,9 +1,9 @@ import CodeMirror, { Doc } from 'codemirror' -import LatexParser from './ide/editor/codemirror/parser' +import LatexMode from './ide/editor/codemirror/LatexMode' export function init (rootEl) { - CodeMirror.defineMode('latex', () => new LatexParser()) + CodeMirror.defineMode('latex', () => new LatexMode()) CodeMirror.defineMIME('application/x-tex', 'latex') CodeMirror.defineMIME('application/x-latex', 'latex') From ec5b31663f392916da7bda640ddc662950c228aa Mon Sep 17 00:00:00 2001 From: Alasdair Smith Date: Wed, 21 Feb 2018 17:07:34 +0000 Subject: [PATCH 06/10] Configure babel to not compile ES6 imports/exports Webpack can automatically handle the transpilation of ES6 imports to ES5. It can also better optimize transpilation as raw ES6 imports can be tree-shaken better. --- services/web/webpack.config.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/services/web/webpack.config.js b/services/web/webpack.config.js index 3f7c199b07..7210a27488 100644 --- a/services/web/webpack.config.js +++ b/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 From 40678cd91ae0c73d5651492212700de95ab9967b Mon Sep 17 00:00:00 2001 From: Alasdair Smith Date: Fri, 23 Feb 2018 16:14:36 +0000 Subject: [PATCH 07/10] Remove erroneous reporter config, missing during merge conflict --- services/web/karma.conf.js | 1 - 1 file changed, 1 deletion(-) diff --git a/services/web/karma.conf.js b/services/web/karma.conf.js index b5f74d0f29..867b6f4ceb 100644 --- a/services/web/karma.conf.js +++ b/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: { From 68d85f03c22031190f79bdc2c44c4cb2e5de5672 Mon Sep 17 00:00:00 2001 From: Alasdair Smith Date: Fri, 23 Feb 2018 16:14:58 +0000 Subject: [PATCH 08/10] Clean up frontend stub --- .../coffee/ide/editor/directives/cmEditorTests.coffee | 2 ++ 1 file changed, 2 insertions(+) diff --git a/services/web/test/unit_frontend/coffee/ide/editor/directives/cmEditorTests.coffee b/services/web/test/unit_frontend/coffee/ide/editor/directives/cmEditorTests.coffee index f7667e74cc..a08e324375 100644 --- a/services/web/test/unit_frontend/coffee/ide/editor/directives/cmEditorTests.coffee +++ b/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('
')($rootScope) From 6a2410105f70fdda7ee93b3e7aba6271d557b62c Mon Sep 17 00:00:00 2001 From: Alasdair Smith Date: Fri, 23 Feb 2018 16:58:11 +0000 Subject: [PATCH 09/10] Add missing underscore dependency and fix linting From 87a0942b3c72ba11302d8f34a587973fcdc91315 Mon Sep 17 00:00:00 2001 From: Alasdair Smith Date: Fri, 2 Mar 2018 10:05:30 +0000 Subject: [PATCH 10/10] Copy paste LatexMode tests from v1 and switch assertions to chai --- services/web/.eslintrc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/services/web/.eslintrc b/services/web/.eslintrc index 3d0b68ae71..01107abc0c 100644 --- a/services/web/.eslintrc +++ b/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",