ProseMirror / prosemirror-tables

Table module for ProseMirror
https://prosemirror-tables.netlify.app/
MIT License
259 stars 155 forks source link

ProseMirror table module

This module defines a schema extension to support tables with rowspan/colspan support, a custom selection class for cell selections in such a table, a plugin to manage such selections and enforce invariants on such tables, and a number of commands to work with tables.

The top-level directory contains a demo.js and index.html, which can be built with pnpm run build_demo to show a simple demo of how the module can be used.

Live Demo

Documentation

The module's main file exports everything you need to work with it. The first thing you'll probably want to do is create a table-enabled schema. That's what tableNodes is for:

class CellSelection extends Selection

A Selection subclass that represents a cell selection spanning part of a table. With the plugin enabled, these will be created when the user selects across cells, and will be drawn by giving selected cells a selectedCell CSS class.

Commands

The following commands can be used to make table-editing functionality available to users.

Utilities

class TableMap

A table map describes the structore of a given table. To avoid recomputing them all the time, they are cached per table node. To be able to do that, positions saved in the map are relative to the start of the table, rather than the start of the document.