# vue2-editor **Repository Path**: Microgalaxy/vue2-editor ## Basic Information - **Project Name**: vue2-editor - **Description**: A text editor using Vue.js and Quill - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2019-05-29 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Vue2Editor

View Documenation for Vue2Editor



![Vue2Editor-Centered](https://www.dropbox.com/s/7com4d32zct44nc/Vue2Editor-Centered.png?raw=1) HTML Editor using [Vue.js](https://vuejs.org) and [Quill](http://quilljs.com/) # Install _You can use Yarn or NPM_ ```bash $ npm install --save vue2-editor ``` **OR** ```bash yarn add vue2-editor ``` # Usage ```javascript // Basic Use - Covers most scenarios import { VueEditor } from "vue2-editor"; // Advanced Use - Hook into Quill's API for Custom Functionality import { VueEditor, Quill } from "vue2-editor"; ``` # Props | Name | Type | Default | Description | | --------------------- | ------- | ---------------------------------------------------- | -------------------------------------------------------------------------------------- | | id | String | quill-container | Set the id (necessary if multiple editors in the same view) | | v-model | String | - | Set v-model to the the content or data property you wish to bind it to | | useCustomImageHandler | Boolean | false | Handle image uploading instead of using default conversion to Base64 | | placeholder | String | - | Placeholder text for the editor | | disabled | Boolean | false | Set to true to disable editor | | customModules | Array | - | Declare Quill modules to register | Use a custom toolbar | | editorToolbar | Array | \*\* _Too long for table. See toolbar example below_ | Use a custom toolbar | | editorOptions | Object | - | Offers object for merging into default config (add formats, custom Quill modules, ect) | ## Events | Name | Parameters | Description | | ---------------- | ---------------------------- | ----------------------------------------------------------------------------------- | | focus | quill | Emitted on `focus` event | | blur | quill | Emitted on `blur` event | | selection-change | range, oldRange, source | Emitted on Quill's `selection-change` event | | text-change | delta, oldDelta, source | Emitted on Quill's `text-change` event | | imageAdded | file, Editor, cursorLocation | Emitted when `useCustomImageHandler` is true and photo is being added to the editor | # Examples ## Example - Basic Setup ```html ``` ## Example - Custom Image Handler If you choose to use the custom image handler, an event is emitted when a a photo is selected. You can see below that 3 parameters are passed. 1. It passes the file to be handled however you need 2. The Editor instance 3. The cursor position at the time of upload so the image can be inserted at the correct position on success **NOTE** In addition to this example, I have created a [ example repo](https://github.com/davidroyer/vue2editor-images) demonstrating this new feature with an actual server. ```html ``` ## Example - Set Contents After Page Load ```html ``` ## Example - Using Multiple Editors ```html ``` ## Example - Custom Toolbar ```html ``` ## Example - Saving The Content ```html ``` ## Example - Use a Live Preview ```html ``` ## How To Use Custom Quill Modules There are 2 ways of using custom modules with Vue2Editor. This is partly because there have been cases in which errors are thrown when importing and attempting to declare custom modules, and partly because I believe it actually separates the concerns nicely. ### Version 1 - **_Import and Register Yourself_** Vue2Editor now exports Quill to assist in this process. 1. When importing VueEditor, also import Quill. 2. Import your custom modules 3. Register the custom modules with Quill 4. Add the necessary configuration to the `editorOptions` object ```html ``` ### Version 2 - **_You Import | Vue2Editor Registers_** **_(Recommended way)_** 1. Import your custom modules 2. Use the `customModules` prop to declare an array of module(s). 3. Add the necessary configuration for those modules in the `editorOptions` object under modules as seen below ```html ``` --- # Development Vue2Editor now uses [Poi](https://github.com/egoist/poi) for development - `yarn dev`: Run example in development mode - `yarn docs`: Development for Docs - `yarn build`: Build component in both format - `yarn lint`: Run eslint # License MIT