@8btc/mditor 0.0.12 → 0.0.13

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.
@@ -27,6 +27,7 @@
27
27
  .vditor-reset {
28
28
  color: rgba(252, 252, 252, 0.9);
29
29
  text-autospace: normal;
30
+
30
31
  h1,
31
32
  h2,
32
33
  h3,
@@ -68,9 +69,11 @@
68
69
  .vditor-reset table tr {
69
70
  /* background-color: #2f363d; */
70
71
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
72
+
71
73
  th {
72
74
  color: #ffffff;
73
75
  }
76
+
74
77
  td {
75
78
  color: #fafafa;
76
79
  }
@@ -151,8 +154,10 @@
151
154
  width: 1rem;
152
155
  height: 1rem;
153
156
  border-radius: 0.25rem;
154
- border: 1px solid #0a0a0a; /* 未选中时黑色边框 */
155
- background-color: transparent; /* 未选中不填充背景 */
157
+ border: 1px solid #0a0a0a;
158
+ /* 未选中时黑色边框 */
159
+ background-color: transparent;
160
+ /* 未选中不填充背景 */
156
161
  position: relative;
157
162
  vertical-align: middle;
158
163
  margin-right: 0.38rem;
@@ -160,7 +165,8 @@
160
165
  }
161
166
 
162
167
  .vditor-task input[type="checkbox"]:checked {
163
- background-color: #fafafa; /* 选中时白底 */
168
+ background-color: #fafafa;
169
+ /* 选中时白底 */
164
170
  }
165
171
 
166
172
  .vditor-task input[type="checkbox"]:checked::after {
@@ -175,3 +181,13 @@
175
181
  top: 50%;
176
182
  transform: translate(-50%, -60%) rotate(45deg);
177
183
  }
184
+
185
+ .vditor-selection-popover__input .vditor-selection-popover__send {
186
+ color: #0a0a0a;
187
+ }
188
+
189
+ .vditor--linenumber {
190
+ .vditor-line-highlight {
191
+ color: #0a0a0a;
192
+ }
193
+ }
package/dist/index.css CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Vditor v0.0.12 - A markdown editor written in TypeScript.
2
+ * Vditor v0.0.13 - 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.12 - A markdown editor written in TypeScript.
28
+ * Vditor v0.0.13 - A markdown editor written in TypeScript.
29
29
  *
30
30
  * MIT License
31
31
  *
@@ -1831,7 +1831,7 @@
1831
1831
  top: 0;
1832
1832
  width: 3em;
1833
1833
  text-align: right;
1834
- color: var(--second-color);
1834
+ color: rgba(252, 252, 252, 0.65);
1835
1835
  font-size: 0.75rem;
1836
1836
  line-height: inherit;
1837
1837
  -webkit-user-select: none;
@@ -1842,7 +1842,7 @@
1842
1842
  }
1843
1843
  .vditor--linenumber .vditor-reset .vditor-line-highlight {
1844
1844
  background-color: #fff3cd !important;
1845
- transition: background-color 0.3s ease-in-out;
1845
+ transition: background-color color 0.3s ease-in-out;
1846
1846
  }
1847
1847
  /* 数学右键菜单全局样式(参考 ECharts 菜单风格) */
1848
1848
  .vditor-math-menu {
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Vditor v0.0.12 - A markdown editor written in TypeScript.
2
+ * Vditor v0.0.13 - A markdown editor written in TypeScript.
3
3
  *
4
4
  * MIT License
5
5
  *
@@ -2486,6 +2486,8 @@ var speechRender = function (element, lang) {
2486
2486
  });
2487
2487
  };
2488
2488
 
2489
+ // EXTERNAL MODULE: ./src/ts/markdown/selectionRender.ts
2490
+ var selectionRender = __webpack_require__(616);
2489
2491
  ;// CONCATENATED MODULE: ./src/ts/markdown/previewRender.ts
2490
2492
  var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
