Editor

Creates a new editor object

Constructor

new Editor(parentopt, defaultCodeopt) → {Editor}

Parameters:
NameTypeAttributesDefaultDescription
parentJQuery.<HTMLElement><optional>
$("#editor")Element to place editor on
defaultCodestring<optional>
""Element to place editor on
Returns:
- New editor object
Type: 
Editor
Example
const editor = new Editor()
const editor = new Editor($("#SOMEELEMENT")) // with parent
const editor = new Editor($("#SOMEELEMENT"), SOMECODEVAR) // with parent & default code

Classes

Editor

Methods

addCustomButton(e, backopt)

Adds an element to the editors buttons
Parameters:
NameTypeAttributesDefaultDescription
eJQuery.<HTMLElement>Element to add
backboolean<optional>
falsePlace on the backside or frontside
Example
editor.addCustomButton($("#SOMEELMT"))
editor.addCustomButton($("#SOMEELMT"), true) // adds to other side

disableTerminal()

Disables the editors terminal
Example
editor.disableTerminal() // Terminal gets hidden

enableTerminal()

Enables the editors terminal
Example
editor.enableTerminal() // Terminal gets unhidden

getContent() → {string}

Gets the editors current content
Returns:
- Editors current content
Type: 
string
Example
editor.getContent() // "Some string"

safeEval(input, testopt)

Safely evaluate users js on the frontend with a test case added if wanted
Parameters:
NameTypeAttributesDefaultDescription
inputstringCode to test
teststring<optional>
nullTest case or null for none
Example
editor.saveEval(editor.getContent()) // tests current content
editor.saveEval(editor.getContent(), ";test == true") // tests current content with test case

setContent(input)

Sets editor content to a piece of code
Parameters:
NameTypeDescription
inputcodeCode to set content to
Example
editor.setContent("// This is some codes")