Home Reference Source Test

markdown-table-editor kernel

The text editor independent part of atom-markdown-table-editor.

demo

You can try it on your browser!

Installation

npm i -S @susisu/mte-kernel

Usage

Implement an interface to the text editor.

interface ITextEditor {
  getCursorPosition(): Point;
  setCursorPosition(pos: Point): void;
  setSelectionRange(range: Range): void;
  getLastRow(): number;
  acceptsTableEdit(row: number): boolean;
  getLine(row: number): string;
  insertLine(row: number, line: string): void;
  deleteLine(row: number): void;
  replaceLines(startRow: number, endRow: number, lines: Array<string>): void;
  transact(func: Function): void;
}

And then you can execute commands through a TableEditor object.

import { TableEditor, options } from "@susisu/mte-kernel";
const textEditor = ...; // interface to the text editor
const tableEditor = new TableEditor(textEditor);
tableEditor.formatAll(options({}));

See the API reference for more information. It is also good to look into atom-markdown-table-editor as a reference implementation.

License

MIT License

Author

Susisu (GitHub, Twitter)

Changelog

2.0.0

  • ! TableEditor#cursorIsInTable now requires options argument
  • Add leftMarginChars option

1.0.0

  • First release