1Writer

JavaScript Documentation / editor

This object contains methods for interacting with 1Writer's text editor.

editor.getSelectedRange()

Returns the range of the current selection in the editor. The returned value is an array of two integer values, contains the positions of the first and last characters.

Example

editor.setSelectedRange(start[, end])

Selects a range of text in the editor. You can move the caret by setting the start parameter to the position where you want the caret to move to and omit the end parameter.

Parameters

Example

editor.getSelectedLineRange()

Returns the range of lines that includes the current selection.

editor.getSelectedText()

Returns the current selected text in the editor.

editor.getTextInRange(start, end)

Returns the text in the given range.

Parameters

editor.replaceTextInRange(start, end, replacement)

Replaces the text in the given range with replacement.

Parameters

editor.replaceSelection(replacement)

Replaces the text in the current selection with replacement.

Parameters

editor.getText()

Returns the entire text in the editor.

editor.setText(text)

Replaces the entire text in the editor with text.

Parameters

editor.getFolderPath()

Returns the folder path of the file that is currently opened in the editor.

editor.getFileName()

Returns the name of the file that is currently opened in the editor.

editor.newFile([text], [name], [callback])

Creates a new file with the given text and name.

Parameters

editor.openFile(path, [mode], [callback])

Opens an existing file.

Parameters

Example

editor.close()

Closes the file that is currently opened in the editor.

editor.isClosed()

Returns a boolean indicating whether a file is currently opened in the editor.