
Product
Socket MCP Adds Org Alerts, Threat Feed Review, and Package Inspection
Socket MCP now lets AI assistants review org alerts, investigate threats using the Socket threat feed, and inspect package files in addition to dependency scoring.
Simple and lightweight Trix rich-text editor Vue.js component for writing daily


v-model easily. $npm install --save vue-trix
$yarn add vue-trix
$npm install --save hanhdt/vue-trix
in the main.js, import the package as a global component.
import "vue-trix";
import VueTrix from "vue-trix";
export default {
// ...
components: {
VueTrix
}
};
Create mounting plugin file
// plugins/vue_trix.js
import Vue from "vue";
import VueTrix from "vue-trix";
Vue.use(VueTrix);
Update Nuxt.js config file
// nuxt.config.js
plugins: [{ src: "~/plugins/vue_trix", mode: "client" }];
Add VueTrix component into *.vue template
<template>
<!-- ... -->
<VueTrix v-model="editorContent" placeholder="Enter content" localStorage/>
<!-- ... -->
</template>
<form ...>
<VueTrix inputId="editor1" v-model="editorContent" placeholder="enter your content..."/>
</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.
// Declare local component's state is loaded from database
export default {
// ...
data() {
return {
editorContent: "<h1>Editor contents</h1>"
};
}
// ...
};
// Assign to v-model directive
<template>
<!-- ... -->
<VueTrix v-model="editorContent"/>
<!-- ... -->
</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
export default {
// ...
methods: {
updateEditorContent(value) {
// Update new content into the database via state mutations.
}
},
watch: {
editorContent: {
handler: "updateEditorContent"
}
}
// ...
};
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
<template>
<!-- ... -->
<VueTrix @trix-attachment-add="handleAttachmentChanges"/>
<!-- ... -->
</template>
In Javascript
const remoteHost = 'your remote host';
function handleAttachmentChanges(event) {
// 1. get file object
let file = event.attachment.file;
// 2. upload file to remote server with FormData
// ...
// 3. if upload success, set back the attachment's URL attribute
// @param object data from remote server response data after upload.
let attributes = {
url: remoteHost + data.path,
href: remoteHost + data.path
};
event.attachment.setAttributes(attributes);
}
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.
FAQs
Lightweight and simple Trix rich-text editor component for Vue.js
The npm package vue-trix receives a total of 1,344 weekly downloads. As such, vue-trix popularity was classified as popular.
We found that vue-trix demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket MCP now lets AI assistants review org alerts, investigate threats using the Socket threat feed, and inspect package files in addition to dependency scoring.

Product
Socket Firewall blocks malicious VS Code and Open VSX extensions before install, protecting developers from compromised editor marketplaces.

Research
More than 140 Mastra npm packages were compromised in a supply chain attack that used a typosquatted dependency to deliver a cross-platform infostealer during installation.