https://github.com/susisu/mte-kernel
text editor independent part of markdown-table-editor
https://github.com/susisu/mte-kernel
javascript markdown
Last synced: 8 months ago
JSON representation
text editor independent part of markdown-table-editor
- Host: GitHub
- URL: https://github.com/susisu/mte-kernel
- Owner: susisu
- License: mit
- Created: 2017-09-09T05:02:54.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2020-11-28T10:49:13.000Z (over 5 years ago)
- Last Synced: 2025-06-03T15:08:19.631Z (about 1 year ago)
- Topics: javascript, markdown
- Language: JavaScript
- Homepage:
- Size: 437 KB
- Stars: 78
- Watchers: 2
- Forks: 39
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# markdown-table-editor kernel
The text editor independent part of [atom-markdown-table-editor][atom-mte].

[You can try it on your browser!](https://susisu.github.io/mte-demo/)
## Installation
``` shell
npm i -S @susisu/mte-kernel
```
## Usage
Implement an [interface to the text editor][doc-ITextEditor].
``` javascript
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): void;
transact(func: Function): void;
}
```
And then you can execute [commands][doc-TableEditor] through a `TableEditor` object.
``` javascript
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][doc-API] for more information.
It is also good to look into [atom-markdown-table-editor][atom-mte-repo] as a reference implementation.
[doc-API]: https://doc.esdoc.org/github.com/susisu/mte-kernel/identifiers.html
[doc-ITextEditor]: https://doc.esdoc.org/github.com/susisu/mte-kernel/class/lib/text-editor.js~ITextEditor.html
[doc-TableEditor]: https://doc.esdoc.org/github.com/susisu/mte-kernel/class/lib/table-editor.js~TableEditor.html
[atom-mte]: https://atom.io/packages/markdown-table-editor
[atom-mte-repo]: https://github.com/susisu/atom-markdown-table-editor
## License
[MIT License](http://opensource.org/licenses/mit-license.php)
## Author
Susisu ([GitHub](https://github.com/susisu), [Twitter](https://twitter.com/susisu2413))