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

prosemirror-tables

Package Overview
Dependencies
Maintainers
1
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prosemirror-tables - npm Package Compare versions

Comparing version 0.6.5 to 0.7.0

4

demo.js

@@ -51,3 +51,3 @@ import {EditorView} from "prosemirror-view"

let doc = DOMParser.fromSchema(schema).parse(document.querySelector("#content"))
let state = EditorState.create({doc, plugins: exampleSetup({schema, menuContent: menu}).concat(
let state = EditorState.create({doc, plugins: [
columnResizing(),

@@ -59,3 +59,3 @@ tableEditing(),

})
)})
].concat(exampleSetup({schema, menuContent: menu}))})
let fix = fixTables(state)

@@ -62,0 +62,0 @@ if (fix) state = state.apply(fix.setMeta("addToHistory", false))

{
"name": "prosemirror-tables",
"version": "0.6.5",
"version": "0.7.0",
"description": "ProseMirror's rowspan/colspan tables component",

@@ -37,6 +37,6 @@ "main": "dist/index.js",

"prosemirror-test-builder": "^1.0.0",
"rollup": "^0.49.0",
"rollup-plugin-buble": "^0.15.0",
"rollup-plugin-commonjs": "^6.0.0",
"rollup-plugin-node-resolve": "^3.0.0",
"rollup": "^0.57.0",
"rollup-plugin-buble": "^0.19.0",
"rollup-plugin-commonjs": "^9.1.0",
"rollup-plugin-node-resolve": "^3.3.0",
"builddocs": "^0.3.0"

@@ -43,0 +43,0 @@ },

@@ -20,3 +20,3 @@ import buble from "rollup-plugin-buble"

commonJS({
include: '**',
include: '../**',
sourceMap: false

@@ -23,0 +23,0 @@ })

@@ -54,5 +54,5 @@ // This file defines a ProseMirror selection subclass that models

if (tableChanged && this.isRowSelection())
return CellSelection.rowSelection($anchorCell, $headCell)
else if (tableChanged && this.isColSelection())
return CellSelection.colSelection($anchorCell, $headCell)
else if (tableChanged && this.isColSelection())
return CellSelection.rowSelection($anchorCell, $headCell)
else

@@ -132,5 +132,5 @@ return new CellSelection($anchorCell, $headCell)

// :: (ResolvedPos, ?ResolvedPos) → CellSelection
// Returns the smallest row selection that covers the given anchor
// Returns the smallest column selection that covers the given anchor
// and head cell.
static rowSelection($anchorCell, $headCell = $anchorCell) {
static colSelection($anchorCell, $headCell = $anchorCell) {
let map = TableMap.get($anchorCell.node(-1)), start = $anchorCell.start(-1)

@@ -172,5 +172,5 @@ let anchorRect = map.findCell($anchorCell.pos - start), headRect = map.findCell($headCell.pos - start)

// :: (ResolvedPos, ?ResolvedPos) → CellSelection
// Returns the smallest column selection that covers the given anchor
// Returns the smallest row selection that covers the given anchor
// and head cell.
static colSelection($anchorCell, $headCell = $anchorCell) {
static rowSelection($anchorCell, $headCell = $anchorCell) {
let map = TableMap.get($anchorCell.node(-1)), start = $anchorCell.start(-1)

@@ -177,0 +177,0 @@ let anchorRect = map.findCell($anchorCell.pos - start), headRect = map.findCell($headCell.pos - start)

@@ -26,3 +26,3 @@ // This file defines a plugin that handles the drawing of cell

// perform more specific behavior.
export function tableEditing() {
export function tableEditing(options = {}) {
return new Plugin({

@@ -58,3 +58,3 @@ key,

handleKeyDown,
handleKeyDown: handleKeyDown(options.deleteRowsAndColumns),

@@ -61,0 +61,0 @@ handlePaste

@@ -14,20 +14,25 @@ // This file defines a number of helpers for wiring up user input to

import {tableNodeTypes} from "./schema"
import {deleteRow, deleteColumn} from "./commands"
export const handleKeyDown = keydownHandler({
"ArrowLeft": arrow("horiz", -1),
"ArrowRight": arrow("horiz", 1),
"ArrowUp": arrow("vert", -1),
"ArrowDown": arrow("vert", 1),
export function handleKeyDown(options) {
let deleteCellSel = deleteCellSelection(options)
"Shift-ArrowLeft": shiftArrow("horiz", -1),
"Shift-ArrowRight": shiftArrow("horiz", 1),
"Shift-ArrowUp": shiftArrow("vert", -1),
"Shift-ArrowDown": shiftArrow("vert", 1),
return keydownHandler({
"ArrowLeft": arrow("horiz", -1),
"ArrowRight": arrow("horiz", 1),
"ArrowUp": arrow("vert", -1),
"ArrowDown": arrow("vert", 1),
"Backspace": deleteCellSelection,
"Mod-Backspace": deleteCellSelection,
"Delete": deleteCellSelection,
"Mod-Delete": deleteCellSelection
})
"Shift-ArrowLeft": shiftArrow("horiz", -1),
"Shift-ArrowRight": shiftArrow("horiz", 1),
"Shift-ArrowUp": shiftArrow("vert", -1),
"Shift-ArrowDown": shiftArrow("vert", 1),
"Backspace": deleteCellSel,
"Mod-Backspace": deleteCellSel,
"Delete": deleteCellSel,
"Mod-Delete": deleteCellSel
})
}
function arrow(axis, dir) {

@@ -72,15 +77,21 @@ return (state, dispatch, view) => {

function deleteCellSelection(state, dispatch) {
let sel = state.selection
if (!(sel instanceof CellSelection)) return false
if (dispatch) {
let tr = state.tr, baseContent = tableNodeTypes(state.schema).cell.createAndFill().content
sel.forEachCell((cell, pos) => {
if (!cell.content.eq(baseContent))
tr.replace(tr.mapping.map(pos + 1), tr.mapping.map(pos + cell.nodeSize - 1),
new Slice(baseContent, 0, 0))
})
if (tr.docChanged) dispatch(tr)
function deleteCellSelection(options) {
return function(state, dispatch) {
let sel = state.selection
if (!(sel instanceof CellSelection)) return false
if (dispatch) {
if (options.deleteRowsAndColumns || true) {
if (sel.isRowSelection()) return deleteColumn(state, dispatch)
else if (sel.isColSelection()) return deleteRow(state, dispatch)
}
let tr = state.tr, baseContent = tableNodeTypes(state.schema).cell.createAndFill().content
sel.forEachCell((cell, pos) => {
if (!cell.content.eq(baseContent))
tr.replace(tr.mapping.map(pos + 1), tr.mapping.map(pos + cell.nodeSize - 1),
new Slice(baseContent, 0, 0))
})
if (tr.docChanged) dispatch(tr)
}
return true
}
return true
}

@@ -87,0 +98,0 @@

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

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