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.
- package/CHANGELOG.md +45 -8
- package/README.md +49 -46
- package/dist/css/content-theme/ant-design.css +185 -1
- package/dist/css/content-theme/dark.css +98 -1
- package/dist/css/content-theme/light.css +76 -1
- package/dist/css/content-theme/wechat.css +69 -1
- package/dist/index.css +10 -8
- package/dist/index.d.ts +5 -1
- package/dist/index.min.js +15433 -8
- package/dist/js/.DS_Store +0 -0
- package/dist/js/highlight.js/highlight.pack.js +1617 -2
- package/dist/js/highlight.js/styles/abap.css +155 -1
- package/dist/js/highlight.js/styles/algol.css +142 -1
- package/dist/js/highlight.js/styles/algol_nu.css +90 -1
- package/dist/js/highlight.js/styles/ant-design.css +469 -1
- package/dist/js/highlight.js/styles/arduino.css +155 -1
- package/dist/js/highlight.js/styles/autumn.css +136 -1
- package/dist/js/highlight.js/styles/borland.css +146 -1
- package/dist/js/highlight.js/styles/bw.css +149 -1
- package/dist/js/highlight.js/styles/colorful.css +156 -1
- package/dist/js/highlight.js/styles/dracula.css +139 -1
- package/dist/js/highlight.js/styles/emacs.css +166 -1
- package/dist/js/highlight.js/styles/friendly.css +182 -1
- package/dist/js/highlight.js/styles/fruity.css +121 -1
- package/dist/js/highlight.js/styles/github.css +173 -1
- package/dist/js/highlight.js/styles/igor.css +122 -1
- package/dist/js/highlight.js/styles/lovelace.css +145 -1
- package/dist/js/highlight.js/styles/manni.css +138 -1
- package/dist/js/highlight.js/styles/monokai.css +131 -1
- package/dist/js/highlight.js/styles/monokailight.css +179 -1
- package/dist/js/highlight.js/styles/murphy.css +144 -1
- package/dist/js/highlight.js/styles/native.css +163 -1
- package/dist/js/highlight.js/styles/paraiso-dark.css +136 -1
- package/dist/js/highlight.js/styles/paraiso-light.css +135 -1
- package/dist/js/highlight.js/styles/pastie.css +180 -1
- package/dist/js/highlight.js/styles/perldoc.css +140 -1
- package/dist/js/highlight.js/styles/pygments.css +158 -1
- package/dist/js/highlight.js/styles/rainbow_dash.css +163 -1
- package/dist/js/highlight.js/styles/rrt.css +158 -1
- package/dist/js/highlight.js/styles/solarized-dark.css +145 -1
- package/dist/js/highlight.js/styles/solarized-dark256.css +145 -1
- package/dist/js/highlight.js/styles/solarized-light.css +162 -1
- package/dist/js/highlight.js/styles/swapoff.css +144 -1
- package/dist/js/highlight.js/styles/tango.css +183 -1
- package/dist/js/highlight.js/styles/trac.css +166 -1
- package/dist/js/highlight.js/styles/vim.css +143 -1
- package/dist/js/highlight.js/styles/vs.css +112 -1
- package/dist/js/highlight.js/styles/xcode.css +173 -1
- package/dist/js/i18n/en_US.js +85 -0
- package/dist/js/i18n/ja_JP.js +85 -0
- package/dist/js/i18n/ko_KR.js +85 -0
- package/dist/js/i18n/ru_RU.js +85 -0
- package/dist/js/i18n/zh_CN.js +85 -0
- package/dist/js/i18n/zh_TW.js +85 -0
- package/dist/js/katex/katex.min.css +1 -1
- package/dist/js/lute/lute.min.js +31 -28
- package/dist/js/mathjax/.DS_Store +0 -0
- package/dist/js/mathjax/input/tex/extensions/{colorv2.js → colorV2.js} +0 -0
- package/dist/js/mathjax/input/tex/extensions/{configmacros.js → configMacros.js} +0 -0
- package/dist/js/mathjax/input/tex/extensions/{tagformat.js → tagFormat.js} +0 -0
- package/dist/js/mathjax/tex-svg-full.js +1 -0
- package/dist/method.d.ts +6 -3
- package/dist/method.min.js +2334 -8
- package/dist/ts/markdown/adapterRender.d.ts +33 -0
- package/dist/ts/markdown/codeRender.d.ts +1 -2
- package/dist/ts/ui/initUI.d.ts +1 -0
- package/dist/ts/wysiwyg/index.d.ts +2 -0
- package/dist/types/index.d.ts +105 -8
- package/package.json +23 -24
- package/src/assets/.DS_Store +0 -0
- package/src/assets/scss/_content.scss +4 -0
- package/src/assets/scss/_reset.scss +11 -0
- package/src/index.ts +159 -99
- package/src/method.ts +6 -2
- package/src/ts/.DS_Store +0 -0
- package/src/ts/constants.ts +8 -4
- package/src/ts/export/index.ts +7 -5
- package/src/ts/hint/index.ts +20 -11
- package/src/ts/markdown/abcRender.ts +3 -2
- package/src/ts/markdown/adapterRender.ts +33 -0
- package/src/ts/markdown/chartRender.ts +3 -2
- package/src/ts/markdown/codeRender.ts +5 -6
- package/src/ts/markdown/flowchartRender.ts +3 -2
- package/src/ts/markdown/graphvizRender.ts +13 -11
- package/src/ts/markdown/highlightRender.ts +3 -3
- package/src/ts/markdown/mathRender.ts +6 -5
- package/src/ts/markdown/mermaidRender.ts +4 -2
- package/src/ts/markdown/mindmapRender.ts +3 -2
- package/src/ts/markdown/plantumlRender.ts +3 -2
- package/src/ts/markdown/previewRender.ts +26 -4
- package/src/ts/preview/image.ts +2 -4
- package/src/ts/preview/index.ts +2 -5
- package/src/ts/toolbar/EditMode.ts +3 -4
- package/src/ts/toolbar/Headings.ts +6 -6
- package/src/ts/toolbar/Info.ts +1 -1
- package/src/ts/toolbar/MenuItem.ts +1 -3
- package/src/ts/toolbar/Record.ts +3 -4
- package/src/ts/ui/initUI.ts +19 -5
- package/src/ts/undo/index.ts +5 -5
- package/src/ts/upload/index.ts +8 -8
- package/src/ts/util/Options.ts +255 -196
- package/src/ts/util/editorCommonEvent.ts +2 -2
- package/src/ts/util/fixBrowserBehavior.ts +10 -6
- package/src/ts/util/processCode.ts +1 -1
- package/src/ts/wysiwyg/highlightToolbarWYSIWYG.ts +298 -138
- package/src/ts/wysiwyg/index.ts +9 -4
- package/dist/js/mathjax/input/.DS_Store +0 -0
- package/dist/js/mathjax/tex-svg.js +0 -1
- package/dist/ts/i18n/index.d.ts +0 -2
- package/src/ts/i18n/index.ts +0 -318
package/CHANGELOG.md
CHANGED
|
@@ -94,18 +94,49 @@
|
|
|
94
94
|
### TODO
|
|
95
95
|
|
|
96
96
|
* [open issues](https://github.com/Vanessa219/vditor/issues)
|
|
97
|
-
* [346](https://github.com/Vanessa219/vditor/issues/346) 内容主题推荐(长期有效) `改进功能`
|
|
98
97
|
|
|
99
|
-
### v3.8.
|
|
98
|
+
### v3.8.9 / 2022-01-xx
|
|
100
99
|
|
|
101
|
-
|
|
102
|
-
* [956](https://github.com/Vanessa219/vditor/issues/956) 改进 plantuml 解析问题 `修复缺陷`
|
|
103
|
-
* 文档修改
|
|
104
|
-
* 3.8.4
|
|
105
|
-
* 添加 hint.parse 配置
|
|
100
|
+
### v3.8.8 / 2021-12-05
|
|
106
101
|
|
|
107
|
-
|
|
102
|
+
* [1129](https://github.com/Vanessa219/vditor/pull/1129) WYSIWYG 下,点击语言后光标切换到代码输入框中 `改进功能`
|
|
103
|
+
* [1122](https://github.com/Vanessa219/vditor/pull/1122) 预览中退出全屏后,工具栏布局错误 `修复缺陷`
|
|
104
|
+
* [1123](https://github.com/Vanessa219/vditor/pull/1123) 预览模式下,工具栏不自动隐藏 `改进功能`
|
|
105
|
+
* [1124](https://github.com/Vanessa219/vditor/pull/1124) 在焦点更改后,代码选择列表不自动隐藏 `改进功能`
|
|
106
|
+
* [1121](https://github.com/Vanessa219/vditor/pull/1121) WYSIWYG 下,Enter 也可以切换到代码输入框中 `改进功能`
|
|
107
|
+
* [1103](https://github.com/Vanessa219/vditor/pull/1103) 支持多语言切换 `改进功能`
|
|
108
|
+
* [1105](https://github.com/Vanessa219/vditor/pull/1105) 兼容 Firefox 中的代码语言选择 `修复缺陷`
|
|
109
|
+
* [1098](https://github.com/Vanessa219/vditor/pull/1098) 兼容 Firefox 中的文件拖拽 `修复缺陷`
|
|
110
|
+
* [1097](https://github.com/Vanessa219/vditor/pull/1097) options.hint.extend[].hint 支持异步 `改进功能`
|
|
111
|
+
* [1101](https://github.com/Vanessa219/vditor/pull/1101) 支持 options.upload.handler 异步 `改进功能`
|
|
112
|
+
* [1089](https://github.com/Vanessa219/vditor/pull/1089) 解决内存泄漏问题 `开发重构`
|
|
113
|
+
* [158](https://github.com/88250/lute/issues/158) Table 紧跟的上一行不是空行时,SpinVditorSVDOM 会将整个表格过滤掉 `修复缺陷`
|
|
108
114
|
|
|
115
|
+
### v3.8.7 / 2021-09-21
|
|
116
|
+
|
|
117
|
+
* [1049](https://github.com/Vanessa219/vditor/issues/1049) #后面没有空格也会渲染为标题 `修复缺陷`
|
|
118
|
+
* [1085](https://github.com/Vanessa219/vditor/issues/1085) XSS 漏洞修复 `修复缺陷`
|
|
119
|
+
* [1074](https://github.com/Vanessa219/vditor/issues/1074) 升级 webpack-dev-server & node-sass `开发重构`
|
|
120
|
+
* [1063](https://github.com/Vanessa219/vditor/issues/1063) 所见即所得模式链接引用语法中链接文本包含行级嵌套的问题 `修复缺陷`
|
|
121
|
+
* [1047](https://github.com/Vanessa219/vditor/issues/1047) 列表换行问题 `修复缺陷`
|
|
122
|
+
* [974](https://github.com/Vanessa219/vditor/issues/974) 所见即所得模式下行级元素间的空格会被删除 `修复缺陷`
|
|
123
|
+
* [1029](https://github.com/Vanessa219/vditor/issues/1029) 公式内小于号大于号等没有转义 `修复缺陷`
|
|
124
|
+
* [1036](https://github.com/Vanessa219/vditor/issues/1036) 标题设置没有配置多语言 `改进功能`
|
|
125
|
+
* [957](https://github.com/Vanessa219/vditor/issues/957) 支持表格横向滚动 `引入特性`
|
|
126
|
+
* [1038](https://github.com/Vanessa219/vditor/issues/1038) 图片使用 pointer 样式 `改进功能`
|
|
127
|
+
* [1034](https://github.com/Vanessa219/vditor/pull/1034) Support Vue and Angular `改进功能`
|
|
128
|
+
* [1016](https://github.com/Vanessa219/vditor/pull/1016) Support Svelte `文档相关`
|
|
129
|
+
* [1009](https://github.com/Vanessa219/vditor/pull/1009/) 对于 markdown 目录下的渲染方法新增 适配模块 `引入特性`
|
|
130
|
+
* [1011](https://github.com/Vanessa219/vditor/issues/1011) 支持导出 JSON `引入特性`
|
|
131
|
+
* [1010](https://github.com/Vanessa219/vditor/issues/1010) 多语言分离 `改进功能`
|
|
132
|
+
* [1008](https://github.com/Vanessa219/vditor/pull/1008) 自定义多语言 `引入特性`
|
|
133
|
+
* [1000](https://github.com/Vanessa219/vditor/issues/1000) 升级 hljs 并添加更多的语言支持 `改进功能`
|
|
134
|
+
* [993](https://github.com/Vanessa219/vditor/pull/993) 加入繁體中文 `引入特性`
|
|
135
|
+
* [980](https://github.com/Vanessa219/vditor/pull/980) 流程图不应渲染代码高亮 `修复缺陷`
|
|
136
|
+
* [987](https://github.com/Vanessa219/vditor/pull/987) 完善 upload 必填项说明 `文档相关`
|
|
137
|
+
* [970](https://github.com/Vanessa219/vditor/pull/970) added ru_RU lang `引入特性`
|
|
138
|
+
* [955](https://github.com/Vanessa219/vditor/issues/955) 为 hint 内容添加是否进行 md 转换的设置 `改进功能`
|
|
139
|
+
* [956](https://github.com/Vanessa219/vditor/issues/956) 改进 plantuml 解析问题 `修复缺陷`
|
|
109
140
|
* [953](https://github.com/Vanessa219/vditor/issues/953) 标题删除需保留空行 `改进功能`
|
|
110
141
|
* [946](https://github.com/Vanessa219/vditor/issues/946) Improve delete behavior in the list item after the code block `修复缺陷`
|
|
111
142
|
* [949](https://github.com/Vanessa219/vditor/issues/949) lute.Md2HTML 3.7.5 后解析无 id 属性 `修复缺陷`
|
|
@@ -134,6 +165,12 @@
|
|
|
134
165
|
* 3.8.1
|
|
135
166
|
* 添加表格增加向上插入行 ⇧⌘F 和向左插入列 ⇧⌘G 的快捷键
|
|
136
167
|
* 快捷键配置格式修改为 ⇧⌘[] / ⌘[] / ⌥⌘[]
|
|
168
|
+
* 3.8.4
|
|
169
|
+
* 添加 hint.parse 配置
|
|
170
|
+
* 3.8.5
|
|
171
|
+
* codeRender 方法中移除 lang 参数
|
|
172
|
+
* 为 options 添加 i18n 语言自定义参数
|
|
173
|
+
* 添加 exportJSON 方法
|
|
137
174
|
|
|
138
175
|
### v3.7.7 / 2021-01-19
|
|
139
176
|
|
package/README.md
CHANGED
|
@@ -6,14 +6,13 @@
|
|
|
6
6
|
<br><br>
|
|
7
7
|
<a title="MIT" target="_blank" href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/license-MIT-orange.svg?style=flat-square"></a>
|
|
8
8
|
<a title="npm bundle size" target="_blank" href="https://www.npmjs.com/package/vditor"><img alt="npm bundle size" src="https://img.shields.io/bundlephobia/minzip/vditor?style=flat-square&color=blueviolet"></a>
|
|
9
|
-
<a title="
|
|
10
|
-
<a title="
|
|
11
|
-
<a title="Downloads" target="_blank" href="https://www.npmjs.com/package/vditor"><img src="https://img.shields.io/npm/dt/vditor.svg?style=flat-square&color=97ca00"></a><br>
|
|
9
|
+
<a title="Version" target="_blank" href="https://www.npmjs.com/package/vditor"><img src="https://img.shields.io/npm/v/vditor.svg?style=flat-square"></a><br>
|
|
10
|
+
<a title="Downloads" target="_blank" href="https://www.npmjs.com/package/vditor"><img src="https://img.shields.io/npm/dt/vditor.svg?style=flat-square&color=97ca00"></a>
|
|
12
11
|
<a title="jsdelivr" target="_blank" href="https://www.jsdelivr.com/package/npm/vditor"><img src="https://data.jsdelivr.com/v1/package/npm/vditor/badge"/></a>
|
|
13
12
|
<a title="Hits" target="_blank" href="https://github.com/88250/hits"><img src="https://hits.b3log.org/Vanessa219/vditor.svg"></a> <br><br>
|
|
14
|
-
<a title="GitHub Watchers" target="_blank" href="https://github.com/Vanessa219/vditor/watchers"><img src="https://img.shields.io/github/watchers/Vanessa219/vditor.svg?label=Watchers&style=social"></a>
|
|
15
|
-
<a title="GitHub Stars" target="_blank" href="https://github.com/Vanessa219/vditor/stargazers"><img src="https://img.shields.io/github/stars/Vanessa219/vditor.svg?label=Stars&style=social"></a>
|
|
16
|
-
<a title="GitHub Forks" target="_blank" href="https://github.com/Vanessa219/vditor/network/members"><img src="https://img.shields.io/github/forks/Vanessa219/vditor.svg?label=Forks&style=social"></a>
|
|
13
|
+
<a title="GitHub Watchers" target="_blank" href="https://github.com/Vanessa219/vditor/watchers"><img src="https://img.shields.io/github/watchers/Vanessa219/vditor.svg?label=Watchers&style=social"></a>
|
|
14
|
+
<a title="GitHub Stars" target="_blank" href="https://github.com/Vanessa219/vditor/stargazers"><img src="https://img.shields.io/github/stars/Vanessa219/vditor.svg?label=Stars&style=social"></a>
|
|
15
|
+
<a title="GitHub Forks" target="_blank" href="https://github.com/Vanessa219/vditor/network/members"><img src="https://img.shields.io/github/forks/Vanessa219/vditor.svg?label=Forks&style=social"></a>
|
|
17
16
|
<a title="Author GitHub Followers" target="_blank" href="https://github.com/vanessa219"><img src="https://img.shields.io/github/followers/vanessa219.svg?label=Followers&style=social"></a>
|
|
18
17
|
</p>
|
|
19
18
|
|
|
@@ -23,7 +22,7 @@
|
|
|
23
22
|
|
|
24
23
|
## 💡 简介
|
|
25
24
|
|
|
26
|
-
[Vditor](https://b3log.org/vditor) 是一款浏览器端的 Markdown 编辑器,支持所见即所得、即时渲染(类似 Typora)和分屏预览模式。它使用 TypeScript 实现,支持原生 JavaScript
|
|
25
|
+
[Vditor](https://b3log.org/vditor) 是一款浏览器端的 Markdown 编辑器,支持所见即所得、即时渲染(类似 Typora)和分屏预览模式。它使用 TypeScript 实现,支持原生 JavaScript 以及 Vue、React、Angular 和 Svelte 等框架。
|
|
27
26
|
|
|
28
27
|
欢迎到 [Vditor 官方讨论区](https://ld246.com/tag/vditor)了解更多。同时也欢迎关注 B3log 开源社区微信公众号 `B3log开源`:
|
|
29
28
|
|
|
@@ -115,7 +114,6 @@ Vditor 在这些方面做了努力,希望能为现代化的通用 Markdown 编
|
|
|
115
114
|
|
|
116
115
|
* [Sym](https://github.com/88250/symphony) 一款用 Java 实现的现代化社区(论坛/BBS/社交网络/博客)平台
|
|
117
116
|
* [Solo](https://github.com/88250/solo) & [Pipe](https://github.com/88250/pipe) B3log 分布式社区的博客端节点,欢迎加入下一代社区网络
|
|
118
|
-
* [思源笔记](https://b3log.org/siyuan) 一款 Markdown 块级引用和双向链接的网状笔记应用
|
|
119
117
|
* [Arya](https://github.com/nicejade/markdown-online-editor) 基于 Vue、Vditor,所构建的在线 Markdown 编辑器
|
|
120
118
|
* [更多案例](https://github.com/Vanessa219/vditor/network/dependents?package_id=UGFja2FnZS0zMTY2Mzg4MzE%3D)
|
|
121
119
|
|
|
@@ -153,6 +151,7 @@ const vditor = new Vditor(id, {options...})
|
|
|
153
151
|
* [官方示例](https://b3log.org/vditor/demo/index.html) / [示例源码](https://github.com/Vanessa219/b3log-index/tree/master/src/vditor)
|
|
154
152
|
* [CommonJS Editor](https://github.com/Vanessa219/vditor/blob/master/demo/index.js)
|
|
155
153
|
* [CommonJS Render](https://github.com/Vanessa219/vditor/blob/master/demo/render.js)
|
|
154
|
+
* [在Svelte中使用](https://github.com/HerbertHe/svelte-vditor-demo)
|
|
156
155
|
|
|
157
156
|
### 主题
|
|
158
157
|
|
|
@@ -194,13 +193,14 @@ Markdown 输出的 HTML 所展现的外观。内置 light,dark,wechat 3 套
|
|
|
194
193
|
|
|
195
194
|
| | 说明 | 默认值 |
|
|
196
195
|
| - | - | - |
|
|
196
|
+
| i18n | 多语言,参见 ITips | - |
|
|
197
197
|
| undoDelay | 历史记录间隔 | - |
|
|
198
198
|
| after | 编辑器异步渲染完成后的回调方法 | - |
|
|
199
199
|
| height | 编辑器总高度 | 'auto' |
|
|
200
200
|
| minHeight | 编辑区域最小高度 | - |
|
|
201
201
|
| width | 编辑器总宽度,支持 % | 'auto' |
|
|
202
202
|
| placeholder | 输入区域为空时的提示 | '' |
|
|
203
|
-
| lang |
|
|
203
|
+
| lang | 语言种类:en_US, ja_JP, ko_KR, ru_RU, zh_CN, zh_TW | 'zh_CN' |
|
|
204
204
|
| input(value: string) | 输入后触发 | - |
|
|
205
205
|
| focus(value: string) | 聚焦后触发 | - |
|
|
206
206
|
| blur(value: string) | 失焦后触发 | - |
|
|
@@ -262,7 +262,7 @@ new Vditor('vditor', {
|
|
|
262
262
|
| | 说明 | 默认值 |
|
|
263
263
|
| - | - | - |
|
|
264
264
|
| enable | 是否启用计数器 | false |
|
|
265
|
-
|
|
|
265
|
+
| after(length: number, counter: options.counter): void | 字数统计回调 | - |
|
|
266
266
|
| max | 允许输入的最大值 | - |
|
|
267
267
|
| type | 统计类型:'markdown', 'text' | 'markdown' |
|
|
268
268
|
|
|
@@ -363,13 +363,15 @@ new Vditor('vditor', {
|
|
|
363
363
|
| extend: IHintExtend[] | 对 @/话题等关键字自动补全的扩展 | [] |
|
|
364
364
|
|
|
365
365
|
```ts
|
|
366
|
+
interface IHintData {
|
|
367
|
+
html: string;
|
|
368
|
+
value: string;
|
|
369
|
+
}
|
|
370
|
+
|
|
366
371
|
interface IHintExtend {
|
|
367
372
|
key: string;
|
|
368
373
|
|
|
369
|
-
hint?(value: string):
|
|
370
|
-
html: string;
|
|
371
|
-
value: string;
|
|
372
|
-
}>;
|
|
374
|
+
hint?(value: string): IHintData[] | Promise<IHintData[]>;
|
|
373
375
|
}
|
|
374
376
|
```
|
|
375
377
|
|
|
@@ -378,35 +380,35 @@ interface IHintExtend {
|
|
|
378
380
|
* 文件上传的数据结构如下。后端返回的数据结构不一致时,可使用 `format` 进行转换。
|
|
379
381
|
|
|
380
382
|
```js
|
|
381
|
-
// POST data
|
|
382
|
-
xhr.send(formData); // formData = FormData.append("file[]", File)
|
|
383
|
-
// return data
|
|
384
|
-
{
|
|
385
|
-
"msg": "",
|
|
386
|
-
"code": 0,
|
|
387
|
-
"data": {
|
|
388
|
-
"errFiles": ['filename', 'filename2'],
|
|
389
|
-
"succMap": {
|
|
390
|
-
"filename3": "filepath3",
|
|
391
|
-
"filename3": "filepath3"
|
|
392
|
-
}
|
|
393
|
-
}
|
|
383
|
+
// POST data
|
|
384
|
+
xhr.send(formData); // formData = FormData.append("file[]", File)
|
|
385
|
+
// return data
|
|
386
|
+
{
|
|
387
|
+
"msg": "",
|
|
388
|
+
"code": 0,
|
|
389
|
+
"data": {
|
|
390
|
+
"errFiles": ['filename', 'filename2'],
|
|
391
|
+
"succMap": {
|
|
392
|
+
"filename3": "filepath3",
|
|
393
|
+
"filename3": "filepath3"
|
|
394
|
+
}
|
|
395
|
+
}
|
|
394
396
|
}
|
|
395
397
|
```
|
|
396
398
|
|
|
397
399
|
* 为了防止站外图片失效, `linkToImgUrl` 可将剪贴板中的站外图片地址传到服务器端进行保存处理,其数据结构如下:
|
|
398
400
|
|
|
399
401
|
```js
|
|
400
|
-
// POST data
|
|
401
|
-
xhr.send(JSON.stringify({url: src})); // src 为站外图片地址
|
|
402
|
-
// return data
|
|
403
|
-
{
|
|
404
|
-
msg: '',
|
|
405
|
-
code: 0,
|
|
406
|
-
data : {
|
|
407
|
-
originalURL: '',
|
|
408
|
-
url: ''
|
|
409
|
-
}
|
|
402
|
+
// POST data
|
|
403
|
+
xhr.send(JSON.stringify({url: src})); // src 为站外图片地址
|
|
404
|
+
// return data
|
|
405
|
+
{
|
|
406
|
+
msg: '',
|
|
407
|
+
code: 0,
|
|
408
|
+
data : {
|
|
409
|
+
originalURL: '',
|
|
410
|
+
url: ''
|
|
411
|
+
}
|
|
410
412
|
}
|
|
411
413
|
```
|
|
412
414
|
|
|
@@ -434,7 +436,7 @@ if (xhr.status === 200) {
|
|
|
434
436
|
|
|
435
437
|
| | 说明 | 默认值 |
|
|
436
438
|
| - | - | - |
|
|
437
|
-
| url | 上传 url | '' |
|
|
439
|
+
| url | 上传 url,为空则不会触发上传相关事件 | '' |
|
|
438
440
|
| max | 上传文件最大 Byte | 10 * 1024 * 1024 |
|
|
439
441
|
| linkToImgUrl | 剪切板中包含图片地址时,使用此 url 重新上传 | '' |
|
|
440
442
|
| linkToImgCallback(responseText: string) | 图片地址上传回调 | - |
|
|
@@ -447,9 +449,9 @@ if (xhr.status === 200) {
|
|
|
447
449
|
| filename(name: string): string | 文件名安全处理 | name => name.replace(/\W/g, '') |
|
|
448
450
|
| accept | 文件上传类型,同[input accept](https://www.w3schools.com/tags/att_input_accept.asp) | - |
|
|
449
451
|
| validate(files: File[]) => string \| boolean | 校验,成功时返回 true 否则返回错误信息 | - |
|
|
450
|
-
| handler(files: File[]) => string \| null | 自定义上传,当发生错误时返回错误信息 | - |
|
|
452
|
+
| handler(files: File[]) => string \| null \| Promise<string> \| Promise<null> | 自定义上传,当发生错误时返回错误信息 | - |
|
|
451
453
|
| format(files: File[], responseText: string): string | 对服务端返回的数据进行转换,以满足内置的数据结构 | - |
|
|
452
|
-
| file(files: File[]): File[] | 将上传的文件处理后再返回 | - |
|
|
454
|
+
| file(files: File[]): File[] \| Promise<File[]> | 将上传的文件处理后再返回 | - |
|
|
453
455
|
| setHeaders(): { [key: string]: string } | 上传前使用返回值设置头 | - |
|
|
454
456
|
| extraData: { [key: string]: string \| Blob } | 为 FormData 添加额外的参数 | - |
|
|
455
457
|
| multiple | 上传文件是否为多个 | true |
|
|
@@ -486,6 +488,7 @@ if (xhr.status === 200) {
|
|
|
486
488
|
|
|
487
489
|
| | 说明 |
|
|
488
490
|
| - | - |
|
|
491
|
+
| exportJSON(markdown: string) | 根据 Markdown 获取对应 JSON |
|
|
489
492
|
| getValue() | 获取 Markdown 内容 |
|
|
490
493
|
| getHTML() | 获取 HTML 内容 |
|
|
491
494
|
| insertValue(value: string, render = true) | 在焦点处插入内容,并默认进行 Markdown 渲染 |
|
|
@@ -524,7 +527,7 @@ Vditor.mermaidRender(document)
|
|
|
524
527
|
```
|
|
525
528
|
|
|
526
529
|
```js
|
|
527
|
-
import VditorPreview from 'vditor/dist/method.min'
|
|
530
|
+
import VditorPreview from 'vditor/dist/method.min'
|
|
528
531
|
VditorPreview.mermaidRender(document)
|
|
529
532
|
```
|
|
530
533
|
|
|
@@ -536,10 +539,10 @@ markdown: string, // 需要渲染的 markdown 原文
|
|
|
536
539
|
options?: IPreviewOptions {
|
|
537
540
|
mode: "dark" | "light";
|
|
538
541
|
anchor?: number; // 为标题添加锚点 0:不渲染;1:渲染于标题前;2:渲染于标题后,默认 0
|
|
539
|
-
customEmoji?: { [key: string]: string }; // 自定义 emoji,默认为 {}
|
|
540
|
-
lang?: (keyof II18nLang); // 语言,默认为 'zh_CN'
|
|
541
|
-
emojiPath?: string; // 表情图片路径
|
|
542
|
-
hljs?: IHljs; // 参见 options.preview.hljs
|
|
542
|
+
customEmoji?: { [key: string]: string }; // 自定义 emoji,默认为 {}
|
|
543
|
+
lang?: (keyof II18nLang); // 语言,默认为 'zh_CN'
|
|
544
|
+
emojiPath?: string; // 表情图片路径
|
|
545
|
+
hljs?: IHljs; // 参见 options.preview.hljs
|
|
543
546
|
speech?: { // 对选中后的内容进行阅读
|
|
544
547
|
enable?: boolean,
|
|
545
548
|
};
|
|
@@ -561,7 +564,7 @@ options?: IPreviewOptions {
|
|
|
561
564
|
| previewImage(oldImgElement: HTMLImageElement, lang: keyof II18n = "zh_CN", theme = "classic") | 点击图片预览 |
|
|
562
565
|
| mermaidRender(element: HTMLElement, cdn = options.cdn, theme = options.theme) | 流程图/时序图/甘特图 |
|
|
563
566
|
| flowchartRender(element: HTMLElement, cdn = options.cdn) | flowchart 渲染 |
|
|
564
|
-
| codeRender(element: HTMLElement
|
|
567
|
+
| codeRender(element: HTMLElement) | 为 element 中的代码块添加复制按钮 |
|
|
565
568
|
| chartRender(element: (HTMLElement \| Document) = document, cdn = options.cdn, theme = options.theme) | 图表渲染 |
|
|
566
569
|
| mindmapRender(element: (HTMLElement \| Document) = document, cdn = options.cdn, theme = options.theme) | 脑图渲染 |
|
|
567
570
|
| plantumlRender(element: (HTMLElement \| Document) = document, cdn = options.cdn) | plantuml 渲染 |
|
|
@@ -23,4 +23,188 @@
|
|
|
23
23
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
24
24
|
* SOFTWARE.
|
|
25
25
|
*
|
|
26
|
-
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
.vditor-reset {
|
|
29
|
+
color: rgba(0, 0, 0, .85);
|
|
30
|
+
font-size: 14px;
|
|
31
|
+
line-height: 2;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.vditor-reset img {
|
|
35
|
+
max-width: calc(100% - 32px);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.vditor-reset p > img {
|
|
39
|
+
margin: 34px 0;
|
|
40
|
+
box-shadow: 0 8px 20px rgba(143, 168, 191, 0.35);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.vditor-reset h1 {
|
|
44
|
+
margin-bottom: 20px;
|
|
45
|
+
color: rgba(0, 0, 0, .85);
|
|
46
|
+
font-weight: 500;
|
|
47
|
+
font-size: 30px;
|
|
48
|
+
font-family: Avenir, -apple-system, BlinkMacSystemFont, segoe ui, Roboto, helvetica neue, Arial, noto sans, sans-serif, apple color emoji, segoe ui emoji, segoe ui symbol, noto color emoji, sans-serif;
|
|
49
|
+
line-height: 38px
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.vditor-reset h2 {
|
|
53
|
+
font-size: 24px;
|
|
54
|
+
line-height: 32px;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.vditor-reset h2,
|
|
58
|
+
.vditor-reset h3,
|
|
59
|
+
.vditor-reset h4,
|
|
60
|
+
.vditor-reset h5,
|
|
61
|
+
.vditor-reset h6 {
|
|
62
|
+
clear: both;
|
|
63
|
+
margin: 1.6em 0 .6em;
|
|
64
|
+
color: rgba(0, 0, 0, .85);
|
|
65
|
+
font-weight: 500;
|
|
66
|
+
font-family: Avenir, -apple-system, BlinkMacSystemFont, segoe ui, Roboto, helvetica neue, Arial, noto sans, sans-serif, apple color emoji, segoe ui emoji, segoe ui symbol, noto color emoji, sans-serif
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.vditor-reset h3 {
|
|
70
|
+
font-size: 18px;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.vditor-reset h4 {
|
|
74
|
+
font-size: 16px;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.vditor-reset h5 {
|
|
78
|
+
font-size: 14px;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.vditor-reset h6 {
|
|
82
|
+
font-size: 12px;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.vditor-reset hr {
|
|
86
|
+
clear: both;
|
|
87
|
+
height: 1px;
|
|
88
|
+
margin: 56px 0;
|
|
89
|
+
background: #f0f0f0;
|
|
90
|
+
border: 0;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.vditor-reset p,
|
|
94
|
+
.vditor-reset pre {
|
|
95
|
+
margin: 1em 0;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.vditor-reset ul > li {
|
|
99
|
+
margin-left: 20px;
|
|
100
|
+
padding-left: 4px;
|
|
101
|
+
list-style-type: circle;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.vditor-reset ol > li {
|
|
105
|
+
margin-left: 20px;
|
|
106
|
+
padding-left: 4px;
|
|
107
|
+
list-style-type: decimal;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.vditor-reset ul > li > p,
|
|
111
|
+
.vditor-reset ol > li > p {
|
|
112
|
+
margin: 0.2em 0;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.vditor-reset code {
|
|
116
|
+
margin: 0 1px;
|
|
117
|
+
padding: .2em .4em;
|
|
118
|
+
font-size: .9em;
|
|
119
|
+
border-radius: 3px;
|
|
120
|
+
border: 1px solid #f0f0f0;
|
|
121
|
+
font-family: sfmono-regular, Consolas, liberation mono, Menlo, Courier, monospace;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.vditor-reset code:not(.hljs):not(.highlight-chroma) {
|
|
125
|
+
background: #f2f4f5;
|
|
126
|
+
color: rgba(0, 0, 0, .65);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.vditor-reset pre {
|
|
130
|
+
font-family: sfmono-regular, Consolas, liberation mono, Menlo, Courier, monospace;
|
|
131
|
+
border-radius: 2px;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.vditor-reset .language-abc svg,
|
|
135
|
+
.vditor-reset .language-abc path {
|
|
136
|
+
fill: currentColor;
|
|
137
|
+
color: rgba(0, 0, 0, .85);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.vditor-reset .language-graphviz polygon {
|
|
141
|
+
fill: transparent;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.vditor-reset strong,
|
|
145
|
+
.vditor-reset b {
|
|
146
|
+
font-weight: 500;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
.vditor-reset > table {
|
|
150
|
+
width: 100%;
|
|
151
|
+
margin: 8px 0 16px;
|
|
152
|
+
direction: ltr;
|
|
153
|
+
empty-cells: show;
|
|
154
|
+
border: 1px solid #f0f0f0;
|
|
155
|
+
border-collapse: collapse;
|
|
156
|
+
border-spacing: 0
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.vditor-reset > table th {
|
|
160
|
+
color: #5c6b77;
|
|
161
|
+
font-weight: 500;
|
|
162
|
+
white-space: nowrap;
|
|
163
|
+
background: rgba(0, 0, 0, .02)
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.vditor-reset > table th, .vditor-reset > table td {
|
|
167
|
+
padding: 16px 24px;
|
|
168
|
+
text-align: left;
|
|
169
|
+
border: 1px solid #f0f0f0
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
.vditor-reset blockquote {
|
|
173
|
+
margin: 1em 0;
|
|
174
|
+
padding-left: .8em;
|
|
175
|
+
color: rgba(0, 0, 0, .45);
|
|
176
|
+
font-size: 90%;
|
|
177
|
+
border-left: 4px solid #f0f0f0
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
.vditor-reset blockquote p {
|
|
181
|
+
margin: 0;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
.vditor-reset .vditor-anchor {
|
|
185
|
+
margin-left: 8px;
|
|
186
|
+
opacity: 0;
|
|
187
|
+
transition: opacity 0.3s;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
.vditor-reset h1:hover .vditor-anchor,
|
|
191
|
+
.vditor-reset h2:hover .vditor-anchor,
|
|
192
|
+
.vditor-reset h3:hover .vditor-anchor,
|
|
193
|
+
.vditor-reset h4:hover .vditor-anchor,
|
|
194
|
+
.vditor-reset h5:hover .vditor-anchor,
|
|
195
|
+
.vditor-reset h6:hover .vditor-anchor {
|
|
196
|
+
display: inline-block;
|
|
197
|
+
opacity: 1;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
.vditor-reset > br,
|
|
201
|
+
.vditor-reset > p > br {
|
|
202
|
+
clear: both;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
.vditor-reset a, .vditor-ir__link {
|
|
206
|
+
color: #1890ff;
|
|
207
|
+
text-decoration: none;
|
|
208
|
+
outline: none;
|
|
209
|
+
cursor: pointer;
|
|
210
|
+
}
|
|
@@ -23,4 +23,101 @@
|
|
|
23
23
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
24
24
|
* SOFTWARE.
|
|
25
25
|
*
|
|
26
|
-
|
|
26
|
+
*/
|
|
27
|
+
.vditor-reset {
|
|
28
|
+
color: #d1d5da;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.vditor-reset a, .vditor-ir__link {
|
|
32
|
+
color: #4285f4;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.vditor-reset h1, .vditor-reset h2 {
|
|
36
|
+
padding-bottom: 0.3em;
|
|
37
|
+
border-bottom: 1px solid #d1d5da
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.vditor-reset hr {
|
|
41
|
+
background-color: #d1d5da
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.vditor-reset blockquote {
|
|
45
|
+
padding: 0 1em;
|
|
46
|
+
color: #b9b9b9;
|
|
47
|
+
border-left: .25em solid #d1d5da
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.vditor-reset iframe {
|
|
51
|
+
border: 1px solid #141414
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.vditor-reset table tr {
|
|
55
|
+
background-color: #2f363d
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.vditor-reset table td, .vditor-reset table th {
|
|
59
|
+
border: 1px solid #dfe2e5
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.vditor-reset table tbody tr:nth-child(2n) {
|
|
63
|
+
background-color: #24292e
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.vditor-reset code:not(.hljs):not(.highlight-chroma) {
|
|
67
|
+
background-color: rgba(66, 133, 244, .36);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.vditor-reset .language-abc svg,
|
|
71
|
+
.vditor-reset .language-abc path {
|
|
72
|
+
fill: currentColor;
|
|
73
|
+
color: #d1d5da;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.language-graphviz polygon {
|
|
77
|
+
fill: rgba(66, 133, 244, .36);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.vditor-reset kbd {
|
|
81
|
+
color: #d1d5da;
|
|
82
|
+
background-color: #2f363d;
|
|
83
|
+
border: 1px solid #141414;
|
|
84
|
+
box-shadow: inset 0 -1px 0 #141414
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.vditor-copy svg {
|
|
88
|
+
color: #b9b9b9
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.vditor-speech {
|
|
92
|
+
background-color: #1d2125;
|
|
93
|
+
border: 1px solid #141414;
|
|
94
|
+
color: #b9b9b9
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.vditor-speech--current, .vditor-speech:hover {
|
|
98
|
+
color: #fff
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.vditor-linkcard a {
|
|
102
|
+
background-color: #1d2125;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.vditor-linkcard a:visited .vditor-linkcard__abstract {
|
|
106
|
+
color: hsla(0, 0%, 72.5%, .36)
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.vditor-linkcard__title {
|
|
110
|
+
color: #d1d5da
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.vditor-linkcard__abstract {
|
|
114
|
+
color: #b9b9b9
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.vditor-linkcard__site {
|
|
118
|
+
color: #fff
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.vditor-linkcard__image {
|
|
122
|
+
background-color: hsla(0, 0%, 72.5%, .36)
|
|
123
|
+
}
|
|
@@ -23,4 +23,79 @@
|
|
|
23
23
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
24
24
|
* SOFTWARE.
|
|
25
25
|
*
|
|
26
|
-
|
|
26
|
+
*/
|
|
27
|
+
.vditor-reset h1, .vditor-reset h2 {
|
|
28
|
+
padding-bottom: 0.3em;
|
|
29
|
+
border-bottom: 1px solid #eaecef;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.vditor-reset hr {
|
|
33
|
+
background-color: #eaecef;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.vditor-reset blockquote {
|
|
37
|
+
color: #6a737d;
|
|
38
|
+
border-left: .25em solid #eaecef
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.vditor-reset iframe {
|
|
42
|
+
border: 1px solid #d1d5da
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.vditor-reset table tr {
|
|
46
|
+
border-top: 1px solid #c6cbd1;
|
|
47
|
+
background-color: #fafbfc
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.vditor-reset table td, .vditor-reset table th {
|
|
51
|
+
border: 1px solid #dfe2e5
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.vditor-reset table tbody tr:nth-child(2n) {
|
|
55
|
+
background-color: #fff
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.vditor-reset code:not(.hljs):not(.highlight-chroma) {
|
|
59
|
+
background-color: rgba(27, 31, 35, .05);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.vditor-reset kbd {
|
|
63
|
+
color: #24292e;
|
|
64
|
+
background-color: #fafbfc;
|
|
65
|
+
border: solid 1px #d1d5da;
|
|
66
|
+
box-shadow: inset 0 -1px 0 #d1d5da;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.vditor-speech {
|
|
70
|
+
background-color: #f6f8fa;
|
|
71
|
+
border: 1px solid #d1d5da;
|
|
72
|
+
color: #586069;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.vditor-speech--current, .vditor-speech:hover {
|
|
76
|
+
color: #4285f4;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.vditor-linkcard a {
|
|
80
|
+
background-color: #f6f8fa;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.vditor-linkcard a:visited .vditor-linkcard__abstract {
|
|
84
|
+
color: rgba(88, 96, 105, 0.36);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.vditor-linkcard__title {
|
|
88
|
+
color: #24292e;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.vditor-linkcard__abstract {
|
|
92
|
+
color: #586069;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.vditor-linkcard__site {
|
|
96
|
+
color: #4285f4;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.vditor-linkcard__image {
|
|
100
|
+
background-color: rgba(88, 96, 105, 0.36);
|
|
101
|
+
}
|