Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

prosemirror-tables

Package Overview
Dependencies
Maintainers
6
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prosemirror-tables

ProseMirror's rowspan/colspan tables component

  • 1.1.2
  • Source
  • npm
  • Socket score

Version published
Maintainers
6
Created

What is prosemirror-tables?

The prosemirror-tables package provides a set of tools for working with tables in the ProseMirror editor. It allows you to create, edit, and manipulate tables within your ProseMirror-based text editor.

What are prosemirror-tables's main functionalities?

Creating a Table

This code demonstrates how to create a table using the prosemirror-tables package. It extends the basic ProseMirror schema to include table nodes and then creates a table node.

const { schema } = require('prosemirror-schema-basic');
const { tableNodes, addTableNodes } = require('prosemirror-tables');
const { Schema } = require('prosemirror-model');

const mySchema = new Schema({
  nodes: addTableNodes(schema.spec.nodes, 'table', 'block'),
  marks: schema.spec.marks
});

const table = mySchema.nodes.table.createAndFill();

Adding a Row

This code shows how to add a row to an existing table in the ProseMirror editor. The addRow function is used to insert a new row at the current selection.

const { addRow } = require('prosemirror-tables');

function addRowToTable(state, dispatch) {
  const { tr } = state;
  dispatch(tr.setSelection(state.selection));
  dispatch(addRow(tr, state.selection.$anchorCell.pos));
}

Deleting a Column

This code demonstrates how to delete a column from a table in the ProseMirror editor. The deleteColumn function is used to remove the column at the current selection.

const { deleteColumn } = require('prosemirror-tables');

function deleteColumnFromTable(state, dispatch) {
  const { tr } = state;
  dispatch(tr.setSelection(state.selection));
  dispatch(deleteColumn(tr, state.selection.$anchorCell.pos));
}

Merging Cells

This code shows how to merge selected cells in a table. The mergeCells function is used to combine the selected cells into a single cell.

const { mergeCells } = require('prosemirror-tables');

function mergeSelectedCells(state, dispatch) {
  const { tr } = state;
  dispatch(tr.setSelection(state.selection));
  dispatch(mergeCells(tr));
}

Other packages similar to prosemirror-tables

FAQs

Package last updated on 11 Jul 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc