canvist_extension_table 0.2.2

canvist: TipTap's `table`, `tableRow`, `tableCell`, and `tableHeader`, with commands to add, remove, merge, and split cells
Documentation

canvist_extension_table

TipTap's table, tableRow, tableCell, and tableHeader, with commands to add, remove, merge, and split cells, for the canvist editor.

Most apps get it through canvist_extensions, which combines every extension behind Cargo features, or canvist, the crate to install. Depend on this crate directly to compile only the extensions you register:

cargo add canvist_extension_table

Usage

Register Table and keep its handle, which offers every command typed:

use canvist_core::Editor;
use canvist_extension_document::Document;
use canvist_extension_paragraph::Paragraph;
use canvist_extension_table::Table;

let mut builder = Editor::builder().extension(Document).extension(Paragraph);
let table = builder.add(Table);
let mut editor = builder.build()?;

editor.run(&table.insert(3, 3, true), &mut env)?;
editor.run(&table.add_row_after(), &mut env)?;
editor.run(&table.merge_cells(), &mut env)?;

Hosts without the typed API run the same commands by name: insertTable with rows, cols, and withHeaderRow, addRowAfter, mergeCells, and the rest. The tableCell query says where the caret sits. Pasting and copying tables as HTML and Markdown needs canvist_extension_clipboard with its table feature.

License

Unlicense