Gathering detailed insights and metrics for vue2-editor
Gathering detailed insights and metrics for vue2-editor
Gathering detailed insights and metrics for vue2-editor
Gathering detailed insights and metrics for vue2-editor
npm install vue2-editor
Typescript
Module System
Node Version
NPM Version
93.5
Supply Chain
99.6
Quality
75.6
Maintenance
50
Vulnerability
100
License
JavaScript (59.21%)
Vue (32.42%)
SCSS (8.37%)
Total Downloads
10,856,558
Last Day
1,284
Last Week
36,324
Last Month
159,943
Last Year
2,239,285
2,512 Stars
397 Commits
361 Forks
39 Watching
11 Branches
5 Contributors
Minified
Minified + Gzipped
Latest Version
2.10.3
Package Id
vue2-editor@2.10.3
Size
50.14 kB
NPM Version
6.14.6
Node Version
12.18.4
Publised On
21 Aug 2021
Cumulative downloads
Total Downloads
Last day
2.5%
1,284
Compared to previous day
Last week
-10%
36,324
Compared to previous week
Last month
-7.8%
159,943
Compared to previous month
Last year
-13.7%
2,239,285
Compared to previous year
1
27
An easy-to-use but yet powerful and customizable rich text editor powered by Quill.js and Vue.js
You can use Yarn or NPM
1npm install vue2-editor
OR
1yarn add vue2-editor
1// Basic Use - Covers most scenarios 2import { VueEditor } from "vue2-editor"; 3 4// Advanced Use - Hook into Quill's API for Custom Functionality 5import { VueEditor, Quill } from "vue2-editor";
Add vue2-editor/nuxt
to modules section of nuxt.config.js
1{ 2 modules: ["vue2-editor/nuxt"]; 3}
To avoid seeing warnings from Vue about a mismatch in content, you'll need to
wrap the VueEditor
component with the client-only
component Nuxt provides as
shown here:
1<client-only> 2 <VueEditor /> 3</client-only>
Name | Type | Default | Description |
---|---|---|---|
customModules | Array | - | Declare Quill modules to register |
disabled | Boolean | false | Set to true to disable editor |
editorOptions | Object | - | Offers object for merging into default config (add formats, custom Quill modules, ect) |
editorToolbar | Array | ** Too long for table. See toolbar example below | Use a custom toolbar |
id | String | quill-container | Set the id (necessary if multiple editors in the same view) |
placeholder | String | - | Placeholder text for the editor |
useCustomImageHandler | Boolean | false | Handle image uploading instead of using default conversion to Base64 |
v-model | String | - | Set v-model to the the content or data property you wish to bind it to |
Name | Parameters | Description |
---|---|---|
blur | quill | Emitted on blur event |
focus | quill | Emitted on focus event |
image-added | file, Editor, cursorLocation | Emitted when useCustomImageHandler is true and photo is being added to the editor |
image-removed | file, Editor, cursorLocation | Emitted when useCustomImageHandler is true and photo has been deleted |
selection-change | range, oldRange, source | Emitted on Quill's selection-change event |
text-change | delta, oldDelta, source | Emitted on Quill's text-change event |
1<template> 2 <div id="app"> 3 <vue-editor v-model="content"></vue-editor> 4 </div> 5</template> 6 7<script> 8import { VueEditor } from "vue2-editor"; 9 10export default { 11 components: { 12 VueEditor 13 }, 14 15 data() { 16 return { 17 content: "<h1>Some initial content</h1>" 18 }; 19 } 20}; 21</script>
If you choose to use the custom image handler, an event is emitted when a a photo is selected. You can see below that 3 parameters are passed.
NOTE In addition to this example, I have created a example repo demonstrating this new feature with an actual server.
1<template> 2 <div id="app"> 3 <vue-editor 4 id="editor" 5 useCustomImageHandler 6 @image-added="handleImageAdded" 7 v-model="htmlForEditor" 8 > 9 </vue-editor> 10 </div> 11</template> 12 13<script> 14import { VueEditor } from "vue2-editor"; 15import axios from "axios"; 16export default { 17 components: { 18 VueEditor 19 }, 20 21 data() { 22 return { 23 htmlForEditor: "" 24 }; 25 }, 26 27 methods: { 28 handleImageAdded: function(file, Editor, cursorLocation, resetUploader) { 29 // An example of using FormData 30 // NOTE: Your key could be different such as: 31 // formData.append('file', file) 32 33 var formData = new FormData(); 34 formData.append("image", file); 35 36 axios({ 37 url: "https://fakeapi.yoursite.com/images", 38 method: "POST", 39 data: formData 40 }) 41 .then(result => { 42 const url = result.data.url; // Get url from response 43 Editor.insertEmbed(cursorLocation, "image", url); 44 resetUploader(); 45 }) 46 .catch(err => { 47 console.log(err); 48 }); 49 } 50 } 51}; 52</script>
1<template> 2 <div id="app"> 3 <button @click="setEditorContent">Set Editor Contents</button> 4 <vue-editor v-model="htmlForEditor"></vue-editor> 5 </div> 6</template> 7 8<script> 9import { VueEditor } from "vue2-editor"; 10 11export default { 12 components: { 13 VueEditor 14 }, 15 16 data() { 17 return { 18 htmlForEditor: null 19 }; 20 }, 21 22 methods: { 23 setEditorContent: function() { 24 this.htmlForEditor = "<h1>Html For Editor</h1>"; 25 } 26 } 27}; 28</script>
1<template> 2 <div id="app"> 3 <vue-editor id="editor1" v-model="editor1Content"></vue-editor> 4 <vue-editor id="editor2" v-model="editor2Content"></vue-editor> 5 </div> 6</template> 7 8<script> 9import { VueEditor } from "vue2-editor"; 10 11export default { 12 components: { 13 VueEditor 14 }, 15 16 data() { 17 return { 18 editor1Content: "<h1>Editor 1 Starting Content</h1>", 19 editor2Content: "<h1>Editor 2 Starting Content</h1>" 20 }; 21 } 22}; 23</script> 24 25<style> 26#editor1, 27#editor2 { 28 height: 350px; 29} 30</style>
1<template> 2 <div id="app"> 3 <vue-editor v-model="content" :editorToolbar="customToolbar"></vue-editor> 4 </div> 5</template> 6 7<script> 8import { VueEditor } from "vue2-editor"; 9 10export default { 11 components: { 12 VueEditor 13 }, 14 15 data() { 16 return { 17 content: "<h1>Html For Editor</h1>", 18 customToolbar: [ 19 ["bold", "italic", "underline"], 20 [{ list: "ordered" }, { list: "bullet" }], 21 ["image", "code-block"] 22 ] 23 }; 24 } 25}; 26</script>
1<template> 2 <div id="app"> 3 <button @click="saveContent"></button> 4 <vue-editor v-model="content"></vue-editor> 5 </div> 6</template> 7 8<script> 9import { VueEditor } from "vue2-editor"; 10 11export default { 12 components: { 13 VueEditor 14 }, 15 16 data() { 17 return { 18 content: "<h3>Initial Content</h3>" 19 }; 20 }, 21 22 methods: { 23 handleSavingContent: function() { 24 // You have the content to save 25 console.log(this.content); 26 } 27 } 28}; 29</script>
1<template> 2 <div id="app"> 3 <vue-editor v-model="content"></vue-editor> 4 <div v-html="content"></div> 5 </div> 6</template> 7 8<script> 9import { VueEditor } from 'vue2-editor' 10 11components: { 12 VueEditor 13}, 14 15export default { 16 data() { 17 return { 18 content: '<h1>Initial Content</h1>' 19 } 20 } 21} 22</script>
There are two ways of using custom modules with Vue2Editor. This is partly because there have been cases in which errors are thrown when importing and attempting to declare custom modules, and partly because I believe it actually separates the concerns nicely.
Vue2Editor now exports Quill to assist in this process.
editorOptions
object1<template> 2 <div id="app"> 3 <vue-editor 4 :editorOptions="editorSettings" 5 v-model="content"> 6 </div> 7</template> 8 9<script> 10 import { VueEditor, Quill } from 'vue2-editor' 11 import { ImageDrop } from 'quill-image-drop-module' 12 import ImageResize from 'quill-image-resize-module' 13 14 Quill.register('modules/imageDrop', ImageDrop) 15 Quill.register('modules/imageResize', ImageResize) 16 17 export default { 18 components: { 19 VueEditor 20 }, 21 data() { 22 return { 23 content: '<h1>Initial Content</h1>', 24 editorSettings: { 25 modules: { 26 imageDrop: true, 27 imageResize: {} 28 } 29 } 30 } 31 } 32 } 33</script>
(Recommended way)
customModules
prop to declare an array of module(s).editorOptions
object under modules as seen below1<template> 2 <div id="app"> 3 <vue-editor 4 :customModules="customModulesForEditor" 5 :editorOptions="editorSettings" 6 v-model="content" 7 > 8 </vue-editor> 9 </div> 10</template> 11 12<script> 13import { VueEditor } from "vue2-editor"; 14import { ImageDrop } from "quill-image-drop-module"; 15import ImageResize from "quill-image-resize-module"; 16 17export default { 18 components: { 19 VueEditor 20 }, 21 data() { 22 return { 23 content: "<h1>Initial Content</h1>", 24 customModulesForEditor: [ 25 { alias: "imageDrop", module: ImageDrop }, 26 { alias: "imageResize", module: ImageResize } 27 ], 28 editorSettings: { 29 modules: { 30 imageDrop: true, 31 imageResize: {} 32 } 33 } 34 }; 35 } 36}; 37</script>
Vue2Editor now uses Poi for development
yarn dev
: Run example in development modeyarn docs
: Development for Docsyarn build
: Build component in both formatyarn lint
: Run eslintMIT
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
0 commit(s) and 2 issue activity found in the last 90 days -- score normalized to 1
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
144 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-12-16
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