vditor 3.11.0 → 3.11.1

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2019 B3log 开源, b3log.org
3
+ Copyright (c) 2019-present B3log 开源, b3log.org
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -201,7 +201,7 @@ Markdown 输出的 HTML 所展现的外观。内置 ant-design, light,dark,w
201
201
  | minHeight | 编辑区域最小高度 | - |
202
202
  | width | 编辑器总宽度,支持 % | 'auto' |
203
203
  | placeholder | 输入区域为空时的提示 | '' |
204
- | lang | 语言种类:en_US, fr_FR, pt_BR, ja_JP, ko_KR, ru_RU, sv_SE, zh_CN, zh_TW | 'zh_CN' |
204
+ | lang | 语言种类:de_DE, en_US, fr_FR, pt_BR, ja_JP, ko_KR, ru_RU, sv_SE, zh_CN, zh_TW | 'zh_CN' |
205
205
  | input(value: string) | 输入后触发 | - |
206
206
  | focus(value: string) | 聚焦后触发 | - |
207
207
  | blur(value: string) | 失焦后触发 | - |
@@ -465,6 +465,7 @@ if (xhr.status === 200) {
465
465
 
466
466
  | | 说明 | 默认值 |
467
467
  | - | - | - |
468
+ | xhr | 上传时使用的 XMLHttpRequest | - |
468
469
  | url | 上传 url,为空则不会触发上传相关事件 | '' |
469
470
  | max | 上传文件最大 Byte | 10 * 1024 * 1024 |
470
471
  | linkToImgUrl | 剪切板中包含图片地址时,使用此 url 重新上传 | '' |
package/dist/index.css CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Vditor v3.11.0 - A markdown editor written in TypeScript.
2
+ * Vditor v3.11.1 - 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 v3.11.0 - A markdown editor written in TypeScript.
28
+ * Vditor v3.11.1 - A markdown editor written in TypeScript.
29
29
  *
30
30
  * MIT License
31
31
  *
package/dist/index.d.ts CHANGED
@@ -4,6 +4,7 @@ import VditorMethod from "./method";
4
4
  declare class Vditor extends VditorMethod {
5
5
  readonly version: string;
6
6
  vditor: IVditor;
7
+ private isDestroyed;
7
8
  /**
8
9
  * @param id 要挂载 Vditor 的元素或者元素 ID。
9
10
  * @param options Vditor 参数
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Vditor v3.11.0 - A markdown editor written in TypeScript.
2
+ * Vditor v3.11.1 - A markdown editor written in TypeScript.
3
3
  *
4
4
  * MIT License
5
5
  *
@@ -2471,7 +2471,7 @@ var previewRender = function (previewElement, markdown, options) { return __awai
2471
2471
  previewElement.innerHTML = html;
2472
2472
  previewElement.classList.add("vditor-reset");
2473
2473
  if (!!mergedOptions.i18n) return [3 /*break*/, 5];
2474
- if (!!["en_US", "fr_FR", "pt_BR", "ja_JP", "ko_KR", "ru_RU", "sv_SE", "zh_CN", "zh_TW"].includes(mergedOptions.lang)) return [3 /*break*/, 2];
2474
+ if (!!["de_DE", "en_US", "fr_FR", "pt_BR", "ja_JP", "ko_KR", "ru_RU", "sv_SE", "zh_CN", "zh_TW"].includes(mergedOptions.lang)) return [3 /*break*/, 2];
2475
2475
  throw new Error("options.lang error, see https://ld246.com/article/1549638745630#options");
2476
2476
  case 2:
2477
2477
  i18nScriptPrefix = "vditorI18nScript";
@@ -2633,7 +2633,7 @@ var Vditor = /** @class */ (function () {
2633
2633
  /* harmony export */ "H": () => (/* binding */ _VDITOR_VERSION),
2634
2634
  /* harmony export */ "g": () => (/* binding */ Constants)
2635
2635
  /* harmony export */ });
2636
- var _VDITOR_VERSION = "3.11.0";
2636
+ var _VDITOR_VERSION = "3.11.1";
2637
2637
 
2638
2638
  var Constants = /** @class */ (function () {
2639
2639
  function Constants() {
@@ -2681,7 +2681,7 @@ var Constants = /** @class */ (function () {
2681
2681
  // 别名
2682
2682
  "js", "ts", "html", "toml", "c#", "bat"
2683
2683
  ];
2684
- Constants.CDN = "https://unpkg.com/vditor@".concat("3.11.0");
2684
+ Constants.CDN = "https://unpkg.com/vditor@".concat("3.11.1");
2685
2685
  Constants.MARKDOWN_OPTIONS = {
2686
2686
  autoSpace: false,
2687
2687
  gfmAutoLink: true,
@@ -9488,6 +9488,7 @@ var uploadFiles = function (vditor, files, element) { return __awaiter(void 0, v
9488
9488
  formData.append(vditor.options.upload.fieldName, validateResult[i]);
9489
9489
  }
9490
9490
  xhr = new XMLHttpRequest();
9491
+ vditor.upload.xhr = xhr;
9491
9492
  xhr.open("POST", vditor.options.upload.url);
9492
9493
  if (vditor.options.upload.token) {
9493
9494
  xhr.setRequestHeader("X-Upload-Token", vditor.options.upload.token);
@@ -9526,6 +9527,7 @@ var uploadFiles = function (vditor, files, element) { return __awaiter(void 0, v
9526
9527
  element.value = "";
9527
9528
  }
9528
9529
  vditor.upload.element.style.display = "none";
9530
+ vditor.upload.xhr = undefined;
9529
9531
  }
9530
9532
  };
9531
9533
  xhr.upload.onprogress = function (event) {
@@ -10799,7 +10801,7 @@ var fixBlockquote = function (vditor, range, event, pElement) {
10799
10801
  };
10800
10802
  var fixTask = function (vditor, range, event) {
10801
10803
  var startContainer = range.startContainer;
10802
- var taskItemElement = (0,hasClosest/* hasClosestByMatchTag */.lG)(startContainer, "li");
10804
+ var taskItemElement = (0,hasClosest/* hasClosestByMatchTag */.lG)(startContainer, "LI");
10803
10805
  if (taskItemElement && taskItemElement.classList.contains("vditor-task")) {
10804
10806
  if (matchHotKey("⇧⌘J", event)) {
10805
10807
  // ctrl + shift: toggle checked
@@ -15409,6 +15411,7 @@ var Vditor = /** @class */ (function (_super) {
15409
15411
  */
15410
15412
  function Vditor(id, options) {
15411
15413
  var _this = _super.call(this) || this;
15414
+ _this.isDestroyed = false;
15412
15415
  _this.version = constants/* VDITOR_VERSION */.H;
15413
15416
  if (typeof id === "string") {
15414
15417
  if (!options) {
@@ -15434,7 +15437,7 @@ var Vditor = /** @class */ (function (_super) {
15434
15437
  var mergedOptions = getOptions.merge();
15435
15438
  // 支持自定义国际化
15436
15439
  if (!mergedOptions.i18n) {
15437
- if (!["en_US", "fr_FR", "pt_BR", "ja_JP", "ko_KR", "ru_RU", "sv_SE", "zh_CN", "zh_TW"].includes(mergedOptions.lang)) {
15440
+ if (!["de_DE", "en_US", "fr_FR", "pt_BR", "ja_JP", "ko_KR", "ru_RU", "sv_SE", "zh_CN", "zh_TW"].includes(mergedOptions.lang)) {
15438
15441
  throw new Error("options.lang error, see https://ld246.com/article/1549638745630#options");
15439
15442
  }
15440
15443
  else {
@@ -15706,6 +15709,7 @@ var Vditor = /** @class */ (function (_super) {
15706
15709
  UIUnbindListener();
15707
15710
  this.vditor.wysiwyg.unbindListener();
15708
15711
  this.vditor.options.after = undefined;
15712
+ this.isDestroyed = true;
15709
15713
  };
15710
15714
  /** 获取评论 ID */
15711
15715
  Vditor.prototype.getCommentIds = function () {
@@ -15809,6 +15813,9 @@ var Vditor = /** @class */ (function (_super) {
15809
15813
  };
15810
15814
  Vditor.prototype.init = function (id, mergedOptions) {
15811
15815
  var _this = this;
15816
+ if (this.isDestroyed) {
15817
+ return;
15818
+ }
15812
15819
  this.vditor = {
15813
15820
  currentMode: mergedOptions.mode,
15814
15821
  element: id,