@8btc/mditor 0.0.16 → 0.0.18

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.
@@ -196,3 +196,21 @@
196
196
  color: #0a0a0a !important;
197
197
  }
198
198
  }
199
+
200
+ .vditor-reset .mermaid-error {
201
+ border: 1px dashed rgba(255, 255, 255, 0.2);
202
+ }
203
+
204
+ .vditor-reset .mermaid-error .mermaid-error-icon {
205
+ border: 1px solid rgba(255, 255, 255, 0.2);
206
+ }
207
+
208
+ .vditor-reset .mermaid-error .mermaid-error-title {
209
+ color: rgba(252, 252, 252, 0.9);
210
+ }
211
+ .vditor-reset .mermaid-error .mermaid-error-message {
212
+ color: #a3a3a3;
213
+ }
214
+ .vditor-reset .mermaid-error .mermaid-error-icon {
215
+ color: rgba(252, 252, 252, 0.9);
216
+ }
package/dist/index.css CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Vditor v0.0.16 - A markdown editor written in TypeScript.
2
+ * Vditor v0.0.18 - 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.16 - A markdown editor written in TypeScript.
28
+ * Vditor v0.0.18 - A markdown editor written in TypeScript.
29
29
  *
30
30
  * MIT License
31
31
  *
@@ -115,7 +115,7 @@
115
115
  }
116
116
  }
117
117
  .vditor-tooltipped {
118
- position: relative;
118
+ position: relative !important;
119
119
  cursor: pointer;
120
120
  }
121
121
  .vditor-tooltipped::after {
@@ -2124,6 +2124,37 @@
2124
2124
  .vditor--dark .vditor-reset .vditor-selection-tag .vditor-selection-tag__lines {
2125
2125
  color: #b9b9b9;
2126
2126
  }
2127
+ .mermaid-error {
2128
+ border: 1px dashed #E5E5E5;
2129
+ border-radius: 0.625rem;
2130
+ padding: 3rem 1.5rem;
2131
+ text-align: center;
2132
+ }
2133
+ .mermaid-error .mermaid-error-icon {
2134
+ display: inline-block;
2135
+ color: #0A0A0A;
2136
+ padding: 0.5rem;
2137
+ border-radius: 0.5rem;
2138
+ margin-bottom: 1.5rem;
2139
+ border: 1px solid #E5E5E5;
2140
+ line-height: 1;
2141
+ }
2142
+ .mermaid-error .mermaid-error-icon > svg {
2143
+ display: block;
2144
+ stroke-width: 2;
2145
+ }
2146
+ .mermaid-error .mermaid-error-title {
2147
+ font-size: 1.25rem;
2148
+ color: #0A0A0A;
2149
+ font-weight: 700;
2150
+ line-height: 140%;
2151
+ margin-bottom: 0.5rem;
2152
+ }
2153
+ .mermaid-error .mermaid-error-message {
2154
+ font-size: 0.875rem;
2155
+ line-height: 140%;
2156
+ color: #737373;
2157
+ }
2127
2158
  details > summary {
2128
2159
  list-style: none;
2129
2160
  }
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Vditor v0.0.16 - A markdown editor written in TypeScript.
2
+ * Vditor v0.0.18 - A markdown editor written in TypeScript.
3
3
  *
4
4
  * MIT License
5
5
  *
@@ -2561,6 +2561,9 @@ var mergeOptions = function (options) {
2561
2561
  markdown: constants/* Constants.MARKDOWN_OPTIONS */.g.MARKDOWN_OPTIONS,
2562
2562
  math: constants/* Constants.MATH_OPTIONS */.g.MATH_OPTIONS,
2563
2563
  mode: "light",
2564
+ link: {
2565
+ isOpen: true,
2566
+ },
2564
2567
  speech: {
2565
2568
  enable: false,
2566
2569
  },
@@ -2620,6 +2623,14 @@ var md2html = function (mdText, options) {
2620
2623
  return lute.Md2HTML(mdText);
2621
2624
  });
2622
2625
  };
