Gathering detailed insights and metrics for laoganma-quill-image-extend-module
Gathering detailed insights and metrics for laoganma-quill-image-extend-module
npm install laoganma-quill-image-extend-module
Typescript
Module System
Node Version
NPM Version
73
Supply Chain
98.9
Quality
75.5
Maintenance
100
Vulnerability
100
License
JavaScript (84.98%)
Vue (15.02%)
Total Downloads
1,494
Last Day
1
Last Week
7
Last Month
25
Last Year
126
26 Commits
1 Watching
2 Branches
1 Contributors
Latest Version
1.0.6
Package Id
laoganma-quill-image-extend-module@1.0.6
Unpacked Size
33.11 kB
Size
7.55 kB
File Count
11
NPM Version
6.4.1
Node Version
10.12.0
Cumulative downloads
Total Downloads
Last day
0%
1
Compared to previous day
Last week
133.3%
7
Compared to previous week
Last month
1,150%
25
Compared to previous month
Last year
-34%
126
Compared to previous year
No dependencies detected.
vue-quill-editor的增强模块,提供上传前压缩图片
功能:
1npm install quill-image-extend-module --save-dev
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)
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
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 }
由于不同的用户的服务器返回的数据格式不尽相同
因此 在配置中,你必须如下操作
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 }
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/26 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
license file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2025-01-27
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