@8btc/mditor 0.0.33 → 0.0.34

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 CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Vditor v0.0.33 - A markdown editor written in TypeScript.
2
+ * Vditor v0.0.34 - 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.33 - A markdown editor written in TypeScript.
28
+ * Vditor v0.0.34 - 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.33 - A markdown editor written in TypeScript.
2
+ * Vditor v0.0.34 - 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.33";
2926
+ var _VDITOR_VERSION = "0.0.34";
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.33");
3228
+ Constants.CDN = "https://webcdn.wujieai.com/vditor@".concat("0.0.34");
3229
3229
  Constants.MARKDOWN_OPTIONS = {
3230
3230
  autoSpace: false,
3231
3231
  gfmAutoLink: true,
@@ -5472,8 +5472,8 @@ var normalizeTex = function (tex) {
5472
5472
  /**
5473
5473
  * 数学公式渲染入口
5474
5474
  *
5475
- * 默认使用 MathJax 渲染(SVG 输出),并在需要时按需加载相关脚本与样式。
5476
- * 支持通过 options.math.engine 切换为 KaTeX
5475
+ * 默认使用 KaTeX 渲染,并在需要时按需加载相关脚本与样式。
5476
+ * 支持通过 options.math.engine 切换为 MathJax
5477
5477
  *
5478
5478
  * 参数说明:
5479
5479
  * - element: 需要进行数学渲染的根容器(默认 document)
@@ -5488,7 +5488,7 @@ var mathRender = function (element, options) {
5488
5488
  var defaultOptions = {
5489
5489
  cdn: _constants__WEBPACK_IMPORTED_MODULE_0__/* .Constants.CDN */ .g.CDN,
5490
5490
  math: {
5491
- engine: "MathJax",
5491
+ engine: "KaTeX",
5492
5492
  inlineDigit: true,
5493
5493
  macros: {},
5494
5494
  },
@@ -5560,39 +5560,21 @@ var mathRender = function (element, options) {
5560
5560
  next();
5561
5561
  };
5562
5562
  if (!window.MathJax) {
5563
- // typeset 设为 true 以正常完成公式渲染;elements 限定为传入的容器,外部使用本包时仅处理该容器,不影响编辑器以外的公式。
5564
- // 渲染时会将 startup.elements 临时设为传入的 element(当前预览/编辑容器),再 clear/updateDocument。
5565
5563
  window.MathJax = {
5566
5564
  loader: {
5567
5565
  paths: { mathjax: "".concat(options.cdn, "/dist/js/mathjax") },
5568
5566
  },
5569
5567
  startup: {
5570
- typeset: true,
5568
+ typeset: false,
5571
5569
  elements: element instanceof HTMLElement ? [element] : [],
5572
5570
  },
5573
5571
  tex: {
5574
- inlineMath: [
5575
- ["$", "$"],
5576
- ["\\(", "\\)"],
5577
- ],
5578
- displayMath: [
5579
- ["$$", "$$"],
5580
- ["\\[", "\\]"],
5581
- ],
5582
- processEscapes: true,
5583
5572
  macros: options.math.macros,
5584
- // 启用 ams 与 unicode,支持 \unicode 宏以渲染 ∯(oiint)
5585
- packages: { "[+]": ["ams", "unicode", "noerrors"] },
5586
- },
5587
- // 关闭 MathJax 自带右键菜单,使用自定义菜单
5588
- options: {
5589
- enableMenu: false,
5590
5573
  },
5591
5574
  };
5592
- // https://github.com/Vanessa219/vditor/issues/1453
5575
+ // https://github.com/Vanessa219/vditor/issues/1453 额外配置(packages、inlineMath、displayMath 等)由调用方通过 mathJaxOptions 传入
5593
5576
  Object.assign(window.MathJax, options.math.mathJaxOptions);
5594
5577
  }
5595
- // 循环加载会抛异常
5596
5578
  (0,_util_addScript__WEBPACK_IMPORTED_MODULE_4__/* .addScriptSync */ .J)("".concat(options.cdn, "/dist/js/mathjax/tex-svg-full.js"), "protyleMathJaxScript");
5597
5579
  var renderMath_1 = function (mathElement, next) {
5598
5580
  var rawText = (0,_util_code160to32__WEBPACK_IMPORTED_MODULE_5__/* .code160to32 */ .X)(mathElement.textContent).trim();
@@ -5609,9 +5591,7 @@ var mathRender = function (element, options) {
5609
5591
  var pre = mathElement.parentElement;
5610
5592
  pre.classList.add("vditor-wysiwyg__preview--math");
5611
5593
  }
5612
- // 绑定自定义右键菜单(编辑区生效,预览区自动跳过)
5613
5594
  (0,_mathContextMenu__WEBPACK_IMPORTED_MODULE_2__/* .bindMathContextMenu */ .xX)(mathElement);
5614
- // 限定 document 范围为当前容器后再 clear/updateDocument,避免处理整页导致编辑器外的 $...$ 被重新渲染;不调用会导致同一公式被渲染 2 次
5615
5595
  var startup = window.MathJax.startup;
5616
5596
  var prevElements = startup.elements;
5617
5597
  if (element instanceof HTMLElement) {
@@ -5624,9 +5604,10 @@ var mathRender = function (element, options) {
5624
5604
  var errorTextElement = node.querySelector('[data-mml-node="merror"]');
5625
5605
  if (errorTextElement &&
5626
5606
  errorTextElement.textContent.trim() !== "") {
5627
- // 渲染失败时按普通文本展示原始内容
5628
- mathElement.textContent = rawText;
5629
- mathElement.className = "language-math";
5607
+ mathElement.innerHTML =
5608
+ errorTextElement.textContent.trim();
5609
+ mathElement.className =
5610
+ "language-math vditor-reset--error";
5630
5611
  }
5631
5612
  if (next) {
5632
5613
  next();
@@ -5634,7 +5615,6 @@ var mathRender = function (element, options) {
5634
5615
  });
5635
5616
  };
5636
5617
  window.MathJax.startup.promise.then(function () {
5637
- // 限定仅处理当前容器,避免组件内部或用户配置导致处理整页、影响编辑器以外的公式
5638
5618
  if (window.MathJax.startup) {
5639
5619
  window.MathJax.startup.typeset = true;
5640
5620
  window.MathJax.startup.elements =