Giter Site home page Giter Site logo

ace-vue2's Introduction

ace-vue2

NPM version

A ace package for Vue2 , and based on brace.

Developing.

Install

$ npm install ace-vue2

Usage

Import it before export in <script> and register the editor in components options.

import editor from 'ace-vue2'
export default {
    components: {
        editor
    },
    ...
}

Or use require to require it in components of Vue options.

export default {
    components: {
        editor:require('vue2-ace-editor'),
    },
    ...
}

Import the editor's mode & theme module from brace before export

import 'brace/mode/javascript'
import 'brace/theme/chrome'

Use the editor as a component in your template.

<editor height="200px" :content="content" > </editor>

content is a String and it is required.

Get the codes which are written in the editor.

See Events part.

To get the value, you can use getValue() method in your vue scripts. getValue() is a method of the editor componnent, and it returns the content of the editor. So, use it as following:

let code = this.$children[0].getValue();

Props

props type defalut required
content String ""
lang String javascript
theme String chrome
height String 400px
width String 100%
sync Boolean false
readOnly Boolean false
options Object {}

Events

change

parameter: type String

Emitted whenever the document is changed. Use v-on:change in template as following:

<editor v-on:change="change"> </editor>

And the event handler in parent component as following:

methods: {
    change: function(doc) {
        console.log(doc);
    }
}

copy

parameter: type String

Emitted when text is copied.

<editor v-on:copy="copy"> </editor>

And the event handler in parent component as following:

methods: {
    copy: function(str) {
        console.log(str);
    }
}

paste

no parameters. Emitted when text is pasted.

<editor v-on:paste="paste"> </editor>

And the event handler in parent component as following:

methods: {
    paste: function() {
        console.log('paste');
    }
}

Methods

getValue : get the content of the editor.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.