@types/codemirror
- Version 5.60.15
- Published
- 154 kB
- 1 dependency
- MIT license
Install
npm i @types/codemirror
yarn add @types/codemirror
pnpm add @types/codemirror
Overview
TypeScript definitions for codemirror
Index
Variables
Functions
- autoLoadMode()
- changeEnd()
- cmpPos()
- CodeMirror()
- colorize()
- countColumn()
- defineDocExtension()
- defineExtension()
- defineInitHook()
- defineMIME()
- defineMode()
- defineOption()
- defineSimpleMode()
- extendMode()
- findEnclosingTag()
- findMatchingTag()
- findModeByExtension()
- findModeByFileName()
- findModeByMIME()
- findModeByName()
- fromTextArea()
- getMode()
- innerMode()
- isWordChar()
- multiplexingMode()
- normalizeKeyMap()
- off()
- on()
- overlayMode()
- registerHelper()
- requireMode()
- runMode()
- scanForClosingTag()
- showHint()
- signal()
- splitLines()
- startState()
Classes
Interfaces
CommandActions
- defaultTabTab()
- delCharAfter()
- delCharBefore()
- deleteLine()
- delGroupAfter()
- delGroupBefore()
- delLineLeft()
- delWordAfter()
- delWordBefore()
- delWrappedLineLeft()
- delWrappedLineRight()
- goCharLeft()
- goCharRight()
- goColumnLeft()
- goColumnRight()
- goDocEnd()
- goDocStart()
- goGroupLeft()
- goGroupRight()
- goLineDown()
- goLineEnd()
- goLineLeft()
- goLineLeftSmart()
- goLineRight()
- goLineStart()
- goLineStartSmart()
- goLineUp()
- goPageDown()
- goPageUp()
- goWordLeft()
- goWordRight()
- indentAuto()
- indentLess()
- indentMore()
- insertSoftTab()
- insertTab()
- killLine()
- newlineAndIndent()
- redo()
- redoSelection()
- selectAll()
- singleSelection()
- toggleOverwrite()
- transposeChars()
- undo()
- undoSelection()
DocOrEditor
- addLineWidget()
- addSelection()
- changeGeneration()
- clearHistory()
- eachLine()
- extendSelection()
- extendSelections()
- extendSelectionsBy()
- findMarks()
- findMarksAt()
- firstLine()
- getAllMarks()
- getCursor()
- getExtending()
- getHistory()
- getLine()
- getLineHandle()
- getLineNumber()
- getMode()
- getRange()
- getSelection()
- getSelections()
- getValue()
- historySize()
- indexFromPos()
- isClean()
- iterLinkedDocs()
- lastLine()
- lineCount()
- lineSeparator()
- linkedDoc()
- listSelections()
- markClean()
- markText()
- modeOption
- posFromIndex()
- redo()
- redoSelection()
- removeLine()
- removeLineWidget()
- replaceRange()
- replaceSelection()
- replaceSelections()
- setBookmark()
- setCursor()
- setExtending()
- setHistory()
- setLine()
- setSelection()
- setSelections()
- setValue()
- somethingSelected()
- state
- undo()
- undoSelection()
- unlinkDoc()
Editor
- addKeyMap()
- addLineClass()
- addLineWidget()
- addOverlay()
- addWidget()
- charCoords()
- clearGutter()
- coordsChar()
- cursorCoords()
- defaultCharWidth()
- defaultTextHeight()
- endOperation()
- execCommand()
- findPosH()
- findPosV()
- findWordAt()
- focus()
- getCursor()
- getDoc()
- getGutterElement()
- getInputField()
- getLineTokens()
- getModeAt()
- getOption()
- getScrollerElement()
- getScrollInfo()
- getStateAfter()
- getTokenAt()
- getTokenTypeAt()
- getValue()
- getViewport()
- getWrapperElement()
- hasFocus()
- heightAtLine()
- indentLine()
- indentSelection()
- isReadOnly()
- lineAtHeight()
- lineInfo()
- off()
- on()
- operation()
- phrase()
- refresh()
- removeKeyMap()
- removeLineClass()
- removeOverlay()
- scrollIntoView()
- scrollTo()
- setCursor()
- setGutterMarker()
- setOption()
- setSize()
- setValue()
- startOperation()
- state
- swapDoc()
- toggleOverwrite()
EditorConfiguration
- addModeClass
- allowDropFileTypes
- autocapitalize
- autocorrect
- autofocus
- configureMouse
- coverGutterNextToScrollbar
- cursorBlinkRate
- cursorHeight
- cursorScrollMargin
- direction
- dragDrop
- electricChars
- extraKeys
- firstLineNumber
- fixedGutter
- flattenSpans
- gutters
- historyEventDelay
- indentUnit
- indentWithTabs
- inputStyle
- keyMap
- lineNumberFormatter
- lineNumbers
- lineSeparator
- lineWiseCopyCut
- lineWrapping
- maxHighlightLength
- mode
- onDragEvent
- onKeyEvent
- pasteLinesPerSelection
- phrases
- pollInterval
- readOnly
- resetSelectionOnContextMenu
- rtlMoveVisually
- screenReaderLabel
- scrollbarStyle
- selectionsMayTouch
- showCursorWhenSelecting
- smartIndent
- specialCharPlaceholder
- specialChars
- spellcheck
- tabindex
- tabSize
- theme
- undoDepth
- value
- viewportMargin
- workDelay
- workTime
ModeSpecOptions
- alignCDATA
- allowAtxHeaderWithoutSpace
- atoms
- base
- baseMode
- doubleDelimiters
- doubleOperators
- emoji
- extra_builtins
- extra_keywords
- fencedCodeBlockDefaultMode
- fencedCodeBlockHighlighting
- gitHubSpice
- hangingIndent
- highlightFormatting
- highlightNonStandardPropertyKeywords
- hooks
- htmlMode
- identifiers
- inMathMode
- json
- jsonld
- leftDelimiter
- matchClosing
- maxBlockquoteDepth
- multiLineStrings
- noIndentKeywords
- rightDelimiter
- singleDelimiters
- singleLineStringErrors
- singleOperators
- statementIndent
- strikethrough
- tags
- taskLists
- tokenTypeOverrides
- trackScope
- tripleDelimiters
- typescript
- useCPP
- version
- wordCharacters
- xml
Type Aliases
Namespaces
Variables
variable commands
const commands: CommandActions;
Commands are parameter-less actions that can be performed on an editor. Their main use is for key bindings. Commands are defined by adding properties to the CodeMirror.commands object.
variable defaults
const defaults: { [option: string]: any };
An object containing default values for all options. You can assign to its properties to modify defaults (though this won't affect editors that have already been created).
variable Doc
const Doc: DocConstructor;
variable fold
const fold: FoldHelpers;
variable hint
const hint: HintHelpers;
variable htmlSchema
const htmlSchema: any;
variable MergeView
const MergeView: MergeViewConstructor;
variable mimeModes
const mimeModes: MimeModeMap;
Maps MIME types to mode specs.
variable modeInfo
const modeInfo: ModeInfo[];
variable modes
const modes: ModeMap;
Maps mode names to their constructors
variable modeURL
let modeURL: string;
variable Pass
const Pass: { toString(): 'CodeMirror.PASS' };
variable Pos
const Pos: PositionConstructor;
variable scrollbarModel
const scrollbarModel: ScrollbarModels;
variable version
const version: string;
It contains a string that indicates the version of the library. This is a triple of integers "major.minor.patch", where patch is zero for releases, and something else (usually one) for dev snapshots.
Functions
function autoLoadMode
autoLoadMode: ( instance: Editor, mode: string, options?: RequireModeOptions) => void;
function changeEnd
changeEnd: (change: EditorChange) => Position;
Utility function that computes an end position from a change (an object with from, to, and text properties, as passed to various event handlers). The returned position will be the end of the changed range, after the change is applied.
function cmpPos
cmpPos: (a: Position, b: Position) => number;
Compare two positions, return 0 if they are the same, a negative number when a is less, and a positive number otherwise.
function CodeMirror
CodeMirror: typeof import('/index.d.ts');
function colorize
colorize: (collection?: ArrayLike<Element>, defaultMode?: string) => void;
Provides a convenient way to syntax-highlight code snippets in a webpage. Depends on the runmode addon (or its standalone variant). Can be called with an array (or other array-ish collection) of DOM nodes that represent the code snippets. By default, it'll get all pre tags. Will read the data-lang attribute of these nodes to figure out their language, and syntax-color their content using the relevant CodeMirror mode (you'll have to load the scripts for the relevant modes yourself). A second argument may be provided to give a default mode, used when no language attribute is found for a node.
function countColumn
countColumn: (line: string, index: number | null, tabSize: number) => number;
Find the column position at a given string index using a given tabsize.
function defineDocExtension
defineDocExtension: (name: string, value: any) => void;
Like defineExtension, but the method will be added to the interface for Doc objects instead.
function defineExtension
defineExtension: (name: string, value: any) => void;
If you want to define extra methods in terms of the CodeMirror API, it is possible to use defineExtension. This will cause the given value(usually a method) to be added to all CodeMirror instances created from then on.
function defineInitHook
defineInitHook: (func: (editor: Editor) => void) => void;
If your extension just needs to run some code whenever a CodeMirror instance is initialized, use CodeMirror.defineInitHook. Give it a function as its only argument, and from then on, that function will be called (with the instance as argument) whenever a new CodeMirror instance is initialized.
function defineMIME
defineMIME: (mime: string, modeSpec: string | ModeSpec<ModeSpecOptions>) => void;
function defineMode
defineMode: (id: string, modefactory: ModeFactory<any>) => void;
id will be the id for the defined mode. Typically, you should use this second argument to defineMode as your module scope function (modes should not leak anything into the global scope!), i.e. write your whole mode inside this function.
function defineOption
defineOption: ( name: string, default_: any, updateFunc: (editor: Editor, val: any, old: any) => void) => void;
Similarly, defineOption can be used to define new options for CodeMirror. The updateFunc will be called with the editor instance and the new value when an editor is initialized, and whenever the option is modified through setOption.
function defineSimpleMode
defineSimpleMode: <K extends string>( name: string, mode: { [P in K]: P extends 'meta' ? Record<string, any> : Rule[] } & { start: Rule[]; }) => void;
function extendMode
extendMode: (name: string, properties: Partial<Mode<any>>) => void;
Sometimes, it is useful to add or override mode object properties from external code. The CodeMirror.extendMode function can be used to add properties to mode objects produced for a specific mode. Its first argument is the name of the mode, its second an object that specifies the properties that should be added. This is mostly useful to add utilities that can later be looked up through getMode.
function findEnclosingTag
findEnclosingTag: ( cm: Editor, pos: Position, range: Range, tag: string) => { open: XmlTag; close: XmlTag } | undefined;
function findMatchingTag
findMatchingTag: ( cm: Editor, pos: Position, range: Range) => | { open: XmlTag; close: XmlTag | null | undefined; at: 'open' | 'close' } | undefined;
function findModeByExtension
findModeByExtension: (ext: string) => ModeInfo | undefined;
function findModeByFileName
findModeByFileName: (filename: string) => ModeInfo | undefined;
function findModeByMIME
findModeByMIME: (mime: string) => ModeInfo | undefined;
function findModeByName
findModeByName: (name: string) => ModeInfo | undefined;
function fromTextArea
fromTextArea: ( host: HTMLTextAreaElement, options?: EditorConfiguration) => EditorFromTextArea;
function getMode
getMode: ( config: EditorConfiguration, mode: string | ModeSpec<ModeSpecOptions>) => Mode<unknown>;
The first argument is a configuration object as passed to the mode constructor function, and the second argument is a mode specification as in the EditorConfiguration mode option.
function innerMode
innerMode: (mode: Mode<any>, state: any) => { state: any; mode: Mode<any> };
Given a state object, returns a {state, mode} object with the inner mode and its state for the current position.
function isWordChar
isWordChar: (ch: string) => boolean;
Check if a char is part of an alphabet.
function multiplexingMode
multiplexingMode: ( outer: Mode<any>, ...others: MultiplexedInnerMode[]) => Mode<any>;
Mode combinator that can be used to easily 'multiplex' between several modes. When given as first argument a mode object, and as other arguments any number of {open, close, mode [, delimStyle, innerStyle, parseDelimiters]} objects, it will return a mode object that starts parsing using the mode passed as first argument, but will switch to another mode as soon as it encounters a string that occurs in one of the open fields of the passed objects. When in a sub-mode, it will go back to the top mode again when the close string is encountered. Pass "\n" for open or close if you want to switch on a blank line.
When delimStyle is specified, it will be the token style returned for the delimiter tokens (as well as [delimStyle]-open on the opening token and [delimStyle]-close on the closing token). When innerStyle is specified, it will be the token style added for each inner mode token. When parseDelimiters is true, the content of the delimiters will also be passed to the inner mode. (And delimStyle is ignored.)
The outer mode will not see the content between the delimiters.
function normalizeKeyMap
normalizeKeyMap: (km: KeyMap) => KeyMap;
Modify a keymap to normalize modifier order and properly recognize multi-stroke bindings.
function off
off: { <T extends keyof DocEventMap>( doc: Doc, eventName: T, handler: DocEventMap[T] ): void; <T extends keyof EditorEventMap>( cm: Editor, eventName: T, handler: EditorEventMap[T] ): void; <T extends keyof LineHandleEventMap>( lineHandle: LineHandle, eventName: T, handler: LineHandleEventMap[T] ): void; <T extends keyof TextMarkerEventMap>( textMarker: TextMarker<unknown>, eventName: T, handler: TextMarkerEventMap[T] ): void; <T extends 'redraw'>( lineWidget: LineWidget, eventName: T, handler: LineWidgetEventMap[T] ): void; (element: any, eventName: string, handler: () => void): void; <T extends keyof CompletionEventMap>( hints: Hints, eventName: T, handler: CompletionEventMap[T] ): void;};
function on
on: { <T extends keyof DocEventMap>( doc: Doc, eventName: T, handler: DocEventMap[T] ): void; <T extends keyof EditorEventMap>( cm: Editor, eventName: T, handler: EditorEventMap[T] ): void; <T extends keyof LineHandleEventMap>( lineHandle: LineHandle, eventName: T, handler: LineHandleEventMap[T] ): void; <T extends keyof TextMarkerEventMap>( textMarker: TextMarker<unknown>, eventName: T, handler: TextMarkerEventMap[T] ): void; <T extends 'redraw'>( LineWidget: LineWidget, eventName: T, handler: LineWidgetEventMap[T] ): void; (element: any, eventName: string, handler: () => void): void; <T extends keyof CompletionEventMap>( hints: Hints, eventName: T, handler: CompletionEventMap[T] ): void;};
function overlayMode
overlayMode: { (base: Mode<any>, overlay: Mode<any>, combine?: boolean): Mode<any>; (base: Mode<any>, overlay: Mode<any>, combine?: boolean): Mode<any>;};
Utility function from the overlay.js addon that allows modes to be combined. The mode given as the base argument takes care of most of the normal mode functionality, but a second (typically simple) mode is used, which can override the style of text. Both modes get to parse all of the text, but when both assign a non-null style to a piece of code, the overlay wins, unless the combine argument was true and not overridden, or state.overlay.combineTokens was true, in which case the styles are combined.
function registerHelper
registerHelper: (namespace: string, name: string, helper: any) => void;
Registers a helper value with the given name in the given namespace (type). This is used to define functionality that may be looked up by mode. Will create (if it doesn't already exist) a property on the CodeMirror object for the given type, pointing to an object that maps names to values. I.e. after doing CodeMirror.registerHelper("hint", "foo", myFoo), the value CodeMirror.hint.foo will point to myFoo.
function requireMode
requireMode: ( mode: string | { name: string }, callback: () => void, options?: RequireModeOptions) => void;
function runMode
runMode: ( text: string, mode: string | ModeSpec<unknown>, callback: | HTMLElement | (( text: string, style?: string | null, row?: number, column?: number, state?: any ) => void), options?: { tabSize?: number | undefined; state?: any }) => void;
Runs a CodeMirror mode over text without opening an editor instance.
Parameter text
The document to run through the highlighter.
Parameter mode
The mode to use (must be loaded as normal).
Parameter callback
If this is a function, it will be called for each token with five arguments, the token's text, the token's style class (may be null for unstyled tokens), the number of row of the token, the column position of token and the state of mode. If it is a DOM node, the tokens will be converted to span elements as in an editor, and inserted into the node (through innerHTML).
function scanForClosingTag
scanForClosingTag: ( cm: Editor, pos: Position, name: string, end?: Position) => XmlTag | null | undefined;
function showHint
showHint: (cm: Editor, hinter?: HintFunction, options?: ShowHintOptions) => void;
Provides a framework for showing autocompletion hints. Defines editor.showHint, which takes an optional options object, and pops up a widget that allows the user to select a completion. Finding hints is done with a hinting functions (the hint option), which is a function that take an editor instance and options object, and return a {list, from, to} object, where list is an array of strings or objects (the completions), and from and to give the start and end of the token that is being completed as {line, ch} objects. An optional selectedHint property (an integer) can be added to the completion object to control the initially selected hint.
function signal
signal: { <T extends keyof DocEventMap>( doc: Doc, eventName: T, ...args: Parameters<DocEventMap[T]> ): void; <T extends keyof EditorEventMap>( cm: Editor, eventName: T, ...args: Parameters<EditorEventMap[T]> ): void; <T extends keyof LineHandleEventMap>( lineHandle: LineHandle, eventName: T, ...args: Parameters<LineHandleEventMap[T]> ): void; <T extends keyof TextMarkerEventMap>( textMarker: TextMarker<unknown>, eventName: T, ...args: Parameters<TextMarkerEventMap[T]> ): void; <T extends 'redraw'>( lineWidget: LineWidget, eventName: T, ...args: Parameters<LineWidgetEventMap[T]> ): void; (target: any, name: string, ...args: any[]): void; <T extends keyof CompletionEventMap>( hints: Hints, eventName: T, ...args: Parameters<CompletionEventMap[T]> ): void;};
Various CodeMirror-related objects emit events, which allow client code to react to various situations. Handlers for such events can be registered with the on and off methods on the objects that the event fires on. To fire your own events, use CodeMirror.signal(target, name, args...), where target is a non-DOM-node object.
function splitLines
splitLines: (text: string) => string[];
Split a string by new line.
function startState
startState: <T>(mode: Mode<T>, a1?: any, a2?: any) => T | boolean;
Call startState of the mode if available, otherwise return true
Classes
class StringStream
class StringStream {}
constructor
constructor(text: string);
property lastColumnPos
lastColumnPos: number;
property lastColumnValue
lastColumnValue: number;
property lineStart
lineStart: number;
property pos
pos: number;
Current position in the string.
property start
start: number;
Where the stream's position was when it was first passed to the token function.
property string
string: string;
The current line's content.
property tabSize
tabSize: number;
Number of spaces per tab character.
method backUp
backUp: (n: number) => void;
Backs up the stream n characters. Backing it up further than the start of the current token will cause things to break, so be careful.
method column
column: () => number;
Returns the column (taking into account tabs) at which the current token starts.
method current
current: () => string;
Get the string between the start of the current token and the current stream position.
method eat
eat: (match: string | RegExp | ((char: string) => boolean)) => string;
match can be a character, a regular expression, or a function that takes a character and returns a boolean. If the next character in the stream 'matches' the given argument, it is consumed and returned. Otherwise, undefined is returned.
method eatSpace
eatSpace: () => boolean;
Shortcut for eatWhile when matching white-space.
method eatWhile
eatWhile: (match: string | RegExp | ((char: string) => boolean)) => boolean;
Repeatedly calls eat with the given argument, until it fails. Returns true if any characters were eaten.
method eol
eol: () => boolean;
Returns true only if the stream is at the end of the line.
method indentation
indentation: () => number;
Tells you how far the current line has been indented, in spaces. Corrects for tab characters.
method lookAhead
lookAhead: (n: number) => string | undefined;
Returns the content of the line n lines ahead in the stream without advancing it. Will return undefined if not found.
method match
match: { (pattern: string, consume?: boolean, caseFold?: boolean): boolean; (pattern: RegExp, consume?: boolean): string[];};
Act like a multi-character eat - if consume is true or not given - or a look-ahead that doesn't update the stream position - if it is false. pattern can be either a string or a regular expression starting with ^. When it is a string, caseFold can be set to true to make the match case-insensitive. When successfully matching a regular expression, the returned value will be the array returned by match, in case you need to extract matched groups.
method next
next: () => string | null;
Returns the next character in the stream and advances it. Also returns null when no more characters are available.
method peek
peek: () => string | null;
Returns the next character in the stream without advancing it. Will return an null at the end of the line.
method skipTo
skipTo: (ch: string) => boolean;
Skips to the next occurrence of the given character, if found on the current line (doesn't advance the stream if the character does not occur on the line).
Returns true if the character was found.
method skipToEnd
skipToEnd: () => void;
Moves the position to the end of the line.
method sol
sol: () => boolean;
Returns true only if the stream is at the start of the line.
class TernServer
class TernServer {}
constructor
constructor(options?: TernOptions);
property docs
readonly docs: { readonly [key: string]: { doc: Doc; name: string; changed: { from: number; to: number } | null; };};
property options
readonly options: TernOptions;
property server
readonly server: Tern.Server;
method addDoc
addDoc: ( name: string, doc: Doc) => { doc: Doc; name: string; changed: { from: number; to: number } | null };
method complete
complete: (cm: Editor) => void;
method delDoc
delDoc: (id: string | Editor | Doc) => void;
method destroy
destroy: () => void;
method hideDoc
hideDoc: (id: string | Editor | Doc) => void;
method jumpBack
jumpBack: (cm: Editor) => void;
method jumpToDef
jumpToDef: (cm: Editor) => void;
method rename
rename: (cm: Editor) => void;
method request
request: { <Q extends Tern.Query>( cm: Doc, query: Q, callback: (error?: Error, data?: Tern.QueryResult<Q>) => void, pos?: Position ): void; <Q extends Tern.Query>( cm: Doc, query: Q, callback: (error?: Error, data?: Tern.QueryRegistry) => void, pos?: Position ): void;};
method selectName
selectName: (cm: Editor) => void;
method showDocs
showDocs: (cm: Editor, pos?: Position, callback?: () => void) => void;
method showType
showType: (cm: Editor, pos?: Position, callback?: () => void) => void;
method updateArgHints
updateArgHints: (cm: Editor) => void;
Interfaces
interface AsyncHintFunction
interface AsyncHintFunction {}
property async
async: true;
call signature
( cm: Editor, callback: (hints: Hints | null | undefined) => void, options: ShowHintOptions): void;
interface AutoCloseBrackets
interface AutoCloseBrackets {}
property closeBefore
closeBefore?: string | undefined;
If the next character is in the string, opening a bracket should be auto-closed.
property explode
explode?: string | undefined;
explode should be a similar string that gives the pairs of characters that, when enter is pressed between them, should have the second character also moved to its own line.
property override
override?: boolean | undefined;
By default, if the active mode has a closeBrackets property, that overrides the configuration given in the option. But you can add an override property with a truthy value to override mode-specific configuration.
property pairs
pairs?: string | undefined;
String containing pairs of matching characters.
property triples
triples?: string | undefined;
String containing chars that could do a triple quote.
interface AutoCloseTags
interface AutoCloseTags {}
property dontCloseTags
dontCloseTags?: readonly string[] | undefined;
An array of tag names that should not be autoclosed. (default is empty tags for HTML, none for XML)
property emptyTags
emptyTags: readonly string[];
An array of XML tag names that should be autoclosed with '/>'. (default is none)
property indentTags
indentTags?: readonly string[] | undefined;
An array of tag names that should, when opened, cause a blank line to be added inside the tag, and the blank line and closing line to be indented. (default is block tags for HTML, none for XML)
property whenClosing
whenClosing?: boolean | undefined;
Whether to autoclose when the '/' of a closing tag is typed. (default true)
property whenOpening
whenOpening?: boolean | undefined;
Whether to autoclose the tag when the final '>' of an opening tag is typed. (default true)
interface CommandActions
interface CommandActions {}
method defaultTabTab
defaultTabTab: (cm: Editor) => void;
If something is selected, indent it by one indent unit. If nothing is selected, insert a tab character.
method delCharAfter
delCharAfter: (cm: Editor) => void;
Delete the character after the cursor.
method delCharBefore
delCharBefore: (cm: Editor) => void;
Delete the character before the cursor.
method deleteLine
deleteLine: (cm: Editor) => void;
Deletes the whole line under the cursor, including newline at the end.
method delGroupAfter
delGroupAfter: (cm: Editor) => void;
Delete to the start of the group after the cursor.
method delGroupBefore
delGroupBefore: (cm: Editor) => void;
Delete to the left of the group before the cursor.
method delLineLeft
delLineLeft: (cm: Editor) => void;
Delete the part of the line before the cursor.
method delWordAfter
delWordAfter: (cm: Editor) => void;
Delete up to the end of the word after the cursor.
method delWordBefore
delWordBefore: (cm: Editor) => void;
Delete up to the start of the word before the cursor.
method delWrappedLineLeft
delWrappedLineLeft: (cm: Editor) => void;
Delete the part of the line from the left side of the visual line the cursor is on to the cursor.
method delWrappedLineRight
delWrappedLineRight: (cm: Editor) => void;
Delete the part of the line from the cursor to the right side of the visual line the cursor is on.
method goCharLeft
goCharLeft: (cm: Editor) => void;
Move the cursor one character left, going to the previous line when hitting the start of line.
method goCharRight
goCharRight: (cm: Editor) => void;
Move the cursor one character right, going to the next line when hitting the end of line.
method goColumnLeft
goColumnLeft: (cm: Editor) => void;
Move the cursor one character left, but don't cross line boundaries.
method goColumnRight
goColumnRight: (cm: Editor) => void;
Move the cursor one character right, don't cross line boundaries.
method goDocEnd
goDocEnd: (cm: Editor) => void;
Move the cursor to the end of the document.
method goDocStart
goDocStart: (cm: Editor) => void;
Move the cursor to the start of the document.
method goGroupLeft
goGroupLeft: (cm: Editor) => void;
Move to the left of the group before the cursor. A group is a stretch of word characters, a stretch of punctuation characters, a newline, or a stretch of more than one whitespace character.
method goGroupRight
goGroupRight: (cm: Editor) => void;
Move to the right of the group after the cursor (see above).
method goLineDown
goLineDown: (cm: Editor) => void;
Move down one line.
method goLineEnd
goLineEnd: (cm: Editor) => void;
Move the cursor to the end of the line.
method goLineLeft
goLineLeft: (cm: Editor) => void;
Move the cursor to the left side of the visual line it is on. If this line is wrapped, that may not be the start of the line.
method goLineLeftSmart
goLineLeftSmart: (cm: Editor) => void;
Move the cursor to the left side of the visual line it is on. If that takes it to the start of the line, behave like goLineStartSmart.
method goLineRight
goLineRight: (cm: Editor) => void;
Move the cursor to the right side of the visual line it is on.
method goLineStart
goLineStart: (cm: Editor) => void;
Move the cursor to the start of the line.
method goLineStartSmart
goLineStartSmart: (cm: Editor) => void;
Move to the start of the text on the line, or if we are already there, to the actual start of the line (including whitespace).
method goLineUp
goLineUp: (cm: Editor) => void;
Move the cursor up one line.
method goPageDown
goPageDown: (cm: Editor) => void;
Move the cursor down one screen, and scroll down by the same distance.
method goPageUp
goPageUp: (cm: Editor) => void;
Move the cursor up one screen, and scroll up by the same distance.
method goWordLeft
goWordLeft: (cm: Editor) => void;
Move the cursor to the start of the previous word.
method goWordRight
goWordRight: (cm: Editor) => void;
Move the cursor to the end of the next word.
method indentAuto
indentAuto: (cm: Editor) => void;
Auto-indent the current line or selection.
method indentLess
indentLess: (cm: Editor) => void;
Dedent the current line or selection by one indent unit.
method indentMore
indentMore: (cm: Editor) => void;
Indent the current line or selection by one indent unit.
method insertSoftTab
insertSoftTab: (cm: Editor) => void;
Insert the amount of spaces that match the width a tab at the cursor position would have.
method insertTab
insertTab: (cm: Editor) => void;
Insert a tab character at the cursor.
method killLine
killLine: (cm: Editor) => void;
Emacs-style line killing. Deletes the part of the line after the cursor. If that consists only of whitespace, the newline at the end of the line is also deleted.
method newlineAndIndent
newlineAndIndent: (cm: Editor) => void;
Insert a newline and auto-indent the new line.
method redo
redo: (cm: Editor) => void;
Redo the last undone change.
method redoSelection
redoSelection: (cm: Editor) => void;
Redo the last change to the selection, or the last text change if no selection changes remain.
method selectAll
selectAll: (cm: Editor) => void;
Select the whole content of the editor.
method singleSelection
singleSelection: (cm: Editor) => void;
When multiple selections are present, this deselects all but the primary selection.
method toggleOverwrite
toggleOverwrite: (cm: Editor) => void;
Flip the overwrite flag.
method transposeChars
transposeChars: (cm: Editor) => void;
Swap the characters before and after the cursor.
method undo
undo: (cm: Editor) => void;
Undo the last change. Note that, because browsers still don't make it possible for scripts to react to or customize the context menu, selecting undo (or redo) from the context menu in a CodeMirror instance does not work.
method undoSelection
undoSelection: (cm: Editor) => void;
Undo the last change to the selection, or if there are no selection-only changes at the top of the history, undo the last change.
interface CommandActions
interface CommandActions {}
method toggleComment
toggleComment: (cm: Editor) => void;
interface CommandActions
interface CommandActions {}
method closeTag
closeTag: (cm: Editor) => void;
interface CommandActions
interface CommandActions {}
method newlineAndIndentContinueMarkdownList
newlineAndIndentContinueMarkdownList: (cm: Editor) => void | typeof Pass;
interface CommandActions
interface CommandActions {}
method toMatchingTag
toMatchingTag: (cm: Editor) => void;
You can bind a key to in order to jump to the tag matching the one under the cursor.
interface CommandActions
interface CommandActions {}
method fold
fold: (cm: Editor) => void;
method foldAll
foldAll: (cm: Editor) => void;
method toggleFold
toggleFold: (cm: Editor) => void;
method unfold
unfold: (cm: Editor) => void;
method unfoldAll
unfoldAll: (cm: Editor) => void;
interface CommandActions
interface CommandActions {}
property autocomplete
autocomplete: typeof showHint;
interface CommandActions
interface CommandActions {}
method goNextDiff
goNextDiff: (cm: Editor) => void;
Move cursor to the next diff
method goPrevDiff
goPrevDiff: (cm: Editor) => void;
Move cursor to the previous diff
interface CommandActions
interface CommandActions {}
method jumpToLine
jumpToLine: (cm: Editor) => void;
interface CommandActions
interface CommandActions {}
method clearSearch
clearSearch: (cm: Editor) => void;
method find
find: (cm: Editor) => void;
method findNext
findNext: (cm: Editor) => void;
method findPersistent
findPersistent: (cm: Editor) => void;
method findPersistentNext
findPersistentNext: (cm: Editor) => void;
method findPersistentPrev
findPersistentPrev: (cm: Editor) => void;
method findPrev
findPrev: (cm: Editor) => void;
method replace
replace: (cm: Editor) => void;
method replaceAll
replaceAll: (cm: Editor) => void;
interface CommandActions
interface CommandActions {}
method wrapLines
wrapLines: (cm: Editor) => void;
interface CommentOptions
interface CommentOptions {}
property blockCommentEnd
blockCommentEnd?: string | undefined;
Override the [comment string properties](https://codemirror.net/doc/manual.html#mode_comment) of the mode with custom comment strings.
property blockCommentLead
blockCommentLead?: string | undefined;
Override the [comment string properties](https://codemirror.net/doc/manual.html#mode_comment) of the mode with custom comment strings.
property blockCommentStart
blockCommentStart?: string | undefined;
Override the [comment string properties](https://codemirror.net/doc/manual.html#mode_comment) of the mode with custom comment strings.
property commentBlankLines
commentBlankLines?: boolean | undefined;
Whether, when adding line comments, to also comment lines that contain only whitespace.
property fullLines
fullLines?: boolean | undefined;
When block commenting, this controls whether the whole lines are indented, or only the precise range that is given. Defaults to
true
.
property indent
indent?: boolean | undefined;
When adding line comments and this is turned on, it will align the comment block to the current indentation of the first line of the block.
property lineComment
lineComment?: string | undefined;
Override the [comment string properties](https://codemirror.net/doc/manual.html#mode_comment) of the mode with custom comment strings.
property padding
padding?: string | null | undefined;
A string that will be inserted after opening and leading markers, and before closing comment markers. Defaults to a single space.
interface CompletionEventMap
interface CompletionEventMap {}
interface CompletionHandle
interface CompletionHandle {}
The Handle used to interact with the autocomplete dialog box.
interface Doc
interface Doc extends DocOrEditor {}
method copy
copy: (copyHistory: boolean) => Doc;
Create an identical copy of the given doc. When copyHistory is true , the history will also be copied.
method getEditor
getEditor: () => Editor | null;
Retrieve the editor associated with a document. May return null.
method off
off: <T extends keyof DocEventMap>( eventName: T, handler: DocEventMap[T]) => void;
method on
on: <T extends keyof DocEventMap>(eventName: T, handler: DocEventMap[T]) => void;
interface DocConstructor
interface DocConstructor {}
construct signature
new ( text: string, mode?: string | ModeSpec<ModeSpecOptions>, firstLineNumber?: number, lineSep?: string): Doc;
call signature
( text: string, mode?: string | ModeSpec<ModeSpecOptions>, firstLineNumber?: number, lineSep?: string): Doc;
interface DocEventMap
interface DocEventMap {}
property beforeChange
beforeChange: (instance: Doc, changeObj: EditorChangeCancellable) => void;
property beforeSelectionChange
beforeSelectionChange: (instance: Doc, obj: EditorSelectionChange) => void;
property change
change: (instance: Doc, changeObj: EditorChange) => void;
property cursorActivity
cursorActivity: (instance: Doc) => void;
interface DocOrEditor
interface DocOrEditor {}
property modeOption
modeOption: string | ModeSpec<ModeSpecOptions>;
Get the mode option
property state
state: any;
Expose the state object, so that the Doc.state.completionActive property is reachable
method addLineWidget
addLineWidget: ( line: any, node: HTMLElement, options?: LineWidgetOptions) => LineWidget;
Adds a line widget, an element shown below a line, spanning the whole of the editor's width, and moving the lines below it downwards. line should be either an integer or a line handle, and node should be a DOM node, which will be displayed below the given line. options, when given, should be an object that configures the behavior of the widget. Note that the widget node will become a descendant of nodes with CodeMirror-specific CSS classes, and those classes might in some cases affect it.
method addSelection
addSelection: (anchor: Position, head?: Position) => void;
Adds a new selection to the existing set of selections, and makes it the primary selection.
method changeGeneration
changeGeneration: (closeEvent?: boolean) => number;
Returns a number that can later be passed to isClean to test whether any edits were made (and not undone) in the meantime. If closeEvent is true, the current history event will be ‘closed’, meaning it can't be combined with further changes (rapid typing or deleting events are typically combined).
method clearHistory
clearHistory: () => void;
Clears the editor's undo history.
method eachLine
eachLine: { (f: (line: LineHandle) => void): void; (start: number, end: number, f: (line: LineHandle) => void): void;};
Iterate over the whole document, and call f for each line, passing the line handle. This is a faster way to visit a range of line handlers than calling getLineHandle for each of them. Note that line handles have a text property containing the line's content (as a string).
Iterate over the range from start up to (not including) end, and call f for each line, passing the line handle. This is a faster way to visit a range of line handlers than calling getLineHandle for each of them. Note that line handles have a text property containing the line's content (as a string).
method extendSelection
extendSelection: ( from: Position, to?: Position, options?: SelectionOptions) => void;
Similar to setSelection, but will, if shift is held or the extending flag is set, move the head of the selection while leaving the anchor at its current place. to is optional, and can be passed to ensure a region (for example a word or paragraph) will end up selected (in addition to whatever lies between that region and the current anchor). When multiple selections are present, all but the primary selection will be dropped by this method. Supports the same options as setSelection.
method extendSelections
extendSelections: (heads: Position[], options?: SelectionOptions) => void;
An equivalent of extendSelection that acts on all selections at once.
method extendSelectionsBy
extendSelectionsBy: (f: (range: Range) => Position) => void;
Applies the given function to all existing selections, and calls extendSelections on the result.
method findMarks
findMarks: (from: Position, to: Position) => TextMarker[];
Returns an array of all the bookmarks and marked ranges found between the given positions.
method findMarksAt
findMarksAt: (pos: Position) => TextMarker[];
Returns an array of all the bookmarks and marked ranges present at the given position.
method firstLine
firstLine: () => number;
Get the first line of the editor. This will usually be zero but for linked sub-views, or documents instantiated with a non-zero first line, it might return other values.
method getAllMarks
getAllMarks: () => TextMarker[];
Returns an array containing all marked ranges in the document.
method getCursor
getCursor: (start?: string) => Position;
start is a an optional string indicating which end of the selection to return. It may be "from", "to", "head" (the side of the selection that moves when you press shift+arrow), or "anchor" (the fixed side of the selection).Omitting the argument is the same as passing "head". A {line, ch} object will be returned.
method getExtending
getExtending: () => boolean;
Get the value of the 'extending' flag.
method getHistory
getHistory: () => any;
Get a (JSON - serializeable) representation of the undo history.
method getLine
getLine: (n: number) => string;
Get the content of line n.
method getLineHandle
getLineHandle: (num: number) => LineHandle;
Fetches the line handle for the given line number.
method getLineNumber
getLineNumber: (handle: LineHandle) => number | null;
Given a line handle, returns the current position of that line (or null when it is no longer in the document).
method getMode
getMode: () => Mode<unknown>;
Gets the mode object for the editor. Note that this is distinct from getOption("mode"), which gives you the mode specification, rather than the resolved, instantiated mode object.
method getRange
getRange: (from: Position, to: Position, seperator?: string) => string;
Get the text between the given points in the editor, which should be {line, ch} objects. An optional third argument can be given to indicate the line separator string to use (defaults to "\n").
method getSelection
getSelection: () => string;
Get the currently selected code.
method getSelections
getSelections: (lineSep?: string) => string[];
Returns an array containing a string for each selection, representing the content of the selections.
method getValue
getValue: (seperator?: string) => string;
Get the current editor content. You can pass it an optional argument to specify the string to be used to separate lines (defaults to "\n").
method historySize
historySize: () => { undo: number; redo: number };
Returns an object with {undo, redo } properties , both of which hold integers , indicating the amount of stored undo and redo operations.
method indexFromPos
indexFromPos: (object: Position) => number;
The reverse of posFromIndex.
method isClean
isClean: (generation?: number) => boolean;
Returns whether the document is currently clean — not modified since initialization or the last call to markClean if no argument is passed, or since the matching call to changeGeneration if a generation value is given.
method iterLinkedDocs
iterLinkedDocs: (fn: (doc: Doc, sharedHist: boolean) => void) => void;
Will call the given function for all documents linked to the target document. It will be passed two arguments, the linked document and a boolean indicating whether that document shares history with the target.
method lastLine
lastLine: () => number;
Get the last line of the editor. This will usually be lineCount() - 1, but for linked sub-views, it might return other values.
method lineCount
lineCount: () => number;
Get the number of lines in the editor.
method lineSeparator
lineSeparator: () => string;
Returns the preferred line separator string for this document, as per the option by the same name. When that option is null, the string "\n" is returned.
method linkedDoc
linkedDoc: (options: { sharedHist?: boolean | undefined; from?: number | undefined; to?: number | undefined; mode?: string | ModeSpec<ModeSpecOptions> | undefined;}) => Doc;
Create a new document that's linked to the target document. Linked documents will stay in sync (changes to one are also applied to the other) until unlinked.
method listSelections
listSelections: () => Range[];
Retrieves a list of all current selections. These will always be sorted, and never overlap (overlapping selections are merged). Each object in the array contains anchor and head properties referring to {line, ch} objects.
method markClean
markClean: () => void;
Set the editor content as 'clean', a flag that it will retain until it is edited, and which will be set again when such an edit is undone again. Useful to track whether the content needs to be saved. This function is deprecated in favor of changeGeneration, which allows multiple subsystems to track different notions of cleanness without interfering.
method markText
markText: ( from: Position, to: Position, options?: TextMarkerOptions) => TextMarker<MarkerRange>;
Can be used to mark a range of text with a specific CSS class name. from and to should be { line , ch } objects.
method posFromIndex
posFromIndex: (index: number) => Position;
Calculates and returns a { line , ch } object for a zero-based index whose value is relative to the start of the editor's text. If the index is out of range of the text then the returned object is clipped to start or end of the text respectively.
method redo
redo: () => void;
Redo one undone edit.
method redoSelection
redoSelection: () => void;
Redo one undone edit or selection change.
method removeLine
removeLine: (n: number) => void;
Remove the given line from the document.
method removeLineWidget
removeLineWidget: (widget: LineWidget) => void;
Remove the line widget
method replaceRange
replaceRange: ( replacement: string | string[], from: Position, to?: Position, origin?: string) => void;
Replace the part of the document between from and to with the given string. from and to must be {line, ch} objects. to can be left off to simply insert the string at position from.
method replaceSelection
replaceSelection: (replacement: string, collapse?: string) => void;
Replace the selection with the given string. By default, the new selection will span the inserted text. The optional collapse argument can be used to change this -- passing "start" or "end" will collapse the selection to the start or end of the inserted text.
method replaceSelections
replaceSelections: (replacements: string[], collapse?: string) => void;
Replaces the content of the selections with the strings in the array. The length of the given array should be the same as the number of active selections. The collapse argument works the same as in replaceSelection.
method setBookmark
setBookmark: ( pos: Position, options?: { widget?: HTMLElement | undefined; insertLeft?: boolean | undefined; shared?: boolean | undefined; handleMouseEvents?: boolean | undefined; }) => TextMarker<Position>;
Inserts a bookmark, a handle that follows the text around it as it is being edited, at the given position. A bookmark has two methods find() and clear(). The first returns the current position of the bookmark, if it is still in the document, and the second explicitly removes the bookmark.
method setCursor
setCursor: ( pos: Position | number, ch?: number, options?: { bias?: number | undefined; origin?: string | undefined; scroll?: boolean | undefined; }) => void;
Set the cursor position. You can either pass a single {line, ch} object, or the line and the character as two separate parameters. Will replace all selections with a single, empty selection at the given position. The supported options are the same as for setSelection
method setExtending
setExtending: (value: boolean) => void;
Sets or clears the 'extending' flag , which acts similar to the shift key, in that it will cause cursor movement and calls to extendSelection to leave the selection anchor in place.
method setHistory
setHistory: (history: any) => void;
Replace the editor's undo history with the one provided, which must be a value as returned by getHistory. Note that this will have entirely undefined results if the editor content isn't also the same as it was when getHistory was called.
method setLine
setLine: (n: number, text: string) => void;
Set the content of line n.
method setSelection
setSelection: ( anchor: Position, head?: Position, options?: { bias?: number | undefined; origin?: string | undefined; scroll?: boolean | undefined; }) => void;
Set a single selection range. anchor and head should be {line, ch} objects. head defaults to anchor when not given.
method setSelections
setSelections: ( ranges: Array<{ anchor: Position; head: Position }>, primary?: number, options?: SelectionOptions) => void;
Sets a new set of selections. There must be at least one selection in the given array. When primary is a number, it determines which selection is the primary one. When it is not given, the primary index is taken from the previous selection, or set to the last range if the previous selection had less ranges than the new one. Supports the same options as setSelection.
method setValue
setValue: (content: string) => void;
Set the editor content.
method somethingSelected
somethingSelected: () => boolean;
Return true if any text is selected.
method undo
undo: () => void;
Undo one edit (if any undo events are stored).
method undoSelection
undoSelection: () => void;
Undo one edit or selection change.
method unlinkDoc
unlinkDoc: (doc: Doc) => void;
Break the link between two documents. After calling this , changes will no longer propagate between the documents, and, if they had a shared history, the history will become separate.
interface DocOrEditor
interface DocOrEditor {}
method getSearchCursor
getSearchCursor: ( query: string | RegExp, start?: Position, caseFold?: boolean) => SearchCursor;
This method can be used to implement search/replace functionality.
query
: This can be a regular * expression or a string (only strings will match across lines - if they contain newlines).start
: This provides the starting position of the search. It can be a `{line, ch} object, or can be left off to default to the start of the documentcaseFold
: This is only relevant when matching a string. IT will cause the search to be case-insenstive
interface Editor
interface Editor extends DocOrEditor {}
Methods prefixed with doc. can, unless otherwise specified, be called both on CodeMirror (editor) instances and CodeMirror.Doc instances. Thus, the Editor interface extends DocOrEditor defining the common API.
property state
state: any;
Expose the state object, so that the Editor.state.completionActive property is reachable
method addKeyMap
addKeyMap: (map: string | KeyMap, bottom?: boolean) => void;
Attach an additional keymap to the editor. This is mostly useful for add - ons that need to register some key handlers without trampling on the extraKeys option. Maps added in this way have a higher precedence than the extraKeys and keyMap options, and between them, the maps added earlier have a lower precedence than those added later, unless the bottom argument was passed, in which case they end up below other keymaps added with this method.
method addLineClass
addLineClass: (line: any, where: string, _class_: string) => LineHandle;
Set a CSS class name for the given line.line can be a number or a line handle. where determines to which element this class should be applied, can can be one of "text" (the text element, which lies in front of the selection), "background"(a background element that will be behind the selection), or "wrap" (the wrapper node that wraps all of the line's elements, including gutter elements). class should be the name of the class to apply.
method addLineWidget
addLineWidget: ( line: any, node: HTMLElement, options?: LineWidgetOptions) => LineWidget;
Adds a line widget, an element shown below a line, spanning the whole of the editor's width, and moving the lines below it downwards. line should be either an integer or a line handle, and node should be a DOM node, which will be displayed below the given line. options, when given, should be an object that configures the behavior of the widget. Note that the widget node will become a descendant of nodes with CodeMirror-specific CSS classes, and those classes might in some cases affect it.
method addOverlay
addOverlay: ( mode: any, options?: { opaque?: boolean | undefined; priority?: number | undefined }) => void;
Enable a highlighting overlay.This is a stateless mini-mode that can be used to add extra highlighting. For example, the search add - on uses it to highlight the term that's currently being searched. mode can be a mode spec or a mode object (an object with a token method). The options parameter is optional. If given, it should be an object. Currently, only the opaque option is recognized. This defaults to off, but can be given to allow the overlay styling, when not null, to override the styling of the base mode entirely, instead of the two being applied together.
method addWidget
addWidget: (pos: Position, node: HTMLElement, scrollIntoView: boolean) => void;
Puts node, which should be an absolutely positioned DOM node, into the editor, positioned right below the given { line , ch } position. When scrollIntoView is true, the editor will ensure that the entire node is visible (if possible). To remove the widget again, simply use DOM methods (move it somewhere else, or call removeChild on its parent).
method charCoords
charCoords: ( pos: Position, mode?: CoordsMode) => { left: number; right: number; top: number; bottom: number };
Returns the position and dimensions of an arbitrary character. pos should be a { line , ch } object. If mode is "local", they will be relative to the top-left corner of the editable document. If it is "page" or not given, they are relative to the top-left corner of the page. This differs from cursorCoords in that it'll give the size of the whole character, rather than just the position that the cursor would have when it would sit at that position.
method clearGutter
clearGutter: (gutterID: string) => void;
Remove all gutter markers in the gutter with the given ID.
method coordsChar
coordsChar: ( object: { left: number; top: number }, mode?: CoordsMode) => Position;
Given an { left , top } object , returns the { line , ch } position that corresponds to it. The optional mode parameter determines relative to what the coordinates are interpreted. It may be "window", "page" (the default), or "local".
method cursorCoords
cursorCoords: ( where?: boolean | Position | null, mode?: CoordsMode) => { left: number; top: number; bottom: number };
Returns an { left , top , bottom } object containing the coordinates of the cursor position. If mode is "local", they will be relative to the top-left corner of the editable document. If it is "page" or not given, they are relative to the top-left corner of the page. where specifies the position at which you want to measure. A boolean indicates either the start(true) or the end(false) of the selection.
method defaultCharWidth
defaultCharWidth: () => number;
Returns the pixel width of an 'x' in the default font for the editor. (Note that for non-monospace fonts, this is mostly useless, and even for monospace fonts, non-ascii characters might have a different width).
method defaultTextHeight
defaultTextHeight: () => number;
Returns the line height of the default font for the editor.
method endOperation
endOperation: () => void;
method execCommand
execCommand: (name: string) => void;
Runs the command with the given name on the editor.
method findPosH
findPosH: ( start: Position, amount: number, unit: string, visually: boolean) => { line: number; ch: number; hitSide?: boolean | undefined };
Used to find the target position for horizontal cursor motion.start is a { line , ch } object, an integer(may be negative), and unit one of the string "char", "column", or "word". Will return a position that is produced by moving amount times the distance specified by unit. When visually is true , motion in right - to - left text will be visual rather than logical. When the motion was clipped by hitting the end or start of the document, the returned value will have a hitSide property set to true.
method findPosV
findPosV: ( start: Position, amount: number, unit: string) => { line: number; ch: number; hitSide?: boolean | undefined };
Similar to findPosH , but used for vertical motion.unit may be "line" or "page". The other arguments and the returned value have the same interpretation as they have in findPosH.
method findWordAt
findWordAt: (pos: Position) => Range;
Returns the start and end of the 'word' (the stretch of letters, whitespace, or punctuation) at the given position.
method focus
focus: () => void;
Give the editor focus.
method getCursor
getCursor: (start?: string) => Position;
start is a an optional string indicating which end of the selection to return. It may be "from", "to", "head" (the side of the selection that moves when you press shift+arrow), or "anchor" (the fixed side of the selection).Omitting the argument is the same as passing "head". A {line, ch} object will be returned.
method getDoc
getDoc: () => Doc;
Retrieve the currently active document from an editor.
method getGutterElement
getGutterElement: () => HTMLElement;
Fetches the DOM node that contains the editor gutters.
method getInputField
getInputField: () => HTMLTextAreaElement;
Returns the hidden textarea used to read input.
method getLineTokens
getLineTokens: (line: number, precise?: boolean) => Token[];
This is similar to getTokenAt, but collects all tokens for a given line into an array.
method getModeAt
getModeAt: (pos: Position) => Mode<unknown>;
Gets the inner mode at a given position. This will return the same as getMode for simple modes, but will return an inner mode for nesting modes (such as htmlmixed).
method getOption
getOption: <K extends keyof EditorConfiguration>( option: K) => EditorConfiguration[K];
Retrieves the current value of the given option for this editor instance.
method getScrollerElement
getScrollerElement: () => HTMLElement;
Returns the DOM node that is responsible for the scrolling of the editor.
method getScrollInfo
getScrollInfo: () => ScrollInfo;
Get an { left , top , width , height , clientWidth , clientHeight } object that represents the current scroll position, the size of the scrollable area, and the size of the visible area(minus scrollbars).
method getStateAfter
getStateAfter: (line?: number) => any;
Returns the mode's parser state, if any, at the end of the given line number. If no line number is given, the state at the end of the document is returned. This can be useful for storing parsing errors in the state, or getting other kinds of contextual information for a line.
method getTokenAt
getTokenAt: (pos: Position, precise?: boolean) => Token;
Retrieves information about the token the current mode found before the given position (a {line, ch} object).
method getTokenTypeAt
getTokenTypeAt: (pos: Position) => string;
This is a (much) cheaper version of getTokenAt useful for when you just need the type of the token at a given position, and no other information. Will return null for unstyled tokens, and a string, potentially containing multiple space-separated style names, otherwise.
method getValue
getValue: (seperator?: string) => string;
Get the content of the current editor document. You can pass it an optional argument to specify the string to be used to separate lines (defaults to "\n").
method getViewport
getViewport: () => { from: number; to: number };
Returns a { from , to } object indicating the start (inclusive) and end (exclusive) of the currently rendered part of the document. In big documents, when most content is scrolled out of view, CodeMirror will only render the visible part, and a margin around it. See also the viewportChange event.
method getWrapperElement
getWrapperElement: () => HTMLElement;
Returns the DOM node that represents the editor, and controls its size. Remove this from your tree to delete an editor instance.
method hasFocus
hasFocus: () => boolean;
Tells you whether the editor currently has focus.
method heightAtLine
heightAtLine: (line: any, mode?: CoordsMode, includeWidgets?: boolean) => number;
Computes the height of the top of a line, in the coordinate system specified by mode, it may be "window", "page" (the default), or "local". When a line below the bottom of the document is specified, the returned value is the bottom of the last line in the document. By default, the position of the actual text is returned. If includeWidgets is true and the line has line widgets, the position above the first line widget is returned.
method indentLine
indentLine: (line: number, dir?: string) => void;
Adjust the indentation of the given line. The second argument (which defaults to "smart") may be one of: "prev" Base indentation on the indentation of the previous line. "smart" Use the mode's smart indentation if available, behave like "prev" otherwise. "add" Increase the indentation of the line by one indent unit. "subtract" Reduce the indentation of the line.
method indentSelection
indentSelection: (how: string) => void;
Indent a selection
method isReadOnly
isReadOnly: () => boolean;
Tells you whether the editor's content can be edited by the user.
method lineAtHeight
lineAtHeight: (height: number, mode?: CoordsMode) => number;
Compute the line at the given pixel height. mode is the relative element to use to compute this line, it may be "window", "page" (the default), or "local"
method lineInfo
lineInfo: (line: any) => { line: any; handle: any; text: string; gutterMarkers: any; textClass: string; bgClass: string; wrapClass: string; widgets: any;};
Returns the line number, text content, and marker status of the given line, which can be either a number or a line handle.
method off
off: { <T extends keyof EditorEventMap>( eventName: T, handler: EditorEventMap[T] ): void; < K extends | 'mousedown' | 'dblclick' | 'touchstart' | 'contextmenu' | 'keydown' | 'keypress' | 'keyup' | 'dragstart' | 'dragenter' | 'dragover' | 'dragleave' | 'drop' >( eventName: K, handler: ( instance: Editor, event: GlobalEventHandlersEventMap[K] ) => void ): void;};
method on
on: { <T extends keyof EditorEventMap>( eventName: T, handler: EditorEventMap[T] ): void; < K extends | 'mousedown' | 'dblclick' | 'touchstart' | 'contextmenu' | 'keydown' | 'keypress' | 'keyup' | 'dragstart' | 'dragenter' | 'dragover' | 'dragleave' | 'drop' >( eventName: K, handler: ( instance: Editor, event: GlobalEventHandlersEventMap[K] ) => void ): void;};
method operation
operation: <T>(fn: () => T) => T;
CodeMirror internally buffers changes and only updates its DOM structure after it has finished performing some operation. If you need to perform a lot of operations on a CodeMirror instance, you can call this method with a function argument. It will call the function, buffering up all changes, and only doing the expensive update after the function returns. This can be a lot faster. The return value from this method will be the return value of your function.
method phrase
phrase: (text: string) => unknown;
Allow the given string to be translated with the phrases option.
method refresh
refresh: () => void;
If your code does something to change the size of the editor element (window resizes are already listened for), or unhides it, you should probably follow up by calling this method to ensure CodeMirror is still looking as intended.
method removeKeyMap
removeKeyMap: (map: string | KeyMap) => void;
Disable a keymap added with addKeyMap.Either pass in the keymap object itself , or a string, which will be compared against the name property of the active keymaps.
method removeLineClass
removeLineClass: (line: any, where: string, class_?: string) => LineHandle;
Remove a CSS class from a line.line can be a line handle or number. where should be one of "text", "background", or "wrap"(see addLineClass). class can be left off to remove all classes for the specified node, or be a string to remove only a specific class.
method removeOverlay
removeOverlay: (mode: any) => void;
Pass this the exact argument passed for the mode parameter to addOverlay to remove an overlay again.
method scrollIntoView
scrollIntoView: ( pos: | Position | null | { line: number; ch: number } | { left: number; top: number; right: number; bottom: number } | { from: Position; to: Position }, margin?: number) => void;
Scrolls the given element into view. pos can be: - a { line , ch } position, referring to a given character - null, to refer to the cursor - a { left , top , right , bottom } object, in editor-local coordinates - a { from, to } object, in editor-local coordinates The margin parameter is optional. When given, it indicates the amount of pixels around the given area that should be made visible as well.
method scrollTo
scrollTo: (x?: number | null, y?: number | null) => void;
Scroll the editor to a given(pixel) position.Both arguments may be left as null or undefined to have no effect.
method setCursor
setCursor: ( pos: Position | number, ch?: number, options?: { bias?: number | undefined; origin?: string | undefined; scroll?: boolean | undefined; }) => void;
Set the cursor position. You can either pass a single {line, ch} object, or the line and the character as two separate parameters. Will replace all selections with a single, empty selection at the given position. The supported options are the same as for setSelection
method setGutterMarker
setGutterMarker: ( line: any, gutterID: string, value: HTMLElement | null) => LineHandle;
Sets the gutter marker for the given gutter (identified by its CSS class, see the gutters option) to the given value. Value can be either null, to clear the marker, or a DOM element, to set it. The DOM element will be shown in the specified gutter next to the specified line.
method setOption
setOption: <K extends keyof EditorConfiguration>( option: K, value: EditorConfiguration[K]) => void;
Change the configuration of the editor. option should the name of an option, and value should be a valid value for that option.
method setSize
setSize: (width: any, height: any) => void;
Programatically set the size of the editor (overriding the applicable CSS rules). width and height height can be either numbers(interpreted as pixels) or CSS units ("100%", for example). You can pass null for either of them to indicate that that dimension should not be changed.
method setValue
setValue: (content: string) => void;
Set the content of the current editor document.
method startOperation
startOperation: () => void;
In normal circumstances, use the above operation method. But if you want to buffer operations happening asynchronously, or that can't all be wrapped in a callback function, you can call startOperation to tell CodeMirror to start buffering changes, and endOperation to actually render all the updates. Be careful: if you use this API and forget to call endOperation, the editor will just never update.
method swapDoc
swapDoc: (doc: Doc) => Doc;
Attach a new document to the editor. Returns the old document, which is now no longer associated with an editor.
method toggleOverwrite
toggleOverwrite: (value?: boolean) => void;
Switches between overwrite and normal insert mode (when not given an argument), or sets the overwrite mode to a specific state (when given an argument).
interface Editor
interface Editor {}
method blockComment
blockComment: (from: Position, to: Position, options?: CommentOptions) => void;
Wrap the code in the given range in a block comment. Will fall back to
lineComment
when no block comment style is defined for the mode.
method lineComment
lineComment: (from: Position, to: Position, options?: CommentOptions) => void;
Set the lines in the given range to be line comments. Will fall back to
blockComment
when no line comment style is defined for the mode.
method toggleComment
toggleComment: (options?: CommentOptions) => void;
Tries to uncomment the current selection, and if that fails, line-comments it.
method uncomment
uncomment: (from: Position, to: Position, options?: CommentOptions) => boolean;
Try to uncomment the given range. Returns
true
if a comment range was found and removed,false
otherwise.
interface Editor
interface Editor {}
method openConfirm
openConfirm: ( template: string | Node, callbacks: readonly ((editor: Editor) => void)[], options?: DialogOptions) => DialogCloseFunction;
method openDialog
openDialog: ( template: string | Node, callback: (value: string, e: Event) => void, options?: OpenDialogOptions) => DialogCloseFunction;
Provides a very simple way to query users for text input.
method openNotification
openNotification: ( template: string | Node, options?: OpenNotificationOptions) => DialogCloseFunction;
interface Editor
interface Editor {}
method addPanel
addPanel: (node: HTMLElement, options?: ShowPanelOptions) => Panel;
Places a DOM node above or below an editor and shrinks the editor to make room for the node. When using the
after
,before
orreplace
options, if the panel doesn't exists or has been removed, the value of theposition
option will be used as a fallback.Parameter node
the DOM node
Parameter options
optional options object
interface Editor
interface Editor {}
property foldCode
foldCode: ( lineOrPos: number | Position, rangeFindeOrFoldOptions?: FoldRangeFinder | FoldOptions, force?: 'fold' | 'unfold') => void;
Helps with code folding. Adds a foldCode method to editor instances, which will try to do a code fold starting at the given line, or unfold the fold that is already present. The method takes as first argument the position that should be folded (may be a line number or a Pos), and as second optional argument either a range-finder function, or an options object.
method foldOption
foldOption: <K extends keyof FoldOptions>(option: K) => FoldOptions[K];
method isFolded
isFolded: (pos: Position) => boolean | undefined;
interface Editor
interface Editor {}
interface Editor
interface Editor {}
property performLint
performLint: () => void;
interface Editor
interface Editor {}
method annotateScrollbar
annotateScrollbar: (options: string | AnnotateScrollbarOptions) => Annotation;
interface Editor
interface Editor {}
method showMatchesOnScrollbar
showMatchesOnScrollbar: ( query: string | RegExp, caseFold?: boolean, className?: string) => SearchAnnotation;
interface Editor
interface Editor {}
method wrapParagraph
wrapParagraph: (pos?: Position, options?: HardwrapOptions) => void;
Wraps the paragraph at the given position. If pos is not given, it defaults to the cursor position.
method wrapParagraphsInRange
wrapParagraphsInRange: ( from: Position, to: Position, options?: HardwrapOptions) => void;
Wraps the paragraphs in (and overlapping with) the given range individually.
method wrapRange
wrapRange: (from: Position, to: Position, options?: HardwrapOptions) => void;
Wraps the given range as one big paragraph.
interface EditorChange
interface EditorChange {}
property from
from: Position;
Position (in the pre-change coordinate system) where the change started.
property origin
origin?: string | undefined;
String representing the origin of the change event and whether it can be merged with history
property removed
removed?: string[] | undefined;
Text that used to be between from and to, which is overwritten by this change.
property text
text: string[];
Array of strings representing the text that replaced the changed range (split by line).
property to
to: Position;
Position (in the pre-change coordinate system) where the change ended.
interface EditorChangeCancellable
interface EditorChangeCancellable extends EditorChange {}
method cancel
cancel: () => void;
method update
update: (from?: Position, to?: Position, text?: string[]) => void;
may be used to modify the change. All three arguments to update are optional, and can be left off to leave the existing value for that field intact. If the change came from undo/redo,
update
is undefined and the change cannot be modified.
interface EditorConfiguration
interface EditorConfiguration {}
property addModeClass
addModeClass?: boolean | undefined;
When enabled (off by default), an extra CSS class will be added to each token, indicating the (inner) mode that produced it, prefixed with "cm-m-". For example, tokens from the XML mode will get the cm-m-xml class.
property allowDropFileTypes
allowDropFileTypes?: string[] | null | undefined;
When set (default is null) only files whose type is in the array can be dropped into the editor. The strings should be MIME types, and will be checked against the type of the File object as reported by the browser.
property autocapitalize
autocapitalize?: boolean | undefined;
Specifies whether or not autocapitalization will be enabled on the input.
property autocorrect
autocorrect?: boolean | undefined;
Specifies whether or not autocorrect will be enabled on the input.
property autofocus
autofocus?: boolean | undefined;
Can be used to make CodeMirror focus itself on initialization. Defaults to off. When fromTextArea is used, and no explicit value is given for this option, it will be set to true when either the source textarea is focused, or it has an autofocus attribute and no other element is focused.
property configureMouse
configureMouse?: | (( cm: Editor, repeat: 'single' | 'double' | 'triple', event: Event ) => MouseSelectionConfiguration) | undefined;
Allows you to configure the behavior of mouse selection and dragging. The function is called when the left mouse button is pressed.
property coverGutterNextToScrollbar
coverGutterNextToScrollbar?: boolean | undefined;
When fixedGutter is on, and there is a horizontal scrollbar, by default the gutter will be visible to the left of this scrollbar. If this option is set to true, it will be covered by an element with class CodeMirror-gutter-filler.
property cursorBlinkRate
cursorBlinkRate?: number | undefined;
Half - period in milliseconds used for cursor blinking. The default blink rate is 530ms.
property cursorHeight
cursorHeight?: number | undefined;
Determines the height of the cursor. Default is 1 , meaning it spans the whole height of the line. For some fonts (and by some tastes) a smaller height (for example 0.85), which causes the cursor to not reach all the way to the bottom of the line, looks better
property cursorScrollMargin
cursorScrollMargin?: number | undefined;
How much extra space to always keep above and below the cursor when approaching the top or bottom of the visible view in a scrollable document. Default is 0.
property direction
direction?: 'ltr' | 'rtl' | undefined;
Flips overall layout and selects base paragraph direction to be left-to-right or right-to-left. Default is "ltr". CodeMirror applies the Unicode Bidirectional Algorithm to each line, but does not autodetect base direction — it's set to the editor direction for all lines. The resulting order is sometimes wrong when base direction doesn't match user intent (for example, leading and trailing punctuation jumps to the wrong side of the line). Therefore, it's helpful for multilingual input to let users toggle this option.
property dragDrop
dragDrop?: boolean | undefined;
Controls whether drag-and - drop is enabled. On by default.
property electricChars
electricChars?: boolean | undefined;
Configures whether the editor should re-indent the current line when a character is typed that might change its proper indentation (only works if the mode supports indentation). Default is true.
property extraKeys
extraKeys?: string | KeyMap | undefined;
Can be used to specify extra keybindings for the editor, alongside the ones defined by keyMap. Should be either null, or a valid keymap value.
property firstLineNumber
firstLineNumber?: number | undefined;
At which number to start counting lines. Default is 1.
property fixedGutter
fixedGutter?: boolean | undefined;
Determines whether the gutter scrolls along with the content horizontally (false) or whether it stays fixed during horizontal scrolling (true, the default).
property flattenSpans
flattenSpans?: boolean | undefined;
By default, CodeMirror will combine adjacent tokens into a single span if they have the same class. This will result in a simpler DOM tree, and thus perform better. With some kinds of styling(such as rounded corners), this will change the way the document looks. You can set this option to false to disable this behavior.
property gutters
gutters?: | Array<string | { className: string; style?: string | undefined }> | undefined;
Can be used to add extra gutters (beyond or instead of the line number gutter). Should be an array of CSS class names, each of which defines a width (and optionally a background), and which will be used to draw the background of the gutters. May include the CodeMirror-linenumbers class, in order to explicitly set the position of the line number gutter (it will default to be to the right of all other gutters). These class names are the keys passed to setGutterMarker.
property historyEventDelay
historyEventDelay?: number | undefined;
The period of inactivity (in milliseconds) that will cause a new history event to be started when typing or deleting. Defaults to 500.
property indentUnit
indentUnit?: number | undefined;
How many spaces a block (whatever that means in the edited language) should be indented. The default is 2.
property indentWithTabs
indentWithTabs?: boolean | undefined;
Whether, when indenting, the first N*tabSize spaces should be replaced by N tabs. Default is false.
property inputStyle
inputStyle?: InputStyle | undefined;
Selects the way CodeMirror handles input and focus. The core library defines the "textarea" and "contenteditable" input models. On mobile browsers, the default is "contenteditable". On desktop browsers, the default is "textarea". Support for IME and screen readers is better in the "contenteditable" model.
property keyMap
keyMap?: string | undefined;
Configures the keymap to use. The default is "default", which is the only keymap defined in codemirror.js itself. Extra keymaps are found in the keymap directory. See the section on keymaps for more information.
property lineNumberFormatter
lineNumberFormatter?: ((line: number) => string) | undefined;
A function used to format line numbers. The function is passed the line number, and should return a string that will be shown in the gutter.
property lineNumbers
lineNumbers?: boolean | undefined;
Whether to show line numbers to the left of the editor.
property lineSeparator
lineSeparator?: string | null | undefined;
Explicitly set the line separator for the editor. By default (value null), the document will be split on CRLFs as well as lone CRs and LFs, and a single LF will be used as line separator in all output (such as getValue). When a specific string is given, lines will only be split on that string, and output will, by default, use that same separator.
property lineWiseCopyCut
lineWiseCopyCut?: boolean | undefined;
When enabled, which is the default, doing copy or cut when there is no selection will copy or cut the whole lines that have cursors on them.
property lineWrapping
lineWrapping?: boolean | undefined;
Whether CodeMirror should scroll or wrap for long lines. Defaults to false (scroll).
property maxHighlightLength
maxHighlightLength?: number | undefined;
When highlighting long lines, in order to stay responsive, the editor will give up and simply style the rest of the line as plain text when it reaches a certain position. The default is 10000. You can set this to Infinity to turn off this behavior.
property mode
mode?: string | ModeSpec<ModeSpecOptions> | undefined;
string|object. The mode to use. When not given, this will default to the first mode that was loaded. It may be a string, which either simply names the mode or is a MIME type associated with the mode. Alternatively, it may be an object containing configuration options for the mode, with a name property that names the mode (for example {name: "javascript", json: true}).
property onDragEvent
onDragEvent?: ((instance: Editor, event: DragEvent) => boolean) | undefined;
When given , this will be called when the editor is handling a dragenter , dragover , or drop event. It will be passed the editor instance and the event object as arguments. The callback can choose to handle the event itself , in which case it should return true to indicate that CodeMirror should not do anything further.
property onKeyEvent
onKeyEvent?: ((instance: Editor, event: KeyboardEvent) => boolean) | undefined;
This provides a rather low-level hook into CodeMirror's key handling. If provided, this function will be called on every keydown, keyup, and keypress event that CodeMirror captures. It will be passed two arguments, the editor instance and the key event. This key event is pretty much the raw key event, except that a stop() method is always added to it. You could feed it to, for example, jQuery.Event to further normalize it. This function can inspect the key event, and handle it if it wants to. It may return true to tell CodeMirror to ignore the event. Be wary that, on some browsers, stopping a keydown does not stop the keypress from firing, whereas on others it does. If you respond to an event, you should probably inspect its type property and only do something when it is keydown (or keypress for actions that need character data).
property pasteLinesPerSelection
pasteLinesPerSelection?: boolean | undefined;
When pasting something from an external source (not from the editor itself), if the number of lines matches the number of selection, CodeMirror will by default insert one line per selection. You can set this to false to disable that behavior.
property phrases
phrases?: { [s: string]: unknown } | undefined;
Some addons run user-visible strings (such as labels in the interface) through the phrase method to allow for translation. This option determines the return value of that method. When it is null or an object that doesn't have a property named by the input string, that string is returned. Otherwise, the value of the property corresponding to that string is returned.
property pollInterval
pollInterval?: number | undefined;
Indicates how quickly CodeMirror should poll its input textarea for changes(when focused). Most input is captured by events, but some things, like IME input on some browsers, don't generate events that allow CodeMirror to properly detect it. Thus, it polls. Default is 100 milliseconds.
property readOnly
readOnly?: boolean | 'nocursor' | undefined;
boolean|string. This disables editing of the editor content by the user. If the special value "nocursor" is given (instead of simply true), focusing of the editor is also disallowed.
property resetSelectionOnContextMenu
resetSelectionOnContextMenu?: boolean | undefined;
Controls whether, when the context menu is opened with a click outside of the current selection, the cursor is moved to the point of the click. Defaults to true.
property rtlMoveVisually
rtlMoveVisually?: boolean | undefined;
Determines whether horizontal cursor movement through right-to-left (Arabic, Hebrew) text is visual (pressing the left arrow moves the cursor left) or logical (pressing the left arrow moves to the next lower index in the string, which is visually right in right-to-left text). The default is false on Windows, and true on other platforms.
property screenReaderLabel
screenReaderLabel?: string | undefined;
This label is read by the screenreaders when CodeMirror text area is focused. This is helpful for accessibility.
property scrollbarStyle
scrollbarStyle?: keyof ScrollbarModels | undefined;
Chooses a scrollbar implementation. The default is "native", showing native scrollbars. The core library also provides the "null" style, which completely hides the scrollbars. Addons can implement additional scrollbar models.
property selectionsMayTouch
selectionsMayTouch?: boolean | undefined;
Determines whether multiple selections are joined as soon as they touch (the default) or only when they overlap (true).
property showCursorWhenSelecting
showCursorWhenSelecting?: boolean | undefined;
Whether the cursor should be drawn when a selection is active. Defaults to false.
property smartIndent
smartIndent?: boolean | undefined;
Whether to use the context-sensitive indentation that the mode provides (or just indent the same as the line before). Defaults to true.
property specialCharPlaceholder
specialCharPlaceholder?: ((char: string) => HTMLElement) | undefined;
A function that, given a special character identified by the specialChars option, produces a DOM node that is used to represent the character. By default, a red dot (•) is shown, with a title tooltip to indicate the character code.
property specialChars
specialChars?: RegExp | undefined;
A regular expression used to determine which characters should be replaced by a special placeholder. Mostly useful for non-printing special characters. The default is /[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b-\u200f\u2028\u2029\ufeff\ufff9-\ufffc]/.
property spellcheck
spellcheck?: boolean | undefined;
Specifies whether or not spellcheck will be enabled on the input.
property tabindex
tabindex?: number | undefined;
The tab index to assign to the editor. If not given, no tab index will be assigned.
property tabSize
tabSize?: number | undefined;
The width of a tab character. Defaults to 4.
property theme
theme?: string | undefined;
The theme to style the editor with. You must make sure the CSS file defining the corresponding .cm-s-[name] styles is loaded. The default is "default".
property undoDepth
undoDepth?: number | undefined;
The maximum number of undo levels that the editor stores. Defaults to 40.
property value
value?: string | Doc | undefined;
The starting value of the editor. Can be a string, or a document object.
property viewportMargin
viewportMargin?: number | undefined;
Specifies the amount of lines that are rendered above and below the part of the document that's currently scrolled into view. This affects the amount of updates needed when scrolling, and the amount of work that such an update does. You should usually leave it at its default, 10. Can be set to Infinity to make sure the whole document is always rendered, and thus the browser's text search works on it. This will have bad effects on performance of big documents.
property workDelay
workDelay?: number | undefined;
See workTime.
property workTime
workTime?: number | undefined;
Highlighting is done by a pseudo background thread that will work for workTime milliseconds, and then use timeout to sleep for workDelay milliseconds. The defaults are 200 and 300, you can change these options to make the highlighting more or less aggressive.
interface EditorConfiguration
interface EditorConfiguration {}
property continueComments
continueComments?: | boolean | string | { key: string; continueLineComment?: boolean | undefined } | undefined;
if true, the editor will make the next line continue a comment when pressing the Enter key. If set to a string, it will continue comments using a custom shortcut.
interface EditorConfiguration
interface EditorConfiguration {}
property autoRefresh
autoRefresh?: boolean | { delay: number } | undefined;
interface EditorConfiguration
interface EditorConfiguration {}
property fullScreen
fullScreen?: boolean | undefined;
When set to true, will make the editor full-screen (as in, taking up the whole browser window). Depends on fullscreen.css
See Also
interface EditorConfiguration
interface EditorConfiguration {}
property placeholder
placeholder?: string | Node | undefined;
Adds a placeholder option that can be used to make content appear in the editor when it is empty and not focused. It can hold either a string or a DOM node. Also gives the editor a CodeMirror-empty CSS class whenever it doesn't contain any text.
interface EditorConfiguration
interface EditorConfiguration {}
property rulers
rulers?: false | ReadonlyArray<number | Ruler> | undefined;
show one or more vertical rulers in the editor.
interface EditorConfiguration
interface EditorConfiguration {}
property autoCloseBrackets
autoCloseBrackets?: AutoCloseBrackets | boolean | string | undefined;
Will auto-close brackets and quotes when typed. By default, it'll auto-close ()[]{}''"", but you can pass it a string similar to that (containing pairs of matching characters), or an object with pairs and optionally explode properties to customize it.
interface EditorConfiguration
interface EditorConfiguration {}
property autoCloseTags
autoCloseTags?: AutoCloseTags | boolean | undefined;
Will auto-close XML tags when '>' or '/' is typed. Depends on the fold/xml-fold.js addon.
interface EditorConfiguration
interface EditorConfiguration {}
property matchBrackets
matchBrackets?: MatchBrackets | boolean | undefined;
interface EditorConfiguration
interface EditorConfiguration {}
property matchTags
matchTags?: MatchTags | boolean | undefined;
When enabled will cause the tags around the cursor to be highlighted (using the CodeMirror-matchingtag class). Depends on the addon/fold/xml-fold.js addon.
interface EditorConfiguration
interface EditorConfiguration {}
property showTrailingSpace
showTrailingSpace?: boolean | undefined;
when enabled, adds the CSS class cm-trailingspace to stretches of whitespace at the end of lines.
interface EditorConfiguration
interface EditorConfiguration {}
property foldOptions
foldOptions?: FoldOptions | undefined;
interface EditorConfiguration
interface EditorConfiguration {}
property foldGutter
foldGutter?: boolean | FoldGutterOptions | undefined;
Provides an option foldGutter, which can be used to create a gutter with markers indicating the blocks that can be folded.
interface EditorConfiguration
interface EditorConfiguration {}
property hintOptions
hintOptions?: ShowHintOptions | undefined;
property showHint
showHint?: boolean | undefined;
interface EditorConfiguration
interface EditorConfiguration {}
property lint
lint?: boolean | LintStateOptions<any> | Linter<any> | undefined;
Optional lint configuration to be used in conjunction with CodeMirror's linter addon.
interface EditorConfiguration
interface EditorConfiguration {}
property scrollButtonHeight
scrollButtonHeight?: number | undefined;
interface EditorConfiguration
interface EditorConfiguration {}
property scrollPastEnd
scrollPastEnd?: boolean | undefined;
When the end of the file is reached it allows you to keep scrolling so that your last few lines of code are not stuck at the bottom of the editor.
interface EditorConfiguration
interface EditorConfiguration {}
property search
search?: | { bottom: boolean; } | undefined;
interface EditorConfiguration
interface EditorConfiguration {}
property highlightSelectionMatches
highlightSelectionMatches?: HighlightSelectionMatches | boolean | undefined;
Adds a highlightSelectionMatches option that can be enabled to highlight all instances of a currently selected word. When enabled, it causes the current word to be highlighted when nothing is selected (defaults to off).
interface EditorConfiguration
interface EditorConfiguration {}
property search
search?: | { bottom: boolean; } | undefined;
interface EditorConfiguration
interface EditorConfiguration {}
property styleActiveLine
styleActiveLine?: StyleActiveLine | boolean | undefined;
When enabled gives the wrapper of the line that contains the cursor the class CodeMirror-activeline, adds a background with the class CodeMirror-activeline-background, and adds the class CodeMirror-activeline-gutter to the line's gutter space is enabled.
interface EditorConfiguration
interface EditorConfiguration {}
property styleSelectedText
styleSelectedText?: boolean | string | undefined;
Causes the selected text to be marked with the CSS class CodeMirror-selectedtext or a custom class when the styleSelectedText option is enabled. Useful to change the colour of the selection (in addition to the background).
interface EditorConfiguration
interface EditorConfiguration {}
property selectionPointer
selectionPointer?: boolean | string | undefined;
Controls the mouse cursor appearance when hovering over the selection. It can be set to a string, like "pointer", or to true, in which case the "default" (arrow) cursor will be used.
interface EditorEventMap
interface EditorEventMap {}
property beforeChange
beforeChange: (instance: Editor, changeObj: EditorChangeCancellable) => void;
property beforeSelectionChange
beforeSelectionChange: (instance: Editor, obj: EditorSelectionChange) => void;
property blur
blur: (instance: Editor, event: FocusEvent) => void;
property change
change: (instance: Editor, changeObj: EditorChange) => void;
property changes
changes: (instance: Editor, changes: EditorChange[]) => void;
property cursorActivity
cursorActivity: (instance: Editor) => void;
property electricInput
electricInput: (instance: Editor, line: number) => void;
property focus
focus: (instance: Editor, event: FocusEvent) => void;
property gutterClick
gutterClick: ( instance: Editor, line: number, gutter: string, clickEvent: Event) => void;
property gutterContextMenu
gutterContextMenu: ( instance: Editor, line: number, gutter: string, contextMenuEvent: MouseEvent) => void;
property inputRead
inputRead: (instance: Editor, changeObj: EditorChange) => void;
property keyHandled
keyHandled: (instance: Editor, name: string, event: Event) => void;
property optionChange
optionChange: (instance: Editor, option: keyof EditorConfiguration) => void;
property overwriteToggle
overwriteToggle: (instance: Editor, overwrite: boolean) => void;
property refresh
refresh: (instance: Editor) => void;
property renderLine
renderLine: ( instance: Editor, lineHandle: LineHandle, element: HTMLElement) => void;
property scroll
scroll: (instance: Editor) => void;
property scrollCursorIntoView
scrollCursorIntoView: (instance: Editor, event: Event) => void;
property swapDoc
swapDoc: (instance: Editor, oldDoc: Doc) => void;
property update
update: (instance: Editor) => void;
property viewportChange
viewportChange: (instance: Editor, from: number, to: number) => void;
interface EditorEventMap
interface EditorEventMap {}
property endCompletion
endCompletion: (instance: Editor) => void;
property startCompletion
startCompletion: (instance: Editor) => void;
interface EditorFromTextArea
interface EditorFromTextArea extends Editor {}
method getTextArea
getTextArea: () => HTMLTextAreaElement;
Returns the textarea that the instance was based on.
method save
save: () => void;
Copy the content of the editor into the textarea.
method toTextArea
toTextArea: () => void;
Remove the editor, and restore the original textarea (with the editor's current content).
interface EditorSelectionChange
interface EditorSelectionChange {}
interface FoldGutterOptions
interface FoldGutterOptions {}
property gutter
gutter?: string | undefined;
The CSS class of the gutter. Defaults to "CodeMirror-foldgutter". You will have to style this yourself to give it a width (and possibly a background).
property indicatorFolded
indicatorFolded?: string | Element | undefined;
A CSS class or DOM element to be used as the marker for folded blocks. Defaults to "CodeMirror-foldgutter-folded".
property indicatorOpen
indicatorOpen?: string | Element | undefined;
A CSS class or DOM element to be used as the marker for open, foldable blocks. Defaults to "CodeMirror-foldgutter-open".
property rangeFinder
rangeFinder?: (cm: Editor, pos: Position) => FoldRange | undefined;
interface FoldOptions
interface FoldOptions {}
property clearOnEnter
clearOnEnter?: boolean | undefined;
property minFoldSize
minFoldSize?: number | undefined;
The minimum amount of lines that a fold should span to be accepted. Defaults to 0, which also allows single-line folds.
property rangeFinder
rangeFinder?: FoldRangeFinder | undefined;
The function that is used to find foldable ranges. If this is not directly passed, it will default to CodeMirror.fold.auto, which uses getHelpers with a "fold" type to find folding functions appropriate for the local mode. There are files in the addon/fold/ directory providing CodeMirror.fold.brace, which finds blocks in brace languages (JavaScript, C, Java, etc), CodeMirror.fold.indent, for languages where indentation determines block structure (Python, Haskell), and CodeMirror.fold.xml, for XML-style languages, and CodeMirror.fold.comment, for folding comment blocks.
property scanUp
scanUp?: boolean | undefined;
When true (default is false), the addon will try to find foldable ranges on the lines above the current one if there isn't an eligible one on the given line.
property widget
widget?: | string | Element | ((from: Position, to: Position) => string | Element) | undefined;
The widget to show for folded ranges. Can be either a string, in which case it'll become a span with class CodeMirror-foldmarker, or a DOM node. To dynamically generate the widget, this can be a function that returns a string or DOM node, which will then render as described. The function will be invoked with parameters identifying the range to be folded.
interface HighlightSelectionMatches
interface HighlightSelectionMatches {}
property annotateScrollbar
annotateScrollbar?: boolean | undefined;
If annotateScrollbar is enabled, the occurences will be highlighted on the scrollbar via the matchesonscrollbar addon.
property delay
delay?: number | undefined;
Used to specify how much time to wait, in milliseconds, before highlighting the matches (default is 100).
property minChars
minChars?: number | undefined;
Minimum amount of selected characters that triggers a highlight (default 2).
property showToken
showToken?: boolean | RegExp | undefined;
Can be set to true or to a regexp matching the characters that make up a word.
property style
style?: string | undefined;
The style to be used to highlight the matches (default "matchhighlight", which will correspond to CSS class cm-matchhighlight).
property trim
trim?: boolean | undefined;
Controls whether whitespace is trimmed from the selection.
property wordsOnly
wordsOnly?: boolean | undefined;
If wordsOnly is enabled, the matches will be highlighted only if the selected text is a word.
interface Hint
interface Hint {}
Interface used by showHint.js Codemirror add-on When completions aren't simple strings, they should be objects with the following properties:
property className
className?: string | undefined;
property displayText
displayText?: string | undefined;
property from
from?: Position | undefined;
property hint
hint?: ((cm: Editor, data: Hints, cur: Hint) => void) | undefined;
Called if a completion is picked. If provided *you* are responsible for applying the completion
property render
render?: ((element: HTMLLIElement, data: Hints, cur: Hint) => void) | undefined;
property text
text: string;
property to
to?: Position | undefined;
interface HintFunction
interface HintFunction {}
call signature
(cm: Editor, options: ShowHintOptions): | Hints | null | undefined | PromiseLike<Hints | null | undefined>;
interface HintFunctionResolver
interface HintFunctionResolver {}
method resolve
resolve: (cm: Editor, post: Position) => HintFunction | AsyncHintFunction;
interface HintHelpers
interface HintHelpers {}
interface HintHelpers
interface HintHelpers {}
property anyword
anyword: HintFunction;
interface HintHelpers
interface HintHelpers {}
property css
css: HintFunction;
interface HintHelpers
interface HintHelpers {}
property xml
xml: HintFunction;
interface HintHelpers
interface HintHelpers {}
property html
html: HintFunction;
interface HintHelpers
interface HintHelpers {}
property coffeescript
coffeescript: HintFunction;
property javascript
javascript: HintFunction;
interface HintHelpers
interface HintHelpers {}
property sql
sql: HintFunction;
interface Hints
interface Hints {}
interface KeyMap
interface KeyMap {}
index signature
[keyName: string]: false | string | ((instance: Editor) => void | typeof Pass);
interface LineHandle
interface LineHandle {}
interface LineHandleEventMap
interface LineHandleEventMap {}
interface LineWidget
interface LineWidget {}
method changed
changed: () => void;
Call this if you made some change to the widget's DOM node that might affect its height. It'll force CodeMirror to update the height of the line that contains the widget.
method clear
clear: () => void;
Removes the widget.
method off
off: <T extends 'redraw'>(eventName: T, handler: LineWidgetEventMap[T]) => void;
method on
on: <T extends 'redraw'>(eventName: T, handler: LineWidgetEventMap[T]) => void;
interface LineWidgetEventMap
interface LineWidgetEventMap {}
property redraw
redraw: () => void;
interface LineWidgetOptions
interface LineWidgetOptions {}
property above
above?: boolean | undefined;
Causes the widget to be placed above instead of below the text of the line.
property className
className?: string | undefined;
Add an extra CSS class name to the wrapper element created for the widget.
property coverGutter
coverGutter?: boolean | undefined;
Whether the widget should cover the gutter.
property handleMouseEvents
handleMouseEvents?: boolean | undefined;
Determines whether the editor will capture mouse and drag events occurring in this widget. Default is false—the events will be left alone for the default browser handler, or specific handlers on the widget, to capture.
property insertAt
insertAt?: number | undefined;
By default, the widget is added below other widgets for the line. This option can be used to place it at a different position (zero for the top, N to put it after the Nth other widget). Note that this only has effect once, when the widget is created.
property noHScroll
noHScroll?: boolean | undefined;
Whether the widget should stay fixed in the face of horizontal scrolling.
property showIfHidden
showIfHidden?: boolean | undefined;
When true, will cause the widget to be rendered even if the line it is associated with is hidden.
interface MarkerRange
interface MarkerRange {}
interface MatchBrackets
interface MatchBrackets {}
property afterCursor
afterCursor?: boolean | undefined;
Only use the character after the start position, never the one before it.
property maxHighlightLineLength
maxHighlightLineLength?: number | undefined;
Don't highlight a bracket in a line longer than this. Defaults to 1000.
property maxScanLineLength
maxScanLineLength?: number | undefined;
Ignore lines longer than this. Defaults to 10000.
property maxScanLines
maxScanLines?: number | undefined;
Stop after scanning this amount of lines without a successful match. Defaults to 1000.
property strict
strict?: boolean | undefined;
Causes only matches where both brackets are at the same side of the start position to be considered.
interface MatchTags
interface MatchTags {}
property bothTags
bothTags?: boolean | undefined;
Highlight both matching tags.
interface MimeModeMap
interface MimeModeMap {}
index signature
[mimeName: string]: string | ModeSpec<ModeSpecOptions>;
interface Mode
interface Mode<T> {}
A Mode is, in the simplest case, a lexer (tokenizer) for your language — a function that takes a character stream as input, advances it past a token, and returns a style for that token. More advanced modes can also handle indentation for the language.
property blankLine
blankLine?: ((state: T) => void) | undefined;
For languages that have significant blank lines, you can define a blankLine(state) method on your mode that will get called whenever a blank line is passed over, so that it can update the parser state.
property blockCommentEnd
blockCommentEnd?: string | undefined;
String that ends a block comment.
property blockCommentLead
blockCommentLead?: string | undefined;
String to put at the start of continued lines in a block comment.
property blockCommentStart
blockCommentStart?: string | undefined;
String that starts a block comment.
property copyState
copyState?: ((state: T) => T) | undefined;
Given a state returns a safe copy of that state.
property electricChars
electricChars?: string | undefined;
Trigger a reindent whenever one of the characters in the string is typed.
property electricinput
electricinput?: RegExp | undefined;
Trigger a reindent whenever the regex matches the part of the line before the cursor.
property indent
indent?: ((state: T, textAfter: string, line: string) => number) | undefined;
Returns the number of spaces of indentation that should be used if a newline were added after the given state. Optionally this can use the textAfter string (which is the text after the current position) or the line string, which is the whole text of the line.
property lineComment
lineComment?: string | undefined;
String that starts a line comment.
property name
name?: string | undefined;
property startState
startState?: (() => T) | undefined;
A function that produces a state object to be used at the start of a document.
property token
token: (stream: StringStream, state: T) => string | null;
This function should read one token from the stream it is given as an argument, optionally update its state, and return a style string, or null for tokens that do not have to be styled. Multiple styles can be returned, separated by spaces.
interface ModeFactory
interface ModeFactory<T> {}
A function that, given a CodeMirror configuration object and an optional mode configuration object, returns a mode object.
call signature
(config: EditorConfiguration, modeOptions?: any): Mode<T>;
interface ModeMap
interface ModeMap {}
index signature
[modeName: string]: ModeFactory<any>;
interface ModeSpecOptions
interface ModeSpecOptions {}
property alignCDATA
alignCDATA?: boolean | undefined;
Setting this to true will force the opening tag of CDATA blocks to not be indented.
property allowAtxHeaderWithoutSpace
allowAtxHeaderWithoutSpace?: boolean | undefined;
Allow lazy headers without whitespace between hashtag and text (default: false).
property atoms
atoms?: unknown | undefined;
List of atom words. Default: "null"
property base
base?: string | undefined;
Below options are supported in Handlebars/Haskell/YAML front matter mode
property baseMode
baseMode?: string | undefined;
property doubleDelimiters
doubleDelimiters?: unknown | undefined;
Regular Expression for double delimiters matching default :^((\+=)|(\-=)|(\*=)|(%=)|(/=)|(&=)|(\|=)|(\^=))
property doubleOperators
doubleOperators?: unknown | undefined;
Regular Expression for double operators matching, default :^((==)|(!=)|(<=)|(>=)|(<>)|(<<)|(>>)|(//)|(\*\*))
property emoji
emoji?: boolean | undefined;
property extra_builtins
extra_builtins?: string[] | undefined;
List of extra words ton consider as builtins
property extra_keywords
extra_keywords?: string[] | undefined;
List of extra words ton consider as keywords
property fencedCodeBlockDefaultMode
fencedCodeBlockDefaultMode?: string | undefined;
Mode to use for fencedCodeBlockHighlighting, if given mode is not included.
property fencedCodeBlockHighlighting
fencedCodeBlockHighlighting?: boolean | undefined;
Whether to syntax-highlight fenced code blocks, if given mode is included, or fencedCodeBlockDefaultMode is set (default: true).
property gitHubSpice
gitHubSpice?: boolean | undefined;
Below options are supported in GFM mode mode
property hangingIndent
hangingIndent?: number | undefined;
If you want to write long arguments to a function starting on a new line, how much that line should be indented. Defaults to one normal indentation unit.
property highlightFormatting
highlightFormatting?: boolean | undefined;
Whether to separately highlight markdown meta characters (*[]()etc.) (default: false).
property highlightNonStandardPropertyKeywords
highlightNonStandardPropertyKeywords?: boolean | undefined;
Whether to highlight non-standard CSS property keywords such as margin-inline or zoom (default: true).
property hooks
hooks?: unknown | undefined;
List of meta hooks. Default: ["`", "$"]
property htmlMode
htmlMode?: boolean | undefined;
This switches the mode to parse HTML instead of XML. This means attributes do not have to be quoted, and some elements (such as br) do not require a closing tag.
property identifiers
identifiers?: unknown | undefined;
RegEx - Regular Expression for identifier, default :^[_A-Za-z][_A-Za-z0-9]*
property inMathMode
inMathMode?: boolean | undefined;
Whether to start parsing in math mode (default: false)
property json
json?: boolean | undefined;
json which will set the mode to expect JSON data rather than a JavaScript program.
property jsonld
jsonld?: boolean | undefined;
jsonld which will set the mode to expect JSON-LD linked data rather than a JavaScript program
property leftDelimiter
leftDelimiter?: string | undefined;
leftDelimiter and rightDelimiter, which should be strings that determine where the Smarty syntax starts and ends.
property matchClosing
matchClosing?: boolean | undefined;
Controls whether the mode checks that close tags match the corresponding opening tag, and highlights mismatches as errors. Defaults to true.
property maxBlockquoteDepth
maxBlockquoteDepth?: boolean | undefined;
Maximum allowed blockquote nesting (default: 0 - infinite nesting).
property multiLineStrings
multiLineStrings?: boolean | undefined;
Whether multi-line strings are accepted. Default: false
property noIndentKeywords
noIndentKeywords?: unknown | undefined;
List of keywords which should not cause indentation to increase.
property rightDelimiter
rightDelimiter?: string | undefined;
property singleDelimiters
singleDelimiters?: unknown | undefined;
Regular Expression for single delimiter matching default :^[\(\)\[\]\{\}@,:`=;\.]
property singleLineStringErrors
singleLineStringErrors?: boolean | undefined;
If you have a single-line string that is not terminated at the end of the line, this will show subsequent lines as errors if true, otherwise it will consider the newline as the end of the string. Default is false.
property singleOperators
singleOperators?: unknown | undefined;
Regular Expression for single operator matching
property statementIndent
statementIndent?: boolean | undefined;
statementIndent which (given a number) will determine the amount of indentation to use for statements continued on a new line.
property strikethrough
strikethrough?: boolean | undefined;
property tags
tags?: { [key: string]: unknown } | undefined;
Below options are supported in HTML mixed mode
property taskLists
taskLists?: boolean | undefined;
property tokenTypeOverrides
tokenTypeOverrides?: unknown | undefined;
When you want to override default token type names (e.g. {code: "code"}).
property trackScope
trackScope?: boolean | undefined;
trackScope can be set to false to turn off tracking of local variables. This will prevent locals from getting the "variable-2" token type, and will break completion of locals with javascript-hint.
property tripleDelimiters
tripleDelimiters?: unknown | undefined;
Regular Expression for triple delimiters matching default :^((//=)|(>>=)|(<<=)|(\*\*=))
property typescript
typescript?: boolean | undefined;
typescript which will activate additional syntax highlighting and some other things for TypeScript code
property useCPP
useCPP?: boolean | undefined;
useCPP, which determines whether C preprocessor directives are recognized.
property version
version?: 2 | 3 | undefined;
The version of Python to recognize. Default is 3.
property wordCharacters
wordCharacters?: unknown | undefined;
wordCharacters, a regexp that indicates which characters should be considered part of an identifier. Defaults to /[\w$]/, which does not handle non-ASCII identifiers. Can be set to something more elaborate to improve Unicode support.
property xml
xml?: boolean | undefined;
Whether to highlight inline XML (default: true).
interface MouseSelectionConfiguration
interface MouseSelectionConfiguration {}
property addNew
addNew?: boolean | undefined;
When enabled, this adds a new range to the existing selection, rather than replacing it. The default behavior is to enable this for command-click on Mac OS, and control-click on other platforms.
property extend
extend?: boolean | undefined;
Whether to extend the existing selection range or start a new one. By default, this is enabled when shift clicking.
property moveOnDrag
moveOnDrag?: boolean | undefined;
When the mouse even drags content around inside the editor, this controls whether it is copied (false) or moved (true). By default, this is enabled by alt-clicking on Mac OS, and ctrl-clicking elsewhere.
property unit
unit?: | 'char' | 'word' | 'line' | 'rectangle' | ((cm: Editor, pos: Position) => { from: Position; to: Position }) | undefined;
The unit by which to select. May be one of the built-in units or a function that takes a position and returns a range around that, for a custom unit. The default is to return "word" for double clicks, "line" for triple clicks, "rectangle" for alt-clicks (or, on Chrome OS, meta-shift-clicks), and "single" otherwise.
interface Panel
interface Panel {}
interface Position
interface Position {}
interface PositionConstructor
interface PositionConstructor {}
construct signature
new (line: number, ch?: number, sticky?: string): Position;
call signature
(line: number, ch?: number, sticky?: string): Position;
interface Range
interface Range {}
interface Rule
interface Rule {}
property dedent
dedent?: boolean | undefined;
property dedentIfLineStart
dedentIfLineStart?: boolean | undefined;
property indent
indent?: boolean | undefined;
property mode
mode?: | { spec: string | ModeSpec<any>; end?: RegExp | undefined; persistent?: boolean | undefined; } | undefined;
property next
next?: string | undefined;
property pop
pop?: boolean | undefined;
property push
push?: string | undefined;
property regex
regex?: string | RegExp | undefined;
property sol
sol?: boolean | undefined;
property token
token?: string | string[] | null | undefined;
interface ScrollbarMeasure
interface ScrollbarMeasure {}
property barLeft
barLeft: number;
property clientHeight
clientHeight: number;
property docHeight
docHeight: number;
property gutterWidth
gutterWidth: number;
property nativeBarWidth
nativeBarWidth: number;
property scrollHeight
scrollHeight: number;
property scrollWidth
scrollWidth: number;
property viewHeight
viewHeight: number;
property viewWidth
viewWidth: number;
interface ScrollbarModel
interface ScrollbarModel {}
method clear
clear: () => void;
method setScrollLeft
setScrollLeft: (pos: number) => void;
method setScrollTop
setScrollTop: (pos: number) => void;
method update
update: (measure: ScrollbarMeasure) => { bottom: number; right: number };
interface ScrollbarModelConstructor
interface ScrollbarModelConstructor {}
construct signature
new ( place: (node: Element) => void, scroll: (pos: number, axis: 'horizontal' | 'vertical') => void): ScrollbarModel;
interface ScrollbarModels
interface ScrollbarModels {}
interface ScrollbarModels
interface ScrollbarModels {}
interface ScrollInfo
interface ScrollInfo {}
property clientHeight
clientHeight: number;
property clientWidth
clientWidth: number;
property height
height: number;
property left
left: number;
property top
top: number;
property width
width: number;
interface SearchCursor
interface SearchCursor {}
method find
find: (reverse: boolean) => boolean | RegExpMatchArray;
Searches forward or backward from the current position. The return value indicates whether a match was found. If matching a regular expression, the return value will be the array returned by the match method, in case you want to extract matched groups
method findNext
findNext: () => boolean | RegExpMatchArray;
Searches forward from the current position. The return value indicates whether a match was found. If matching a regular expression, the return value will be the array returned by the match method, in case you want to extract matched groups
method findPrevious
findPrevious: () => boolean | RegExpMatchArray;
Searches backward from the current position. The return value indicates whether a match was found. If matching a regular expression, the return value will be the array returned by the match method, in case you want to extract matched groups
method from
from: () => Position;
Only valid when the last call to find, findNext, or findPrevious did not return false. Returns {line, ch} objects pointing the start of the match.
method replace
replace: (text: string, origin?: string) => void;
Replaces the currently found match with the given text and adjusts the cursor position to reflect the deplacement.
method to
to: () => Position;
Only valid when the last call to find, findNext, or findPrevious did not return false. Returns {line, ch} objects pointing the end of the match.
interface SelectionOptions
interface SelectionOptions {}
property bias
bias?: number | undefined;
Determine the direction into which the selection endpoints should be adjusted when they fall inside an atomic range. Can be either -1 (backward) or 1 (forward). When not given, the bias will be based on the relative position of the old selection—the editor will try to move further away from that, to prevent getting stuck.
property origin
origin?: string | undefined;
Determines whether the selection history event may be merged with the previous one. When an origin starts with the character +, and the last recorded selection had the same origin and was similar (close in time, both collapsed or both non-collapsed), the new one will replace the old one. When it starts with *, it will always replace the previous event (if that had the same origin). Built-in motion uses the "+move" origin. User input uses the "+input" origin.
property scroll
scroll?: boolean | undefined;
Determines whether the selection head should be scrolled into view. Defaults to true.
interface ShowHintOptions
interface ShowHintOptions {}
property alignWithWord
alignWithWord?: boolean | undefined;
property closeCharacters
closeCharacters?: RegExp | undefined;
property closeOnPick
closeOnPick?: boolean | undefined;
property closeOnUnfocus
closeOnUnfocus?: boolean | undefined;
property completeOnSingleClick
completeOnSingleClick?: boolean | undefined;
property completeSingle
completeSingle?: boolean | undefined;
property container
container?: HTMLElement | null | undefined;
property customKeys
customKeys?: | { [key: string]: | ((editor: Editor, handle: CompletionHandle) => void) | string; } | null | undefined;
property extraKeys
extraKeys?: | { [key: string]: | ((editor: Editor, handle: CompletionHandle) => void) | string; } | null | undefined;
property hint
hint?: HintFunction | AsyncHintFunction | HintFunctionResolver | undefined;
property moveOnOverlap
moveOnOverlap?: boolean | undefined;
property paddingForScrollbar
paddingForScrollbar?: boolean | undefined;
property scrollMargin
scrollMargin?: number | undefined;
property updateOnCursorActivity
updateOnCursorActivity?: boolean | undefined;
property words
words?: readonly string[] | undefined;
interface ShowHintOptions
interface ShowHintOptions {}
interface ShowHintOptions
interface ShowHintOptions {}
property matchInMiddle
matchInMiddle?: boolean | undefined;
property quoteChar
quoteChar?: string | undefined;
property schemaInfo
schemaInfo?: any;
interface ShowHintOptions
interface ShowHintOptions {}
property defaultTable
defaultTable?: string | undefined;
property disableKeywords
disableKeywords?: boolean | undefined;
property tables
tables?: | ReadonlyArray<string | { text: string; columns: string[] }> | Record<string, string[] | { columns: string[] }> | undefined;
interface ShowPanelOptions
interface ShowPanelOptions {}
property after
after?: Panel | undefined;
The new panel will be added after the given panel.
property before
before?: Panel | undefined;
The new panel will be added before the given panel.
property height
height?: number | undefined;
The initial height of the panel. Defaults to the offsetHeight of the node.
property position
position?: 'top' | 'after-top' | 'bottom' | 'before-bottom' | undefined;
Controls the position of the newly added panel. The following values are recognized:
top
(default): Adds the panel at the very top.after-top
: Adds the panel at the bottom of the top panels.bottom
: Adds the panel at the very bottom.before-bottom
: Adds the panel at the top of the bottom panels.
property replace
replace?: Panel | undefined;
The new panel will replace the given panel.
property stable
stable?: boolean | undefined;
Whether to scroll the editor to keep the text's vertical position stable, when adding a panel above it. Defaults to false.
interface SqlHintTable
interface SqlHintTable {}
property columns
columns: string[];
interface StyleActiveLine
interface StyleActiveLine {}
property nonEmpty
nonEmpty: boolean;
Controls whether single-line selections, or just cursor selections, are styled. Defaults to false (only cursor selections).
interface TernOptions
interface TernOptions {}
property defs
defs?: Tern.Def[] | undefined;
An array of JSON definition data structures.
property plugins
plugins?: Tern.ConstructorOptions['plugins'] | undefined;
An object mapping plugin names to configuration options.
property useWorker
useWorker?: boolean | undefined;
Set to true to enable web worker mode. You'll probably want to feature detect the actual value you use here, for example !!window.Worker.
property workerDeps
workerDeps?: string[] | undefined;
An array of paths pointing (relative to workerScript) to the Acorn and Tern libraries and any Tern plugins you want to load. Or, if you minified those into a single script and included them in the workerScript, simply leave this undefined.
property workerScript
workerScript?: string | undefined;
The main script of the worker. Point this to wherever you are hosting worker.js from this directory.
method completionTip
completionTip: ( data: Tern.CompletionsQueryResult) => string | HTMLElement | null;
Customize the content in tooltips for completions. Is passed a single argument — the completion's data as returned by Tern — and may return a string, DOM node, or null to indicate that no tip should be shown. By default the docstring is shown.
method fileFilter
fileFilter: (value: string, docName: string, doc: Doc) => string;
This function will be applied to documents before passing them on to Tern.
method getFile
getFile: (name: string, callback: (docValue: string | null) => any) => any;
Can be used to access files in the project that haven't been loaded yet. Simply do callback(null) to indicate that a file is not available.
method responseFilter
responseFilter: <Q extends Tern.Query>( doc: Doc, query: Q, request: Tern.Document, error: Error | undefined, data: Tern.QueryResult<Q> | undefined) => Tern.QueryResult<Q> | undefined;
This function will be applied to the Tern responses before treating them
method showError
showError: (editor: Editor, message: Error | string) => void;
Can be used to override the way errors are displayed.
method switchToDoc
switchToDoc: (name: string, doc: Doc) => void;
This function should, when providing a multi-file view, switch the view or focus to the named file.
method typeTip
typeTip: (data: Tern.TypeQueryResult) => string | HTMLElement | null;
Like completionTip, but for the tooltips shown for type queries.
interface TextMarker
interface TextMarker<T = MarkerRange | Position> extends Partial<TextMarkerOptions> {}
method changed
changed: () => void;
Called when you've done something that might change the size of the marker and want to cheaply update the display
method clear
clear: () => void;
Remove the mark.
method find
find: () => T | undefined;
Returns a {from, to} object (both holding document positions), indicating the current position of the marked range, or undefined if the marker is no longer in the document.
method off
off: <T extends keyof TextMarkerEventMap>( eventName: T, handler: TextMarkerEventMap[T]) => void;
method on
on: <T extends keyof TextMarkerEventMap>( eventName: T, handler: TextMarkerEventMap[T]) => void;
interface TextMarkerEventMap
interface TextMarkerEventMap {}
property beforeCursorEnter
beforeCursorEnter: () => void;
property clear
clear: (from: Position, to: Position) => void;
property hide
hide: () => void;
property unhide
unhide: () => void;
interface TextMarkerOptions
interface TextMarkerOptions {}
property addToHistory
addToHistory?: boolean | undefined;
When set to true (default is false), adding this marker will create an event in the undo history that can be individually undone (clearing the marker).
property atomic
atomic?: boolean | undefined;
Atomic ranges act as a single unit when cursor movement is concerned — i.e. it is impossible to place the cursor inside of them. You can control whether the cursor is allowed to be placed directly before or after them using selectLeft or selectRight. If selectLeft (or right) is not provided, then inclusiveLeft (or right) will control this behavior.
property attributes
attributes?: { [name: string]: string } | undefined;
When given, add the attributes in the given object to the elements created for the marked text. Adding class or style attributes this way is not supported.
property className
className?: string | undefined;
Assigns a CSS class to the marked stretch of text.
property clearOnEnter
clearOnEnter?: boolean | undefined;
When enabled, will cause the mark to clear itself whenever the cursor enters its range. This is mostly useful for text - replacement widgets that need to 'snap open' when the user tries to edit them. The "clear" event fired on the range handle can be used to be notified when this happens.
property clearWhenEmpty
clearWhenEmpty?: boolean | undefined;
Determines whether the mark is automatically cleared when it becomes empty. Default is true.
property collapsed
collapsed?: boolean | undefined;
Collapsed ranges do not show up in the display. Setting a range to be collapsed will automatically make it atomic.
property css
css?: string | undefined;
A string of CSS to be applied to the covered text. For example "color: #fe3".
property endStyle
endStyle?: string | undefined;
Equivalent to startStyle, but for the rightmost span.
property handleMouseEvents
handleMouseEvents?: boolean | undefined;
When replacedWith is given, this determines whether the editor will capture mouse and drag events occurring in this widget. Default is false—the events will be left alone for the default browser handler, or specific handlers on the widget, to capture.
property inclusiveLeft
inclusiveLeft?: boolean | undefined;
Determines whether text inserted on the left of the marker will end up inside or outside of it.
property inclusiveRight
inclusiveRight?: boolean | undefined;
Like inclusiveLeft, but for the right side.
property readOnly
readOnly?: boolean | undefined;
A read-only span can, as long as it is not cleared, not be modified except by calling setValue to reset the whole document. Note: adding a read-only span currently clears the undo history of the editor, because existing undo events being partially nullified by read - only spans would corrupt the history (in the current implementation).
property replacedWith
replacedWith?: HTMLElement | undefined;
Use a given node to display this range. Implies both collapsed and atomic. The given DOM node must be an inline element (as opposed to a block element).
property selectLeft
selectLeft?: boolean | undefined;
For atomic ranges, determines whether the cursor is allowed to be placed directly to the left of the range. Has no effect on non-atomic ranges.
property selectRight
selectRight?: boolean | undefined;
Like selectLeft, but for the right side.
property shared
shared?: boolean | undefined;
When the target document is linked to other documents, you can set shared to true to make the marker appear in all documents. By default, a marker appears only in its target document.
property startStyle
startStyle?: string | undefined;
Can be used to specify an extra CSS class to be applied to the leftmost span that is part of the marker.
property title
title?: string | undefined;
When given, will give the nodes created for this span a HTML title attribute with the given value.
interface Token
interface Token {}
property end
end: number;
The character at which the token ends.
property start
start: number;
The character(on the given line) at which the token starts.
property state
state: any;
The mode's state at the end of this token.
property string
string: string;
The token's string.
property type
type: string | null;
The token type the mode assigned to the token, such as "keyword" or "comment" (may also be null).
Type Aliases
type CoordsMode
type CoordsMode = 'window' | 'page' | 'local' | 'div';
type DOMEvent
type DOMEvent = | 'mousedown' | 'dblclick' | 'touchstart' | 'contextmenu' | 'keydown' | 'keypress' | 'keyup' | 'cut' | 'copy' | 'paste' | 'dragstart' | 'dragenter' | 'dragover' | 'dragleave' | 'drop';
type InputStyle
type InputStyle = 'textarea' | 'contenteditable';
type ModeSpec
type ModeSpec<T> = { [P in keyof T]: T[P];} & { name: string };
Namespaces
namespace lint
namespace lint {}
Package Files (46)
- addon/comment/comment.d.ts
- addon/comment/continuecomment.d.ts
- addon/dialog/dialog.d.ts
- addon/display/autorefresh.d.ts
- addon/display/fullscreen.d.ts
- addon/display/panel.d.ts
- addon/display/placeholder.d.ts
- addon/display/rulers.d.ts
- addon/edit/closebrackets.d.ts
- addon/edit/closetag.d.ts
- addon/edit/continuelist.d.ts
- addon/edit/matchbrackets.d.ts
- addon/edit/matchtags.d.ts
- addon/edit/trailingspace.d.ts
- addon/fold/foldcode.d.ts
- addon/fold/foldgutter.d.ts
- addon/fold/xml-fold.d.ts
- addon/hint/anyword-hint.d.ts
- addon/hint/css-hint.d.ts
- addon/hint/html-hint.d.ts
- addon/hint/javascript-hint.d.ts
- addon/hint/show-hint.d.ts
- addon/hint/sql-hint.d.ts
- addon/hint/xml-hint.d.ts
- addon/lint/lint.d.ts
- addon/merge/merge.d.ts
- addon/mode/loadMode.d.ts
- addon/mode/multiplex.d.ts
- addon/mode/simple.d.ts
- addon/runmode/colorize.d.ts
- addon/runmode/runmode.d.ts
- addon/scroll/annotatescrollbar.d.ts
- addon/scroll/scrollpastend.d.ts
- addon/scroll/simplescrollbars.d.ts
- addon/search/jump-to-line.d.ts
- addon/search/match-highlighter.d.ts
- addon/search/matchesonscrollbar.d.ts
- addon/search/search.d.ts
- addon/search/searchcursor.d.ts
- addon/selection/active-line.d.ts
- addon/selection/mark-selection.d.ts
- addon/selection/selection-pointer.d.ts
- addon/tern/tern.d.ts
- addon/wrap/hardwrap.d.ts
- index.d.ts
- mode/meta.d.ts
Dependencies (1)
Dev Dependencies (0)
No dev dependencies.
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@types/codemirror
.
- Markdown[![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@types/codemirror)
- HTML<a href="https://www.jsdocs.io/package/@types/codemirror"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 11916 ms. - Missing or incorrect documentation? Open an issue for this package.