CodeMirrorExt(el, optionsopt)

Class CodeMirrorExt

new CodeMirrorExt(el, optionsopt)

Creates an instance of CodeMirrorExt.

Parameters:
Name Type Attributes Default Description
el HTMLElement

container jquery element

options Object <optional>
{}

codeMirror options

Members

protected, static this.cm

Methods

addWidget(selection, node, style, offset)

Add widget

Parameters:
Name Type Description
selection object

Selection object

node HTMLElement

Widget node

style string

Adding style "over" or "bottom"

offset number

Adding offset

blur()

blur focus to current Editor

focus()

Set focus to current Editor

getCaretPosition() → {Object}

Get current caret position

Returns:
Object

getCurrentRange() → {Object}

getCurrentRange

Returns:
Object -
  • selection range

getCursor(startopt) → {Cursor}

get code mirror cursor

Parameters:
Name Type Attributes Default Description
start string <optional>
'head'

which end of the selection. 'from'|'to'|'head'|'anchor'

Returns:
Cursor -
  • code mirror cursor

getEditor() → {CodeMirror}

Get CodeMirror instance

Returns:
CodeMirror

getRange() → {Object}

Get start, end position of current selection

Returns:
Object

getValue() → {string}

Get editor value

Returns:
string -
  • codeMirror text value

getWrapperElement() → {HTMLElement}

get code mirror wrapper element

Returns:
HTMLElement -
  • code mirror wrapper element

moveCursorToEnd()

Set cursor position to end

moveCursorToStart()

Set cursor position to start

off(type, func)

remove codemirror event handler

Parameters:
Name Type Description
type string

event type

func function

handler function

on(type, func)

add codemirror event handler

Parameters:
Name Type Description
type string

event type

func function

handler function

remove()

Remove Editor from document

replaceRelativeOffset(content, offset, overwriteLength)

Replace selection with replacement content and offset

Parameters:
Name Type Description
content string

Replacement content text

offset number

Offset

overwriteLength number

Length to overwrite

replaceSelection(content, selection)

Replace selection with given replacement content

Parameters:
Name Type Description
content string

Replacement content text

selection object

Selection object

reset()

Reset Editor

scrollTop(value) → {number}

Scroll Editor content to Top

Parameters:
Name Type Description
value number

Scroll amount

Returns:
number -
  • changed scroll top

setHeight(height)

Set Editor height

Parameters:
Name Type Description
height number

Editor height

setMinHeight(minHeight)

set min height

Parameters:
Name Type Description
minHeight number

min height

setValue(markdown, cursorToEndopt)

Set Editor value

Parameters:
Name Type Attributes Default Description
markdown string

Markdown syntax text

cursorToEnd boolean <optional>
true

move cursor to contents end