2626
+ /**
2627
+ * 预览区域渲染入口
2628
+ * - 负责将 Markdown 转为 HTML 并对各类增强特性进行初始化
2629
+ * - 支持目录点击定位与链接点击行为配置(link.click / link.isOpen)
2630
+ * @param previewElement 预览容器元素
2631
+ * @param markdown Markdown 文本内容
2632
+ * @param options 预览配置项,支持 link 点击行为自定义
2633
+ */
2623
2634
  var previewRender = function (previewElement, markdown, options) { return __awaiter(void 0, void 0, void 0, function () {
2624
2635
  var mergedOptions, html, i18nScriptPrefix, i18nScriptID_1;
2625
2636
  return __generator(this, function (_a) {
@@ -2711,6 +2722,7 @@ var previewRender = function (previewElement, markdown, options) { return __awai
2711
2722
  lazyLoadImageRender(previewElement);
2712
2723
  }
2713
2724
  previewElement.addEventListener("click", function (event) {
2725
+ var _a, _b;
2714
2726
  var spanElement = (0,hasClosest/* hasClosestByMatchTag */.lG)(event.target, "SPAN");
2715
2727
  if (spanElement &&
2716
2728
  (0,hasClosest/* hasClosestByClassName */.fb)(spanElement, "vditor-toc")) {
@@ -2720,6 +2732,16 @@ var previewRender = function (previewElement, markdown, options) { return __awai
2720
2732
  }
2721
2733
  return;
2722
2734
  }
2735
+ if (event.target.tagName === "A") {
2736
+ if ((_a = mergedOptions.link) === null || _a === void 0 ? void 0 : _a.click) {
2737
+ mergedOptions.link.click(event.target);
2738
+ }
2739
+ else if ((_b = mergedOptions.link) === null || _b === void 0 ? void 0 : _b.isOpen) {
2740
+ window.open(event.target.getAttribute("href"));
2741
+ }
2742
+ event.preventDefault();
2743
+ return;
2744
+ }
2723
2745
  });
2724
2746
  return [2 /*return*/];
2725
2747
  }
@@ -2844,7 +2866,7 @@ var Vditor = /** @class */ (function () {
2844
2866
  /* harmony export */ "H": () => (/* binding */ _VDITOR_VERSION),
2845
2867
  /* harmony export */ "g": () => (/* binding */ Constants)
2846
2868
  /* harmony export */ });
2847
- var _VDITOR_VERSION = "0.0.16";
2869
+ var _VDITOR_VERSION = "0.0.18";
2848
2870
 
2849
2871
  var Constants = /** @class */ (function () {
2850
2872
  function Constants() {
@@ -3146,7 +3168,7 @@ var Constants = /** @class */ (function () {
3146
3168
  "c#",
3147
3169
  "bat",
3148
3170
  ];
3149
- Constants.CDN = "https://webcdn.wujieai.com/vditor@".concat("0.0.16");
3171
+ Constants.CDN = "https://webcdn.wujieai.com/vditor@".concat("0.0.18");
3150
3172
  Constants.MARKDOWN_OPTIONS = {
3151
3173
  autoSpace: false,
3152
3174
  gfmAutoLink: true,
@@ -5748,19 +5770,19 @@ var mermaidRender = function (element, cdn, theme) {
5748
5770
  startOnLoad: false,
5749
5771
  flowchart: {
5750
5772
  htmlLabels: true,
5751
- useMaxWidth: !0
5773
+ useMaxWidth: !0,
5752
5774
  },
5753
5775
  sequence: {
5754
5776
  useMaxWidth: true,
5755
5777
  diagramMarginX: 8,
5756
5778
  diagramMarginY: 8,
5757
5779
  boxMargin: 8,
5758
- showSequenceNumbers: true // Mermaid 时序图增加序号 https://github.com/siyuan-note/siyuan/pull/6992 https://mermaid.js.org/syntax/sequenceDiagram.html#sequencenumbers
5780
+ showSequenceNumbers: true, // Mermaid 时序图增加序号 https://github.com/siyuan-note/siyuan/pull/6992 https://mermaid.js.org/syntax/sequenceDiagram.html#sequencenumbers
5759
5781
  },
5760
5782
  gantt: {
5761
5783
  leftPadding: 75,
5762
- rightPadding: 20
5763
- }
5784
+ rightPadding: 20,
5785
+ },
5764
5786
  };
5765
5787
  if (theme === "dark") {
5766
5788
  config.theme = "dark";
@@ -5772,7 +5794,8 @@ var mermaidRender = function (element, cdn, theme) {
5772
5794
  switch (_a.label) {
5773
5795
  case 0:
5774
5796
  code = _adapterRender__WEBPACK_IMPORTED_MODULE_1__.mermaidRenderAdapter.getCode(item);
5775
- if (item.getAttribute("data-processed") === "true" || code.trim() === "") {
5797
+ if (item.getAttribute("data-processed") === "true" ||
5798
+ code.trim() === "") {
5776
5799
  return [2 /*return*/];
5777
5800
  }
5778
5801
  id = "mermaid" + (0,_util_function__WEBPACK_IMPORTED_MODULE_3__/* .genUUID */ .Wb)();
@@ -5787,7 +5810,7 @@ var mermaidRender = function (element, cdn, theme) {
5787
5810
  case 3:
5788
5811
  e_1 = _a.sent();
5789
5812
  errorElement = document.querySelector("#" + id);
5790
- item.innerHTML = "".concat(errorElement.outerHTML, "<br>\n<div style=\"text-align: left\"><small>").concat(e_1.message.replace(/\n/, "<br>"), "</small></div>");
5813
+ item.innerHTML = "\n<div class=\"mermaid-error\">\n<div class=\"mermaid-error-icon\"><svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"lucide lucide-bug-icon lucide-bug\"><path d=\"M12 20v-9\"/><path d=\"M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z\"/><path d=\"M14.12 3.88 16 2\"/><path d=\"M21 21a4 4 0 0 0-3.81-4\"/><path d=\"M21 5a4 4 0 0 1-3.55 3.97\"/><path d=\"M22 13h-4\"/><path d=\"M3 21a4 4 0 0 1 3.81-4\"/><path d=\"M3 5a4 4 0 0 0 3.55 3.97\"/><path d=\"M6 13H2\"/><path d=\"m8 2 1.88 1.88\"/><path d=\"M9 7.13V6a3 3 0 1 1 6 0v1.13\"/></svg></div>\n<div class=\"mermaid-error-title\">\u56FE\u8868\u52A0\u8F7D\u5931\u8D25</div>\n<div class=\"mermaid-error-message\">".concat(e_1.message.replace(/\n/, "<br>"), "</div>\n</div>");
5791
5814
  errorElement.parentElement.remove();
5792
5815
  return [3 /*break*/, 4];
5793
5816
  case 4: