vditor 3.8.6 → 3.8.10
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/README.md +11 -11
- package/dist/index.css +1 -1
- package/dist/index.min.js +189 -82
- package/dist/js/i18n/zh_CN.js +1 -1
- package/dist/js/lute/lute.min.js +14 -14
- package/dist/method.min.js +45 -21
- package/dist/ts/ui/initUI.d.ts +1 -0
- package/dist/ts/wysiwyg/index.d.ts +2 -0
- package/dist/types/index.d.ts +7 -3
- package/package.json +4 -4
- package/src/assets/.DS_Store +0 -0
- package/src/index.ts +12 -2
- package/src/ts/.DS_Store +0 -0
- package/src/ts/hint/index.ts +20 -11
- package/src/ts/markdown/codeRender.ts +8 -4
- package/src/ts/markdown/outlineRender.ts +5 -1
- package/src/ts/markdown/previewRender.ts +12 -4
- package/src/ts/markdown/speechRender.ts +6 -2
- package/src/ts/preview/index.ts +0 -1
- package/src/ts/toolbar/Info.ts +1 -1
- package/src/ts/ui/initUI.ts +19 -5
- package/src/ts/upload/index.ts +4 -4
- package/src/ts/util/editorCommonEvent.ts +2 -2
- package/src/ts/util/fixBrowserBehavior.ts +10 -6
- package/src/ts/wysiwyg/highlightToolbarWYSIWYG.ts +11 -3
- package/src/ts/wysiwyg/index.ts +8 -2
- package/CHANGELOG.md +0 -1069
- package/dist/images/.DS_Store +0 -0
- package/dist/js/.DS_Store +0 -0
- package/dist/js/lute/.DS_Store +0 -0
- package/dist/js/mathjax/.DS_Store +0 -0
package/dist/index.min.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Vditor v3.8.
|
|
2
|
+
* Vditor v3.8.10 - A markdown editor written in TypeScript.
|
|
3
3
|
*
|
|
4
4
|
* MIT License
|
|
5
5
|
*
|
|
@@ -1797,12 +1797,8 @@ diff_match_patch.prototype.patch_make = function (a, opt_b, opt_c) {
|
|
|
1797
1797
|
if (typeof a == 'string' && typeof opt_b == 'string' && typeof opt_c == 'undefined') {
|
|
1798
1798
|
// Method 1: text1, text2
|
|
1799
1799
|
// Compute diffs from text1 and text2.
|
|
1800
|
-
text1 =
|
|
1801
|
-
|
|
1802
|
-
a;
|
|
1803
|
-
diffs = this.diff_main(text1,
|
|
1804
|
-
/** @type {string} */
|
|
1805
|
-
opt_b, true);
|
|
1800
|
+
text1 = a;
|
|
1801
|
+
diffs = this.diff_main(text1, opt_b, true);
|
|
1806
1802
|
|
|
1807
1803
|
if (diffs.length > 2) {
|
|
1808
1804
|
this.diff_cleanupSemantic(diffs);
|
|
@@ -1811,27 +1807,17 @@ diff_match_patch.prototype.patch_make = function (a, opt_b, opt_c) {
|
|
|
1811
1807
|
} else if (a && typeof a == 'object' && typeof opt_b == 'undefined' && typeof opt_c == 'undefined') {
|
|
1812
1808
|
// Method 2: diffs
|
|
1813
1809
|
// Compute text1 from diffs.
|
|
1814
|
-
diffs =
|
|
1815
|
-
/** @type {!Array.<!diff_match_patch.Diff>} */
|
|
1816
|
-
a;
|
|
1810
|
+
diffs = a;
|
|
1817
1811
|
text1 = this.diff_text1(diffs);
|
|
1818
1812
|
} else if (typeof a == 'string' && opt_b && typeof opt_b == 'object' && typeof opt_c == 'undefined') {
|
|
1819
1813
|
// Method 3: text1, diffs
|
|
1820
|
-
text1 =
|
|
1821
|
-
|
|
1822
|
-
a;
|
|
1823
|
-
diffs =
|
|
1824
|
-
/** @type {!Array.<!diff_match_patch.Diff>} */
|
|
1825
|
-
opt_b;
|
|
1814
|
+
text1 = a;
|
|
1815
|
+
diffs = opt_b;
|
|
1826
1816
|
} else if (typeof a == 'string' && typeof opt_b == 'string' && opt_c && typeof opt_c == 'object') {
|
|
1827
1817
|
// Method 4: text1, text2, diffs
|
|
1828
1818
|
// text2 is not used.
|
|
1829
|
-
text1 =
|
|
1830
|
-
|
|
1831
|
-
a;
|
|
1832
|
-
diffs =
|
|
1833
|
-
/** @type {!Array.<!diff_match_patch.Diff>} */
|
|
1834
|
-
opt_c;
|
|
1819
|
+
text1 = a;
|
|
1820
|
+
diffs = opt_c;
|
|
1835
1821
|
} else {
|
|
1836
1822
|
throw new Error('Unknown call format to patch_make.');
|
|
1837
1823
|
}
|
|
@@ -2545,6 +2531,10 @@ var speechRender = function (element, lang) {
|
|
|
2545
2531
|
}
|
|
2546
2532
|
var playSVG = '<svg><use xlink:href="#vditor-icon-play"></use></svg>';
|
|
2547
2533
|
var pauseSVG = '<svg><use xlink:href="#vditor-icon-pause"></use></svg>';
|
|
2534
|
+
if (!document.getElementById("vditorIconScript")) {
|
|
2535
|
+
playSVG = '<svg viewBox="0 0 32 32"><path d="M3.436 0l25.128 16-25.128 16v-32z"></path></svg>';
|
|
2536
|
+
pauseSVG = '<svg viewBox="0 0 32 32"><path d="M20.617 0h9.128v32h-9.128v-32zM2.255 32v-32h9.128v32h-9.128z"></path></svg>';
|
|
2537
|
+
}
|
|
2548
2538
|
var speechDom = document.querySelector(".vditor-speech");
|
|
2549
2539
|
if (!speechDom) {
|
|
2550
2540
|
speechDom = document.createElement("div");
|
|
@@ -2736,7 +2726,7 @@ var md2html = function (mdText, options) {
|
|
|
2736
2726
|
});
|
|
2737
2727
|
};
|
|
2738
2728
|
var previewRender = function (previewElement, markdown, options) { return __awaiter(void 0, void 0, void 0, function () {
|
|
2739
|
-
var mergedOptions, html;
|
|
2729
|
+
var mergedOptions, html, i18nScriptPrefix, i18nScriptID_1;
|
|
2740
2730
|
return __generator(this, function (_a) {
|
|
2741
2731
|
switch (_a.label) {
|
|
2742
2732
|
case 0:
|
|
@@ -2749,17 +2739,32 @@ var previewRender = function (previewElement, markdown, options) { return __awai
|
|
|
2749
2739
|
}
|
|
2750
2740
|
previewElement.innerHTML = html;
|
|
2751
2741
|
previewElement.classList.add("vditor-reset");
|
|
2752
|
-
if (
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2742
|
+
if (!!mergedOptions.i18n) return [3 /*break*/, 5];
|
|
2743
|
+
if (!!["en_US", "ja_JP", "ko_KR", "ru_RU", "zh_CN", "zh_TW"].includes(mergedOptions.lang)) return [3 /*break*/, 2];
|
|
2744
|
+
throw new Error("options.lang error, see https://ld246.com/article/1549638745630#options");
|
|
2745
|
+
case 2:
|
|
2746
|
+
i18nScriptPrefix = "vditorI18nScript";
|
|
2747
|
+
i18nScriptID_1 = i18nScriptPrefix + mergedOptions.lang;
|
|
2748
|
+
document.querySelectorAll("head script[id^=\"" + i18nScriptPrefix + "\"]").forEach(function (el) {
|
|
2749
|
+
if (el.id !== i18nScriptID_1) {
|
|
2750
|
+
document.head.removeChild(el);
|
|
2758
2751
|
}
|
|
2759
|
-
}
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2752
|
+
});
|
|
2753
|
+
return [4 /*yield*/, (0,addScript/* addScript */.G)(mergedOptions.cdn + "/dist/js/i18n/" + mergedOptions.lang + ".js", i18nScriptID_1)];
|
|
2754
|
+
case 3:
|
|
2755
|
+
_a.sent();
|
|
2756
|
+
_a.label = 4;
|
|
2757
|
+
case 4: return [3 /*break*/, 6];
|
|
2758
|
+
case 5:
|
|
2759
|
+
window.VditorI18n = mergedOptions.i18n;
|
|
2760
|
+
_a.label = 6;
|
|
2761
|
+
case 6:
|
|
2762
|
+
if (!mergedOptions.icon) return [3 /*break*/, 8];
|
|
2763
|
+
return [4 /*yield*/, (0,addScript/* addScript */.G)(mergedOptions.cdn + "/dist/js/icons/" + mergedOptions.icon + ".js", "vditorIconScript")];
|
|
2764
|
+
case 7:
|
|
2765
|
+
_a.sent();
|
|
2766
|
+
_a.label = 8;
|
|
2767
|
+
case 8:
|
|
2763
2768
|
(0,setContentTheme/* setContentTheme */.Z)(mergedOptions.theme.current, mergedOptions.theme.path);
|
|
2764
2769
|
if (mergedOptions.anchor === 1) {
|
|
2765
2770
|
previewElement.classList.add("vditor-reset--anchor");
|
|
@@ -2790,9 +2795,6 @@ var previewRender = function (previewElement, markdown, options) { return __awai
|
|
|
2790
2795
|
if (mergedOptions.lazyLoadImage) {
|
|
2791
2796
|
lazyLoadImageRender(previewElement);
|
|
2792
2797
|
}
|
|
2793
|
-
if (mergedOptions.icon) {
|
|
2794
|
-
(0,addScript/* addScript */.G)(mergedOptions.cdn + "/dist/js/icons/" + mergedOptions.icon + ".js", "vditorIconScript");
|
|
2795
|
-
}
|
|
2796
2798
|
previewElement.addEventListener("click", function (event) {
|
|
2797
2799
|
var spanElement = (0,hasClosest/* hasClosestByMatchTag */.lG)(event.target, "SPAN");
|
|
2798
2800
|
if (spanElement && (0,hasClosest/* hasClosestByClassName */.fb)(spanElement, "vditor-toc")) {
|
|
@@ -2890,7 +2892,7 @@ var Vditor = /** @class */ (function () {
|
|
|
2890
2892
|
/* harmony export */ "H": () => (/* binding */ _VDITOR_VERSION),
|
|
2891
2893
|
/* harmony export */ "g": () => (/* binding */ Constants)
|
|
2892
2894
|
/* harmony export */ });
|
|
2893
|
-
var _VDITOR_VERSION = "3.8.
|
|
2895
|
+
var _VDITOR_VERSION = "3.8.10";
|
|
2894
2896
|
|
|
2895
2897
|
var Constants = /** @class */ (function () {
|
|
2896
2898
|
function Constants() {
|
|
@@ -2916,7 +2918,7 @@ var Constants = /** @class */ (function () {
|
|
|
2916
2918
|
"swift", "ini", "typescript", "vbnet", "yaml",
|
|
2917
2919
|
"ada", "clojure", "dart", "erb", "fortran", "gradle", "haskell", "julia", "julia-repl", "lisp", "matlab",
|
|
2918
2920
|
"pgsql", "powershell", "sql_more", "stata", "cmake", "mathematica"];
|
|
2919
|
-
Constants.CDN = "https://cdn.jsdelivr.net/npm/vditor@" + "3.8.
|
|
2921
|
+
Constants.CDN = "https://cdn.jsdelivr.net/npm/vditor@" + "3.8.10";
|
|
2920
2922
|
Constants.MARKDOWN_OPTIONS = {
|
|
2921
2923
|
autoSpace: false,
|
|
2922
2924
|
codeBlockPreview: true,
|
|
@@ -3107,6 +3109,7 @@ var chartRender = function (element, cdn, theme) {
|
|
|
3107
3109
|
|
|
3108
3110
|
var codeRender = function (element) {
|
|
3109
3111
|
element.querySelectorAll("pre > code").forEach(function (e, index) {
|
|
3112
|
+
var _a, _b, _c;
|
|
3110
3113
|
if (e.parentElement.classList.contains("vditor-wysiwyg__pre") ||
|
|
3111
3114
|
e.parentElement.classList.contains("vditor-ir__marker--pre")) {
|
|
3112
3115
|
return;
|
|
@@ -3134,10 +3137,13 @@ var codeRender = function (element) {
|
|
|
3134
3137
|
});
|
|
3135
3138
|
codeText = codeElement.innerText;
|
|
3136
3139
|
}
|
|
3140
|
+
var iconHTML = '<svg><use xlink:href="#vditor-icon-copy"></use></svg>';
|
|
3141
|
+
if (!document.getElementById("vditorIconScript")) {
|
|
3142
|
+
iconHTML = '<svg viewBox="0 0 32 32"><path d="M22.545-0h-17.455c-1.6 0-2.909 1.309-2.909 2.909v20.364h2.909v-20.364h17.455v-2.909zM26.909 5.818h-16c-1.6 0-2.909 1.309-2.909 2.909v20.364c0 1.6 1.309 2.909 2.909 2.909h16c1.6 0 2.909-1.309 2.909-2.909v-20.364c0-1.6-1.309-2.909-2.909-2.909zM26.909 29.091h-16v-20.364h16v20.364z"></path></svg>';
|
|
3143
|
+
}
|
|
3137
3144
|
var divElement = document.createElement("div");
|
|
3138
3145
|
divElement.className = "vditor-copy";
|
|
3139
|
-
divElement.innerHTML = "<span aria-label=\"" + window.VditorI18n.copy + "\"\nonmouseover=\"this.setAttribute('aria-label', '" + window.VditorI18n.copy + "')\"\nclass=\"vditor-tooltipped vditor-tooltipped__w\"\nonclick=\"this.previousElementSibling.select();document.execCommand('copy');" +
|
|
3140
|
-
("this.setAttribute('aria-label', '" + window.VditorI18n.copied + "')\"><svg><use xlink:href=\"#vditor-icon-copy\"></use></svg></span>");
|
|
3146
|
+
divElement.innerHTML = "<span aria-label=\"" + (((_a = window.VditorI18n) === null || _a === void 0 ? void 0 : _a.copy) || "复制") + "\"\nonmouseover=\"this.setAttribute('aria-label', '" + (((_b = window.VditorI18n) === null || _b === void 0 ? void 0 : _b.copy) || "复制") + "')\"\nclass=\"vditor-tooltipped vditor-tooltipped__w\"\nonclick=\"this.previousElementSibling.select();document.execCommand('copy');this.setAttribute('aria-label', '" + (((_c = window.VditorI18n) === null || _c === void 0 ? void 0 : _c.copy) || "已复制") + "')\">" + iconHTML + "</span>";
|
|
3141
3147
|
var textarea = document.createElement("textarea");
|
|
3142
3148
|
textarea.value = (0,_util_code160to32__WEBPACK_IMPORTED_MODULE_0__/* .code160to32 */ .X)(codeText);
|
|
3143
3149
|
divElement.insertAdjacentElement("afterbegin", textarea);
|
|
@@ -3822,7 +3828,11 @@ var outlineRender = function (contentElement, targetElement, vditor) {
|
|
|
3822
3828
|
var headingsElement = tempElement.firstElementChild.querySelectorAll("li > span[data-target-id]");
|
|
3823
3829
|
headingsElement.forEach(function (item, index) {
|
|
3824
3830
|
if (item.nextElementSibling && item.nextElementSibling.tagName === "UL") {
|
|
3825
|
-
|
|
3831
|
+
var iconHTML = "<svg class='vditor-outline__action'><use xlink:href='#vditor-icon-down'></use></svg>";
|
|
3832
|
+
if (!document.getElementById("vditorIconScript")) {
|
|
3833
|
+
iconHTML = '<svg class="vditor-outline__action" viewBox="0 0 32 32"><path d="M3.76 6.12l12.24 12.213 12.24-12.213 3.76 3.76-16 16-16-16 3.76-3.76z"></path></svg>';
|
|
3834
|
+
}
|
|
3835
|
+
item.innerHTML = iconHTML + "<span>" + item.innerHTML + "</span>";
|
|
3826
3836
|
}
|
|
3827
3837
|
else {
|
|
3828
3838
|
item.innerHTML = "<svg></svg><span>" + item.innerHTML + "</span>";
|
|
@@ -6241,6 +6251,7 @@ var setTheme = function (vditor) {
|
|
|
6241
6251
|
|
|
6242
6252
|
|
|
6243
6253
|
|
|
6254
|
+
|
|
6244
6255
|
var initUI = function (vditor) {
|
|
6245
6256
|
vditor.element.innerHTML = "";
|
|
6246
6257
|
vditor.element.classList.add("vditor");
|
|
@@ -6284,11 +6295,14 @@ var initUI = function (vditor) {
|
|
|
6284
6295
|
contentElement.appendChild(vditor.hint.element);
|
|
6285
6296
|
contentElement.appendChild(vditor.tip.element);
|
|
6286
6297
|
vditor.element.appendChild(contentElement);
|
|
6298
|
+
contentElement.addEventListener("click", function () {
|
|
6299
|
+
hidePanel(vditor, ["subToolbar"]);
|
|
6300
|
+
});
|
|
6287
6301
|
if (vditor.toolbar.elements.export) {
|
|
6288
6302
|
// for export pdf
|
|
6289
6303
|
vditor.element.insertAdjacentHTML("beforeend", '<iframe style="width: 100%;height: 0;border: 0"></iframe>');
|
|
6290
6304
|
}
|
|
6291
|
-
setEditMode(vditor, vditor.options.mode, afterRender(vditor
|
|
6305
|
+
setEditMode(vditor, vditor.options.mode, afterRender(vditor));
|
|
6292
6306
|
document.execCommand("DefaultParagraphSeparator", false, "p");
|
|
6293
6307
|
if (navigator.userAgent.indexOf("iPhone") > -1 && typeof window.visualViewport !== "undefined") {
|
|
6294
6308
|
// https://github.com/Vanessa219/vditor/issues/379
|
|
@@ -6323,10 +6337,14 @@ var setPadding = function (vditor) {
|
|
|
6323
6337
|
- vditor.options.preview.maxWidth) / 2;
|
|
6324
6338
|
vditor.ir.element.style.padding = "10px " + Math.max(minPadding, padding) + "px";
|
|
6325
6339
|
}
|
|
6326
|
-
if (vditor.preview.element.style.display !== "block"
|
|
6340
|
+
if (vditor.preview.element.style.display !== "block") {
|
|
6327
6341
|
vditor.toolbar.element.style.paddingLeft = Math.max(5, parseInt(vditor[vditor.currentMode].element.style.paddingLeft || "0", 10) +
|
|
6328
6342
|
(vditor.options.outline.position === "left" ? vditor.outline.element.offsetWidth : 0)) + "px";
|
|
6329
6343
|
}
|
|
6344
|
+
else {
|
|
6345
|
+
vditor.toolbar.element.style.paddingLeft = (5 +
|
|
6346
|
+
(vditor.options.outline.position === "left" ? vditor.outline.element.offsetWidth : 0)) + "px";
|
|
6347
|
+
}
|
|
6330
6348
|
};
|
|
6331
6349
|
var setTypewriterPosition = function (vditor) {
|
|
6332
6350
|
if (!vditor.options.typewriterMode) {
|
|
@@ -6346,9 +6364,14 @@ var setTypewriterPosition = function (vditor) {
|
|
|
6346
6364
|
// 由于 Firefox padding-bottom bug,只能使用 :after
|
|
6347
6365
|
vditor[vditor.currentMode].element.style.setProperty("--editor-bottom", ((height - vditor.toolbar.element.offsetHeight) / 2) + "px");
|
|
6348
6366
|
};
|
|
6349
|
-
var
|
|
6367
|
+
var resizeCb;
|
|
6368
|
+
function UIUnbindListener() {
|
|
6369
|
+
window.removeEventListener("resize", resizeCb);
|
|
6370
|
+
}
|
|
6371
|
+
var afterRender = function (vditor) {
|
|
6350
6372
|
setTypewriterPosition(vditor);
|
|
6351
|
-
|
|
6373
|
+
UIUnbindListener();
|
|
6374
|
+
window.addEventListener("resize", resizeCb = function () {
|
|
6352
6375
|
setPadding(vditor);
|
|
6353
6376
|
setTypewriterPosition(vditor);
|
|
6354
6377
|
});
|
|
@@ -7560,7 +7583,7 @@ var highlightToolbarWYSIWYG = function (vditor) {
|
|
|
7560
7583
|
codeElement_1.className.indexOf("language-") > -1
|
|
7561
7584
|
? codeElement_1.className.split("-")[1].split(" ")[0]
|
|
7562
7585
|
: "";
|
|
7563
|
-
language_1.oninput = function () {
|
|
7586
|
+
language_1.oninput = function (e) {
|
|
7564
7587
|
if (language_1.value.trim() !== "") {
|
|
7565
7588
|
codeElement_1.className = "language-" + language_1.value;
|
|
7566
7589
|
}
|
|
@@ -7574,6 +7597,13 @@ var highlightToolbarWYSIWYG = function (vditor) {
|
|
|
7574
7597
|
processCodeRender(blockRenderElement.lastElementChild, vditor);
|
|
7575
7598
|
}
|
|
7576
7599
|
afterRenderEvent(vditor);
|
|
7600
|
+
// 当鼠标点选语言时,触发自定义input事件
|
|
7601
|
+
if (e.detail === 1) {
|
|
7602
|
+
// 选择语言后,输入焦点切换到代码输入框
|
|
7603
|
+
range.setStart(codeElement_1.firstChild, 0);
|
|
7604
|
+
range.collapse(true);
|
|
7605
|
+
(0,selection/* setSelectionFocus */.Hc)(range);
|
|
7606
|
+
}
|
|
7577
7607
|
};
|
|
7578
7608
|
language_1.onkeydown = function (event) {
|
|
7579
7609
|
if (event.isComposing) {
|
|
@@ -7588,15 +7618,16 @@ var highlightToolbarWYSIWYG = function (vditor) {
|
|
|
7588
7618
|
event.preventDefault();
|
|
7589
7619
|
return;
|
|
7590
7620
|
}
|
|
7621
|
+
vditor.hint.select(event, vditor);
|
|
7591
7622
|
if (!(0,compatibility/* isCtrl */.yl)(event) &&
|
|
7592
7623
|
!event.shiftKey &&
|
|
7593
|
-
event.altKey &&
|
|
7594
7624
|
event.key === "Enter") {
|
|
7595
7625
|
range.setStart(codeElement_1.firstChild, 0);
|
|
7596
7626
|
range.collapse(true);
|
|
7597
7627
|
(0,selection/* setSelectionFocus */.Hc)(range);
|
|
7628
|
+
event.preventDefault();
|
|
7629
|
+
event.stopPropagation();
|
|
7598
7630
|
}
|
|
7599
|
-
vditor.hint.select(event, vditor);
|
|
7600
7631
|
};
|
|
7601
7632
|
language_1.onkeyup = function (event) {
|
|
7602
7633
|
if (event.isComposing ||
|
|
@@ -8641,7 +8672,7 @@ var focusEvent = function (vditor, editorElement) {
|
|
|
8641
8672
|
if (vditor.options.focus) {
|
|
8642
8673
|
vditor.options.focus(getMarkdown(vditor));
|
|
8643
8674
|
}
|
|
8644
|
-
hidePanel(vditor, ["subToolbar"]);
|
|
8675
|
+
hidePanel(vditor, ["subToolbar", "hint"]);
|
|
8645
8676
|
});
|
|
8646
8677
|
};
|
|
8647
8678
|
var dblclickEvent = function (vditor, editorElement) {
|
|
@@ -8679,7 +8710,7 @@ var dropEvent = function (vditor, editorElement) {
|
|
|
8679
8710
|
// 编辑器内选中文字拖拽
|
|
8680
8711
|
execAfterRender(vditor);
|
|
8681
8712
|
}
|
|
8682
|
-
else if (event.dataTransfer.types
|
|
8713
|
+
else if (event.dataTransfer.types.includes("Files") || event.dataTransfer.types.includes("text/html")) {
|
|
8683
8714
|
// 外部文件拖入编辑器中或者编辑器内选中文字拖拽
|
|
8684
8715
|
paste(vditor, event, {
|
|
8685
8716
|
pasteCode: function (code) {
|
|
@@ -9231,7 +9262,7 @@ var genUploadedLabel = function (responseText, vditor) {
|
|
|
9231
9262
|
type = type.toLowerCase();
|
|
9232
9263
|
if (type.indexOf(".wav") === 0 || type.indexOf(".mp3") === 0 || type.indexOf(".ogg") === 0) {
|
|
9233
9264
|
if (vditor.currentMode === "wysiwyg") {
|
|
9234
|
-
succFileText += "<div class=\"vditor-wysiwyg__block\" data-type=\"html-block\"\n data-block=\"0\"><pre><code><audio controls=\"controls\" src=\"" + path + "\"></audio></code></pre
|
|
9265
|
+
succFileText += "<div class=\"vditor-wysiwyg__block\" data-type=\"html-block\"\n data-block=\"0\"><pre><code><audio controls=\"controls\" src=\"" + path + "\"></audio></code></pre>\n";
|
|
9235
9266
|
}
|
|
9236
9267
|
else if (vditor.currentMode === "ir") {
|
|
9237
9268
|
succFileText += "<audio controls=\"controls\" src=\"" + path + "\"></audio>\n";
|
|
@@ -9249,7 +9280,7 @@ var genUploadedLabel = function (responseText, vditor) {
|
|
|
9249
9280
|
|| type.indexOf(".svg") === 0
|
|
9250
9281
|
|| type.indexOf(".webp") === 0) {
|
|
9251
9282
|
if (vditor.currentMode === "wysiwyg") {
|
|
9252
|
-
succFileText += "<img alt=\"" + filename + "\" src=\"" + path + "\"
|
|
9283
|
+
succFileText += "<img alt=\"" + filename + "\" src=\"" + path + "\">\n";
|
|
9253
9284
|
}
|
|
9254
9285
|
else {
|
|
9255
9286
|
succFileText += "\n";
|
|
@@ -9257,7 +9288,7 @@ var genUploadedLabel = function (responseText, vditor) {
|
|
|
9257
9288
|
}
|
|
9258
9289
|
else {
|
|
9259
9290
|
if (vditor.currentMode === "wysiwyg") {
|
|
9260
|
-
succFileText += "<a href=\"" + path + "\">" + filename + "</a
|
|
9291
|
+
succFileText += "<a href=\"" + path + "\">" + filename + "</a>\n";
|
|
9261
9292
|
}
|
|
9262
9293
|
else {
|
|
9263
9294
|
succFileText += "[" + filename + "](" + path + ")\n";
|
|
@@ -9282,14 +9313,16 @@ var uploadFiles = function (vditor, files, element) { return __awaiter(void 0, v
|
|
|
9282
9313
|
}
|
|
9283
9314
|
fileList.push(fileItem);
|
|
9284
9315
|
}
|
|
9285
|
-
if (vditor.options.upload.handler)
|
|
9286
|
-
|
|
9287
|
-
|
|
9288
|
-
|
|
9289
|
-
|
|
9290
|
-
|
|
9316
|
+
if (!vditor.options.upload.handler) return [3 /*break*/, 2];
|
|
9317
|
+
return [4 /*yield*/, vditor.options.upload.handler(fileList)];
|
|
9318
|
+
case 1:
|
|
9319
|
+
isValidate = _b.sent();
|
|
9320
|
+
if (typeof isValidate === "string") {
|
|
9321
|
+
vditor.tip.show(isValidate);
|
|
9291
9322
|
return [2 /*return*/];
|
|
9292
9323
|
}
|
|
9324
|
+
return [2 /*return*/];
|
|
9325
|
+
case 2:
|
|
9293
9326
|
if (!vditor.options.upload.url || !vditor.upload) {
|
|
9294
9327
|
if (element) {
|
|
9295
9328
|
element.value = "";
|
|
@@ -9297,12 +9330,12 @@ var uploadFiles = function (vditor, files, element) { return __awaiter(void 0, v
|
|
|
9297
9330
|
vditor.tip.show("please config: options.upload.url");
|
|
9298
9331
|
return [2 /*return*/];
|
|
9299
9332
|
}
|
|
9300
|
-
if (!vditor.options.upload.file) return [3 /*break*/,
|
|
9333
|
+
if (!vditor.options.upload.file) return [3 /*break*/, 4];
|
|
9301
9334
|
return [4 /*yield*/, vditor.options.upload.file(fileList)];
|
|
9302
|
-
case
|
|
9335
|
+
case 3:
|
|
9303
9336
|
fileList = _b.sent();
|
|
9304
|
-
_b.label =
|
|
9305
|
-
case
|
|
9337
|
+
_b.label = 4;
|
|
9338
|
+
case 4:
|
|
9306
9339
|
if (vditor.options.upload.validate) {
|
|
9307
9340
|
isValidate = vditor.options.upload.validate(fileList);
|
|
9308
9341
|
if (typeof isValidate === "string") {
|
|
@@ -9825,10 +9858,14 @@ var listToggle = function (vditor, range, type, cancel) {
|
|
|
9825
9858
|
var element = void 0;
|
|
9826
9859
|
if (type === "list") {
|
|
9827
9860
|
element = document.createElement("ul");
|
|
9861
|
+
element.setAttribute("data-marker", "*");
|
|
9828
9862
|
}
|
|
9829
9863
|
else {
|
|
9830
9864
|
element = document.createElement("ol");
|
|
9865
|
+
element.setAttribute("data-marker", "1.");
|
|
9831
9866
|
}
|
|
9867
|
+
element.setAttribute("data-block", "0");
|
|
9868
|
+
element.setAttribute("data-tight", itemElement.parentElement.getAttribute("data-tight"));
|
|
9832
9869
|
element.innerHTML = itemElement.parentElement.innerHTML;
|
|
9833
9870
|
itemElement.parentElement.parentNode.replaceChild(element, itemElement.parentElement);
|
|
9834
9871
|
}
|
|
@@ -10824,7 +10861,7 @@ var paste = function (vditor, event, callback) { return fixBrowserBehavior_await
|
|
|
10824
10861
|
else {
|
|
10825
10862
|
textHTML = event.dataTransfer.getData("text/html");
|
|
10826
10863
|
textPlain = event.dataTransfer.getData("text/plain");
|
|
10827
|
-
if (event.dataTransfer.types
|
|
10864
|
+
if (event.dataTransfer.types.includes("Files")) {
|
|
10828
10865
|
files = event.dataTransfer.items;
|
|
10829
10866
|
}
|
|
10830
10867
|
}
|
|
@@ -10908,6 +10945,7 @@ var paste = function (vditor, event, callback) { return fixBrowserBehavior_await
|
|
|
10908
10945
|
if (doc.body) {
|
|
10909
10946
|
textHTML = doc.body.innerHTML;
|
|
10910
10947
|
}
|
|
10948
|
+
textHTML = Lute.Sanitize(textHTML);
|
|
10911
10949
|
vditor.wysiwyg.getComments(vditor);
|
|
10912
10950
|
height = vditor[vditor.currentMode].element.scrollHeight;
|
|
10913
10951
|
code = processPasteCode(textHTML, textPlain, vditor.currentMode);
|
|
@@ -10966,7 +11004,7 @@ var paste = function (vditor, event, callback) { return fixBrowserBehavior_await
|
|
|
10966
11004
|
vditor.outline.render(vditor);
|
|
10967
11005
|
return [3 /*break*/, 6];
|
|
10968
11006
|
case 3:
|
|
10969
|
-
if (!(files.length > 0 && vditor.options.upload.url)) return [3 /*break*/, 5];
|
|
11007
|
+
if (!(files.length > 0 && (vditor.options.upload.url || vditor.options.upload.handler))) return [3 /*break*/, 5];
|
|
10970
11008
|
return [4 /*yield*/, uploadFiles(vditor, files)];
|
|
10971
11009
|
case 4:
|
|
10972
11010
|
_b.sent();
|
|
@@ -11254,6 +11292,42 @@ var process_processToolbar = function (vditor, actionBtn, prefix, suffix) {
|
|
|
11254
11292
|
};
|
|
11255
11293
|
|
|
11256
11294
|
;// CONCATENATED MODULE: ./src/ts/hint/index.ts
|
|
11295
|
+
var hint_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
11296
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
11297
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
11298
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
11299
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
11300
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
11301
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
11302
|
+
});
|
|
11303
|
+
};
|
|
11304
|
+
var hint_generator = (undefined && undefined.__generator) || function (thisArg, body) {
|
|
11305
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
11306
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
11307
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
11308
|
+
function step(op) {
|
|
11309
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
11310
|
+
while (_) try {
|
|
11311
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
11312
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
11313
|
+
switch (op[0]) {
|
|
11314
|
+
case 0: case 1: t = op; break;
|
|
11315
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
11316
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
11317
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
11318
|
+
default:
|
|
11319
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
11320
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
11321
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
11322
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
11323
|
+
if (t[2]) _.ops.pop();
|
|
11324
|
+
_.trys.pop(); continue;
|
|
11325
|
+
}
|
|
11326
|
+
op = body.call(thisArg, _);
|
|
11327
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
11328
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
11329
|
+
}
|
|
11330
|
+
};
|
|
11257
11331
|
|
|
11258
11332
|
|
|
11259
11333
|
|
|
@@ -11287,15 +11361,25 @@ var Hint = /** @class */ (function () {
|
|
|
11287
11361
|
return;
|
|
11288
11362
|
}
|
|
11289
11363
|
}
|
|
11290
|
-
if (vditor.currentMode === "wysiwyg" && range.startContainer.nodeType !== 3
|
|
11291
|
-
range.startContainer
|
|
11292
|
-
var inputElement =
|
|
11293
|
-
|
|
11294
|
-
|
|
11295
|
-
|
|
11296
|
-
|
|
11297
|
-
|
|
11298
|
-
|
|
11364
|
+
if (vditor.currentMode === "wysiwyg" && range.startContainer.nodeType !== 3) {
|
|
11365
|
+
var startContainer = range.startContainer;
|
|
11366
|
+
var inputElement = void 0;
|
|
11367
|
+
if (startContainer.classList.contains("vditor-input")) {
|
|
11368
|
+
inputElement = startContainer;
|
|
11369
|
+
}
|
|
11370
|
+
else {
|
|
11371
|
+
inputElement = startContainer.firstElementChild;
|
|
11372
|
+
}
|
|
11373
|
+
if (inputElement && inputElement.classList.contains("vditor-input")) {
|
|
11374
|
+
inputElement.value = value.trimRight();
|
|
11375
|
+
range.selectNodeContents(inputElement);
|
|
11376
|
+
range.collapse(false);
|
|
11377
|
+
// {detail: 1}用于标识这个自定义事件是在编程语言选择后触发的
|
|
11378
|
+
// 用于在鼠标选择语言后,自动聚焦到代码输入框
|
|
11379
|
+
inputElement.dispatchEvent(new CustomEvent("input", { detail: 1 }));
|
|
11380
|
+
_this.recentLanguage = value.trimRight();
|
|
11381
|
+
return;
|
|
11382
|
+
}
|
|
11299
11383
|
}
|
|
11300
11384
|
range.setStart(range.startContainer, _this.lastIndex);
|
|
11301
11385
|
range.deleteContents();
|
|
@@ -11379,9 +11463,19 @@ var Hint = /** @class */ (function () {
|
|
|
11379
11463
|
vditor.options.hint.extend.forEach(function (item) {
|
|
11380
11464
|
if (item.key === _this.splitChar) {
|
|
11381
11465
|
clearTimeout(_this.timeId);
|
|
11382
|
-
_this.timeId = window.setTimeout(function () {
|
|
11383
|
-
|
|
11384
|
-
|
|
11466
|
+
_this.timeId = window.setTimeout(function () { return hint_awaiter(_this, void 0, void 0, function () {
|
|
11467
|
+
var _a;
|
|
11468
|
+
return hint_generator(this, function (_b) {
|
|
11469
|
+
switch (_b.label) {
|
|
11470
|
+
case 0:
|
|
11471
|
+
_a = this.genHTML;
|
|
11472
|
+
return [4 /*yield*/, item.hint(key)];
|
|
11473
|
+
case 1:
|
|
11474
|
+
_a.apply(this, [_b.sent(), key, vditor]);
|
|
11475
|
+
return [2 /*return*/];
|
|
11476
|
+
}
|
|
11477
|
+
});
|
|
11478
|
+
}); }, vditor.options.hint.delay);
|
|
11385
11479
|
}
|
|
11386
11480
|
});
|
|
11387
11481
|
}
|
|
@@ -12982,7 +13076,7 @@ var Info = /** @class */ (function (_super) {
|
|
|
12982
13076
|
var _this = _super.call(this, vditor, menuItem) || this;
|
|
12983
13077
|
_this.element.children[0].addEventListener((0,compatibility/* getEventName */.Le)(), function (event) {
|
|
12984
13078
|
event.preventDefault();
|
|
12985
|
-
vditor.tip.show("<div style=\"max-width: 520px; font-size: 14px;line-height: 22px;margin-bottom: 14px;\">\n<p style=\"text-align: center;margin: 14px 0\">\n <em>\u4E0B\u4E00\u4EE3\u7684 Markdown \u7F16\u8F91\u5668\uFF0C\u4E3A\u672A\u6765\u800C\u6784\u5EFA</em>\n</p>\n<div style=\"display: flex;margin-bottom: 14px;flex-wrap: wrap;align-items: center\">\n <img src=\"https://cdn.jsdelivr.net/npm/vditor/src/assets/images/logo.png\" style=\"margin: 0 auto;height: 68px\"/>\n <div> </div>\n <div style=\"flex: 1;min-width: 250px\">\n Vditor \u662F\u4E00\u6B3E\u6D4F\u89C8\u5668\u7AEF\u7684 Markdown \u7F16\u8F91\u5668\uFF0C\u652F\u6301\u6240\u89C1\u5373\u6240\u5F97\u3001\u5373\u65F6\u6E32\u67D3\uFF08\u7C7B\u4F3C Typora\uFF09\u548C\u5206\u5C4F\u9884\u89C8\u6A21\u5F0F\u3002\n \u5B83\u4F7F\u7528 TypeScript \u5B9E\u73B0\uFF0C\u652F\u6301\u539F\u751F JavaScript\
|
|
13079
|
+
vditor.tip.show("<div style=\"max-width: 520px; font-size: 14px;line-height: 22px;margin-bottom: 14px;\">\n<p style=\"text-align: center;margin: 14px 0\">\n <em>\u4E0B\u4E00\u4EE3\u7684 Markdown \u7F16\u8F91\u5668\uFF0C\u4E3A\u672A\u6765\u800C\u6784\u5EFA</em>\n</p>\n<div style=\"display: flex;margin-bottom: 14px;flex-wrap: wrap;align-items: center\">\n <img src=\"https://cdn.jsdelivr.net/npm/vditor/src/assets/images/logo.png\" style=\"margin: 0 auto;height: 68px\"/>\n <div> </div>\n <div style=\"flex: 1;min-width: 250px\">\n Vditor \u662F\u4E00\u6B3E\u6D4F\u89C8\u5668\u7AEF\u7684 Markdown \u7F16\u8F91\u5668\uFF0C\u652F\u6301\u6240\u89C1\u5373\u6240\u5F97\u3001\u5373\u65F6\u6E32\u67D3\uFF08\u7C7B\u4F3C Typora\uFF09\u548C\u5206\u5C4F\u9884\u89C8\u6A21\u5F0F\u3002\n \u5B83\u4F7F\u7528 TypeScript \u5B9E\u73B0\uFF0C\u652F\u6301\u539F\u751F JavaScript \u4EE5\u53CA Vue\u3001React\u3001Angular \u548C Svelte \u7B49\u6846\u67B6\u3002\n </div>\n</div>\n<div style=\"display: flex;flex-wrap: wrap;\">\n <ul style=\"list-style: none;flex: 1;min-width:148px\">\n <li>\n \u9879\u76EE\u5730\u5740\uFF1A<a href=\"https://b3log.org/vditor\" target=\"_blank\">b3log.org/vditor</a>\n </li>\n <li>\n \u5F00\u6E90\u534F\u8BAE\uFF1AMIT\n </li>\n </ul>\n <ul style=\"list-style: none;margin-right: 18px\">\n <li>\n \u7EC4\u4EF6\u7248\u672C\uFF1AVditor v" + constants/* VDITOR_VERSION */.H + " / Lute v" + Lute.Version + "\n </li>\n <li>\n \u8D5E\u52A9\u6350\u8D60\uFF1A<a href=\"https://ld246.com/sponsor\" target=\"_blank\">https://ld246.com/sponsor</a>\n </li>\n </ul>\n</div>\n</div>", 0);
|
|
12986
13080
|
});
|
|
12987
13081
|
return _this;
|
|
12988
13082
|
}
|
|
@@ -14556,6 +14650,9 @@ var WYSIWYG = /** @class */ (function () {
|
|
|
14556
14650
|
WYSIWYG.prototype.hideComment = function () {
|
|
14557
14651
|
this.selectPopover.setAttribute("style", "display:none");
|
|
14558
14652
|
};
|
|
14653
|
+
WYSIWYG.prototype.unbindListener = function () {
|
|
14654
|
+
window.removeEventListener("scroll", this.scrollListener);
|
|
14655
|
+
};
|
|
14559
14656
|
WYSIWYG.prototype.copy = function (event, vditor) {
|
|
14560
14657
|
var range = getSelection().getRangeAt(0);
|
|
14561
14658
|
if (range.toString() === "") {
|
|
@@ -14595,7 +14692,8 @@ var WYSIWYG = /** @class */ (function () {
|
|
|
14595
14692
|
};
|
|
14596
14693
|
WYSIWYG.prototype.bindEvent = function (vditor) {
|
|
14597
14694
|
var _this = this;
|
|
14598
|
-
|
|
14695
|
+
this.unbindListener();
|
|
14696
|
+
window.addEventListener("scroll", this.scrollListener = function () {
|
|
14599
14697
|
hidePanel(vditor, ["hint"]);
|
|
14600
14698
|
if (_this.popover.style.display !== "block" || _this.selectPopover.style.display !== "block") {
|
|
14601
14699
|
return;
|
|
@@ -14967,7 +15065,14 @@ var Vditor = /** @class */ (function (_super) {
|
|
|
14967
15065
|
throw new Error("options.lang error, see https://ld246.com/article/1549638745630#options");
|
|
14968
15066
|
}
|
|
14969
15067
|
else {
|
|
14970
|
-
|
|
15068
|
+
var i18nScriptPrefix = "vditorI18nScript";
|
|
15069
|
+
var i18nScriptID_1 = i18nScriptPrefix + mergedOptions.lang;
|
|
15070
|
+
document.querySelectorAll("head script[id^=\"" + i18nScriptPrefix + "\"]").forEach(function (el) {
|
|
15071
|
+
if (el.id !== i18nScriptID_1) {
|
|
15072
|
+
document.head.removeChild(el);
|
|
15073
|
+
}
|
|
15074
|
+
});
|
|
15075
|
+
(0,addScript/* addScript */.G)(mergedOptions.cdn + "/dist/js/i18n/" + mergedOptions.lang + ".js", i18nScriptID_1).then(function () {
|
|
14971
15076
|
_this.init(id, mergedOptions);
|
|
14972
15077
|
});
|
|
14973
15078
|
}
|
|
@@ -15188,6 +15293,8 @@ var Vditor = /** @class */ (function (_super) {
|
|
|
15188
15293
|
this.vditor.element.removeAttribute("style");
|
|
15189
15294
|
document.getElementById("vditorIconScript").remove();
|
|
15190
15295
|
this.clearCache();
|
|
15296
|
+
UIUnbindListener();
|
|
15297
|
+
this.vditor.wysiwyg.unbindListener();
|
|
15191
15298
|
};
|
|
15192
15299
|
/** 获取评论 ID */
|
|
15193
15300
|
Vditor.prototype.getCommentIds = function () {
|
|
@@ -15350,12 +15457,12 @@ var Vditor = /** @class */ (function (_super) {
|
|
|
15350
15457
|
});
|
|
15351
15458
|
};
|
|
15352
15459
|
return Vditor;
|
|
15353
|
-
}(method
|
|
15460
|
+
}(method["default"]));
|
|
15354
15461
|
/* harmony default export */ const src = (Vditor);
|
|
15355
15462
|
|
|
15356
15463
|
})();
|
|
15357
15464
|
|
|
15358
|
-
__webpack_exports__ = __webpack_exports__
|
|
15465
|
+
__webpack_exports__ = __webpack_exports__["default"];
|
|
15359
15466
|
/******/ return __webpack_exports__;
|
|
15360
15467
|
/******/ })()
|
|
15361
15468
|
;
|
package/dist/js/i18n/zh_CN.js
CHANGED