Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/susisu/mte-kernel
text editor independent part of markdown-table-editor
https://github.com/susisu/mte-kernel
javascript markdown
Last synced: 2 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 (over 7 years ago)
- Default Branch: master
- Last Pushed: 2020-11-28T10:49:13.000Z (about 4 years ago)
- Last Synced: 2024-10-11T21:19:36.516Z (3 months ago)
- Topics: javascript, markdown
- Language: JavaScript
- Homepage:
- Size: 437 KB
- Stars: 76
- Watchers: 2
- Forks: 35
- 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].![demo](https://github.com/susisu/markdown-table-editor/wiki/images/demo.gif)
[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))