2491
2493
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
@@ -2543,6 +2545,7 @@ var __generator = (undefined && undefined.__generator) || function (thisArg, bod
2543
2545
 
2544
2546
 
2545
2547
 
2548
+
2546
2549
 
2547
2550
 
2548
2551
  var mergeOptions = function (options) {
@@ -2673,6 +2676,7 @@ var previewRender = function (previewElement, markdown, options) { return __awai
2673
2676
  (0,mindmapRender/* mindmapRender */.P)(previewElement, mergedOptions.cdn, mergedOptions.mode);
2674
2677
  (0,plantumlRender/* plantumlRender */.B)(previewElement, mergedOptions.cdn);
2675
2678
  (0,abcRender/* abcRender */.Q)(previewElement, mergedOptions.cdn);
2679
+ (0,selectionRender/* selectionRender */.V)(previewElement);
2676
2680
  if (mergedOptions.render.media.enable) {
2677
2681
  (0,mediaRender/* mediaRender */.Y)(previewElement);
2678
2682
  }
@@ -2733,6 +2737,7 @@ var attachLineNumbers = __webpack_require__(626);
2733
2737
 
2734
2738
 
2735
2739
 
2740
+
2736
2741
 
2737
2742
 
2738
2743
  var Vditor = /** @class */ (function () {
@@ -2793,6 +2798,8 @@ var Vditor = /** @class */ (function () {
2793
2798
  Vditor.mediaRender = mediaRender/* mediaRender */.Y;
2794
2799
  /** 对选中的文字进行阅读 */
2795
2800
  Vditor.speechRender = speechRender;
2801
+ /** 渲染 selection 代码块为文件选择标签 */
2802
+ Vditor.selectionRender = selectionRender/* selectionRender */.V;
2796
2803
  /** 对图片进行懒加载 */
2797
2804
  Vditor.lazyLoadImageRender = lazyLoadImageRender;
2798
2805
  /** Markdown 文本转换为 HTML,该方法需使用[异步编程](https://ld246.com/article/1546828434083?r=Vaness) */
@@ -2818,7 +2825,7 @@ var Vditor = /** @class */ (function () {
2818
2825
  /* harmony export */ "H": () => (/* binding */ _VDITOR_VERSION),
2819
2826
  /* harmony export */ "g": () => (/* binding */ Constants)
2820
2827
  /* harmony export */ });
2821
- var _VDITOR_VERSION = "0.0.12";
2828
+ var _VDITOR_VERSION = "0.0.13";
2822
2829
 
2823
2830
  var Constants = /** @class */ (function () {
2824
2831
  function Constants() {
@@ -3120,7 +3127,7 @@ var Constants = /** @class */ (function () {
3120
3127
  "c#",
3121
3128
  "bat",
3122
3129
  ];
3123
- Constants.CDN = "https://webcdn.wujieai.com/vditor@".concat("0.0.12");
3130
+ Constants.CDN = "https://webcdn.wujieai.com/vditor@".concat("0.0.13");
3124
3131
  Constants.MARKDOWN_OPTIONS = {
3125
3132
  autoSpace: false,
3126
3133
  gfmAutoLink: true,
@@ -5981,6 +5988,40 @@ var plantumlRender = function (element, cdn) {
5981
5988
  };
5982
5989
 
5983
5990
 
5991
+ /***/ }),
5992
+
5993
+ /***/ 616:
5994
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
5995
+
5996
+ "use strict";
5997
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5998
+ /* harmony export */ "V": () => (/* binding */ selectionRender)
5999
+ /* harmony export */ });
6000
+ /**
6001
+ * 渲染 selection 代码块为文件选择标签
6002
+ */
6003
+ var selectionRender = function (element) {
6004
+ element.querySelectorAll("pre > code.language-selection").forEach(function (codeElement) {
6005
+ var preElement = codeElement.parentElement;
6006
+ var content = codeElement.textContent.trim();
6007
+ var lines = content.split('\n');
6008
+ var tags = lines.map(function (line) {
6009
+ var match = line.trim().match(/^(.+?)\s+(\d+-\d+)$/);
6010
+ if (match) {
6011
+ var filename = match[1], lineRange = match[2];
6012
+ return "<div class=\"vditor-selection-tag\">\n <span class=\"vditor-selection-tag__file\">".concat(filename, "</span>\n <span class=\"vditor-selection-tag__lines\">").concat(lineRange, "</span>\n </div>");
6013
+ }
6014
+ return '';
6015
+ }).filter(function (tag) { return tag; }).join('');
6016
+ if (tags) {
6017
+ var container = document.createElement('div');
6018
+ container.innerHTML = tags;
6019
+ preElement.parentNode.replaceChild(container, preElement);
6020
+ }
6021
+ });
6022
+ };
6023
+
6024
+
5984
6025
  /***/ }),
5985
6026
 
5986
6027
  /***/ 214:
@@ -15248,31 +15289,8 @@ var Outline = /** @class */ (function () {
15248
15289
 
15249
15290
  // EXTERNAL MODULE: ./src/ts/markdown/mediaRender.ts
15250
15291
  var mediaRender = __webpack_require__(280);
15251
- ;// CONCATENATED MODULE: ./src/ts/markdown/selectionRender.ts
15252
- /**
15253
- * 渲染 selection 代码块为文件选择标签
15254
- */
15255
- var selectionRender = function (element) {
15256
- element.querySelectorAll("pre > code.language-selection").forEach(function (codeElement) {
15257
- var preElement = codeElement.parentElement;
15258
- var content = codeElement.textContent.trim();
15259
- var lines = content.split('\n');
15260
- var tags = lines.map(function (line) {
15261
- var match = line.trim().match(/^(.+?)\s+(\d+-\d+)$/);
15262
- if (match) {
15263
- var filename = match[1], lineRange = match[2];
15264
- return "<div class=\"vditor-selection-tag\">\n <span class=\"vditor-selection-tag__file\">".concat(filename, "</span>\n <span class=\"vditor-selection-tag__lines\">").concat(lineRange, "</span>\n </div>");
15265
- }
15266
- return '';
15267
- }).filter(function (tag) { return tag; }).join('');
15268
- if (tags) {
15269
- var container = document.createElement('div');
15270
- container.innerHTML = tags;
15271
- preElement.parentNode.replaceChild(container, preElement);
15272
- }
15273
- });
15274
- };
15275
-
15292
+ // EXTERNAL MODULE: ./src/ts/markdown/selectionRender.ts
15293
+ var selectionRender = __webpack_require__(616);
15276
15294
  ;// CONCATENATED MODULE: ./src/ts/preview/index.ts
15277
15295
 
15278
15296
 
@@ -15455,7 +15473,7 @@ var Preview = /** @class */ (function () {
15455
15473
  if (vditor.options.preview.render.media.enable) {
15456
15474
  (0,mediaRender/* mediaRender */.Y)(vditor.preview.previewElement);
15457
15475
  }
15458
- selectionRender(vditor.preview.previewElement);
15476
+ (0,selectionRender/* selectionRender */.V)(vditor.preview.previewElement);
15459
15477
  vditor.options.customRenders.forEach(function (item) {
15460
15478
  {
15461
15479
  item.render(vditor.preview.previewElement, vditor);
@@ -17947,7 +17965,7 @@ var wysiwyg_generator = (undefined && undefined.__generator) || function (thisAr
17947
17965
  var WYSIWYG = /** @class */ (function () {
17948
17966
  function WYSIWYG(vditor) {
17949
17967
  var _this = this;
17950
- var _a, _b;
17968
+ var _a;
17951
17969
  this.composingLock = false;
17952
17970
  this.commentIds = [];
17953
17971
  this.vditor = vditor;
@@ -17956,7 +17974,7 @@ var WYSIWYG = /** @class */ (function () {
17956
17974
  if ((_a = vditor.options.lineNumber) === null || _a === void 0 ? void 0 : _a.enable) {
17957
17975
  divElement.classList.add("vditor--linenumber");
17958
17976
  }
17959
- divElement.innerHTML = "<pre class=\"vditor-reset\" placeholder=\"".concat(vditor.options.placeholder, "\"\n contenteditable=\"true\" spellcheck=\"false\"></pre>\n<div class=\"vditor-panel vditor-panel--none\"></div>\n<div class=\"vditor-selection-popover\">\n <div class=\"vditor-selection-popover__actions\">\n <button type=\"button\" data-action=\"ai\" aria-label=\"AI\u7F16\u8F91\" class=\"vditor-selection-popover__btn\" disabled>\u2728 AI\u7F16\u8F91</button>\n <button type=\"button\" data-action=\"cut\" aria-label=\"\u526A\u5207\" class=\"vditor-selection-popover__btn\">\u526A\u5207</button>\n <button type=\"button\" data-action=\"copy\" aria-label=\"\u590D\u5236\" class=\"vditor-selection-popover__btn\">\u590D\u5236</button>\n </div>\n <div class=\"vditor-selection-popover__input\">\n <textarea placeholder=\"\u8BF7\u8F93\u5165\u60A8\u60F3\u4FEE\u6539\u7684\u5185\u5BB9\"></textarea>\n <button class=\"vditor-selection-popover__send\">\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"lucide lucide-sparkles-icon lucide-sparkles\"><path d=\"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z\"/><path d=\"M20 2v4\"/><path d=\"M22 4h-4\"/><circle cx=\"4\" cy=\"20\" r=\"2\"/></svg>\n </button>\n </div>\n</div>");
17977
+ divElement.innerHTML = "<pre class=\"vditor-reset\" placeholder=\"".concat(vditor.options.placeholder, "\"\n contenteditable=\"true\" spellcheck=\"false\"></pre>\n<div class=\"vditor-panel vditor-panel--none\"></div>\n<div class=\"vditor-selection-popover\">\n <div class=\"vditor-selection-popover__actions\">\n <button type=\"button\" data-action=\"ai\" aria-label=\"AI\u7F16\u8F91\" class=\"vditor-selection-popover__btn\">\u2728 AI\u7F16\u8F91</button>\n <button type=\"button\" data-action=\"cut\" aria-label=\"\u526A\u5207\" class=\"vditor-selection-popover__btn\">\u526A\u5207</button>\n <button type=\"button\" data-action=\"copy\" aria-label=\"\u590D\u5236\" class=\"vditor-selection-popover__btn\">\u590D\u5236</button>\n </div>\n <div class=\"vditor-selection-popover__input\">\n <textarea placeholder=\"\u8BF7\u8F93\u5165\u60A8\u60F3\u4FEE\u6539\u7684\u5185\u5BB9\"></textarea>\n <button class=\"vditor-selection-popover__send\">\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"lucide lucide-sparkles-icon lucide-sparkles\"><path d=\"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z\"/><path d=\"M20 2v4\"/><path d=\"M22 4h-4\"/><circle cx=\"4\" cy=\"20\" r=\"2\"/></svg>\n </button>\n </div>\n</div>");
17960
17978
  this.element = divElement.firstElementChild;
17961
17979
  this.popover = divElement.firstElementChild
17962
17980
  .nextElementSibling;
@@ -17978,9 +17996,16 @@ var WYSIWYG = /** @class */ (function () {
17978
17996
  }
17979
17997
  _this.hideSelectionPopover();
17980
17998
  };
17981
- // 阻止点击输入区域时清除选区
17982
- (_b = this.selectPopover
17983
- .querySelector(".vditor-selection-popover__input")) === null || _b === void 0 ? void 0 : _b.addEventListener("mousedown", function (event) {
17999
+ // 阻止点击 popover 内任何区域时导致编辑器失去焦点
18000
+ // 但不影响 textarea 获取焦点和按钮点击
18001
+ this.selectPopover.addEventListener("mousedown", function (event) {
18002
+ var target = event.target;
18003
+ // 如果点击的是 textarea 或 button,允许默认行为
18004
+ if (target.tagName === "TEXTAREA" || target.tagName === "BUTTON") {
18005
+ return;
18006
+ }
18007
+ // 其他情况阻止默认行为,防止编辑器失去焦点
18008
+ event.preventDefault();
17984
18009
  event.stopPropagation();
17985
18010
  });
17986
18011
  // 输入验证
@@ -18004,16 +18029,18 @@ var WYSIWYG = /** @class */ (function () {
18004
18029
  copyEvent(vditor, this.element, this.copy);
18005
18030
  cutEvent(vditor, this.element, this.copy);
18006
18031
  // 选择浮窗按钮事件绑定
18007
- var aiBtn = this.selectPopover.querySelector('[data-action="ai"]');
18008
- if (aiBtn) {
18009
- /**
18010
- * AI编辑按钮占位事件
18011
- * - 当前仅输出日志,不执行编辑逻辑
18012
- */
18013
- aiBtn.onclick = function () {
18014
- console.log("[Selection AI Edit] clicked");
18015
- };
18016
- }
18032
+ // const aiBtn = this.selectPopover.querySelector(
18033
+ // '[data-action="ai"]'
18034
+ // ) as HTMLButtonElement | null;
18035
+ // if (aiBtn) {
18036
+ // /**
18037
+ // * AI编辑按钮占位事件
18038
+ // * - 当前仅输出日志,不执行编辑逻辑
18039
+ // */
18040
+ // aiBtn.onclick = () => {
18041
+ // console.log("[Selection AI Edit] clicked");
18042
+ // };
18043
+ // }
18017
18044
  var copyBtn = this.selectPopover.querySelector('[data-action="copy"]');
18018
18045
  if (copyBtn) {
18019
18046
  /**