Trevixal API
    Preparing search index...

    Module @trevixal/extension-table

    @trevixal/extension-table

    CI npm types license

    Documentation · Live editor · Changelog · Issues

    The Trevixal editor

    • Insert, merge, split, sort; row and column editing
    • Column resize, header rows, alignment and borders
    • Keyboard navigation and CSV import/export
    • 10.2 kB minified and gzipped, with TypeScript types in the package

    Tables: structure, merging, sorting, borders, CSV, and the keyboard.

    npm install @trevixal/extension-table
    

    Merge the nodes into your schema:

    new Schema({ nodes: { ...defaultNodes(), ...tableNodes() }, marks: defaultMarks() })
    
    import { tableKeymap, insertTable, addRow, toggleHeaderRow } from '@trevixal/extension-table'

    const editor = createEditor({ schema, element, keymap: tableKeymap() })

    editor.exec(insertTable({ rows: 3, cols: 3 }))
    editor.exec(addRow('after'))
    editor.exec(toggleHeaderRow)

    tableKeymap() makes Tab and Shift+Tab move between cells, then fall through to code-block indentation and list nesting. Each binding chains through every context the key means something in, because an override replaces the base binding wholesale.

    Structure: insertTable, addRow, addColumn, deleteRow, deleteColumn, deleteTable, mergeCells, splitCell, toggleHeaderRow, goToNextCell.

    Appearance: setCellAlign, setCellBackground, setTableBorders (all, outer, horizontal, none), setTableBorderColor.

    Data: sortTable, convertTextToTable, convertTableToText, parseCSV, insertTableFromCSV, tableToCSV, csvAtSelection, detectDelimiter.

    Sizing: createTableResizeHandles for drag handles, plus setColumnWidth, setRowHeight, setTableWidth, distributeColumnsEvenly, clearTableSizing.

    Moving: moveRow, moveColumn, swapCellContent.

    Cells merge across columns only. rowspan is not in the model, which keeps every row a flat list of cells and every structural edit simple arithmetic (ADR-0006). A column move that would cut through a merged cell declines rather than silently rewriting the merge.

    A drag stores proportions, not pixels. A width measured in a fullscreen window is meaningless in a narrow one, and table-layout: fixed will widen a table past any max-width to fit its columns. Columns are stored as a share of the table, the table as a share of the space it sits in.

    Apache-2.0

    BuiltTable
    CellContext
    CellRef
    ColumnLine
    DrawnTable
    FormulaScope
    InsertCSVOptions
    InsertTableOptions
    MeasuredSizingOptions
    Placed
    ResizeHandles
    ResizeHandlesOptions
    RowFilter
    RowLine
    SortTableOptions
    SplitCellsOptions
    TableDesign
    TableGeometry
    TableLayout
    TableSizing
    TableSizingTarget
    TableStyleChoice
    TableTools
    TableToolsOptions
    TableToTextOptions
    TableUICommands
    TableUICommandsOptions
    TextToTableOptions
    CellAlign
    CellSide
    CellVerticalAlign
    ChartKind
    ColumnType
    CSVDelimiter
    FilterCondition
    MeasureTable
    MoveDirection
    TableBorders
    TableBorderStyle
    TableBorderWidth
    TableDesignOption
    TableStyle
    TableStyleOption
    TableTool
    TextSeparator
    ACTIVE_CELL_CLASS
    autoFitContents
    autoFitWindow
    CELL_SIDES
    CELL_VERTICAL_ALIGNS
    clearTableSizing
    COLUMN_TYPES
    deleteColumn
    deleteRow
    deleteTable
    escapeTableOnEnter
    FILTER_CONDITIONS
    FORMULA_ERROR
    FORMULA_FUNCTIONS
    FORMULA_ZERO_DIVIDE
    GRID_BAND_ATTRIBUTE
    GRID_COLUMN_ATTRIBUTE
    GRID_LAST_ATTRIBUTE
    hideColumn
    MAX_SPLIT_COLUMNS
    MAX_SPLIT_ROWS
    mergeCells
    RANGE_CELL_CLASS
    showAllColumns
    showAllRows
    SNAP_DISTANCE
    splitCell
    TABLE_BORDER_STYLES
    TABLE_BORDER_WIDTHS
    TABLE_BORDERS
    TABLE_DESIGN_OPTIONS
    TABLE_STYLE_OPTIONS
    TABLE_STYLES
    toggleFreezeFirstColumn
    toggleFreezeHeaderRow
    toggleHeaderRow
    addColumn
    addRow
    buildTable
    caretAtGrid
    cellContextAt
    cellPadding
    cellShownText
    cellSideHidden
    cellsInSelection
    cellValueType
    cellVerticalAlign
    columnCount
    columnStart
    columnTypeAt
    compareCellText
    convertTableToText
    convertTextToTable
    createTableResizeHandles
    createTableTools
    csvAtSelection
    detectDelimiter
    detectTextSeparator
    distributeColumnsEvenly
    distributeRowsEvenly
    drawColumnLine
    drawRowLine
    enableCellCheckboxes
    enableCellSelection
    evaluateFormula
    filterRows
    fixColumnWidths
    formatFormulaResult
    formatForType
    formulaAt
    formulaNear
    formulaNodes
    formulaSteps
    goToNextCell
    gridCellOf
    hiddenAt
    hiddenBordersValue
    hiddenSides
    hideCellBorder
    highlightActiveCell
    insertDrawnTable
    insertFormula
    insertTable
    insertTableChart
    insertTableFromCSV
    installFormulaUpdater
    isoDate
    markGridColumns
    measureCellShare
    measureTableGeometry
    mergeRect
    moveColumn
    moveRow
    parseCellNumber
    parseCSV
    passesFilter
    placementsOf
    rowGroups
    rowspanOf
    rowsToCSV
    safeTableLength
    setCellAlign
    setCellBackground
    setCellPadding
    setCellVerticalAlign
    setColumnType
    setColumnWidth
    setRowHeight
    setTableBorderColor
    setTableBorders
    setTableBorderStyle
    setTableBorderWidth
    setTableSizing
    setTableStyle
    setTableWidth
    showCellBorder
    sortTable
    splitCellInto
    suggestedFormula
    swapCellContent
    tableBorders
    tableBorderStyle
    tableBorderWidth
    tableChartSource
    tableColumnLabels
    tableDesignAt
    tableFrom
    tableKeymap
    tableLayoutAt
    tableNodes
    tableStyle
    tableToCSV
    tableToRows
    tableUICommands
    toggleCellChecked
    toggleTableStyleOption
    updateFormulasTransform