Split Editor

October 13, 2019 ยท View on GitHub

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.

Demo

http://securingsincity.github.io/react-ace/split.html

Example Code

import React from "react";
import { render } from "react-dom";

import { split as SplitEditor } from "react-ace";

import "ace-builds/src-noconflict/mode-java";
import "ace-builds/src-noconflict/theme-github";

// Render editor
render(
  <SplitEditor
    mode="java"
    theme="github"
    splits={2}
    orientation="below"
    value={["hi", "hello"]}
    name="UNIQUE_ID_OF_DIV"
    editorProps={{ $blockScrolling: true }}
  />,
  document.getElementById("example")
);

Available Props

PropDefaultTypeDescription
name'ace-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
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 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