Skip to content

text editor independent part of markdown-table-editor

License

Notifications You must be signed in to change notification settings

susisu/mte-kernel

Repository files navigation

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)

About

text editor independent part of markdown-table-editor

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published