Socket
Socket
Sign inDemoInstall

vue2-brace-editor

Package Overview
Dependencies
72
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue2-brace-editor

A Vue component for integrating ace editor using brace


Version published
Maintainers
1
Weekly downloads
701
decreased by-14.41%

Weekly downloads

Readme

Source

Vue2-Brace-Editor

A Vue components for Ace / Brace

Install

npm install vue2-brace-editor

Basic Usage


<template>
  // Full editor component
  <AceEditor
    :fontSize="14"
    :showPrintMargin="true"
    :showGutter="true"
    :highlightActiveLine="true"
    mode="javascript"
    theme="monokai"
    :onChange="onChange"
    name="editor"
    :editorProps="{$blockScrolling: true}"
  />

  // Split editor component
   <SplitEditor
    mode="javascript"
    theme="monokai"
    :splits="2"
    orientation="beside"
    name="editor"
    :editorProps="{$blockScrolling: true}"
  />
</template>

<script>
  import Vue from 'vue';
  import brace from 'brace';
  import { Ace as AceEditor, Split as SplitEditor } from 'vue2-brace-editor';

  import 'brace/mode/javascript';
  import 'brace/theme/monokai';

  export default {
    components: {
      AceEditor,
      SplitEditor,
    },
    $el: 'root',
    methods: {
      onChange(newValue) {
        console.log('change',newValue);
      }
    }
  }
</script>

Ace Editor - Full

This is the main component of Vue2-brace. It creates an instance of the Ace Editor.

Available Props

PropDefaultTypeDescription
name'brace-editor'StringUnique Id to be used for the editor
mode''StringLanguage for parsing and code highlighting
theme''Stringtheme to use
value''Stringvalue you want to populate in the code highlighter
defaultValue''StringDefault value of the editor
height'500px'StringCSS value for height
width'500px'StringCSS value for width
classNameStringcustom className
fontSize12Numberpixel value for font-size
showGuttertrueBooleanshow gutter
showPrintMargintrueBooleanshow print margin
highlightActiveLinetrueBooleanhighlight active line
focusfalseBooleanwhether to focus
cursorStart1Numberthe location of the cursor
wrapEnabledfalseBooleanWrapping lines
readOnlyfalseBooleanmake the editor read only
minLinesNumberMinimum number of lines to be displayed
maxLinesNumberMaximum number of lines to be displayed
enableBasicAutocompletionfalseBooleanEnable basic autocompletion
enableLiveAutocompletionfalseBooleanEnable live autocompletion
tabSize4NumbertabSize
debounceChangePeriodnullNumberA debounce delay period for the onChange event
onLoadFunctioncalled on editor load. The first argument is the instance of the editor
onBeforeLoadFunctioncalled before editor load. the first argument is an instance of ace
onChangeFunctionoccurs on document change it has 2 arguments the value and the event.
onCopyFunctiontriggered by editor copy event, and passes text as argument
onPasteFunctionTriggered by editor paste event, and passes text as argument
onSelectionChangeFunctiontriggered by editor selectionChange event, and passes a Selection as it's first argument and the event as the second
onCursorChangeFunctiontriggered by editor changeCursor event, and passes a Selection as it's first argument and the event as the second
onFocusFunctiontriggered by editor focus event
onBlurFunctiontriggered by editor blur event.It has two arguments event and editor
onInputFunctiontriggered by editor input event
onScrollFunctiontriggered by editor scroll event
onValidateFunctiontriggered, when annotations are changed
editorPropsObjectproperties to apply directly to the Ace editor instance
setOptionsObjectoptions to apply directly to the Ace editor instance
keyboardHandlerStringcorresponding to the keybinding mode to set (such as vim or emacs)
commandsArraynew commands to add to the editor
annotationsArrayannotations to show in the editor i.e. [{ row: 0, column: 2, type: 'error', text: 'Some error.'}], displayed in the gutter
markersArraymarkers to show in the editor, i.e. [{ startRow: 0, startCol: 2, endRow: 1, endCol: 20, className: 'error-marker', type: 'background' }]
styleObjectcamelCased properties

Split Editor

This allows for a split editor which can create multiple linked instances of the Ace editor. Each instance shares a theme and other properties while having their own value.

Available Props

PropDefaultTypeDescription
name'brace-editor'StringUnique Id to be used for the editor
mode''StringLanguage for parsing and code highlighting
splits2NumberNumber of views to have
orientation'beside'StringThe orientation of the splits either beside or below
theme''Stringtheme to use
value''Array of Stringsvalue you want to populate in each code editor
defaultValue''Array of StringsDefault value for each editor
height'500px'StringCSS value for height
width'500px'StringCSS value for width
classNameStringcustom className
fontSize12Numberpixel value for font-size
showGuttertrueBooleanshow gutter
showPrintMargintrueBooleanshow print margin
highlightActiveLinetrueBooleanhighlight active line
focusfalseBooleanwhether to focus
cursorStart1Numberthe location of the cursor
wrapEnabledfalseBooleanWrapping lines
readOnlyfalseBooleanmake the editor read only
minLinesNumberMinimum number of lines to be displayed
maxLinesNumberMaximum number of lines to be displayed
enableBasicAutocompletionfalseBooleanEnable basic autocompletion
enableLiveAutocompletionfalseBooleanEnable live autocompletion
tabSize4NumbertabSize
onLoadFunctioncalled on editor load. The first argument is the instance of the editor
onBeforeLoadFunctioncalled before editor load. the first argument is an instance of ace
onChangeFunctionoccurs on document change it has 2 arguments the value of each editor and the event.
onCopyFunctiontriggered by editor copy event, and passes text as argument
onPasteFunctionTriggered by editor paste event, and passes text as argument
onSelectionChangeFunctiontriggered by editor selectionChange event, and passes a Selection as it's first argument and the event as the second
onCursorChangeFunctiontriggered by editor changeCursor event, and passes a Selection as it's first argument and the event as the second
onFocusFunctiontriggered by editor focus event
onBlurFunctiontriggered by editor blur event
onInputFunctiontriggered by editor input event
onScrollFunctiontriggered by editor scroll event
editorPropsObjectproperties to apply directly to the Ace editor instance
setOptionsObjectoptions to apply directly to the Ace editor instance
keyboardHandlerStringcorresponding to the keybinding mode to set (such as vim or emacs)
commandsArraynew commands to add to the editor
annotationsArray of Arraysannotations to show in the editor i.e. [{ row: 0, column: 2, type: 'error', text: 'Some error.'}], displayed in the gutter
markersArray of Arraysmarkers to show in the editor, i.e. [{ startRow: 0, startCol: 2, endRow: 1, endCol: 20, className: 'error-marker', type: 'background' }]
styleObjectcamelCased properties

How to contribute

To contribute, fork this repo to your private repository and create a pull request based on the feature you want to add. However ensure to follow the AirBnB coding style guide.

Disclaimer

This app and its functions are limited by time constraint and is in no way at its best.

FAQ

  • Can I fork this repository?
    • Yes you can.
  • Can I contribute to the project?
    • Yes you can, however it is advised you follow the AirBnB style guide for your PR to be considered being merged to the project
  • Can I modify the project, for usage?
    • This project is an open source project, so you can.

Dependencies

  • brace - browserify compatible version of the ace editor.

Authors

Hector Johnson - github.com/hector101

License

(The MIT License)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Keywords

FAQs

Last updated on 23 Oct 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc