Mavon Editor

2.10.4 · active · verified Tue Apr 21

Mavon Editor is a versatile Vue-based Markdown editor component designed for rich text editing with Markdown syntax. It officially supports Vue 2 up to version 2.10.4 and Vue 3 from version 3.0.0 onwards, offering a consistent API across major Vue versions. The project maintains an active release cadence, frequently delivering updates, bug fixes, and security enhancements. Key features include integrated image upload capabilities, full-screen editing mode, theme support, and robust XSS protection (significantly improved in v2.10.x). Its primary differentiators are its comprehensive dual support for both Vue 2 and Vue 3 ecosystems, along with its strong focus on security, making it a reliable plug-and-play component for Markdown editing needs in Vue applications.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates global registration of Mavon Editor as a Vue 3 plugin and its usage within a root component. It showcases two-way data binding with `v-model`, basic configuration props, and event handling for markdown and HTML output, including a placeholder for image upload.

import { createApp, ref } from 'vue';
import mavonEditor from 'mavon-editor';
import 'mavon-editor/dist/css/index.css';

const app = createApp({
  template: `
    <div id="app" style="padding: 20px;">
      <h1>My Vue 3 Markdown App</h1>
      <mavon-editor
        v-model="markdownContent"
        :toolbarsFlag="true"
        :subfield="true"
        :boxShadow="true"
        style="height: 500px;"
        @change="onEditorChange"
        @imgAdd="onImageAdd"
      />
      <div style="margin-top: 20px;">
        <h3>Rendered HTML Preview:</h3>
        <div v-html="htmlContent" style="border: 1px solid #ccc; padding: 10px;"></div>
      </div>
    </div>
  `,
  setup() {
    const markdownContent = ref('# Hello Mavon Editor\n\nThis is a **Vue 3** markdown editor instance.\n\n```typescript\nconst message: string = "Hello World!";\nconsole.log(message);\n```\n\nYou can easily write Markdown, preview it, and even upload images.\n\n<span style="color: red;">This text is red.</span>');
    const htmlContent = ref('');

    const onEditorChange = (markdown, html) => {
      console.log('Markdown changed:', markdown);
      htmlContent.value = html;
    };

    const onImageAdd = (pos, $file) => {
      // Implement image upload logic here
      console.log(`Image at position ${pos} added:`, $file.name);
      // Example: Upload to server and replace markdown with uploaded URL
      // editor.$img2Url(pos, 'http://example.com/your-uploaded-image.png');
    };

    return { markdownContent, htmlContent, onEditorChange, onImageAdd };
  }
});

app.use(mavonEditor);
app.mount('#app');

view raw JSON →