Installations
npm install quill-image-extend-module-fixed
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
12.16.2
NPM Version
6.14.4
Score
72.7
Supply Chain
98.9
Quality
75.2
Maintenance
100
Vulnerability
100
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (83.27%)
Vue (16.73%)
Developer
NextBoy
Download Statistics
Total Downloads
406
Last Day
1
Last Week
3
Last Month
6
Last Year
53
GitHub Statistics
708 Stars
26 Commits
127 Forks
11 Watching
2 Branches
1 Contributors
Bundle Size
3.89 kB
Minified
1.58 kB
Minified + Gzipped
Package Meta Information
Latest Version
3.0.0
Package Id
quill-image-extend-module-fixed@3.0.0
Unpacked Size
30.49 kB
Size
6.03 kB
File Count
9
NPM Version
6.14.4
Node Version
12.16.2
Total Downloads
Cumulative downloads
Total Downloads
406
Last day
0%
1
Compared to previous day
Last week
200%
3
Compared to previous week
Last month
100%
6
Compared to previous month
Last year
-30.3%
53
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
No dependencies detected.
sorry everyone, 由于作者自身原因,没有精力和时间处理issues,该插件已经不做维护了,希望大家见谅。
quill-image-extend-module
vue-quill-editor的增强模块,
功能:
- 提供图片上传到服务器的功能
- 复制插入
- 拖拽插入
- 显示上传进度
- 显示上传成功或者失败
- 支持与其他模块一起使用(例如调整图片大小)
更新情况
- version 1.1
- 增加上传显示文字样式
- 增加图片超过自定义大小的回调 sizeError
- 修复同一页面多个富文本编辑器上传图片只能插入第一个编辑器的bug
- 引入QuillWatch 全局监听多个富文本编辑器
- version 1.1.2
- 由于编辑器本身就有复制功能,因此取消了复制上传服务器的功能,避免冲突,复制上传采用富文本编辑器自带的功能
- 修复图片插入老是跑到最后面的问题
Install
1npm install quill-image-extend-module --save-dev
use
1 import {quillEditor, Quill} from 'vue-quill-editor' 2 import {container, ImageExtend, QuillWatch} from 'quill-image-extend-module' 3 4 Quill.register('modules/ImageExtend', ImageExtend)
example
1<template> 2 <div class="quill-wrap"> 3 <quill-editor 4 v-model="content" 5 ref="myQuillEditor" 6 :options="editorOption" 7 > 8 </quill-editor> 9 </div> 10</template> 11<script> 12 import {quillEditor, Quill} from 'vue-quill-editor' 13 import {container, ImageExtend, QuillWatch} from 'quill-image-extend-module' 14 15 Quill.register('modules/ImageExtend', ImageExtend) 16 export default { 17 components: {quillEditor}, 18 data() { 19 return { 20 content: '', 21 // 富文本框参数设置 22 editorOption: { 23 modules: { 24 ImageExtend: { 25 loading: true, 26 name: 'img', 27 action: updateUrl, 28 response: (res) => { 29 return res.info 30 } 31 }, 32 toolbar: { 33 container: container, 34 handlers: { 35 'image': function () { 36 QuillWatch.emit(this.quill.id) 37 } 38 } 39 } 40 } 41 } 42 } 43 } 44 } 45</script> 46
quill-image-extend-module 的所有可配置项
1 editorOption: { 2 modules: { 3 ImageExtend: { // 如果不作设置,即{} 则依然开启复制粘贴功能且以base64插入 4 name: 'img', // 图片参数名 5 size: 3, // 可选参数 图片大小,单位为M,1M = 1024kb 6 action: updateUrl, // 服务器地址, 如果action为空,则采用base64插入图片 7 // response 为一个函数用来获取服务器返回的具体图片地址 8 // 例如服务器返回{code: 200; data:{ url: 'baidu.com'}} 9 // 则 return res.data.url 10 response: (res) => { 11 return res.info 12 }, 13 headers: (xhr) => { 14 // xhr.setRequestHeader('myHeader','myValue') 15 }, // 可选参数 设置请求头部 16 sizeError: () => {}, // 图片超过大小的回调 17 start: () => {}, // 可选参数 自定义开始上传触发事件 18 end: () => {}, // 可选参数 自定义上传结束触发的事件,无论成功或者失败 19 error: () => {}, // 可选参数 上传失败触发的事件 20 success: () => {}, // 可选参数 上传成功触发的事件 21 change: (xhr, formData) => { 22 // xhr.setRequestHeader('myHeader','myValue') 23 // formData.append('token', 'myToken') 24 } // 可选参数 每次选择图片触发,也可用来设置头部,但比headers多了一个参数,可设置formData 25 }, 26 toolbar: { // 如果不上传图片到服务器,此处不必配置 27 container: container, // container为工具栏,此次引入了全部工具栏,也可自行配置 28 handlers: { 29 'image': function () { // 劫持原来的图片点击按钮事件 30 QuillWatch.emit(this.quill.id) 31 } 32 } 33 } 34 } 35 }
注意事项 (matters need attention)
由于不同的用户的服务器返回的数据格式不尽相同
因此 在配置中,你必须如下操作
1 // 你必须把返回的数据中所包含的图片地址 return 回去 2 respnse: (res) => { 3 return res.info // 这里切记要return回你的图片地址 4 }
比如你的服务器返回的成功数据为
1{ 2code: 200, 3starus: true, 4result: { 5 img: 'http://placehold.it/100x100' // 服务器返回的数据中的图片的地址 6 } 7}
那么你应该在参数中写为:
1 // 你必须把返回的数据中所包含的图片地址 return 回去 2 respnse: (res) => { 3 return res.result.img // 这里切记要return回你的图片地址 4 }
与其他模块一起使用(以resize-module为例子)
1<template> 2 <div class="quill-wrap"> 3 <quill-editor 4 v-model="content" 5 ref="myQuillEditor" 6 :options="editorOption" 7 > 8 </quill-editor> 9 </div> 10</template> 11<script> 12 import {quillEditor, Quill} from 'vue-quill-editor' 13 import {container, ImageExtend, QuillWatch} from 'quill-image-extend-module' 14 import ImageResize from 'quill-image-resize-module' 15 16 Quill.register('modules/ImageExtend', ImageExtend) 17 // use resize module 18 Quill.register('modules/ImageResize', ImageResize) 19 export default { 20 components: {quillEditor}, 21 data() { 22 return { 23 content: '', 24 // 富文本框参数设置 25 editorOption: { 26 modules: { 27 ImageResize: {}, 28 ImageExtend: { 29 name: 'img', 30 size: 2, // 单位为M, 1M = 1024KB 31 action: updateUrl, 32 headers: (xhr) => { 33 }, 34 response: (res) => { 35 return res.info 36 } 37 }, 38 toolbar: { 39 container: container, 40 handlers: { 41 'image': function () { 42 QuillWatch.emit(this.quill.id) 43 } 44 } 45 } 46 } 47 } 48 } 49 } 50 } 51</script> 52
(如果觉得还不错,请右上角点击下星星,此致敬礼)
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/20 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
license file not detected
Details
- Warn: project does not have a license file
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 9 are checked with a SAST tool
Score
2.6
/10
Last Scanned on 2025-02-03
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More