vditor 3.8.4 → 3.8.8

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.
Files changed (110) hide show
  1. package/CHANGELOG.md +45 -8
  2. package/README.md +49 -46
  3. package/dist/css/content-theme/ant-design.css +185 -1
  4. package/dist/css/content-theme/dark.css +98 -1
  5. package/dist/css/content-theme/light.css +76 -1
  6. package/dist/css/content-theme/wechat.css +69 -1
  7. package/dist/index.css +10 -8
  8. package/dist/index.d.ts +5 -1
  9. package/dist/index.min.js +15433 -8
  10. package/dist/js/.DS_Store +0 -0
  11. package/dist/js/highlight.js/highlight.pack.js +1617 -2
  12. package/dist/js/highlight.js/styles/abap.css +155 -1
  13. package/dist/js/highlight.js/styles/algol.css +142 -1
  14. package/dist/js/highlight.js/styles/algol_nu.css +90 -1
  15. package/dist/js/highlight.js/styles/ant-design.css +469 -1
  16. package/dist/js/highlight.js/styles/arduino.css +155 -1
  17. package/dist/js/highlight.js/styles/autumn.css +136 -1
  18. package/dist/js/highlight.js/styles/borland.css +146 -1
  19. package/dist/js/highlight.js/styles/bw.css +149 -1
  20. package/dist/js/highlight.js/styles/colorful.css +156 -1
  21. package/dist/js/highlight.js/styles/dracula.css +139 -1
  22. package/dist/js/highlight.js/styles/emacs.css +166 -1
  23. package/dist/js/highlight.js/styles/friendly.css +182 -1
  24. package/dist/js/highlight.js/styles/fruity.css +121 -1
  25. package/dist/js/highlight.js/styles/github.css +173 -1
  26. package/dist/js/highlight.js/styles/igor.css +122 -1
  27. package/dist/js/highlight.js/styles/lovelace.css +145 -1
  28. package/dist/js/highlight.js/styles/manni.css +138 -1
  29. package/dist/js/highlight.js/styles/monokai.css +131 -1
  30. package/dist/js/highlight.js/styles/monokailight.css +179 -1
  31. package/dist/js/highlight.js/styles/murphy.css +144 -1
  32. package/dist/js/highlight.js/styles/native.css +163 -1
  33. package/dist/js/highlight.js/styles/paraiso-dark.css +136 -1
  34. package/dist/js/highlight.js/styles/paraiso-light.css +135 -1
  35. package/dist/js/highlight.js/styles/pastie.css +180 -1
  36. package/dist/js/highlight.js/styles/perldoc.css +140 -1
  37. package/dist/js/highlight.js/styles/pygments.css +158 -1
  38. package/dist/js/highlight.js/styles/rainbow_dash.css +163 -1
  39. package/dist/js/highlight.js/styles/rrt.css +158 -1
  40. package/dist/js/highlight.js/styles/solarized-dark.css +145 -1
  41. package/dist/js/highlight.js/styles/solarized-dark256.css +145 -1
  42. package/dist/js/highlight.js/styles/solarized-light.css +162 -1
  43. package/dist/js/highlight.js/styles/swapoff.css +144 -1
  44. package/dist/js/highlight.js/styles/tango.css +183 -1
  45. package/dist/js/highlight.js/styles/trac.css +166 -1
  46. package/dist/js/highlight.js/styles/vim.css +143 -1
  47. package/dist/js/highlight.js/styles/vs.css +112 -1
  48. package/dist/js/highlight.js/styles/xcode.css +173 -1
  49. package/dist/js/i18n/en_US.js +85 -0
  50. package/dist/js/i18n/ja_JP.js +85 -0
  51. package/dist/js/i18n/ko_KR.js +85 -0
  52. package/dist/js/i18n/ru_RU.js +85 -0
  53. package/dist/js/i18n/zh_CN.js +85 -0
  54. package/dist/js/i18n/zh_TW.js +85 -0
  55. package/dist/js/katex/katex.min.css +1 -1
  56. package/dist/js/lute/lute.min.js +31 -28
  57. package/dist/js/mathjax/.DS_Store +0 -0
  58. package/dist/js/mathjax/input/tex/extensions/{colorv2.js → colorV2.js} +0 -0
  59. package/dist/js/mathjax/input/tex/extensions/{configmacros.js → configMacros.js} +0 -0
  60. package/dist/js/mathjax/input/tex/extensions/{tagformat.js → tagFormat.js} +0 -0
  61. package/dist/js/mathjax/tex-svg-full.js +1 -0
  62. package/dist/method.d.ts +6 -3
  63. package/dist/method.min.js +2334 -8
  64. package/dist/ts/markdown/adapterRender.d.ts +33 -0
  65. package/dist/ts/markdown/codeRender.d.ts +1 -2
  66. package/dist/ts/ui/initUI.d.ts +1 -0
  67. package/dist/ts/wysiwyg/index.d.ts +2 -0
  68. package/dist/types/index.d.ts +105 -8
  69. package/package.json +23 -24
  70. package/src/assets/.DS_Store +0 -0
  71. package/src/assets/scss/_content.scss +4 -0
  72. package/src/assets/scss/_reset.scss +11 -0
  73. package/src/index.ts +159 -99
  74. package/src/method.ts +6 -2
  75. package/src/ts/.DS_Store +0 -0
  76. package/src/ts/constants.ts +8 -4
  77. package/src/ts/export/index.ts +7 -5
  78. package/src/ts/hint/index.ts +20 -11
  79. package/src/ts/markdown/abcRender.ts +3 -2
  80. package/src/ts/markdown/adapterRender.ts +33 -0
  81. package/src/ts/markdown/chartRender.ts +3 -2
  82. package/src/ts/markdown/codeRender.ts +5 -6
  83. package/src/ts/markdown/flowchartRender.ts +3 -2
  84. package/src/ts/markdown/graphvizRender.ts +13 -11
  85. package/src/ts/markdown/highlightRender.ts +3 -3
  86. package/src/ts/markdown/mathRender.ts +6 -5
  87. package/src/ts/markdown/mermaidRender.ts +4 -2
  88. package/src/ts/markdown/mindmapRender.ts +3 -2
  89. package/src/ts/markdown/plantumlRender.ts +3 -2
  90. package/src/ts/markdown/previewRender.ts +26 -4
  91. package/src/ts/preview/image.ts +2 -4
  92. package/src/ts/preview/index.ts +2 -5
  93. package/src/ts/toolbar/EditMode.ts +3 -4
  94. package/src/ts/toolbar/Headings.ts +6 -6
  95. package/src/ts/toolbar/Info.ts +1 -1
  96. package/src/ts/toolbar/MenuItem.ts +1 -3
  97. package/src/ts/toolbar/Record.ts +3 -4
  98. package/src/ts/ui/initUI.ts +19 -5
  99. package/src/ts/undo/index.ts +5 -5
  100. package/src/ts/upload/index.ts +8 -8
  101. package/src/ts/util/Options.ts +255 -196
  102. package/src/ts/util/editorCommonEvent.ts +2 -2
  103. package/src/ts/util/fixBrowserBehavior.ts +10 -6
  104. package/src/ts/util/processCode.ts +1 -1
  105. package/src/ts/wysiwyg/highlightToolbarWYSIWYG.ts +298 -138
  106. package/src/ts/wysiwyg/index.ts +9 -4
  107. package/dist/js/mathjax/input/.DS_Store +0 -0
  108. package/dist/js/mathjax/tex-svg.js +0 -1
  109. package/dist/ts/i18n/index.d.ts +0 -2
  110. package/src/ts/i18n/index.ts +0 -318
@@ -0,0 +1,33 @@
1
+ export declare const mathRenderAdapter: {
2
+ getCode: (mathElement: Element) => string;
3
+ getElements: (element: HTMLElement) => NodeListOf<Element>;
4
+ };
5
+ export declare const mermaidRenderAdapter: {
6
+ /** 不仅要返回code,并且需要将 code 设置为 el 的 innerHTML */
7
+ getCode: (el: Element) => string;
8
+ getElements: (element: HTMLElement) => NodeListOf<Element>;
9
+ };
10
+ export declare const mindmapRenderAdapter: {
11
+ getCode: (el: Element) => string;
12
+ getElements: (el: HTMLElement | Document) => NodeListOf<Element>;
13
+ };
14
+ export declare const chartRenderAdapter: {
15
+ getCode: (el: HTMLElement) => string;
16
+ getElements: (el: HTMLElement | Document) => NodeListOf<Element>;
17
+ };
18
+ export declare const abcRenderAdapter: {
19
+ getCode: (el: Element) => string;
20
+ getElements: (el: HTMLElement | Document) => NodeListOf<Element>;
21
+ };
22
+ export declare const graphvizRenderAdapter: {
23
+ getCode: (el: Element) => string;
24
+ getElements: (el: HTMLElement | Document) => NodeListOf<Element>;
25
+ };
26
+ export declare const flowchartRenderAdapter: {
27
+ getCode: (el: Element) => string;
28
+ getElements: (el: HTMLElement | Document) => NodeListOf<Element>;
29
+ };
30
+ export declare const plantumlRenderAdapter: {
31
+ getCode: (el: Element) => string;
32
+ getElements: (el: HTMLElement | Document) => NodeListOf<Element>;
33
+ };
@@ -1,2 +1 @@
1
- /// <reference types="./types" />
2
- export declare const codeRender: (element: HTMLElement, lang?: keyof II18n) => void;
1
+ export declare const codeRender: (element: HTMLElement) => void;
@@ -7,3 +7,4 @@ declare global {
7
7
  export declare const initUI: (vditor: IVditor) => void;
8
8
  export declare const setPadding: (vditor: IVditor) => void;
9
9
  export declare const setTypewriterPosition: (vditor: IVditor) => void;
10
+ export declare function UIUnbindListener(): void;
@@ -9,11 +9,13 @@ declare class WYSIWYG {
9
9
  preventInput: boolean;
10
10
  composingLock: boolean;
11
11
  commentIds: string[];
12
+ private scrollListener;
12
13
  constructor(vditor: IVditor);
13
14
  getComments(vditor: IVditor, getData?: boolean): ICommentsData[];
14
15
  triggerRemoveComment(vditor: IVditor): void;
15
16
  showComment(): void;
16
17
  hideComment(): void;
18
+ unbindListener(): void;
17
19
  private copy;
18
20
  private bindEvent;
19
21
  }
@@ -2,6 +2,10 @@ declare module "*.svg";
2
2
 
3
3
  declare module "*.png";
4
4
 
5
+ interface Window {
6
+ VditorI18n: ITips;
7
+ }
8
+
5
9
  interface IObject {
6
10
  [key: string]: string;
7
11
  }
@@ -114,6 +118,8 @@ declare class Lute {
114
118
 
115
119
  public static NewNodeID(): string;
116
120
 
121
+ public static Sanitize(html: string): string;
122
+
117
123
  private constructor();
118
124
 
119
125
  public SetJSRenderers(options?: {
@@ -216,6 +222,9 @@ declare class Lute {
216
222
 
217
223
  // 粘贴是 md 转换为 sv
218
224
  public Md2VditorSVDOM(text: string): string;
225
+
226
+ // 将markdown转化为JSON结构输出 https://github.com/88250/lute/issues/120
227
+ public RenderJSON(markdown: string): string;
219
228
  }
220
229
 
221
230
  declare const webkitAudioContext: {
@@ -223,11 +232,95 @@ declare const webkitAudioContext: {
223
232
  new(contextOptions?: AudioContextOptions): AudioContext,
224
233
  };
225
234
 
235
+ interface ITips {
236
+ [index: string]: string;
237
+
238
+ alignCenter: string;
239
+ alignLeft: string;
240
+ alignRight: string;
241
+ alternateText: string;
242
+ bold: string;
243
+ both: string;
244
+ check: string;
245
+ close: string;
246
+ code: string;
247
+ "code-theme": string;
248
+ column: string;
249
+ comment: string;
250
+ confirm: string;
251
+ "content-theme": string;
252
+ copied: string;
253
+ copy: string;
254
+ "delete-column": string;
255
+ "delete-row": string;
256
+ devtools: string;
257
+ down: string;
258
+ downloadTip: string;
259
+ edit: string;
260
+ "edit-mode": string;
261
+ emoji: string;
262
+ export: string;
263
+ fileTypeError: string;
264
+ footnoteRef: string;
265
+ fullscreen: string;
266
+ generate: string;
267
+ headings: string;
268
+ help: string;
269
+ imageURL: string;
270
+ indent: string;
271
+ info: string;
272
+ "inline-code": string;
273
+ "insert-after": string;
274
+ "insert-before": string;
275
+ insertColumnLeft: string;
276
+ insertColumnRight: string;
277
+ insertRowAbove: string;
278
+ insertRowBelow: string;
279
+ instantRendering: string;
280
+ italic: string;
281
+ language: string;
282
+ line: string;
283
+ link: string;
284
+ linkRef: string;
285
+ list: string;
286
+ more: string;
287
+ nameEmpty: string;
288
+ "ordered-list": string;
289
+ outdent: string;
290
+ outline: string;
291
+ over: string;
292
+ performanceTip: string;
293
+ preview: string;
294
+ quote: string;
295
+ record: string;
296
+ "record-tip": string;
297
+ recording: string;
298
+ redo: string;
299
+ remove: string;
300
+ row: string;
301
+ spin: string;
302
+ splitView: string;
303
+ strike: string;
304
+ table: string;
305
+ textIsNotEmpty: string;
306
+ title: string;
307
+ tooltipText: string;
308
+ undo: string;
309
+ up: string;
310
+ update: string;
311
+ upload: string;
312
+ uploadError: string;
313
+ uploading: string;
314
+ wysiwyg: string;
315
+ }
316
+
226
317
  interface II18n {
227
- en_US: IObject;
228
- ja_JP: IObject;
229
- ko_KR: IObject;
230
- zh_CN: IObject;
318
+ en_US: ITips;
319
+ ja_JP: ITips;
320
+ ko_KR: ITips;
321
+ ru_RU: ITips;
322
+ zh_CN: ITips;
323
+ zh_TW: ITips;
231
324
  }
232
325
 
233
326
  interface IClasses {
@@ -279,7 +372,7 @@ interface IUpload {
279
372
  validate?(files: File[]): string | boolean;
280
373
 
281
374
  /** 自定义上传,当发生错误时返回错误信息 */
282
- handler?(files: File[]): string | null;
375
+ handler?(files: File[]): string | null | Promise<string> | Promise<null>;
283
376
 
284
377
  /** 对服务端返回的数据进行转换,以满足内置的数据结构 */
285
378
  format?(files: File[], responseText: string): string;
@@ -288,7 +381,7 @@ interface IUpload {
288
381
  linkToImgFormat?(responseText: string): string;
289
382
 
290
383
  /** 将上传的文件处理后再返回 */
291
- file?(files: File[]): File[];
384
+ file?(files: File[]): File[] | Promise<File[]>;
292
385
 
293
386
  /** 图片地址上传后的回调 */
294
387
  linkToImgCallback?(responseText: string): void;
@@ -416,6 +509,7 @@ interface IPreviewOptions {
416
509
  mode: "dark" | "light";
417
510
  customEmoji?: IObject;
418
511
  lang?: (keyof II18n);
512
+ i18n?: ITips;
419
513
  lazyLoadImage?: string;
420
514
  emojiPath?: string;
421
515
  hljs?: IHljs;
@@ -443,7 +537,7 @@ interface IHintData {
443
537
  interface IHintExtend {
444
538
  key: string;
445
539
 
446
- hint?(value: string): IHintData[];
540
+ hint?(value: string): IHintData[] | Promise<IHintData[]>;
447
541
  }
448
542
 
449
543
  /** @link https://ld246.com/article/1549638745630#options-hint */
@@ -490,6 +584,8 @@ interface IOptions {
490
584
  placeholder?: string;
491
585
  /** 多语言。默认值: 'zh_CN' */
492
586
  lang?: (keyof II18n);
587
+ /** 国际化, 自定义语言。优先级低于lang */
588
+ i18n?: ITips;
493
589
  /** @link https://ld246.com/article/1549638745630#options-fullscreen */
494
590
  fullscreen?: {
495
591
  index: number;
@@ -556,7 +652,7 @@ interface IOptions {
556
652
  after?(): void;
557
653
 
558
654
  /** 输入后触发 */
559
- input?(value: string, previewElement?: HTMLElement): void;
655
+ input?(value: string): void;
560
656
 
561
657
  /** 聚焦后触发 */
562
658
  focus?(value: string): void;
@@ -651,6 +747,7 @@ interface IVditor {
651
747
  triggerRemoveComment(vditor: IVditor): void,
652
748
  showComment(): void,
653
749
  hideComment(): void,
750
+ unbindListener(): void,
654
751
  };
655
752
  ir?: {
656
753
  range: Range,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vditor",
3
- "version": "3.8.4",
3
+ "version": "3.8.8",
4
4
  "description": "♏ 易于使用的 Markdown 编辑器,为适配不同的应用场景而生",
5
5
  "author": "Vanessa <v@b3log.org> (http://vanessa.b3log.org)",
6
6
  "homepage": "https://b3log.org/vditor",
@@ -19,36 +19,35 @@
19
19
  },
20
20
  "types": "dist/index.d.ts",
21
21
  "devDependencies": {
22
- "@babel/core": "^7.10.4",
23
- "@babel/preset-env": "^7.10.4",
22
+ "@babel/core": "^7.14.2",
23
+ "@babel/preset-env": "^7.14.2",
24
24
  "@types/diff-match-patch": "^1.0.32",
25
- "@types/jest": "^26.0.19",
26
- "@types/puppeteer": "^2.1.1",
27
- "autoprefixer": "^9.8.4",
28
- "babel-loader": "^8.1.0",
29
- "copy-webpack-plugin": "^6.0.3",
30
- "css-loader": "^3.6.0",
25
+ "@types/jest": "^26.0.23",
26
+ "@types/puppeteer": "^2.1.5",
27
+ "autoprefixer": "^9.8.6",
28
+ "babel-loader": "^8.2.2",
29
+ "clean-webpack-plugin": "^4.0.0-alpha.0",
30
+ "copy-webpack-plugin": "^6.4.1",
31
+ "css-loader": "^5.2.4",
31
32
  "file-loader": "^4.3.0",
32
- "html-webpack-plugin": "^3.2.0",
33
+ "html-webpack-plugin": "^5.3.1",
33
34
  "identity-obj-proxy": "^3.0.0",
34
35
  "jest": "^26.6.3",
35
36
  "mini-css-extract-plugin": "^0.8.2",
36
- "node-sass": "^4.14.1",
37
- "on-build-webpack": "^0.1.0",
38
- "optimize-css-assets-webpack-plugin": "^5.0.3",
39
- "postcss-loader": "^3.0.0",
37
+ "node-sass": "^6.0.1",
38
+ "postcss-loader": "^5.2.0",
40
39
  "puppeteer": "^1.20.0",
41
- "rimraf": "^3.0.2",
42
- "sass-loader": "^7.3.1",
43
- "style-loader": "^1.2.1",
44
- "ts-jest": "^26.4.4",
40
+ "sass-loader": "^10.2.0",
41
+ "style-loader": "^1.3.0",
42
+ "terser-webpack-plugin": "^5.1.2",
43
+ "ts-jest": "^26.5.6",
45
44
  "ts-loader": "^6.2.2",
46
45
  "tslint": "^5.20.1",
47
- "typescript": "^3.9.6",
48
- "webpack": "^4.43.0",
49
- "webpack-bundle-analyzer": "^3.8.0",
50
- "webpack-cli": "^3.3.12",
51
- "webpack-dev-server": "^3.11.0"
46
+ "typescript": "^3.9.9",
47
+ "webpack": "^5.37.0",
48
+ "webpack-bundle-analyzer": "^3.9.0",
49
+ "webpack-cli": "^4.7.0",
50
+ "webpack-dev-server": "^4.1.0"
52
51
  },
53
52
  "license": "MIT",
54
53
  "repository": "git://github.com/Vanessa219/vditor.git",
@@ -59,7 +58,7 @@
59
58
  "lint": "tslint --fix -c tslint.json '{src,types}/**/*.ts'",
60
59
  "test:watch": "jest --watch",
61
60
  "test": "jest --coverage",
62
- "start": "webpack-dev-server --config webpack.start.js",
61
+ "start": "webpack serve --config webpack.start.js",
63
62
  "build": "webpack"
64
63
  },
65
64
  "keywords": [
Binary file
@@ -91,6 +91,10 @@
91
91
  padding: 10px;
92
92
  margin: 0 auto;
93
93
  }
94
+
95
+ img:not(.emoji) {
96
+ cursor: pointer;
97
+ }
94
98
  }
95
99
 
96
100
  &-devtools {
@@ -155,6 +155,9 @@
155
155
  margin-bottom: 16px;
156
156
  overflow: auto;
157
157
  border-spacing: 0;
158
+ display: block;
159
+ word-break: keep-all;
160
+ width: 100%;
158
161
 
159
162
  tr {
160
163
  background-color: #fafbfc;
@@ -166,6 +169,14 @@
166
169
  padding: 6px 13px;
167
170
  border: 1px solid #dfe2e5;
168
171
  word-break: normal;
172
+ white-space: nowrap;
173
+
174
+ &:first-child::after {
175
+ content: "";
176
+ display: inline-block;
177
+ vertical-align: top;
178
+ min-height: 24px;
179
+ }
169
180
  }
170
181
 
171
182
  th {