@8btc/mditor 0.0.31 → 0.0.32
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.css +2 -2
- package/dist/index.js +65 -42
- package/dist/index.min.js +1 -1
- package/dist/method.js +64 -41
- package/dist/method.min.js +1 -1
- package/package.json +1 -1
- package/src/ts/markdown/mathRender.ts +64 -45
- package/src/ts/util/addScript.ts +5 -3
package/dist/index.css
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Vditor v0.0.
|
|
2
|
+
* Vditor v0.0.32 - A markdown editor written in TypeScript.
|
|
3
3
|
*
|
|
4
4
|
* MIT License
|
|
5
5
|
*
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
*
|
|
26
26
|
*/
|
|
27
27
|
/*!
|
|
28
|
-
* Vditor v0.0.
|
|
28
|
+
* Vditor v0.0.32 - A markdown editor written in TypeScript.
|
|
29
29
|
*
|
|
30
30
|
* MIT License
|
|
31
31
|
*
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Vditor v0.0.
|
|
2
|
+
* Vditor v0.0.32 - A markdown editor written in TypeScript.
|
|
3
3
|
*
|
|
4
4
|
* MIT License
|
|
5
5
|
*
|
|
@@ -2923,7 +2923,7 @@ var Vditor = /** @class */ (function () {
|
|
|
2923
2923
|
/* harmony export */ "H": () => (/* binding */ _VDITOR_VERSION),
|
|
2924
2924
|
/* harmony export */ "g": () => (/* binding */ Constants)
|
|
2925
2925
|
/* harmony export */ });
|
|
2926
|
-
var _VDITOR_VERSION = "0.0.
|
|
2926
|
+
var _VDITOR_VERSION = "0.0.32";
|
|
2927
2927
|
|
|
2928
2928
|
var Constants = /** @class */ (function () {
|
|
2929
2929
|
function Constants() {
|
|
@@ -3225,7 +3225,7 @@ var Constants = /** @class */ (function () {
|
|
|
3225
3225
|
"c#",
|
|
3226
3226
|
"bat",
|
|
3227
3227
|
];
|
|
3228
|
-
Constants.CDN = "https://webcdn.wujieai.com/vditor@".concat("0.0.
|
|
3228
|
+
Constants.CDN = "https://webcdn.wujieai.com/vditor@".concat("0.0.32");
|
|
3229
3229
|
Constants.MARKDOWN_OPTIONS = {
|
|
3230
3230
|
autoSpace: false,
|
|
3231
3231
|
gfmAutoLink: true,
|
|
@@ -5592,8 +5592,48 @@ var mathRender = function (element, options) {
|
|
|
5592
5592
|
// https://github.com/Vanessa219/vditor/issues/1453
|
|
5593
5593
|
Object.assign(window.MathJax, options.math.mathJaxOptions);
|
|
5594
5594
|
}
|
|
5595
|
-
|
|
5596
|
-
|
|
5595
|
+
var mathJaxScriptUrl = "".concat(options.cdn, "/dist/js/mathjax/tex-svg-full.js");
|
|
5596
|
+
var mathJaxScriptId = "protyleMathJaxScript";
|
|
5597
|
+
// Qt WebView 中同步 XHR 被限制,addScriptSync 无法加载脚本,改为异步 addScript
|
|
5598
|
+
var isQtWebView_1 = typeof navigator !== "undefined" &&
|
|
5599
|
+
/Qt|QtWebEngine/i.test(navigator.userAgent);
|
|
5600
|
+
var runRenderChain = function () {
|
|
5601
|
+
window.MathJax.startup.promise.then(function () {
|
|
5602
|
+
if (window.MathJax.startup) {
|
|
5603
|
+
window.MathJax.startup.typeset = true;
|
|
5604
|
+
window.MathJax.startup.elements =
|
|
5605
|
+
element instanceof HTMLElement ? [element] : [];
|
|
5606
|
+
}
|
|
5607
|
+
var chains = [];
|
|
5608
|
+
var _loop_1 = function (i) {
|
|
5609
|
+
var mathElement = mathElements[i];
|
|
5610
|
+
if (!mathElement.parentElement.classList.contains("vditor-wysiwyg__pre") &&
|
|
5611
|
+
!mathElement.parentElement.classList.contains("vditor-ir__marker--pre") &&
|
|
5612
|
+
!mathElement.getAttribute("data-math") &&
|
|
5613
|
+
(0,_util_code160to32__WEBPACK_IMPORTED_MODULE_5__/* .code160to32 */ .X)(mathElement.textContent).trim()) {
|
|
5614
|
+
chains.push(function (next) {
|
|
5615
|
+
if (i === mathElements.length - 1) {
|
|
5616
|
+
renderMath_1(mathElement);
|
|
5617
|
+
}
|
|
5618
|
+
else {
|
|
5619
|
+
renderMath_1(mathElement, next);
|
|
5620
|
+
}
|
|
5621
|
+
});
|
|
5622
|
+
}
|
|
5623
|
+
};
|
|
5624
|
+
for (var i = 0; i < mathElements.length; i++) {
|
|
5625
|
+
_loop_1(i);
|
|
5626
|
+
}
|
|
5627
|
+
chainAsync_1(chains);
|
|
5628
|
+
});
|
|
5629
|
+
};
|
|
5630
|
+
if (isQtWebView_1) {
|
|
5631
|
+
(0,_util_addScript__WEBPACK_IMPORTED_MODULE_4__/* .addScript */ .G)(mathJaxScriptUrl, mathJaxScriptId).then(runRenderChain);
|
|
5632
|
+
}
|
|
5633
|
+
else {
|
|
5634
|
+
(0,_util_addScript__WEBPACK_IMPORTED_MODULE_4__/* .addScriptSync */ .J)(mathJaxScriptUrl, mathJaxScriptId);
|
|
5635
|
+
runRenderChain();
|
|
5636
|
+
}
|
|
5597
5637
|
var renderMath_1 = function (mathElement, next) {
|
|
5598
5638
|
var rawText = (0,_util_code160to32__WEBPACK_IMPORTED_MODULE_5__/* .code160to32 */ .X)(mathElement.textContent).trim();
|
|
5599
5639
|
var math = normalizeTex(rawText);
|
|
@@ -5602,6 +5642,7 @@ var mathRender = function (element, options) {
|
|
|
5602
5642
|
var mathOptions = window.MathJax.getMetricsFor(mathElement);
|
|
5603
5643
|
mathOptions.display = inPreviewPre || mathElement.tagName === "DIV";
|
|
5604
5644
|
window.MathJax.tex2svgPromise(math, mathOptions).then(function (node) {
|
|
5645
|
+
var _a, _b;
|
|
5605
5646
|
mathElement.innerHTML = "";
|
|
5606
5647
|
mathElement.setAttribute("data-math", math);
|
|
5607
5648
|
mathElement.append(node);
|
|
@@ -5612,14 +5653,25 @@ var mathRender = function (element, options) {
|
|
|
5612
5653
|
// 绑定自定义右键菜单(编辑区生效,预览区自动跳过)
|
|
5613
5654
|
(0,_mathContextMenu__WEBPACK_IMPORTED_MODULE_2__/* .bindMathContextMenu */ .xX)(mathElement);
|
|
5614
5655
|
// 限定 document 范围为当前容器后再 clear/updateDocument,避免处理整页导致编辑器外的 $...$ 被重新渲染;不调用会导致同一公式被渲染 2 次
|
|
5615
|
-
|
|
5616
|
-
|
|
5617
|
-
|
|
5618
|
-
|
|
5619
|
-
|
|
5620
|
-
|
|
5621
|
-
|
|
5622
|
-
|
|
5656
|
+
// Qt WebView 中 clear/updateDocument 可能清掉刚插入的节点或抛错,故跳过
|
|
5657
|
+
if (!isQtWebView_1) {
|
|
5658
|
+
try {
|
|
5659
|
+
var startup = window.MathJax.startup;
|
|
5660
|
+
var prevElements = startup.elements;
|
|
5661
|
+
if (element instanceof HTMLElement) {
|
|
5662
|
+
startup.elements = [element];
|
|
5663
|
+
}
|
|
5664
|
+
startup.document.clear();
|
|
5665
|
+
startup.document.updateDocument();
|
|
5666
|
+
startup.elements =
|
|
5667
|
+
prevElements !== undefined ? prevElements : [];
|
|
5668
|
+
}
|
|
5669
|
+
catch (_) {
|
|
5670
|
+
if (((_b = (_a = window.MathJax) === null || _a === void 0 ? void 0 : _a.startup) === null || _b === void 0 ? void 0 : _b.elements) !== undefined) {
|
|
5671
|
+
window.MathJax.startup.elements = [];
|
|
5672
|
+
}
|
|
5673
|
+
}
|
|
5674
|
+
}
|
|
5623
5675
|
var errorTextElement = node.querySelector('[data-mml-node="merror"]');
|
|
5624
5676
|
if (errorTextElement &&
|
|
5625
5677
|
errorTextElement.textContent.trim() !== "") {
|
|
@@ -5632,35 +5684,6 @@ var mathRender = function (element, options) {
|
|
|
5632
5684
|
}
|
|
5633
5685
|
});
|
|
5634
5686
|
};
|
|
5635
|
-
window.MathJax.startup.promise.then(function () {
|
|
5636
|
-
// 限定仅处理当前容器,避免组件内部或用户配置导致处理整页、影响编辑器以外的公式
|
|
5637
|
-
if (window.MathJax.startup) {
|
|
5638
|
-
window.MathJax.startup.typeset = true;
|
|
5639
|
-
window.MathJax.startup.elements =
|
|
5640
|
-
element instanceof HTMLElement ? [element] : [];
|
|
5641
|
-
}
|
|
5642
|
-
var chains = [];
|
|
5643
|
-
var _loop_1 = function (i) {
|
|
5644
|
-
var mathElement = mathElements[i];
|
|
5645
|
-
if (!mathElement.parentElement.classList.contains("vditor-wysiwyg__pre") &&
|
|
5646
|
-
!mathElement.parentElement.classList.contains("vditor-ir__marker--pre") &&
|
|
5647
|
-
!mathElement.getAttribute("data-math") &&
|
|
5648
|
-
(0,_util_code160to32__WEBPACK_IMPORTED_MODULE_5__/* .code160to32 */ .X)(mathElement.textContent).trim()) {
|
|
5649
|
-
chains.push(function (next) {
|
|
5650
|
-
if (i === mathElements.length - 1) {
|
|
5651
|
-
renderMath_1(mathElement);
|
|
5652
|
-
}
|
|
5653
|
-
else {
|
|
5654
|
-
renderMath_1(mathElement, next);
|
|
5655
|
-
}
|
|
5656
|
-
});
|
|
5657
|
-
}
|
|
5658
|
-
};
|
|
5659
|
-
for (var i = 0; i < mathElements.length; i++) {
|
|
5660
|
-
_loop_1(i);
|
|
5661
|
-
}
|
|
5662
|
-
chainAsync_1(chains);
|
|
5663
|
-
});
|
|
5664
5687
|
}
|
|
5665
5688
|
};
|
|
5666
5689
|
|