Gathering detailed insights and metrics for vue-trix
Gathering detailed insights and metrics for vue-trix
Gathering detailed insights and metrics for vue-trix
Gathering detailed insights and metrics for vue-trix
npm install vue-trix
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
243 Stars
487 Commits
37 Forks
4 Watching
31 Branches
13 Contributors
Updated on 04 Nov 2024
Vue (57.82%)
JavaScript (39.54%)
HTML (2.63%)
Cumulative downloads
Total Downloads
Last day
-23.3%
340
Compared to previous day
Last week
-6.3%
2,088
Compared to previous week
Last month
-8.7%
11,066
Compared to previous month
Last year
4%
154,267
Compared to previous year
1
27
Simple and lightweight Trix rich-text editor Vue.js component for writing daily
v-model
easily.1 npm install --save vue-trix
1 yarn add vue-trix
1 npm install --save hanhdt/vue-trix
in the main.js
, import the package as a global component.
1import "vue-trix";
1import VueTrix from "vue-trix"; 2 3export default { 4 // ... 5 components: { 6 VueTrix 7 } 8};
Create mounting plugin file
1// plugins/vue_trix.js 2import Vue from "vue"; 3import VueTrix from "vue-trix"; 4 5Vue.use(VueTrix);
Update Nuxt.js config file
1// nuxt.config.js 2plugins: [{ src: "~/plugins/vue_trix", mode: "client" }];
Add VueTrix
component into *.vue
template
1 <template> 2 <!-- ... --> 3 <VueTrix v-model="editorContent" placeholder="Enter content" localStorage/> 4 <!-- ... --> 5 </template>
1 <form ...> 2 <VueTrix inputId="editor1" v-model="editorContent" placeholder="enter your content..."/> 3 </form>
inputId
: This is referenced id
of the hidden input field defined, it is optional.inputName
: This is referenced name
of the hidden input field defined, default value is content
.placeholder
: The placeholder option attribute specifies a short hint that describes the expected value of a editor.autofocus
: Automatically focus the editor when it loadsdisabledEditor
: This prop will put the editor in read-only mode.localStorage
: The boolean attribute allows saving editor state into browser's localStorage (optional, default is false
).In case, you want to load initial data from database then display into the editor. you can use v-model
directive with local component's state.
1// Declare local component's state is loaded from database 2export default { 3 // ... 4 data() { 5 return { 6 editorContent: "<h1>Editor contents</h1>" 7 }; 8 } 9 // ... 10};
1 // Assign to v-model directive 2 <template> 3 <!-- ... --> 4 <VueTrix v-model="editorContent"/> 5 <!-- ... --> 6 </template>
The local component's state will be changed reactively when you modified contents inside the trix editor UI. Therefore, you need to watch
the local state for updating content back to database
1export default { 2 // ... 3 methods: { 4 updateEditorContent(value) { 5 // Update new content into the database via state mutations. 6 } 7 }, 8 watch: { 9 editorContent: { 10 handler: "updateEditorContent" 11 } 12 } 13 // ... 14};
The <VueTrix/>
element emits several events which you can use to observe and respond to changes in editor state.
@trix-file-accept
fires before an attachment is added to the document. If you don’t want to accept dropped or pasted files, call preventDefault() on this event.
@trix-attachment-add
fires after an attachment is added to the document. You can access the Trix attachment object through the attachment property on the event. If the attachment object has a file property, you should store this file remotely and set the attachment’s URL attribute.
@trix-attachment-remove
fires when an attachment is removed from the document. You can access the Trix attachment object through the attachment property on the event. You may wish to use this event to clean up remotely stored files.
Add binding event listener to trix-attachment-add
1 <template> 2 <!-- ... --> 3 <VueTrix @trix-attachment-add="handleAttachmentChanges"/> 4 <!-- ... --> 5 </template>
In Javascript
1 const remoteHost = 'your remote host'; 2 3 function handleAttachmentChanges(event) { 4 // 1. get file object 5 let file = event.attachment.file; 6 7 // 2. upload file to remote server with FormData 8 // ... 9 10 // 3. if upload success, set back the attachment's URL attribute 11 // @param object data from remote server response data after upload. 12 let attributes = { 13 url: remoteHost + data.path, 14 href: remoteHost + data.path 15 }; 16 event.attachment.setAttributes(attributes); 17 }
If you're interested in contributing to Vue-Trix or share your opinions, please consider to submitting a pull request or post issues. Also, I will try to code-self documentation.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 3/5 approved changesets -- score normalized to 6
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
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
64 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-25
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