Skip to content
This repository was archived by the owner on Apr 6, 2020. It is now read-only.

nhn/toast-ui.vue-editor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Vue wrapper for TOAST UI Editor

This is Vue component wrapping TOAST UI Editor.

vue2 github version npm version license PRs welcome code with hearth by NHN ent.

🚩 Table of Contents

πŸ’Ύ Install

Using npm

npm install --save @toast-ui/vue-editor

Via Contents Delivery Network (CDN)

TOAST UI products are available over the CDN powered by TOAST Cloud.

You can use the CDN as below.

<script src="https://uicdn.toast.com/toast-ui.vue-editor/latest/vue-editor.js"></script>

πŸ”¨ Usage

If you want to more details, see Tutorials πŸ‘€

Load

  • Using module

    If you use some kind of bundle loader like webpack of rollup, you can add the import like this:

    // es modules
    import { Editor } from '@toast-ui/vue-editor'
    // commonjs require
    var ToustUI = require('@toast-ui/vue-editor'); // you can use toastui.Editor
  • Using only Vue wrapper component

    vue-eidtor.js has all of the tui.editor. If you only need vue wrapper component, you can use @toast-ui/vue-editor/src/index.js like this:

    import { Editor } from '@toast-ui/vue-editor/src/index'
  • Using <script>

    If you just add javascript file to your html, you use CDN or vue-editor.js downloaded. Insert <script> in your html like this:

    <script src="path/to/vue-editor.js"></script>

Implement

First implement <tui-editor> in the template.

<template>
    <tui-editor/>
</template>

And then add Editor to the components in your component or Vue instance like this:

import { Editor } from '@toast-ui/vue-editor'

export default {
  components: {
    'tui-editor': Editor
  }
}

or

import { Editor } from '@toast-ui/vue-editor'
new Vue({
    el: '#app',
    components: {
        'tui-editor': Editor
    }
});

Using v-model

If you use v-model, you have to declare a data for binding.

In the example below, editorText is binding to the text of the editor.

<template>
    <tui-editor v-model="editorText"/>
</template>
<script>
import { Editor } from '@toast-ui/vue-editor'

export default {
  components: {
    'tui-editor': Editor
  },
  data() {
      return {
          editorText: ''
      }
  }
}
</script>

Props

Name Type Default Description
value String '' This prop can change content of the editor. If you using v-model, don't use it.
options Object following defaultOptions Options of tui.editor. This is for initailize tui.editor.
height String '300px' This prop can control the height of the editor.
previewStyle String 'tab' This prop can change preview style of the editor. (tab or vertical)
mode String 'markdown' This prop can change mode of the editor. (markdownor wysiwyg)
html String - If you want change content of the editor using html format, use this prop.
visible Boolean true This prop can control visible of the eiditor.
const defaultOptions = {
    minHeight: '200px',
    language: 'en_US',
    useCommandShortcut: true,
    useDefaultHTMLSanitizer: true,
    usageStatistics: true,
    hideModeSwitch: false,
    toolbarItems: [
        'heading',
        'bold',
        'italic',
        'strike',
        'divider',
        'hr',
        'quote',
        'divider',
        'ul',
        'ol',
        'task',
        'indent',
        'outdent',
        'divider',
        'table',
        'image',
        'link',
        'divider',
        'code',
        'codeblock'
    ]
};

Event

  • load : It would be emitted when editor fully load
  • change : It would be emitted when content changed
  • stateChange : It would be emitted when format change by cursor position
  • focus : It would be emitted when editor get focus
  • blur : It would be emitted when editor loose focus

Method

If you want to more manipulate the Editor, you can use invoke method to call the method of tui.editor. For more information of method, see method of tui.editor.

First, you need to assign ref attribute of <tui-editor/> and then you can use invoke method through this.$refs like this:

<template>
    <tui-editor ref="tuiEditor"/>
</template>
<script>
import { Editor } from '@toast-ui/vue-editor'

export default {
    components: {
        'tui-editor': Editor
    },
    methods: {
        scroll() {
            this.$refs.tuiEditor.invoke('scrollTop', 10);
        },
        moveTop() {
            this.$refs.tuiEditor.invoke('moveCursorToStart');
        },
        getHtml() {
            let html = this.$refs.tuiEditor.invoke('getHtml');
        }
    }
};
</script>

πŸ”§ Pull Request Steps

TOAST UI products are open source, so you can create a pull request(PR) after you fix issues. Run npm scripts and develop yourself with the following process.

Setup

Fork develop branch into your personal repository. Clone it to local computer. Install node modules. Before starting development, you should check to haveany errors.

$ git clone https://github.com/{your-personal-repo}/[[repo name]].git
$ cd [[repo name]]
$ npm install

Develop

Let's start development!

Pull Request

Before PR, check to test lastly and then check any errors. If it has no error, commit and then push it!

For more information on PR's step, please see links of Contributing section.

πŸ“™ Documents

πŸ’¬ Contributing

πŸ“œ License

This software is licensed under the MIT Β© NHN Ent.

About

This repository is DEPRECATED! GO TO πŸ‘‰ https://github.com/nhn/tui.editor/tree/master/apps/vue-editor

Topics

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors 7