Search results

Getting Started

This section explains the steps to create a Word document editor within your application and demonstrates the basic usage of the DocumentEditor component.

Dependencies

The list of dependencies required to use the DocumentEditor component in your application is given below:

|-- @syncfusion/ej2-vue-documenteditor
|-- @syncfusion/ej2-vue-base
    |-- @syncfusion/ej2-documenteditor
    |-- @syncfusion/ej2-base
    |-- @syncfusion/ej2-buttons
    |-- @syncfusion/ej2-compression
    |-- @syncfusion/ej2-data
    |-- @syncfusion/ej2-dropdowns
    |-- @syncfusion/ej2-file-utils
    |-- @syncfusion/ej2-inputs
    |-- @syncfusion/ej2-lists
    |-- @syncfusion/ej2-navigations
    |-- @syncfusion/ej2-popups
    |-- @syncfusion/ej2-splitbuttons

Get Started with Vue CLI

You can use Vue CLI to setup your vue applications. To install Vue CLI use the following command.

npm install -g @vue/cli

Start a new project using below Vue CLI command.

vue init webpack-simple quickstart

cd quickstart
npm install

Adding Syncfusion packages

All the available Essential JS 2 packages are published in npmjs.com registry. You can choose the component that you want to install. For this application, we are going to use DocumentEditor component.

To install DocumentEditor component, use the following command

npm install @syncfusion/ej2-vue-documenteditor

Registering DocumentEditor Component

You can register the DocumentEditor component in your application by using the Vue.use().

Refer to the code example given below.

import { DocumentEditorPlugin } from '@syncfusion/ej2-vue-documenteditor';

Vue.use(DocumentEditorPlugin);

Registering DocumentEditorPlugin in vue, will register the DocumentEditor component along with its required child directives globally.

Adding CSS Reference

The DocumentEditor has different themes. They are:

  • Material
  • Fabric
  • Bootstrap
  • High Contrast

import DocumentEditor component CSS as given below in <style> section of the App.vue file.

<style>
<!-- Material theme used for this sample -->
@import "../../node_modules/@syncfusion/ej2-vue-documenteditor/styles/material.css";
</style>

Adding DocumentEditor Component

Add the Vue DocumentEditor by using <ejs-documenteditor> selector in <template> section of the App.vue file.

{% raw %}

<template>
  <div id="app">
      <ejs-documenteditor> </ejs-documenteditor>
  </div>
</template>

<script>
import Vue from 'vue';
import { DocumentEditorPlugin } from '@syncfusion/ej2-vue-documenteditor';

Vue.use(DocumentEditorPlugin);
export default {
  data () {
    return {
    }
  }
}
</script>

{% endraw %}

Module injection

To create DocumentEditor with additional features, inject the required modules. The following modules are used to extend DocumentEditor’s basic functionality.

  • Print - Inject this module to use documenteditor print feature.
  • Selection - Inject this module to use document selection feature.
  • Editor - Inject this module to enable document editing feature.
  • EditorHistory - Inject this module to use document editing with undo and redo feature.
  • Search - Inject this module to use search content within document feature.
  • OptionsPane - Inject this module to use find and replace content within document feature.
  • WordExport - Inject this module to export document in client side as Word document (*.docx) format.
  • TextExport - Inject this module to use export document in client side as Text document (.txt) format.
  • SfdtExport - Inject this module to export document in client side as Syncfusion Document Text (*.sfdt) format.
  • ImageResizer - Inject this module to use image resizer feature.
  • ContextMenu - Inject this module to use context menu when right clicked on document.
  • ParagraphDialog - Inject this module to modify paragraph format options via paragraph dialog.
  • FontDialog - Inject this module to modify character format options via font dialog.
  • HyperlinkDialog - Inject this module to insert or edit hyperlink via hyperlink dialog.
  • TableDialog - Inject this module to use insert table via insert table dialog.
  • TableOfContentsDialog - Inject this module to insert table of contents via TOC dialog.
  • PageSetupDialog - Inject this module to modify page set up via page set up dialog.
  • ListDialog - Inject this module to modify list format option via list dialog feature.
  • StyleDialog - Inject this module to create or modify style via style dialog feature.
  • StylesDialog - Inject this module to create or modify styles via style dialog feature.
  • BulletsAndNumberingDialog - Inject this module to apply or modify list paragraph style via bullet and numbering dialog feature.
  • TablePropertiesDialog - Inject this module to modify table, row and cell properties via Table Properties dialog feature.
  • BordersAndShadingDialog - Inject this module to modify borders and shading of table or cell via Borders And Shading Dialog.
  • TableOptionsDialog - Inject this module to modify table margin and spacing value via Table Options dialog
  • CellOptionsDialog - Inject this module to modify cell margin values via Cell Options dialog .
  • BookmarkDialog - Inject this module to add, navigate or delete bookmarks via Bookmark dialog .

Run the application

The Vue DocumentEditor application is configured to compile and run the application in a browser. Use the following command to run the application.

npm run dev

Output will be displayed as follows.

Source
Preview
app.vue
<template>
  <div id="app">
    <ejs-documenteditor id="container6"  style="width: 100%;height: 100%;" :isReadOnly='false' :enablePrint='true' :enableSfdtExport='true' :enableSelection='true' :enableContextMenu='true' :enableSearch='true' :enableOptionsPane='true' :enableWordExport='true' :enableTextExport='true' :enableEditor='true' :enableImageResizer='true' :enableEditorHistory='true' :enableHyperlinkDialog='true' :enableTableDialog='true' :enableBookmarkDialog='true' :enableTableOfContentsDialog='true' :enablePageSetupDialog='true' :enableStyleDialog='true' :enableListDialog='true' :enableParagraphDialog='true' :enableFontDialog='true' :enableTablePropertiesDialog='true' :enableBordersAndShadingDialog='true' :enableTableOptionsDialog='true'></ejs-documenteditor>
  </div>
</template>
<script>
import Vue from 'vue'
import { DocumentEditorPlugin, DocumentEditorComponent, Print, SfdtExport, WordExport, TextExport, Selection, Search, Editor, ImageResizer, EditorHistory, ContextMenu, OptionsPane, HyperlinkDialog, TableDialog, BookmarkDialog, TableOfContentsDialog, PageSetupDialog, StyleDialog, ListDialog, ParagraphDialog, BulletsAndNumberingDialog, FontDialog, TablePropertiesDialog, BordersAndShadingDialog, TableOptionsDialog, CellOptionsDialog, StylesDialog } from '@syncfusion/ej2-vue-documenteditor';

Vue.use(DocumentEditorPlugin);

export default {
  data() {
    return {
    };
  },
  provide: {
    DocumentEditor: [Print, SfdtExport, WordExport, TextExport, Selection, Search, Editor, ImageResizer, EditorHistory, ContextMenu, OptionsPane, HyperlinkDialog, TableDialog, BookmarkDialog, TableOfContentsDialog, PageSetupDialog, StyleDialog, ListDialog, ParagraphDialog, BulletsAndNumberingDialog, FontDialog, TablePropertiesDialog, BordersAndShadingDialog, TableOptionsDialog, CellOptionsDialog, StylesDialog]
  }
}
</script>
<style>
 @import "../../node_modules/@syncfusion/ej2-vue-documenteditor/styles/material.css";
</style>


{% endraw %}