Home Reference Source
import CodeEditorViewController from '~/controllers/CodeEditorViewController.js'
public class | source

CodeEditorViewController

Extends:

ViewController → CodeEditorViewController

OO-wrapper for a codeeditor.

Constructor Summary

Public Constructor
public

constructor(element: HTMLTextArea, theme: CodeEditorTheme, opts: Object)

Creates CodeEditor wrapper for element.

Member Summary

Public Members
public set

If should auto resize (i.e.

public
public set

lines: nuumber

Sets the height in the # of lines that should be shown

public set

Checks if should be validated

public
public get

Returns value of editor

public set

Sets the value of the editor

Method Summary

Public Methods
public

addWidget(template: Template)

Adds a DOM element as a widget

public

observeValue(): Observable

Obtains observable of value

public

async setLanguage(lang: Language | string)

Sets the language if possible

public

Sets the theme given a type

Inherited Summary

From class ViewController
public static

forClass(className: string, predicate: Function, root: HTMLElement)

Creates a view controller directly for all members of a class.

public static

of(elem: string | Element): ViewController

Returns a canolical VC of an element if it exists

Public Constructors

public constructor(element: HTMLTextArea, theme: CodeEditorTheme, opts: Object) source

Creates CodeEditor wrapper for element. Reccomended to use a Random to create a unique name.

Override:

ViewController#constructor

Params:

NameTypeAttributeDescription
element HTMLTextArea

element id. If an HTMLElement w/o parent then appending

theme CodeEditorTheme

Theme to use for Ace.

opts Object
  • optional
  • default: {}

config opts

opts.lines number
  • nullable: true

amont of lines to show

opts.autoresize number
  • nullable: true

If to autoresize the box

Public Members

public set autoresize: boolean source

If should auto resize (i.e. starts at 1)

public delegate: ActionControllerDelegate source

public set lines: nuumber source

Sets the height in the # of lines that should be shown

public set shouldValidate: boolean source

Checks if should be validated

public theme: CodeEditorTheme source

public get value: string source

Returns value of editor

public set value: string source

Sets the value of the editor

Public Methods

public addWidget(template: Template) source

Adds a DOM element as a widget

Params:

NameTypeAttributeDescription
template Template

If it implements CodeEditorWidgetTemplate then delegate didSetState to is overriden

opts.id string

an 'id' describes the text value of the node

public observeValue(): Observable source

Obtains observable of value

Return:

Observable

public async setLanguage(lang: Language | string) source

Sets the language if possible

Params:

NameTypeAttributeDescription
lang Language | string
  • nullable: true

Language object. Null if default

public async setThemeType(type: CodeEditorThemeType) source

Sets the theme given a type

Params:

NameTypeAttributeDescription
type CodeEditorThemeType

Type of theme