@8btc/mditor 0.0.32 → 0.0.33
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 +43 -65
- package/dist/index.min.js +1 -1
- package/dist/js/mathjax/tex-svg-full.js +34 -1
- package/dist/method.js +42 -64
- package/dist/method.min.js +1 -1
- package/package.json +1 -1
- package/src/ts/markdown/mathRender.ts +44 -63
- package/src/ts/util/addScript.ts +3 -5
package/dist/index.css
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Vditor v0.0.
|
|
2
|
+
* Vditor v0.0.33 - 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.33 - 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.33 - 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.33";
|
|
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.33");
|
|
3229
3229
|
Constants.MARKDOWN_OPTIONS = {
|
|
3230
3230
|
autoSpace: false,
|
|
3231
3231
|
gfmAutoLink: true,
|
|
@@ -5592,48 +5592,8 @@ 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
|
-
|
|
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
|
-
}
|
|
5595
|
+
// 循环加载会抛异常
|
|
5596
|
+
(0,_util_addScript__WEBPACK_IMPORTED_MODULE_4__/* .addScriptSync */ .J)("".concat(options.cdn, "/dist/js/mathjax/tex-svg-full.js"), "protyleMathJaxScript");
|
|
5637
5597
|
var renderMath_1 = function (mathElement, next) {
|
|
5638
5598
|
var rawText = (0,_util_code160to32__WEBPACK_IMPORTED_MODULE_5__/* .code160to32 */ .X)(mathElement.textContent).trim();
|
|
5639
5599
|
var math = normalizeTex(rawText);
|
|
@@ -5642,7 +5602,6 @@ var mathRender = function (element, options) {
|
|
|
5642
5602
|
var mathOptions = window.MathJax.getMetricsFor(mathElement);
|
|
5643
5603
|
mathOptions.display = inPreviewPre || mathElement.tagName === "DIV";
|
|
5644
5604
|
window.MathJax.tex2svgPromise(math, mathOptions).then(function (node) {
|
|
5645
|
-
var _a, _b;
|
|
5646
5605
|
mathElement.innerHTML = "";
|
|
5647
5606
|
mathElement.setAttribute("data-math", math);
|
|
5648
5607
|
mathElement.append(node);
|
|
@@ -5653,25 +5612,15 @@ var mathRender = function (element, options) {
|
|
|
5653
5612
|
// 绑定自定义右键菜单(编辑区生效,预览区自动跳过)
|
|
5654
5613
|
(0,_mathContextMenu__WEBPACK_IMPORTED_MODULE_2__/* .bindMathContextMenu */ .xX)(mathElement);
|
|
5655
5614
|
// 限定 document 范围为当前容器后再 clear/updateDocument,避免处理整页导致编辑器外的 $...$ 被重新渲染;不调用会导致同一公式被渲染 2 次
|
|
5656
|
-
|
|
5657
|
-
|
|
5658
|
-
|
|
5659
|
-
|
|
5660
|
-
|
|
5661
|
-
|
|
5662
|
-
|
|
5663
|
-
|
|
5664
|
-
|
|
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
|
-
}
|
|
5615
|
+
var startup = window.MathJax.startup;
|
|
5616
|
+
var prevElements = startup.elements;
|
|
5617
|
+
if (element instanceof HTMLElement) {
|
|
5618
|
+
startup.elements = [element];
|
|
5619
|
+
}
|
|
5620
|
+
startup.document.clear();
|
|
5621
|
+
startup.document.updateDocument();
|
|
5622
|
+
startup.elements =
|
|
5623
|
+
prevElements !== undefined ? prevElements : [];
|
|
5675
5624
|
var errorTextElement = node.querySelector('[data-mml-node="merror"]');
|
|
5676
5625
|
if (errorTextElement &&
|
|
5677
5626
|
errorTextElement.textContent.trim() !== "") {
|
|
@@ -5684,6 +5633,35 @@ var mathRender = function (element, options) {
|
|
|
5684
5633
|
}
|
|
5685
5634
|
});
|
|
5686
5635
|
};
|
|
5636
|
+
window.MathJax.startup.promise.then(function () {
|
|
5637
|
+
// 限定仅处理当前容器,避免组件内部或用户配置导致处理整页、影响编辑器以外的公式
|
|
5638
|
+
if (window.MathJax.startup) {
|
|
5639
|
+
window.MathJax.startup.typeset = true;
|
|
5640
|
+
window.MathJax.startup.elements =
|
|
5641
|
+
element instanceof HTMLElement ? [element] : [];
|
|
5642
|
+
}
|
|
5643
|
+
var chains = [];
|
|
5644
|
+
var _loop_1 = function (i) {
|
|
5645
|
+
var mathElement = mathElements[i];
|
|
5646
|
+
if (!mathElement.parentElement.classList.contains("vditor-wysiwyg__pre") &&
|
|
5647
|
+
!mathElement.parentElement.classList.contains("vditor-ir__marker--pre") &&
|
|
5648
|
+
!mathElement.getAttribute("data-math") &&
|
|
5649
|
+
(0,_util_code160to32__WEBPACK_IMPORTED_MODULE_5__/* .code160to32 */ .X)(mathElement.textContent).trim()) {
|
|
5650
|
+
chains.push(function (next) {
|
|
5651
|
+
if (i === mathElements.length - 1) {
|
|
5652
|
+
renderMath_1(mathElement);
|
|
5653
|
+
}
|
|
5654
|
+
else {
|
|
5655
|
+
renderMath_1(mathElement, next);
|
|
5656
|
+
}
|
|
5657
|
+
});
|
|
5658
|
+
}
|
|
5659
|
+
};
|
|
5660
|
+
for (var i = 0; i < mathElements.length; i++) {
|
|
5661
|
+
_loop_1(i);
|
|
5662
|
+
}
|
|
5663
|
+
chainAsync_1(chains);
|
|
5664
|
+
});
|
|
5687
5665
|
}
|
|
5688
5666
|
};
|
|
5689
5667
|
|