UNPKG

slate-edit-table

Version:

A Slate plugin to handle keyboard events in tables.

27 lines (22 loc) 529 B
// @flow import { Block, Text, type Node } from 'slate'; import type Options from '../options'; /** * Create a new cell */ function createCell(opts: Options, nodes?: Node[]): Block { return Block.create({ type: opts.typeCell, nodes: nodes || [createEmptyContent(opts)] }); } /** * Create a new default content block */ function createEmptyContent(opts: Options): Block { return Block.create({ type: opts.typeContent, nodes: [Text.create()] }); } export default createCell;