@8btc/mditor 0.0.26 → 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 +2 -2
- package/dist/index.js +10 -174
- package/dist/index.min.js +1 -1
- package/dist/js/lute/lute.min.js +3 -3
- package/dist/method.js +7 -170
- package/dist/method.min.js +1 -1
- package/dist/types/index.d.ts +0 -16
- package/package.json +1 -1
- package/src/ts/markdown/mathRender.ts +4 -1
- package/src/ts/markdown/previewRender.ts +1 -6
- package/src/ts/util/Options.ts +0 -1
- package/src/ts/util/attachLineNumbers.ts +1 -20
- package/dist/ts/markdown/customRender.d.ts +0 -73
- package/src/ts/markdown/customRender.ts +0 -203
package/dist/index.css
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Vditor v0.0.
|
|
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.
|
|
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.
|
|
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
|
-
/***/
|
|
2264
|
+
/***/ 408:
|
|
2265
2265
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
2266
2266
|
|
|
2267
2267
|
"use strict";
|
|
@@ -2490,148 +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
|
-
console.log(element, customComponents, "customComponents");
|
|
2583
|
-
// 反向遍历以避免 DOM 修改时的索引问题
|
|
2584
|
-
Array.from(customElements)
|
|
2585
|
-
.reverse()
|
|
2586
|
-
.forEach(function (el) {
|
|
2587
|
-
var attributes = {};
|
|
2588
|
-
el.getAttributeNames().forEach(function (name) {
|
|
2589
|
-
attributes[name] = el.getAttribute(name) || "";
|
|
2590
|
-
});
|
|
2591
|
-
// 使用 innerHTML 保留内部 HTML 内容,而不仅仅是纯文本
|
|
2592
|
-
var content = el.innerHTML || "";
|
|
2593
|
-
// 使用 HTML 渲染
|
|
2594
|
-
var htmlString = component.renderHTML(__assign(__assign({}, attributes), { children: content }));
|
|
2595
|
-
el.outerHTML = htmlString;
|
|
2596
|
-
});
|
|
2597
|
-
});
|
|
2598
|
-
}
|
|
2599
|
-
/**
|
|
2600
|
-
* 批量处理自定义组件 - 用于预处理 HTML 字符串
|
|
2601
|
-
* @param html HTML 字符串
|
|
2602
|
-
* @param customComponents 自定义组件集合
|
|
2603
|
-
* @returns 处理后的 HTML 字符串
|
|
2604
|
-
*/
|
|
2605
|
-
function processCustomComponents(html, customComponents) {
|
|
2606
|
-
var result = html;
|
|
2607
|
-
Object.keys(customComponents).forEach(function (tagName) {
|
|
2608
|
-
var component = customComponents[tagName];
|
|
2609
|
-
result = renderCustomComponentHTML(result, tagName, component);
|
|
2610
|
-
});
|
|
2611
|
-
return result;
|
|
2612
|
-
}
|
|
2613
|
-
/**
|
|
2614
|
-
* 处理 markdown 中的自定义组件
|
|
2615
|
-
* 将 markdown 中的自定义标签转换为对应的 HTML
|
|
2616
|
-
* @param markdown markdown 字符串
|
|
2617
|
-
* @param customComponents 自定义组件集合
|
|
2618
|
-
* @returns 处理后的 markdown 字符串
|
|
2619
|
-
*/
|
|
2620
|
-
function processMarkdownCustomComponents(markdown, customComponents) {
|
|
2621
|
-
var result = markdown;
|
|
2622
|
-
Object.keys(customComponents).forEach(function (tagName) {
|
|
2623
|
-
var component = customComponents[tagName];
|
|
2624
|
-
result = renderCustomComponentHTML(result, tagName, component);
|
|
2625
|
-
});
|
|
2626
|
-
return result;
|
|
2627
|
-
}
|
|
2628
|
-
/**
|
|
2629
|
-
* 导出默认函数和其他公共 API
|
|
2630
|
-
*/
|
|
2631
|
-
function customRender(element, customComponents) {
|
|
2632
|
-
renderCustomComponents(element, customComponents);
|
|
2633
|
-
}
|
|
2634
|
-
|
|
2635
2493
|
;// CONCATENATED MODULE: ./src/ts/markdown/previewRender.ts
|
|
2636
2494
|
var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2637
2495
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
@@ -2691,7 +2549,6 @@ var __generator = (undefined && undefined.__generator) || function (thisArg, bod
|
|
|
2691
2549
|
|
|
2692
2550
|
|
|
2693
2551
|
|
|
2694
|
-
|
|
2695
2552
|
|
|
2696
2553
|
|
|
2697
2554
|
var mergeOptions = function (options) {
|
|
@@ -2832,8 +2689,6 @@ var previewRender = function (previewElement, markdown, options) { return __awai
|
|
|
2832
2689
|
_a.sent();
|
|
2833
2690
|
_a.label = 8;
|
|
2834
2691
|
case 8:
|
|
2835
|
-
console.log(previewElement, "previewElement");
|
|
2836
|
-
customRender(previewElement, mergedOptions.customComponents || {});
|
|
2837
2692
|
(0,setContentTheme/* setContentTheme */.Z)(mergedOptions.theme.current, mergedOptions.theme.path);
|
|
2838
2693
|
if (mergedOptions.anchor === 1) {
|
|
2839
2694
|
previewElement.classList.add("vditor-reset--anchor");
|
|
@@ -2906,7 +2761,6 @@ var previewRender = function (previewElement, markdown, options) { return __awai
|
|
|
2906
2761
|
.querySelectorAll(".language-math")
|
|
2907
2762
|
.forEach(function (mathEl) {
|
|
2908
2763
|
var mathSource = mathEl.getAttribute("data-math");
|
|
2909
|
-
console.log(mathEl.tagName, "mathEl");
|
|
2910
2764
|
if (mathSource) {
|
|
2911
2765
|
if (mathEl.tagName === "SPAN") {
|
|
2912
2766
|
var textNode = document.createTextNode("$".concat(mathSource, "$"));
|
|
@@ -3069,7 +2923,7 @@ var Vditor = /** @class */ (function () {
|
|
|
3069
2923
|
/* harmony export */ "H": () => (/* binding */ _VDITOR_VERSION),
|
|
3070
2924
|
/* harmony export */ "g": () => (/* binding */ Constants)
|
|
3071
2925
|
/* harmony export */ });
|
|
3072
|
-
var _VDITOR_VERSION = "0.0.
|
|
2926
|
+
var _VDITOR_VERSION = "0.0.28";
|
|
3073
2927
|
|
|
3074
2928
|
var Constants = /** @class */ (function () {
|
|
3075
2929
|
function Constants() {
|
|
@@ -3371,7 +3225,7 @@ var Constants = /** @class */ (function () {
|
|
|
3371
3225
|
"c#",
|
|
3372
3226
|
"bat",
|
|
3373
3227
|
];
|
|
3374
|
-
Constants.CDN = "https://webcdn.wujieai.com/vditor@".concat("0.0.
|
|
3228
|
+
Constants.CDN = "https://webcdn.wujieai.com/vditor@".concat("0.0.28");
|
|
3375
3229
|
Constants.MARKDOWN_OPTIONS = {
|
|
3376
3230
|
autoSpace: false,
|
|
3377
3231
|
gfmAutoLink: true,
|
|
@@ -5706,12 +5560,15 @@ var mathRender = function (element, options) {
|
|
|
5706
5560
|
next();
|
|
5707
5561
|
};
|
|
5708
5562
|
if (!window.MathJax) {
|
|
5563
|
+
// 关闭自动 typeset,避免处理整个 document 导致页面其他区域(如用户消息)中的 $...$ 被重新渲染。
|
|
5564
|
+
// 公式仅由本函数内对 tex2svgPromise 的显式调用渲染,且仅针对传入的 element 内的节点。
|
|
5709
5565
|
window.MathJax = {
|
|
5710
5566
|
loader: {
|
|
5711
5567
|
paths: { mathjax: "".concat(options.cdn, "/dist/js/mathjax") },
|
|
5712
5568
|
},
|
|
5713
5569
|
startup: {
|
|
5714
|
-
typeset:
|
|
5570
|
+
typeset: false,
|
|
5571
|
+
elements: [],
|
|
5715
5572
|
},
|
|
5716
5573
|
tex: {
|
|
5717
5574
|
inlineMath: [
|
|
@@ -7213,26 +7070,6 @@ var attachLineNumbersToBlocks = function (root, sourceMarkdown) {
|
|
|
7213
7070
|
tableGroups: tableGroups,
|
|
7214
7071
|
});
|
|
7215
7072
|
}
|
|
7216
|
-
console.log("[LineNumber][perf]", {
|
|
7217
|
-
cached: !!cached,
|
|
7218
|
-
times: {
|
|
7219
|
-
normalize: Math.round((tNorm - t0) * 100) / 100,
|
|
7220
|
-
index: Math.round((tIndexDone - tNorm) * 100) / 100,
|
|
7221
|
-
blocks: Math.round((tBlockDone - tIndexDone) * 100) / 100,
|
|
7222
|
-
ul: Math.round((tUlDone - tBlockDone) * 100) / 100,
|
|
7223
|
-
ol: Math.round((tOlDone - tUlDone) * 100) / 100,
|
|
7224
|
-
table: Math.round((tTableDone - tIndexDone) * 100) / 100,
|
|
7225
|
-
apply: Math.round((tApplyDone - tTableDone) * 100) / 100,
|
|
7226
|
-
total: Math.round((tApplyDone - t0) * 100) / 100,
|
|
7227
|
-
},
|
|
7228
|
-
counts: {
|
|
7229
|
-
blocks: blocks.length,
|
|
7230
|
-
ul: ulElements.length,
|
|
7231
|
-
ol: olElements.length,
|
|
7232
|
-
tables: tables.length,
|
|
7233
|
-
updates: attrUpdates.length,
|
|
7234
|
-
},
|
|
7235
|
-
});
|
|
7236
7073
|
};
|
|
7237
7074
|
/**
|
|
7238
7075
|
* 节流后的行号更新函数,避免频繁更新 data-linenumber
|
|
@@ -8075,8 +7912,8 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
8075
7912
|
"default": () => (/* binding */ src)
|
|
8076
7913
|
});
|
|
8077
7914
|
|
|
8078
|
-
// EXTERNAL MODULE: ./src/method.ts +
|
|
8079
|
-
var method = __webpack_require__(
|
|
7915
|
+
// EXTERNAL MODULE: ./src/method.ts + 4 modules
|
|
7916
|
+
var method = __webpack_require__(408);
|
|
8080
7917
|
// EXTERNAL MODULE: ./src/ts/constants.ts
|
|
8081
7918
|
var constants = __webpack_require__(145);
|
|
8082
7919
|
// EXTERNAL MODULE: ./src/ts/markdown/getMarkdown.ts
|
|
@@ -18165,7 +18002,6 @@ var Options = /** @class */ (function () {
|
|
|
18165
18002
|
type: "markdown",
|
|
18166
18003
|
},
|
|
18167
18004
|
customRenders: [],
|
|
18168
|
-
customComponents: {},
|
|
18169
18005
|
debugger: false,
|
|
18170
18006
|
fullscreen: {
|
|
18171
18007
|
index: 90,
|