0.0.6 • Published 2 years ago

react-sql-editor v0.0.6

Weekly downloads
-
License
-
Repository
-
Last release
2 years ago

Hello react-sql-editor!

This is the main component of React-Ace. It creates an instance of the SQL Ace Editor.

Install

npm i react-sql-editor

Demo

https://github.com/weiqian825/react-sql-editor/blob/master/src/SqlEditor/index.md

Example Code

import React from 'react';
import SqlEditor, { READ_VALIDATORS } from 'react-sql-editor';

export default () => (
  <SqlEditor
    title="Sql Editor"
    width="auto"
    height="300px"
    isShowHeader={true}
    onChange={data => {
      console.log(data);
    }}
    validatorConfig={{
      maxSqlNum: 1,
      validators: READ_VALIDATORS,
    }}
  />
);

Primary Available Props

PropDefaultTypeDescription
onChangeconsole.log(data)FunctiononChange
isShowHeaderfalseBooleanShow SQL Editor Header
validatorConfigObjectSQL Validator rule Config

Primary export util

PropDefaultTypeDescription
formatSqlconsole.log(data)FunctionformatSql
getValidateSqlconsole.log(data)FunctiongetValidateSql

validatorConfig Options

KeyDefaultTypeDescription
maxSqlNum1Numbersupport sql query num
validatorssqlValidatorRuleArray< >sql validator conf

Other Available Props

PropDefaultTypeDescription
name'sql editor'StringUnique Id to be used for the editor
placeholder'please input sql here'StringPlaceholder text to be displayed when editor is empty
mode'mysql'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
fontSize16Numberpixel 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
enableSnippetsfalseBooleanEnable snippets
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' }]. Make sure to define the class (eg. ".error-marker") and set position: absolute for it.
styleObjectcamelCased properties
0.0.5

2 years ago

0.0.4

2 years ago

0.0.6

2 years ago

0.0.2

3 years ago