@susisu/mte-kernel

2.1.1 • Public • Published

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)

Package Sidebar

Install

npm i @susisu/mte-kernel

Weekly Downloads

69

Version

2.1.1

License

MIT

Unpacked Size

599 kB

Total Files

22

Last publish

Collaborators

  • susisu