@8btc/mditor 0.0.27 → 0.0.28

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.27 - A markdown editor written in TypeScript.
2
+ * Vditor v0.0.28 - 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.27 - A markdown editor written in TypeScript.
28
+ * Vditor v0.0.28 - 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.27 - A markdown editor written in TypeScript.
2
+ * Vditor v0.0.28 - A markdown editor written in TypeScript.
3
3
  *
4
4
  * MIT License
5
5
  *
@@ -2261,7 +2261,7 @@ module.exports.DIFF_EQUAL = DIFF_EQUAL;
2261
2261
 
2262
2262
  /***/ }),
2263
2263
 
2264
- /***/ 242:
2264
+ /***/ 408:
2265
2265
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2266
2266
 
2267
2267
  "use strict";
@@ -2490,147 +2490,6 @@ var speechRender = function (element, lang) {
2490
2490
  var selectionRender = __webpack_require__(616);
2491
2491
  // EXTERNAL MODULE: ./src/ts/util/mathSelection.ts
2492
2492
  var mathSelection = __webpack_require__(35);
2493
- ;// CONCATENATED MODULE: ./src/ts/markdown/customRender.ts
2494
- /**
2495
- * 自定义组件渲染模块
2496
- * 支持将 HTML 标签(如 <read-button label="文献解读">)转换为自定义 HTML
2497
- */
2498
- var __assign = (undefined && undefined.__assign) || function () {
2499
- __assign = Object.assign || function(t) {
2500
- for (var s, i = 1, n = arguments.length; i < n; i++) {
2501
- s = arguments[i];
2502
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
2503
- t[p] = s[p];
2504
- }
2505
- return t;
2506
- };
2507
- return __assign.apply(this, arguments);
2508
- };
2509
- /**
2510
- * 解析 HTML 属性字符串
2511
- * @param str 属性字符串,如 'label="文献解读" id="test"'
2512
- * @returns 属性对象
2513
- */
2514
- function parseAttributes(str) {
2515
- var attributes = {};
2516
- if (!str)
2517
- return attributes;
2518
- var attrRegex = /(\w+)="([^"]*)"/g;
2519
- var match;
2520
- while ((match = attrRegex.exec(str)) !== null) {
2521
- attributes[match[1]] = match[2];
2522
- }
2523
- return attributes;
2524
- }
2525
- /**
2526
- * 从 HTML 字符串中提取自定义标签
2527
- * @param html HTML 字符串
2528
- * @param tagName 标签名称,如 'read-button'
2529
- * @returns 匹配的标签信息数组
2530
- */
2531
- function extractCustomTags(html, tagName) {
2532
- var results = [];
2533
- // 匹配自闭合标签和非自闭合标签
2534
- var selfClosingRegex = new RegExp("<".concat(tagName, "\\s+([^>]*)\\s*/>"), "g");
2535
- var openCloseRegex = new RegExp("<".concat(tagName, "\\s+([^>]*)>([^<]*)</").concat(tagName, ">"), "g");
2536
- var match;
2537
- // 处理自闭合标签
2538
- while ((match = selfClosingRegex.exec(html)) !== null) {
2539
- results.push({
2540
- fullTag: match[0],
2541
- attributes: parseAttributes(match[1]),
2542
- content: "",
2543
- });
2544
- }
2545
- // 处理开闭合标签
2546
- while ((match = openCloseRegex.exec(html)) !== null) {
2547
- results.push({
2548
- fullTag: match[0],
2549
- attributes: parseAttributes(match[1]),
2550
- content: match[2],
2551
- });
2552
- }
2553
- return results;
2554
- }
2555
- /**
2556
- * 使用 HTML 字符串渲染自定义标签
2557
- * @param html HTML 字符串
2558
- * @param tagName 标签名称
2559
- * @param component 自定义组件配置
2560
- * @returns 修改后的 HTML 字符串
2561
- */
2562
- function renderCustomComponentHTML(html, tagName, component) {
2563
- var tags = extractCustomTags(html, tagName);
2564
- var result = html;
2565
- // 反向遍历以保持位置正确性
2566
- for (var i = tags.length - 1; i >= 0; i--) {
2567
- var tag = tags[i];
2568
- var htmlString = component.renderHTML(tag.attributes);
2569
- result = result.replace(tag.fullTag, htmlString);
2570
- }
2571
- return result;
2572
- }
2573
- /**
2574
- * 在 DOM 元素中查找并渲染自定义组件
2575
- * @param element DOM 元素
2576
- * @param customComponents 自定义组件集合
2577
- */
2578
- function renderCustomComponents(element, customComponents) {
2579
- Object.keys(customComponents).forEach(function (tagName) {
2580
- var component = customComponents[tagName];
2581
- var customElements = element.querySelectorAll(tagName);
2582
- // 反向遍历以避免 DOM 修改时的索引问题
2583
- Array.from(customElements)
2584
- .reverse()
2585
- .forEach(function (el) {
2586
- var attributes = {};
2587
- el.getAttributeNames().forEach(function (name) {
2588
- attributes[name] = el.getAttribute(name) || "";
2589
- });
2590
- // 使用 innerHTML 保留内部 HTML 内容,而不仅仅是纯文本
2591
- var content = el.innerHTML || "";
2592
- // 使用 HTML 渲染
2593
- var htmlString = component.renderHTML(__assign(__assign({}, attributes), { children: content }));
2594
- el.outerHTML = htmlString;
2595
- });
2596
- });
2597
- }
2598
- /**
2599
- * 批量处理自定义组件 - 用于预处理 HTML 字符串
2600
- * @param html HTML 字符串
2601
- * @param customComponents 自定义组件集合
2602
- * @returns 处理后的 HTML 字符串
2603
- */
2604
- function processCustomComponents(html, customComponents) {
2605
- var result = html;
2606
- Object.keys(customComponents).forEach(function (tagName) {
2607
- var component = customComponents[tagName];
2608
- result = renderCustomComponentHTML(result, tagName, component);
2609
- });
2610
- return result;
2611
- }
2612
- /**
2613
- * 处理 markdown 中的自定义组件
2614
- * 将 markdown 中的自定义标签转换为对应的 HTML
2615
- * @param markdown markdown 字符串
2616
- * @param customComponents 自定义组件集合
2617
- * @returns 处理后的 markdown 字符串
2618
- */
2619
- function processMarkdownCustomComponents(markdown, customComponents) {
2620
- var result = markdown;
2621
- Object.keys(customComponents).forEach(function (tagName) {
2622
- var component = customComponents[tagName];
2623
- result = renderCustomComponentHTML(result, tagName, component);
2624
- });
2625
- return result;
2626
- }
2627
- /**
2628
- * 导出默认函数和其他公共 API
2629
- */
2630
- function customRender(element, customComponents) {
2631
- renderCustomComponents(element, customComponents);
2632
- }
2633
-
2634
2493
  ;// CONCATENATED MODULE: ./src/ts/markdown/previewRender.ts
2635
2494
  var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
2636
2495
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
@@ -2690,7 +2549,6 @@ var __generator = (undefined && undefined.__generator) || function (thisArg, bod
2690
2549
 
2691
2550
 
2692
2551
 
2693
-
2694
2552
 
2695
2553
 
2696
2554
  var mergeOptions = function (options) {
@@ -2831,7 +2689,6 @@ var previewRender = function (previewElement, markdown, options) { return __awai
2831
2689
  _a.sent();
2832
2690
  _a.label = 8;
2833
2691
  case 8:
2834
- customRender(previewElement, mergedOptions.customComponents || {});
2835
2692
  (0,setContentTheme/* setContentTheme */.Z)(mergedOptions.theme.current, mergedOptions.theme.path);
2836
2693
  if (mergedOptions.anchor === 1) {
2837
2694
  previewElement.classList.add("vditor-reset--anchor");
@@ -3066,7 +2923,7 @@ var Vditor = /** @class */ (function () {
3066
2923
  /* harmony export */ "H": () => (/* binding */ _VDITOR_VERSION),
3067
2924
  /* harmony export */ "g": () => (/* binding */ Constants)
3068
2925
  /* harmony export */ });
3069
- var _VDITOR_VERSION = "0.0.27";
2926
+ var _VDITOR_VERSION = "0.0.28";
3070
2927
 
3071
2928
  var Constants = /** @class */ (function () {
3072
2929
  function Constants() {
@@ -3368,7 +3225,7 @@ var Constants = /** @class */ (function () {
3368
3225
  "c#",
3369
3226
  "bat",
3370
3227
  ];
3371
- Constants.CDN = "https://webcdn.wujieai.com/vditor@".concat("0.0.27");
3228
+ Constants.CDN = "https://webcdn.wujieai.com/vditor@".concat("0.0.28");
3372
3229
  Constants.MARKDOWN_OPTIONS = {
3373
3230
  autoSpace: false,
3374
3231
  gfmAutoLink: true,
@@ -5703,12 +5560,15 @@ var mathRender = function (element, options) {
5703
5560
  next();
5704
5561
  };
5705
5562
  if (!window.MathJax) {
5563
+ // 关闭自动 typeset,避免处理整个 document 导致页面其他区域(如用户消息)中的 $...$ 被重新渲染。
5564
+ // 公式仅由本函数内对 tex2svgPromise 的显式调用渲染,且仅针对传入的 element 内的节点。
5706
5565
  window.MathJax = {
5707
5566
  loader: {
5708
5567
  paths: { mathjax: "".concat(options.cdn, "/dist/js/mathjax") },
5709
5568
  },
5710
5569
  startup: {
5711
- typeset: true,
5570
+ typeset: false,
5571
+ elements: [],
5712
5572
  },
5713
5573
  tex: {
5714
5574
  inlineMath: [
@@ -8052,8 +7912,8 @@ __webpack_require__.d(__webpack_exports__, {
8052
7912
  "default": () => (/* binding */ src)
8053
7913
  });
8054
7914
 
8055
- // EXTERNAL MODULE: ./src/method.ts + 5 modules
8056
- var method = __webpack_require__(242);
7915
+ // EXTERNAL MODULE: ./src/method.ts + 4 modules
7916
+ var method = __webpack_require__(408);
8057
7917
  // EXTERNAL MODULE: ./src/ts/constants.ts
8058
7918
  var constants = __webpack_require__(145);
8059
7919
  // EXTERNAL MODULE: ./src/ts/markdown/getMarkdown.ts
@@ -18142,7 +18002,6 @@ var Options = /** @class */ (function () {
18142
18002
  type: "markdown",
18143
18003
  },
18144
18004
  customRenders: [],
18145
- customComponents: {},
18146
18005
  debugger: false,
18147
18006
  fullscreen: {
18148
18007
  index: 90,