The default keydown pipeline (see Processors) includes support for inserting closing
brackets and for "typing over" closing brackets. These functions are implemented by the
bracketProcessor
in DefaultProcessors.
This processor can be excluded from the pipeline by setting the enabled
option to false
,
or, by specifying a replacement for the bracket processor.
💡 Note: These options are ignored if a custom keydownPipeline is being used.
If true
, the editor will automatically add closing brackets, quotes, etc. when typing, and
will "type-over" closing brackets, quotes, etc.
Default: true
.
Optional
replacement?: InputProcessorThe replacement for the bracket processor.
The dir
option specifies the direction of the prevailing script in the editor. This is useful
for languages like Arabic which read right to left.
💡 Note: Most properties which can be set after initialization are generally not included in the options, but this value is unlikely to change over the lifetime of the editor, so it is included here even though it can be changed after initialization at will.
Optional
gutterSettings for the Gutter. See Gutters
Optional
border?: booleanWhether to show a border between the gutter and the editor's text.
Default: false
.
Optional
class?: stringThe CSS class to apply to the gutter's DOM element.
This is useful for applying styles to the gutter, such as background, foreground, and border colors.
Optional
renderA function that is called for each line in the gutter. It is passed the line number and the DOM element for the line. You may use this function to customize the line numbers in the gutter.
Optional
width?: stringThe width of the gutter as a CSS value (e.x.: '55px'
)
Default: '55px'
.
Optional
highlightThe syntax highlighting function. This function is called whenever the editor's text changes and syntax highlighting needs to be re-applied.
💡 Note: Do not use this callback as a replacement for the onChange
callback. The
highlight function may be deferred to a later time, and may not be called immediately after the
text changes. Use the onChange
callback for that.
💡 Note: Currently the entire contents of the source will be available to the highlighter. This may not remain true in the future, but we will add a setting to control this behavior if it changes.
The element to highlight. Its textContents will be the source code to highlight. The function should replace the element's innerHTML with the highlighted source code.
Optional
keydownWhen specified, all options related to default input processors will be ignored, and the specified processors will be used instead.
You may build your own pipelines by reusing the default processors, by writing your own, or by writing your own which include the default processors.
This pipeline handles keypresses before they have been inserted into the editor's text.
Optional
keyupLike keydownPipeline, but handles keypresses after they have been inserted into the editor's text.
Optional
languageThe language to use for syntax highlighting.
Optional
maxThe maximum number of recent changes to keep in the history.
Default: 300
The default keydown pipeline (see Processors) includes support for automatic indentation, and for inserting additional indentation when the preceeding line ends with an open bracket. There is also support for moving text after the cursor to the next line when the user presses the enter key. This is useful for automatically converting the closing bracket to the next line. These functions are implemented in DefaultProcessors#enterProcessor.
The characters (or sequence of characters) which trigger indentation are specified by the
indentOn
option.
The characters (or sequence of characters) which trigger automatically moving following text to
the next line are specified by the moveToNewLine
option.
This processor can be excluded from the pipeline by setting the enabled
option to false
,
or, by specifying a replacement for the bracket processor.
💡 Note: These options are ignored if a custom keydownPipeline is being used.
If enabled
is true, the editor will preserve the indentation of the current line on the
next line when pressing enter.
Default: true
.
Optional
incrementThe incrementIndentationOn
option specifies a regular expression that is used to determine
whether the editor should indent the new line further when the user presses the enter key.
Typically this is open brackets, but it can be any character or sequence of characters.
Default: /[({[]$/
Optional
moveThe moveToNewLine
option specifies a regular expression that is used to determine whether
the editor should move the cursor to the beginning of the next line when the user presses the
enter key.
Typically this is closing brackets, but it can be any character or sequence of characters.
Default: /^[)}\]]/
Optional
replacement?: InputProcessorThe replacement for the newline processor.
The tab
option specifies the string that is inserted when the user presses the tab key.
💡 Note: this value is used across many different processors, so it is included here. For example, when the user presses the tab key, the tab processor inserts this value. When the user presses the enter key, the newline processor inserts this value at the beginning of the new line if the previous line ends with an open bracket. When we configure the default keydown pipeline, we need this value to be consistent across all processors. So it has been "elevated" from the processor configurations to here.
The default keydown pipeline (see Processors) includes support for automatically inserting custom tab characters when the user presses the tab key, for handling shift-tab to unindent, and for handling multi-line tabbing.
TODO: And for handling the backspace key at the beginning of a line.
This processor can be excluded from the pipeline by setting the enabled
option to false
,
or, by specifying a replacement for the bracket processor.
💡 Note: These options are ignored if a custom keydownPipeline is being used.
If enabled
is true, the editor will insert custom tab characters when the user presses the
tab key, and handle shift-tab to unindent, as well as multi-line selections.
Default: true
.
Optional
replacement?: InputProcessorThe replacement for the tab processor.
If window
is specified, the editor will use it instead of the global window
object.
Generated using TypeDoc
Options
These are the options for configuring a new KullnaEditor when calling createEditor.
💡 Note: Additional options are available for configuring the editor after initialization. See the documentation for KullnaEditor for more information.
Below is a comprehensive example of how to use these options. All of these options are optional, but they are included here for your reference: