ToastUIEditor(options)

Class ToastUIEditor

new ToastUIEditor(options)

ToastUI Editor

Parameters:
Name Type Description
options object

Option object

Properties
Name Type Attributes Default Description
height string <optional>
'300px'

Editor's height style value. Height is applied as border-box ex) '300px', '100%', 'auto'

minHeight string <optional>
'200px'

Editor's min-height style value in pixel ex) '300px'

initialValue string

Editor's initial value

previewStyle string

Markdown editor's preview style (tab, vertical)

initialEditType string

Initial editor type (markdown, wysiwyg)

events object

eventlist Event list

Properties
Name Type Description
load function

It would be emitted when editor fully load

change function

It would be emitted when content changed

stateChange function

It would be emitted when format change by cursor position

focus function

It would be emitted when editor get focus

blur function

It would be emitted when editor loose focus

hooks object

Hook list

Properties
Name Type Description
previewBeforeHook function

Submit preview to hook URL before preview be shown

addImageBlobHook addImageBlobHook

hook for image upload.

language string <optional>
'en_US'

language

useCommandShortcut boolean <optional>
true

whether use keyboard shortcuts to perform commands

useDefaultHTMLSanitizer boolean <optional>
true

use default htmlSanitizer

codeBlockLanguages Array.<string> <optional>

supported code block languages to be listed. default is what highlight.js supports

usageStatistics boolean <optional>
true

send hostname to google analytics

toolbarItems Array.<object> <optional>

toolbar items.

hideModeSwitch boolean <optional>
false

hide mode switch tab bar

Members

static Button :Class.<Button>

Button class

Deprecated:
  • Yes

static codeBlockManager :CodeBlockManager

CodeBlockManager instance

static CommandManager :Class.<CommandManager>

CommandManager class

static domUtils :DomUtil

domUtil instance

static i18n :I18n

I18n instance

static isViewer :boolean

check whther is viewer

static markdownitHighlight :MarkdownIt

MarkdownIt hightlight instance

static WwCodeBlockManager :Class.<WwCodeBlockManager>

WwCodeBlockManager class

static WwTableManager :Class.<WwTableManager>

WwTableManager class

static WwTableSelectionManager :Class.<WwTableSelectionManager>

WwTableManager class

Methods

static defineExtension(name, ext)

Define extension

Parameters:
Name Type Description
name string

Extension name

ext ExtManager~extension

extension

static factory(options) → {ToastUIEditor}

Factory method for Editor

Parameters:
Name Type Description
options object

Option for initialize TUIEditor

Returns:
ToastUIEditor

static getInstances() → {Array}

Get instance of TUIEditor

Returns:
Array

addHook(type, handler)

Add hook to TUIEditor event

Parameters:
Name Type Description
type string

Event type

handler function

Event handler

addWidget(selection, node, style, offsetopt)

Add widget to selection

Parameters:
Name Type Attributes Description
selection Range

Current selection

node Node

widget node

style string

Adding style "over" or "bottom"

offset number <optional>

Offset for adjust position

afterAddedCommand()

After added command.

blur()

Remove focus of current Editor

changeMode(mode, isWithoutFocus)

Change editor's mode to given mode string

Parameters:
Name Type Description
mode string

Editor mode name of want to change

isWithoutFocus boolean

Change mode without focus

changePreviewStyle(style)

change preview style

Parameters:
Name Type Description
style string

'tab'|'vertical'

exec()

call commandManager's exec method

focus()

Set focus to current Editor

getCodeMirror() → {CodeMirror}

Get CodeMirror instance

Returns:
CodeMirror

getCurrentModeEditor() → {string}

Get current editor mode name

Returns:
string

getCurrentPreviewStyle() → {string}

Get current Markdown editor's preview style

Returns:
string

getHtml() → {string}

Get html syntax text.

Returns:
string

getMarkdown() → {string}

Get markdown syntax text.

Returns:
string

getRange() → {Object|Range}

Get current range

Returns:
Object | Range

getSelectedText() → {string}

get selected text

Returns:
string -
  • selected text

getSquire() → {SquireExt}

Get SquireExt instance

Returns:
SquireExt

getTextObject(range) → {object}

Get text object of current range

Parameters:
Name Type Description
range Object | Range

Range object of each editor

Returns:
object -

TextObject class

getUI() → {UI}

Get _ui property

Returns:
UI

getValue() → {string}

Get editor value.

Returns:
string
Deprecated:
  • Yes

height(height) → {string}

Set and return edithr height

Parameters:
Name Type Description
height string

editor height

Returns:
string -

editor height

hide()

Hide TUIEditor

insertText(text)

insert text

Parameters:
Name Type Description
text string

text string to insert

isMarkdownMode() → {boolean}

Return true if current editor mode is Markdown

Returns:
boolean

isViewer() → {boolean}

Return false

Returns:
boolean

isWysiwygMode() → {boolean}

Return true if current editor mode is WYSIWYG

Returns:
boolean

minHeight(minHeight) → {string}

Set / Get min content height

Parameters:
Name Type Description
minHeight string

min content height in pixel

Returns:
string -
  • min height in pixel

moveCursorToEnd()

Set cursor position to end

moveCursorToStart()

Set cursor position to start

off(type)

Unbind eventHandler from event type

Parameters:
Name Type Description
type string

Event type

on(type, handler)

Bind eventHandler to event type

Parameters:
Name Type Description
type string

Event type

handler function

Event handler

remove()

Remove TUIEditor from document

removeHook(type)

Remove hook from TUIEditor event

Parameters:
Name Type Description
type string

Event type

reset()

Reset TUIEditor

scrollTop(value) → {number}

Scroll Editor content to Top

Parameters:
Name Type Description
value number

Scroll amount

Returns:
number

setHtml(html, cursorToEndopt)

Set html value.

Parameters:
Name Type Attributes Default Description
html string

html syntax text

cursorToEnd boolean <optional>
true

move cursor to contents end

setMarkdown(markdown, cursorToEndopt)

Set markdown syntax text.

Parameters:
Name Type Attributes Default Description
markdown string

markdown syntax text.

cursorToEnd boolean <optional>
true

move cursor to contents end

setUI(UI)

Set UI to private UI property

Parameters:
Name Type Description
UI UI

UI instance

setValue(value, cursorToEndopt)

Set markdown syntax text.

Parameters:
Name Type Attributes Default Description
value string

markdown syntax text

cursorToEnd boolean <optional>
true

move cursor to contents end

Deprecated:
  • Yes

show()

Show TUIEditor