md-editor-v3 2.3.0 → 2.4.0-beta.0

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 CHANGED
@@ -31,6 +31,20 @@ Markdown editor for vue3, developed in `jsx` and `typescript`.
31
31
  yarn add md-editor-v3
32
32
  ```
33
33
 
34
+ Please install `@types/marked` in your typescript project if you want to configure `renderer`:
35
+
36
+ ```shell
37
+ yarn add @types/marked -D
38
+ ```
39
+
40
+ Install existing extension of language and preview theme:
41
+
42
+ ```shell
43
+ yarn add @vavt/md-editor-extension
44
+ ```
45
+
46
+ For more ways to use or contribute, please refer to: [md-editor-extension](https://github.com/imzbf/md-editor-extension)
47
+
34
48
  ## Usage
35
49
 
36
50
  ```vue
@@ -108,6 +122,7 @@ mark and emoji extensions
108
122
  'quote',
109
123
  'unorderedList',
110
124
  'orderedList',
125
+ 'task', // ^2.4.0
111
126
  '-',
112
127
  'codeRow',
113
128
  'code',
@@ -153,6 +168,7 @@ export interface ToolbarTips {
153
168
  quote?: string;
154
169
  unorderedList?: string;
155
170
  orderedList?: string;
171
+ task?: string; // ^2.4.0
156
172
  codeRow?: string;
157
173
  code?: string;
158
174
  link?: string;
@@ -250,7 +266,7 @@ export interface StaticTextDefaultValue {
250
266
  <template #defToolbars>
251
267
  <normal-toolbar title="mark" @onClick="handler">
252
268
  <template #trigger>
253
- <svg class="md-icon" aria-hidden="true">
269
+ <svg class="md-editor-icon" aria-hidden="true">
254
270
  <use xlink:href="#icon-mark"></use>
255
271
  </svg>
256
272
  </template>
@@ -591,11 +607,11 @@ const onUploadImg = async (files, callback) => {
591
607
  --md-scrollbar-thumb-avtive-color: if(@isDark, #3a3a3a, #00000061);
592
608
  }
593
609
 
594
- .md {
610
+ .md-editor {
595
611
  .css-vars(false);
596
612
  }
597
613
 
598
- .md-dark {
614
+ .md-editor-dark {
599
615
  .css-vars(true);
600
616
  }
601
617
  ```
@@ -603,7 +619,7 @@ const onUploadImg = async (files, callback) => {
603
619
  Change background color in dark mode:
604
620
 
605
621
  ```css
606
- .md-dark {
622
+ .md-editor-dark {
607
623
  --md-bk-color: #333 !important;
608
624
  }
609
625
  ```
@@ -1,7 +1,7 @@
1
1
  import { CodeCss, Config, ConfigOption, Footers, StaticTextDefault } from './type';
2
- export declare const prefix = "md";
2
+ export declare const prefix = "md-editor";
3
3
  export declare const iconScriptId = "md-editor-v3";
4
- export declare const iconfontUrl = "https://at.alicdn.com/t/font_2605852_pqekijay2ij.js";
4
+ export declare const iconfontUrl = "https://at.alicdn.com/t/c/font_2605852_lxu1yrwwsea.js";
5
5
  export declare const cdnBase = "https://cdnjs.cloudflare.com/ajax/libs";
6
6
  export declare const highlightUrl: string;
7
7
  export declare const prettierUrl: {
@@ -21,6 +21,7 @@ export interface ToolbarTips {
21
21
  quote?: string;
22
22
  unorderedList?: string;
23
23
  orderedList?: string;
24
+ task?: string;
24
25
  codeRow?: string;
25
26
  code?: string;
26
27
  link?: string;
@@ -18,8 +18,8 @@ var __spreadValues = (a, b) => {
18
18
  };
19
19
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
20
  import { onMounted, onBeforeUnmount, provide, computed, reactive, watch, ref, defineComponent, createVNode, cloneVNode, nextTick, inject, Fragment, toRef, isVNode } from "vue";
21
- const prefix = "md";
22
- const iconfontUrl = "https://at.alicdn.com/t/font_2605852_pqekijay2ij.js";
21
+ const prefix = "md-editor";
22
+ const iconfontUrl = "https://at.alicdn.com/t/c/font_2605852_lxu1yrwwsea.js";
23
23
  const cdnBase = "https://cdnjs.cloudflare.com/ajax/libs";
24
24
  const highlightUrl = `${cdnBase}/highlight.js/11.5.1/highlight.min.js`;
25
25
  const prettierUrl = {
@@ -43,6 +43,7 @@ const allToolbar = [
43
43
  "quote",
44
44
  "unorderedList",
45
45
  "orderedList",
46
+ "task",
46
47
  "-",
47
48
  "codeRow",
48
49
  "code",
@@ -78,6 +79,7 @@ const staticTextDefault = {
78
79
  quote: "\u5F15\u7528",
79
80
  unorderedList: "\u65E0\u5E8F\u5217\u8868",
80
81
  orderedList: "\u6709\u5E8F\u5217\u8868",
82
+ task: "\u4EFB\u52A1\u5217\u8868",
81
83
  codeRow: "\u884C\u5185\u4EE3\u7801",
82
84
  code: "\u5757\u7EA7\u4EE3\u7801",
83
85
  link: "\u94FE\u63A5",
@@ -157,6 +159,7 @@ const staticTextDefault = {
157
159
  quote: "quote",
158
160
  unorderedList: "unordered list",
159
161
  orderedList: "ordered list",
162
+ task: "task list",
160
163
  codeRow: "inline code",
161
164
  code: "block-level code",
162
165
  link: "link",
@@ -1761,7 +1764,7 @@ var ToolBar = defineComponent({
1761
1764
  uploadRef.value.addEventListener("change", uploadHandler);
1762
1765
  });
1763
1766
  const barRender = (barItem) => {
1764
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O;
1767
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P;
1765
1768
  if (allToolbar.includes(barItem)) {
1766
1769
  switch (barItem) {
1767
1770
  case "-": {
@@ -1951,10 +1954,24 @@ var ToolBar = defineComponent({
1951
1954
  "xlink:href": "#icon-ordered-list"
1952
1955
  }, null)])]);
1953
1956
  }
1957
+ case "task": {
1958
+ return createVNode("div", {
1959
+ "class": `${prefix}-toolbar-item`,
1960
+ "title": (_p = ult.value.toolbarTips) == null ? void 0 : _p.task,
1961
+ "onClick": () => {
1962
+ emitHandler("task");
1963
+ }
1964
+ }, [createVNode("svg", {
1965
+ "class": `${prefix}-icon`,
1966
+ "aria-hidden": "true"
1967
+ }, [createVNode("use", {
1968
+ "xlink:href": "#icon-task"
1969
+ }, null)])]);
1970
+ }
1954
1971
  case "codeRow": {
1955
1972
  return createVNode("div", {
1956
1973
  "class": `${prefix}-toolbar-item`,
1957
- "title": (_p = ult.value.toolbarTips) == null ? void 0 : _p.codeRow,
1974
+ "title": (_q = ult.value.toolbarTips) == null ? void 0 : _q.codeRow,
1958
1975
  "onClick": () => {
1959
1976
  emitHandler("codeRow");
1960
1977
  }
@@ -1968,7 +1985,7 @@ var ToolBar = defineComponent({
1968
1985
  case "code": {
1969
1986
  return createVNode("div", {
1970
1987
  "class": `${prefix}-toolbar-item`,
1971
- "title": (_q = ult.value.toolbarTips) == null ? void 0 : _q.code,
1988
+ "title": (_r = ult.value.toolbarTips) == null ? void 0 : _r.code,
1972
1989
  "onClick": () => {
1973
1990
  emitHandler("code");
1974
1991
  }
@@ -1982,7 +1999,7 @@ var ToolBar = defineComponent({
1982
1999
  case "link": {
1983
2000
  return createVNode("div", {
1984
2001
  "class": `${prefix}-toolbar-item`,
1985
- "title": (_r = ult.value.toolbarTips) == null ? void 0 : _r.link,
2002
+ "title": (_s = ult.value.toolbarTips) == null ? void 0 : _s.link,
1986
2003
  "onClick": () => {
1987
2004
  modalData.type = "link";
1988
2005
  modalData.linkVisible = true;
@@ -2012,17 +2029,17 @@ var ToolBar = defineComponent({
2012
2029
  modalData.type = "image";
2013
2030
  modalData.linkVisible = true;
2014
2031
  }
2015
- }, [(_s = ult.value.imgTitleItem) == null ? void 0 : _s.link]), createVNode("li", {
2032
+ }, [(_t = ult.value.imgTitleItem) == null ? void 0 : _t.link]), createVNode("li", {
2016
2033
  "class": `${prefix}-menu-item`,
2017
2034
  "onClick": () => {
2018
2035
  uploadRef.value.click();
2019
2036
  }
2020
- }, [(_t = ult.value.imgTitleItem) == null ? void 0 : _t.upload]), createVNode("li", {
2037
+ }, [(_u = ult.value.imgTitleItem) == null ? void 0 : _u.upload]), createVNode("li", {
2021
2038
  "class": `${prefix}-menu-item`,
2022
2039
  "onClick": () => {
2023
2040
  modalData.clipVisible = true;
2024
2041
  }
2025
- }, [(_u = ult.value.imgTitleItem) == null ? void 0 : _u.clip2upload])])
2042
+ }, [(_v = ult.value.imgTitleItem) == null ? void 0 : _v.clip2upload])])
2026
2043
  }, {
2027
2044
  default: () => {
2028
2045
  var _a2;
@@ -2072,7 +2089,7 @@ var ToolBar = defineComponent({
2072
2089
  case "revoke": {
2073
2090
  return createVNode("div", {
2074
2091
  "class": `${prefix}-toolbar-item`,
2075
- "title": (_v = ult.value.toolbarTips) == null ? void 0 : _v.revoke,
2092
+ "title": (_w = ult.value.toolbarTips) == null ? void 0 : _w.revoke,
2076
2093
  "onClick": () => {
2077
2094
  bus.emit(editorId, "ctrlZ");
2078
2095
  }
@@ -2086,7 +2103,7 @@ var ToolBar = defineComponent({
2086
2103
  case "next": {
2087
2104
  return createVNode("div", {
2088
2105
  "class": `${prefix}-toolbar-item`,
2089
- "title": (_w = ult.value.toolbarTips) == null ? void 0 : _w.next,
2106
+ "title": (_x = ult.value.toolbarTips) == null ? void 0 : _x.next,
2090
2107
  "onClick": () => {
2091
2108
  bus.emit(editorId, "ctrlShiftZ");
2092
2109
  }
@@ -2100,7 +2117,7 @@ var ToolBar = defineComponent({
2100
2117
  case "save": {
2101
2118
  return createVNode("div", {
2102
2119
  "class": `${prefix}-toolbar-item`,
2103
- "title": (_x = ult.value.toolbarTips) == null ? void 0 : _x.save,
2120
+ "title": (_y = ult.value.toolbarTips) == null ? void 0 : _y.save,
2104
2121
  "onClick": () => {
2105
2122
  bus.emit(editorId, "onSave");
2106
2123
  }
@@ -2114,7 +2131,7 @@ var ToolBar = defineComponent({
2114
2131
  case "prettier": {
2115
2132
  return !props.noPrettier ? createVNode("div", {
2116
2133
  "class": `${prefix}-toolbar-item`,
2117
- "title": (_y = ult.value.toolbarTips) == null ? void 0 : _y.prettier,
2134
+ "title": (_z = ult.value.toolbarTips) == null ? void 0 : _z.prettier,
2118
2135
  "onClick": () => {
2119
2136
  emitHandler("prettier");
2120
2137
  }
@@ -2128,7 +2145,7 @@ var ToolBar = defineComponent({
2128
2145
  case "pageFullscreen": {
2129
2146
  return !props.setting.fullscreen && createVNode("div", {
2130
2147
  "class": `${prefix}-toolbar-item`,
2131
- "title": (_z = ult.value.toolbarTips) == null ? void 0 : _z.pageFullscreen,
2148
+ "title": (_A = ult.value.toolbarTips) == null ? void 0 : _A.pageFullscreen,
2132
2149
  "onClick": () => {
2133
2150
  props.updateSetting(!props.setting.pageFullScreen, "pageFullScreen");
2134
2151
  }
@@ -2142,7 +2159,7 @@ var ToolBar = defineComponent({
2142
2159
  case "fullscreen": {
2143
2160
  return createVNode("div", {
2144
2161
  "class": `${prefix}-toolbar-item`,
2145
- "title": (_A = ult.value.toolbarTips) == null ? void 0 : _A.fullscreen,
2162
+ "title": (_B = ult.value.toolbarTips) == null ? void 0 : _B.fullscreen,
2146
2163
  "onClick": fullScreenHandler
2147
2164
  }, [createVNode("svg", {
2148
2165
  "class": `${prefix}-icon`,
@@ -2154,7 +2171,7 @@ var ToolBar = defineComponent({
2154
2171
  case "preview": {
2155
2172
  return createVNode("div", {
2156
2173
  "class": `${prefix}-toolbar-item`,
2157
- "title": (_B = ult.value.toolbarTips) == null ? void 0 : _B.preview,
2174
+ "title": (_C = ult.value.toolbarTips) == null ? void 0 : _C.preview,
2158
2175
  "onClick": () => {
2159
2176
  props.updateSetting(!props.setting.preview, "preview");
2160
2177
  }
@@ -2168,7 +2185,7 @@ var ToolBar = defineComponent({
2168
2185
  case "htmlPreview": {
2169
2186
  return createVNode("div", {
2170
2187
  "class": `${prefix}-toolbar-item`,
2171
- "title": (_C = ult.value.toolbarTips) == null ? void 0 : _C.htmlPreview,
2188
+ "title": (_D = ult.value.toolbarTips) == null ? void 0 : _D.htmlPreview,
2172
2189
  "onClick": () => {
2173
2190
  props.updateSetting(!props.setting.htmlPreview, "htmlPreview");
2174
2191
  }
@@ -2182,7 +2199,7 @@ var ToolBar = defineComponent({
2182
2199
  case "catalog": {
2183
2200
  return createVNode("div", {
2184
2201
  "class": `${prefix}-toolbar-item`,
2185
- "title": (_D = ult.value.toolbarTips) == null ? void 0 : _D.catalog,
2202
+ "title": (_E = ult.value.toolbarTips) == null ? void 0 : _E.catalog,
2186
2203
  "onClick": () => {
2187
2204
  bus.emit(editorId, "catalogShow");
2188
2205
  },
@@ -2197,7 +2214,7 @@ var ToolBar = defineComponent({
2197
2214
  case "github": {
2198
2215
  return createVNode("div", {
2199
2216
  "class": `${prefix}-toolbar-item`,
2200
- "title": (_E = ult.value.toolbarTips) == null ? void 0 : _E.github,
2217
+ "title": (_F = ult.value.toolbarTips) == null ? void 0 : _F.github,
2201
2218
  "onClick": () => goto("https://github.com/imzbf/md-editor-v3")
2202
2219
  }, [createVNode("svg", {
2203
2220
  "class": `${prefix}-icon`,
@@ -2223,42 +2240,42 @@ var ToolBar = defineComponent({
2223
2240
  "onClick": () => {
2224
2241
  emitHandler("flow");
2225
2242
  }
2226
- }, [(_F = ult.value.mermaid) == null ? void 0 : _F.flow]), createVNode("li", {
2243
+ }, [(_G = ult.value.mermaid) == null ? void 0 : _G.flow]), createVNode("li", {
2227
2244
  "class": `${prefix}-menu-item`,
2228
2245
  "onClick": () => {
2229
2246
  emitHandler("sequence");
2230
2247
  }
2231
- }, [(_G = ult.value.mermaid) == null ? void 0 : _G.sequence]), createVNode("li", {
2248
+ }, [(_H = ult.value.mermaid) == null ? void 0 : _H.sequence]), createVNode("li", {
2232
2249
  "class": `${prefix}-menu-item`,
2233
2250
  "onClick": () => {
2234
2251
  emitHandler("gantt");
2235
2252
  }
2236
- }, [(_H = ult.value.mermaid) == null ? void 0 : _H.gantt]), createVNode("li", {
2253
+ }, [(_I = ult.value.mermaid) == null ? void 0 : _I.gantt]), createVNode("li", {
2237
2254
  "class": `${prefix}-menu-item`,
2238
2255
  "onClick": () => {
2239
2256
  emitHandler("class");
2240
2257
  }
2241
- }, [(_I = ult.value.mermaid) == null ? void 0 : _I.class]), createVNode("li", {
2258
+ }, [(_J = ult.value.mermaid) == null ? void 0 : _J.class]), createVNode("li", {
2242
2259
  "class": `${prefix}-menu-item`,
2243
2260
  "onClick": () => {
2244
2261
  emitHandler("state");
2245
2262
  }
2246
- }, [(_J = ult.value.mermaid) == null ? void 0 : _J.state]), createVNode("li", {
2263
+ }, [(_K = ult.value.mermaid) == null ? void 0 : _K.state]), createVNode("li", {
2247
2264
  "class": `${prefix}-menu-item`,
2248
2265
  "onClick": () => {
2249
2266
  emitHandler("pie");
2250
2267
  }
2251
- }, [(_K = ult.value.mermaid) == null ? void 0 : _K.pie]), createVNode("li", {
2268
+ }, [(_L = ult.value.mermaid) == null ? void 0 : _L.pie]), createVNode("li", {
2252
2269
  "class": `${prefix}-menu-item`,
2253
2270
  "onClick": () => {
2254
2271
  emitHandler("relationship");
2255
2272
  }
2256
- }, [(_L = ult.value.mermaid) == null ? void 0 : _L.relationship]), createVNode("li", {
2273
+ }, [(_M = ult.value.mermaid) == null ? void 0 : _M.relationship]), createVNode("li", {
2257
2274
  "class": `${prefix}-menu-item`,
2258
2275
  "onClick": () => {
2259
2276
  emitHandler("journey");
2260
2277
  }
2261
- }, [(_M = ult.value.mermaid) == null ? void 0 : _M.journey])]),
2278
+ }, [(_N = ult.value.mermaid) == null ? void 0 : _N.journey])]),
2262
2279
  "key": "bar-mermaid"
2263
2280
  }, {
2264
2281
  default: () => {
@@ -2292,12 +2309,12 @@ var ToolBar = defineComponent({
2292
2309
  "onClick": () => {
2293
2310
  emitHandler("katexInline");
2294
2311
  }
2295
- }, [(_N = ult.value.katex) == null ? void 0 : _N.inline]), createVNode("li", {
2312
+ }, [(_O = ult.value.katex) == null ? void 0 : _O.inline]), createVNode("li", {
2296
2313
  "class": `${prefix}-menu-item`,
2297
2314
  "onClick": () => {
2298
2315
  emitHandler("katexBlock");
2299
2316
  }
2300
- }, [(_O = ult.value.katex) == null ? void 0 : _O.block])]),
2317
+ }, [(_P = ult.value.katex) == null ? void 0 : _P.block])]),
2301
2318
  "key": "bar-katex"
2302
2319
  }, {
2303
2320
  default: () => {
@@ -5025,6 +5042,13 @@ const directive2flag = (direct, selectedText = "", inputArea, params) => {
5025
5042
  deviationStart = 2;
5026
5043
  break;
5027
5044
  }
5045
+ case "task": {
5046
+ targetValue = `- [ ] ${selectedText}`;
5047
+ deviationStart = 6;
5048
+ deviationEnd = targetValue.length;
5049
+ select = true;
5050
+ break;
5051
+ }
5028
5052
  case "code": {
5029
5053
  targetValue = "```language\n" + selectedText + "\n```\n";
5030
5054
  deviationStart = 3;
@@ -5730,17 +5754,20 @@ const useAutoGenrator = (props, textAreaRef) => {
5730
5754
  event.cancelBubble = true;
5731
5755
  event.preventDefault();
5732
5756
  event.stopPropagation();
5733
- if (/^\d+\.\s+$|^-\s+$/.test(enterPressRow)) {
5734
- const resetPrefixStr = prefixStr == null ? void 0 : prefixStr.replace(new RegExp(enterPressRow + "$"), "");
5757
+ if (/^(\d+\.|-)\s+(\[[x\s]\]\s+)?$/.test(enterPressRow)) {
5758
+ const resetPrefixStr = prefixStr == null ? void 0 : prefixStr.replace(/(\d+\.|-)\s+(\[[x\s]\]\s+)?$/, "");
5735
5759
  props.onChange(resetPrefixStr + subStr);
5736
5760
  setPosition(textAreaRef.value, resetPrefixStr == null ? void 0 : resetPrefixStr.length);
5737
5761
  } else if (/^-\s+.+/.test(enterPressRow)) {
5738
- props.onChange(insert(textAreaRef.value, "\n- ", {}));
5762
+ const newLine = /^-\s+\[[x\s]\]/.test(enterPressRow) ? "\n- [ ] " : "\n- ";
5763
+ props.onChange(insert(textAreaRef.value, newLine, {}));
5739
5764
  } else {
5740
5765
  const lastOrderMatch = enterPressRow == null ? void 0 : enterPressRow.match(/\d+(?=\.)/);
5741
5766
  const nextOrder = lastOrderMatch && Number(lastOrderMatch[0]) + 1 || 1;
5742
- props.onChange(insert(textAreaRef.value, `
5743
- ${nextOrder}. `, {}));
5767
+ const newLine = /^\d\.\s+\[[x\s]\]/.test(enterPressRow) ? `
5768
+ ${nextOrder}. [ ] ` : `
5769
+ ${nextOrder}. `;
5770
+ props.onChange(insert(textAreaRef.value, newLine, {}));
5744
5771
  }
5745
5772
  }
5746
5773
  }