Home

Awesome

<div align="center"> <img src="https://github.com/motla/vue-document-editor/raw/master/img/logo.png" alt="vue-document-editor" width="304"> </div> <div align="center"> <img src="https://github.com/motla/vue-document-editor/raw/master/img/preview.png" width="500"> </div>

vue-document-editor is a rich-text editor built on top of Vue.js, using the native contenteditable browser implementation and some JavaScript trickery to spread content over paper-sized pages. It is mainly designed to allow targeted modifications to pre-formatted documents using HTML or interactive templates.

:speech_balloon: This package does not intend to replace a proper document editor with full functionality. If you're looking for a powerful word processor, check out CKEditor for Vue.js or Collabora Online Development Edition.

Features

:rocket: See live demo

:speech_balloon: This package doesn't include any toolbar. The demo features vue-file-toolbar-menu for the toolbar.

Installation

In your Vue.js 3.x project:
npm install vue-document-editor
In your Vue.js 2.x project:
npm install vue-document-editor@1
:speech_balloon: If you prefer static files, import assets from the dist folder

Basic example

MyComponent.vue
<template>
  <div style="font-family: Avenir, sans-serif">
    <vue-document-editor v-model:content="content" /> <!-- Vue 3 syntax -->
    <!-- <vue-document-editor :content.sync="content" /> --> <!-- Vue 2 syntax -->
  </div>
</template>

<script>
import VueDocumentEditor from 'vue-document-editor'

export default {
  components: { VueDocumentEditor },
  data () {
    return { 
      content: ["<h1>Hello!</h1>Fill this page with text and new pages will be created as it overflows."]
    }
  }
}
</script>
<details> <summary><small>same example using static files loaded with a CDN (Vue 3)</small></summary>
<html>
<head>
  <script src="https://cdn.jsdelivr.net/npm/vue@3/dist/vue.global.prod.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/vue-document-editor@2/dist/VueDocumentEditor.umd.min.js"></script>
  <link href="https://cdn.jsdelivr.net/npm/vue-document-editor@2/dist/VueDocumentEditor.css" rel="stylesheet">
</head>
<body>
  <div id="app">
    <div style="font-family: Avenir, sans-serif">
      <vue-document-editor v-model:content="content" />
    </div>
  </div>
  <script>
  const app = Vue.createApp({
    components: { VueDocumentEditor },
    data () {
      return { 
        content: ["<h1>Hello!</h1>Fill this page with text and new pages will be created as it overflows."]
      }
    }
  }).mount('#app');
  </script>
</body>
</html>
</details> <details> <summary><small>same example using static files loaded with a CDN (Vue 2)</small></summary>
<html>
<head>
  <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/vue-document-editor@1/dist/VueDocumentEditor.umd.min.js"></script>
  <link href="https://cdn.jsdelivr.net/npm/vue-document-editor@1/dist/VueDocumentEditor.css" rel="stylesheet">
</head>
<body>
  <div id="app">
    <div style="font-family: Avenir, sans-serif">
      <vue-document-editor :content.sync="content" />
    </div>
  </div>
  <script>
  var app = new Vue({
    el: '#app',
    components: { VueDocumentEditor },
    data () {
      return { 
        content: ["<h1>Hello!</h1>Fill this page with text and new pages will be created as it overflows."]
      }
    }
  })
  </script>
</body>
</html>
</details>

Complete example

See the Demo.vue file and the InvoiceTemplate.ce.vue file corresponding to the live demo.

API

For the list of props, data and styling variables: :blue_book: read the API.

Known issues / limitations

Project development

Licensing

Copyright (c) 2020 Romain Lamothe, MIT License