acsi-core 0.9.2 → 0.9.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +79 -69
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +79 -69
- package/dist/index.modern.js.map +1 -1
- package/dist/utils/latexExtractor.d.ts +6 -0
- package/package.json +2 -2
package/dist/index.modern.js
CHANGED
|
@@ -7,8 +7,13 @@ import { useDispatch, useSelector } from 'react-redux';
|
|
|
7
7
|
import { Link } from 'react-router-dom';
|
|
8
8
|
import { FormGroup, Input, Label, Modal, ModalHeader, ModalBody, ModalFooter, Tooltip, Row, Col, Button, Pagination, PaginationItem, PaginationLink } from 'reactstrap';
|
|
9
9
|
import ReactSelect, { components } from 'react-select';
|
|
10
|
+
import ReactMarkdown from 'react-markdown';
|
|
11
|
+
import remarkMath from 'remark-math';
|
|
12
|
+
import remarkGfm from 'remark-gfm';
|
|
13
|
+
import rehypeKatex from 'rehype-katex';
|
|
14
|
+
import remarkRehype from 'remark-rehype';
|
|
15
|
+
import rehypeRaw from 'rehype-raw';
|
|
10
16
|
import 'katex/dist/katex.min.css';
|
|
11
|
-
import renderMathInElement from 'katex/contrib/auto-render';
|
|
12
17
|
import Cookies from 'js-cookie';
|
|
13
18
|
export { default as Cookies } from 'js-cookie';
|
|
14
19
|
import moment from 'moment';
|
|
@@ -1662,72 +1667,77 @@ var CoreTooltip = function CoreTooltip(_ref) {
|
|
|
1662
1667
|
}, content));
|
|
1663
1668
|
};
|
|
1664
1669
|
|
|
1665
|
-
var
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
var latexStart = -1;
|
|
1678
|
-
if (content.includes("_")) {
|
|
1679
|
-
latexStart = content.search(/[a-zA-Z]_/);
|
|
1680
|
-
} else if (content.includes("^")) {
|
|
1681
|
-
latexStart = content.search(/[a-zA-Z]\^/);
|
|
1682
|
-
} else if (content.includes("\\")) {
|
|
1683
|
-
latexStart = content.search(/\\/);
|
|
1684
|
-
}
|
|
1685
|
-
if (latexStart !== -1) {
|
|
1686
|
-
var _prefix = content.substring(0, latexStart);
|
|
1687
|
-
var _equation = content.substring(latexStart);
|
|
1688
|
-
return _prefix + "\\(" + _equation + "\\)";
|
|
1689
|
-
} else {
|
|
1690
|
-
return content;
|
|
1670
|
+
var LatexExtractor = /*#__PURE__*/function () {
|
|
1671
|
+
function LatexExtractor() {}
|
|
1672
|
+
LatexExtractor.ApplyLatexFormat = function ApplyLatexFormat(content) {
|
|
1673
|
+
var allComponents = LatexExtractor.extractAllLatexUltimate(content);
|
|
1674
|
+
var multiLineFormulas = LatexExtractor.extractMultiLineFormulas(content);
|
|
1675
|
+
var foundLatexStr = multiLineFormulas[0] || "";
|
|
1676
|
+
if (foundLatexStr && foundLatexStr !== "" && content.includes(foundLatexStr)) {
|
|
1677
|
+
var firstPosition = content.indexOf(allComponents[0]);
|
|
1678
|
+
if (firstPosition > 0) {
|
|
1679
|
+
var textPart = content.slice(0, firstPosition).trim();
|
|
1680
|
+
var latexPart = content.slice(firstPosition).trim();
|
|
1681
|
+
return textPart + (" $$" + latexPart + "$$");
|
|
1691
1682
|
}
|
|
1692
1683
|
}
|
|
1684
|
+
return content.replace(foundLatexStr, "$$" + foundLatexStr + "$$");
|
|
1685
|
+
};
|
|
1686
|
+
return LatexExtractor;
|
|
1687
|
+
}();
|
|
1688
|
+
LatexExtractor.extractAllLatexUltimate = function (content) {
|
|
1689
|
+
var latexRegex = /(\\[a-zA-Z]+\s*\{[^}]*\}(?:\s*\{[^}]*\})*|\\[a-zA-Z]+|\\[a-zA-Z]+\s*[^\\\s\{]+|[a-zA-Z]+\^{[^}]*}|[a-zA-Z]+\_{[^}]*}|\$[^$]+\$|\\\([^)]+\\\)|\\\[[^\]]+\\\]|\\[a-zA-Z]+\d*|(?:\\[a-zA-Z]+\s*)+[^\\]*(?=\\\\|\.|$))/g;
|
|
1690
|
+
var matches = content.match(latexRegex) || [];
|
|
1691
|
+
return matches.map(function (match) {
|
|
1692
|
+
return match.trim();
|
|
1693
|
+
}).filter(function (match) {
|
|
1694
|
+
return match.length > 1 && !match.match(/^[,\s\.]*$/) && (match.includes("\\") || match.includes("^{") || match.includes("_{") || match.includes("$") || !!match.match(/[a-zA-Z]\s*[=+\-*/]\s*[a-zA-Z0-9]/));
|
|
1693
1695
|
});
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
display: true
|
|
1719
|
-
}]
|
|
1720
|
-
});
|
|
1721
|
-
} catch (error) {
|
|
1722
|
-
console.error("Error rendering math:", error);
|
|
1696
|
+
};
|
|
1697
|
+
LatexExtractor.extractMultiLineFormulas = function (content) {
|
|
1698
|
+
var formulas = content.split(/\\\\/);
|
|
1699
|
+
return formulas.map(function (formula) {
|
|
1700
|
+
return formula.trim().replace(/\.$/, "");
|
|
1701
|
+
}).filter(function (formula) {
|
|
1702
|
+
return formula.length > 0 && LatexExtractor.isMathFormula(formula);
|
|
1703
|
+
});
|
|
1704
|
+
};
|
|
1705
|
+
LatexExtractor.isMathFormula = function (text) {
|
|
1706
|
+
return !!text && (text.includes("=") || text.includes("\\") || text.includes("^{") || text.includes("_{") || !!text.match(/[a-zA-Z]\s*[=+\-*/]\s*[a-zA-Z0-9]/));
|
|
1707
|
+
};
|
|
1708
|
+
|
|
1709
|
+
var _excluded$3 = ["node"];
|
|
1710
|
+
var MarkdownLatexRender = function MarkdownLatexRender(_ref) {
|
|
1711
|
+
var content = _ref.content;
|
|
1712
|
+
var updatedMarkdown = formatContent(content);
|
|
1713
|
+
return React.createElement("span", null, React.createElement(ReactMarkdown, {
|
|
1714
|
+
remarkPlugins: [remarkMath, remarkGfm, remarkRehype],
|
|
1715
|
+
rehypePlugins: [rehypeKatex, rehypeRaw],
|
|
1716
|
+
components: {
|
|
1717
|
+
p: function p(_ref2) {
|
|
1718
|
+
var props = _objectWithoutPropertiesLoose(_ref2, _excluded$3);
|
|
1719
|
+
return React.createElement("span", Object.assign({}, props));
|
|
1723
1720
|
}
|
|
1724
1721
|
}
|
|
1725
|
-
},
|
|
1726
|
-
return React.createElement("div", {
|
|
1727
|
-
ref: displayRef,
|
|
1728
|
-
className: "equation-support"
|
|
1729
|
-
});
|
|
1722
|
+
}, updatedMarkdown));
|
|
1730
1723
|
};
|
|
1724
|
+
function formatContent(content) {
|
|
1725
|
+
var lines = content.split("\n");
|
|
1726
|
+
var result = [];
|
|
1727
|
+
var i = 0;
|
|
1728
|
+
while (i < lines.length) {
|
|
1729
|
+
var line = lines[i];
|
|
1730
|
+
var appliedLatexFormat = LatexExtractor.ApplyLatexFormat(line);
|
|
1731
|
+
if (appliedLatexFormat !== line) {
|
|
1732
|
+
result.push(appliedLatexFormat);
|
|
1733
|
+
i++;
|
|
1734
|
+
continue;
|
|
1735
|
+
}
|
|
1736
|
+
result.push(line);
|
|
1737
|
+
i++;
|
|
1738
|
+
}
|
|
1739
|
+
return result.join("\n");
|
|
1740
|
+
}
|
|
1731
1741
|
|
|
1732
1742
|
var CookieService = /*#__PURE__*/function () {
|
|
1733
1743
|
function CookieService() {}
|
|
@@ -3324,7 +3334,7 @@ var CustomOption = function CustomOption(props) {
|
|
|
3324
3334
|
}, props.data.label));
|
|
3325
3335
|
};
|
|
3326
3336
|
|
|
3327
|
-
var _excluded$
|
|
3337
|
+
var _excluded$4 = ["isDefault", "defaultValue", "options", "isDisabled", "scrollBottom", "value", "isMulti"];
|
|
3328
3338
|
var CustomSelect = function CustomSelect(_ref) {
|
|
3329
3339
|
var isDefault = _ref.isDefault,
|
|
3330
3340
|
options = _ref.options,
|
|
@@ -3332,7 +3342,7 @@ var CustomSelect = function CustomSelect(_ref) {
|
|
|
3332
3342
|
scrollBottom = _ref.scrollBottom,
|
|
3333
3343
|
value = _ref.value,
|
|
3334
3344
|
isMulti = _ref.isMulti,
|
|
3335
|
-
rest = _objectWithoutPropertiesLoose(_ref, _excluded$
|
|
3345
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$4);
|
|
3336
3346
|
var initialValues = Array.isArray(value) ? options.filter(function (i) {
|
|
3337
3347
|
return value.includes(i.value);
|
|
3338
3348
|
}) : isMulti ? options === null || options === void 0 ? void 0 : options.filter(function (i) {
|
|
@@ -3359,7 +3369,7 @@ var CustomSelect = function CustomSelect(_ref) {
|
|
|
3359
3369
|
}, rest));
|
|
3360
3370
|
};
|
|
3361
3371
|
|
|
3362
|
-
var _excluded$
|
|
3372
|
+
var _excluded$5 = ["isDefault", "defaultValue", "options", "isDisabled", "scrollBottom", "value", "isMulti"];
|
|
3363
3373
|
var CustomAsyncSelect = function CustomAsyncSelect(_ref) {
|
|
3364
3374
|
var isDefault = _ref.isDefault,
|
|
3365
3375
|
options = _ref.options,
|
|
@@ -3367,7 +3377,7 @@ var CustomAsyncSelect = function CustomAsyncSelect(_ref) {
|
|
|
3367
3377
|
scrollBottom = _ref.scrollBottom,
|
|
3368
3378
|
value = _ref.value,
|
|
3369
3379
|
isMulti = _ref.isMulti,
|
|
3370
|
-
rest = _objectWithoutPropertiesLoose(_ref, _excluded$
|
|
3380
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$5);
|
|
3371
3381
|
var initialValues = Array.isArray(value) ? options.filter(function (i) {
|
|
3372
3382
|
return value.includes(i.value);
|
|
3373
3383
|
}) : isMulti ? options.filter(function (i) {
|
|
@@ -3394,14 +3404,14 @@ var CustomAsyncSelect = function CustomAsyncSelect(_ref) {
|
|
|
3394
3404
|
}, rest));
|
|
3395
3405
|
};
|
|
3396
3406
|
|
|
3397
|
-
var _excluded$
|
|
3407
|
+
var _excluded$6 = ["defaultValue", "options", "isDisabled", "scrollBottom", "value", "isMulti"];
|
|
3398
3408
|
var CustomCreatable = function CustomCreatable(_ref) {
|
|
3399
3409
|
var options = _ref.options,
|
|
3400
3410
|
isDisabled = _ref.isDisabled,
|
|
3401
3411
|
scrollBottom = _ref.scrollBottom,
|
|
3402
3412
|
value = _ref.value,
|
|
3403
3413
|
isMulti = _ref.isMulti,
|
|
3404
|
-
rest = _objectWithoutPropertiesLoose(_ref, _excluded$
|
|
3414
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$6);
|
|
3405
3415
|
var initialValues = Array.isArray(value) ? options.filter(function (i) {
|
|
3406
3416
|
return value.includes(i.value);
|
|
3407
3417
|
}) : isMulti ? options.filter(function (i) {
|
|
@@ -3428,7 +3438,7 @@ var CustomCreatable = function CustomCreatable(_ref) {
|
|
|
3428
3438
|
}, rest));
|
|
3429
3439
|
};
|
|
3430
3440
|
|
|
3431
|
-
var _excluded$
|
|
3441
|
+
var _excluded$7 = ["defaultValue", "options", "isDisabled", "scrollBottom", "value", "isMulti"];
|
|
3432
3442
|
var CustomSelectOption = function CustomSelectOption(_ref) {
|
|
3433
3443
|
var defaultValue = _ref.defaultValue,
|
|
3434
3444
|
options = _ref.options,
|
|
@@ -3436,7 +3446,7 @@ var CustomSelectOption = function CustomSelectOption(_ref) {
|
|
|
3436
3446
|
scrollBottom = _ref.scrollBottom,
|
|
3437
3447
|
value = _ref.value,
|
|
3438
3448
|
isMulti = _ref.isMulti,
|
|
3439
|
-
rest = _objectWithoutPropertiesLoose(_ref, _excluded$
|
|
3449
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$7);
|
|
3440
3450
|
var initialValues = defaultValue !== null && typeof defaultValue !== "undefined" ? options.find(function (option) {
|
|
3441
3451
|
return option.value === defaultValue;
|
|
3442
3452
|
}) || null : null;
|