Compare commits

..

No commits in common. "8e96fb45ed5ac734b650a6b34a65912a4b8c11b4" and "5850c556c80edc9d606f9fc9cf20eafef34b1f89" have entirely different histories.

2 changed files with 17 additions and 26 deletions

View File

@ -6,9 +6,9 @@ import search from "./search";
import axios from 'axios'; import axios from 'axios';
import qs from 'querystring' import qs from 'querystring'
import $ from 'jquery'; import $ from 'jquery';
import Mustache from 'mustache';
import getCaretCoordinates from './caret-position' import getCaretCoordinates from './caret-position'
import moment from 'moment' import moment from 'moment'
import "moment/locale/nl"
// import mermaid from 'mermaid' // import mermaid from 'mermaid'
// import {Network, parseDOTNetwork} from "vis-network/peer"; // import {Network, parseDOTNetwork} from "vis-network/peer";
// import PrismJS from 'prismjs' // import PrismJS from 'prismjs'
@ -20,6 +20,9 @@ import "moment/locale/nl"
// import 'prismjs/components/prism-markup-templating' // import 'prismjs/components/prism-markup-templating'
// import 'prismjs/components/prism-jq' // import 'prismjs/components/prism-jq'
import MD from './markdown' import MD from './markdown'
import he from 'he'
import {all, create} from 'mathjs'
import formulaFunctions from './formula'
import actions from './actions' import actions from './actions'
moment.locale('nl') moment.locale('nl')
@ -316,27 +319,26 @@ function Editor(holder, input) {
}) })
} }
async function transformMathExpression(converted, scope) { function transformMathExpression(converted, scope) {
return Promise.all([ try {
import(/* webpackChunkName: "mathjs" */ 'mathjs'),
import(/* webpackChunkName: "mathjs" */ './formula')
]).then((promises) => {
const mathjs = promises[0]
if (math === undefined) { if (math === undefined) {
math = mathjs.create(mathjs.all) math = create(all)
math.import(promises[1]) math.import(formulaFunctions)
} }
let expr = converted.substring(1); let expr = converted.substring(1);
let parsedExpr = math.parse(expr) let parsedExpr = math.parse(expr)
let compiled = parsedExpr.compile() let compiled = parsedExpr.compile()
let evaluated = compiled.evaluate(scope); let evaluated = compiled.evaluate(scope);
if (parsedExpr.isAssignmentNode) { if (parsedExpr.isAssignmentNode) {
return parsedExpr.object.name + " = <i>" + evaluated.toString() + "</i>" converted = parsedExpr.object.name + " = <i>" + evaluated.toString() + "</i>"
} else {
converted = "<span class='expression'>" + expr + " = </span><i>" + evaluated.toString() + "</i>"
} }
return "<span class='expression'>" + expr + " = </span><i>" + evaluated.toString() + "</i>" } catch (e) {
}).catch(e => { converted = converted + ' <span style="background: red; color: white;">' + e.message + '</span>';
return converted + ' <span style="background: red; color: white;">' + e.message + '</span>'; }
}) return converted;
} }
function transform(text, element, id, editor, scope) { function transform(text, element, id, editor, scope) {
@ -357,14 +359,7 @@ function Editor(holder, input) {
} else if (converted.startsWith("```", 0) || converted.startsWith("$$", 0)) { } else if (converted.startsWith("```", 0) || converted.startsWith("$$", 0)) {
converted = MD.render(converted) converted = MD.render(converted)
} else if (converted.startsWith("=", 0)) { } else if (converted.startsWith("=", 0)) {
transformMathExpression(converted, scope) converted = transformMathExpression(converted, scope);
.then(converted => {
MD.options.html = true
converted = MD.renderInline(converted)
MD.options.html = false
element.html(converted)
})
} else { } else {
let re = /^([A-Z0-9 ]+)::\s*(.*)$/i; let re = /^([A-Z0-9 ]+)::\s*(.*)$/i;
let res = text.match(re) let res = text.match(re)

View File

@ -49,10 +49,6 @@ module.exports = env => {
new webpack.EnvironmentPlugin({ new webpack.EnvironmentPlugin({
DEBUG: false, DEBUG: false,
NODE_DEBUG: false, NODE_DEBUG: false,
}),
new webpack.IgnorePlugin({
resourceRegExp: /^\.\/locale$/,
contextRegExp: /moment$/,
}) })
], ],
// //