@chahindb7/vue3-editor
Version:
HTML editor using Vue.js 3, and Quill.js, an open source editor with advanced table functionality (quill-table-better)
203 lines (160 loc) • 4.16 kB
Markdown
and powerful rich text editor powered by Quill.js 2.0.3 and Vue.js 3
- **Vue 3 Composition API Support**: Built specifically for Vue 3
- **Quill 2.0.0**: Latest version of Quill.js with improved performance
- **Advanced Table Support**: Rich table functionality with `quill-table-better`
- **v-model Support**: Two-way data binding with reactive updates
- **Customizable Toolbar**: Easy toolbar configuration
- **TypeScript Ready**: Full TypeScript support
- **Lightweight**: Minimal dependencies, maximum performance
```bash
npm install
```
```vue
<template>
<div>
<VueEditor v-model="content" placeholder="Start typing..." />
<div v-html="content"></div>
</div>
</template>
<script>
import { ref } from 'vue'
export default {
setup() {
const content = ref('<p>Hello World!</p>')
return {
content
}
}
}
</script>
```
Vue3 Editor includes advanced table functionality powered by `quill-table-better`:
- Multiple cell selection and operations
- Enhanced table context menus
- Cell merging and splitting
- Column and row operations
- Drag and drop table resizing
- Copy/paste table content
- Multilingual support
The table module is automatically registered and available in the toolbar:
```vue
<template>
<VueEditor
v-model="content"
:editorToolbar="tableToolbar"
placeholder="Create tables with ease..."
/>
</template>
<script setup>
import { ref } from 'vue'
const content = ref('')
// Toolbar with table-better module
const tableToolbar = [
['bold', 'italic', 'underline'],
[{ header: [1, 2, 3, false] }],
['table-better'], // Advanced table functionality
['link', 'clean']
]
</script>
```
The editor automatically configures the table module:
```javascript
// quill-table-better configuration
'table-better': {
language: 'en_US',
menus: ['column', 'row', 'merge', 'table', 'cell', 'wrap', 'copy', 'delete'],
toolbarTable: true
}
```
```vue
<template>
<VueEditor
v-model="content"
:editorToolbar="tableToolbar"
/>
</template>
<script setup>
import { ref } from 'vue'
const content = ref('')
// Use table-better module
const tableToolbar = [
['bold', 'italic'],
['table-better'], // Advanced table functionality
['clean']
]
</script>
```
| Feature | Available |
|---------|-----------|
| Interface | Modern button |
| Multi-cell selection | ✅ |
| Context menus | ✅ |
| Cell merging | ✅ |
| Drag resize | ✅ |
| Basic operations | ✅ |
```javascript
// Get table module
const tableBetter = quill.getModule('table-better')
tableBetter.insertTable(3, 3) // Insert 3x3 table
tableBetter.deleteTable() // Delete current table
```
| Prop | Type | Default | Description |
|------|------|---------|-------------|
| `modelValue` | String | `''` | The HTML content of the editor |
| `placeholder` | String | `''` | Placeholder text when editor is empty |
| `disabled` | Boolean | `false` | Whether the editor is disabled |
| `editorToolbar` | Array/Object | `defaultToolbar` | Custom toolbar configuration |
| `editorOptions` | Object | `{}` | Additional Quill editor options |
| Event | Description | Payload |
|-------|-------------|---------|
| `ready` | Fired when editor is ready | `quill` instance |
| `text-change` | Fired when content changes | HTML content |
| `update:modelValue` | v-model update event | HTML content |
```vue
<template>
<VueEditor
v-model="content"
:editorToolbar="customToolbar"
/>
</template>
<script>
export default {
data() {
return {
content: '',
customToolbar: [
['bold', 'italic', 'underline'],
[{ 'list': 'ordered'}, { 'list': 'bullet' }],
['link', 'image']
]
}
}
}
</script>
```
```bash
npm install
npm run serve
npm run build
```
MIT
> A simple