Home Reference Source Test
import {ITextEditor} from '@susisu/mte-kernel'
public interface | source

ITextEditor

The ITextEditor represents an interface to a text editor.

Test:

Method Summary

Public Methods
public

Checks if the editor accepts a table at a row to be editted.

public

Deletes a line at a specified row.

public

Gets the current cursor position.

public

Gets the last row index of the text editor.

public

Gets a line string at a row.

public

Inserts a line at a specified row.

public

replaceLines(startRow: number, endRow: number, lines: Array<string>): undefined

Replace lines in a specified range.

public

Sets the cursor position to a specified one.

public

Sets the selection range.

public

Batches multiple operations as a single undo/redo step.

Public Methods

public acceptsTableEdit(row: number): boolean source

Checks if the editor accepts a table at a row to be editted. It should return false if, for example, the row is in a code block (not Markdown).

Params:

NameTypeAttributeDescription
row number

A row index in the text editor.

Return:

boolean

true if the table at the row can be editted.

Test:

public deleteLine(row: number): undefined source

Deletes a line at a specified row.

Params:

NameTypeAttributeDescription
row number

Row index, starts from 0.

Return:

undefined

Test:

public getCursorPosition(): Point source

Gets the current cursor position.

Return:

Point

A point object that represents the cursor position.

Test:

public getLastRow(): number source

Gets the last row index of the text editor.

Return:

number

The last row index.

Test:

public getLine(row: number): string source

Gets a line string at a row.

Params:

NameTypeAttributeDescription
row number

Row index, starts from 0.

Return:

string

The line at the specified row. The line must not contain an EOL like "\n" or "\r".

Test:

public insertLine(row: number, line: string): undefined source

Inserts a line at a specified row.

Params:

NameTypeAttributeDescription
row number

Row index, starts from 0.

line string

A string to be inserted. This must not contain an EOL like "\n" or "\r".

Return:

undefined

Test:

public replaceLines(startRow: number, endRow: number, lines: Array<string>): undefined source

Replace lines in a specified range.

Params:

NameTypeAttributeDescription
startRow number

Start row index, starts from 0.

endRow number

End row index. Lines from startRow to endRow - 1 is replaced.

lines Array<string>

An array of string. Each strings must not contain an EOL like "\n" or "\r".

Return:

undefined

Test:

public setCursorPosition(pos: Point): undefined source

Sets the cursor position to a specified one.

Params:

NameTypeAttributeDescription
pos Point

A point object which the cursor position is set to.

Return:

undefined

Test:

public setSelectionRange(range: Range): undefined source

Sets the selection range. This method also expects the cursor position to be moved as the end of the selection range.

Params:

NameTypeAttributeDescription
range Range

A range object that describes a selection range.

Return:

undefined

Test:

public transact(func: Function): undefined source

Batches multiple operations as a single undo/redo step.

Params:

NameTypeAttributeDescription
func Function

A callback function that executes some operations on the text editor.

Return:

undefined

Test: