prosemirror-tables-adui
Advanced tools
Comparing version 1.0.0 to 1.0.1
{ | ||
"name": "prosemirror-tables-adui", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "ProseMirror's rowspan/colspan tables component", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -75,5 +75,5 @@ import {Plugin, PluginKey} from "prosemirror-state" | ||
if (event.clientX - left <= handleWidth) | ||
cell = edgeCell(view, event, "left") | ||
cell = edgeCell(view, event, "left", handleWidth) | ||
else if (right - event.clientX <= handleWidth) | ||
cell = edgeCell(view, event, "right") | ||
cell = edgeCell(view, event, "right", handleWidth) | ||
} | ||
@@ -116,7 +116,7 @@ | ||
while (dom.nodeName != "TABLE") { dom = dom.parentNode; } | ||
const cols = [...dom.getElementsByTagName('col')]; | ||
const cols = [].slice.call(dom.getElementsByTagName('col')) | ||
let cellMaxWidth = 960; | ||
cols.forEach((col, i) => { | ||
if (i !== colIndex) { | ||
cellMaxWidth = cellMaxWidth - (col.style.width ? parseInt(col.style.width.split('px')[0], 10) : 100); | ||
cellMaxWidth = cellMaxWidth - ((col.style && col.style.width) ? parseInt(col.style.width.split('px')[0], 10) : cellMinWidth); | ||
} | ||
@@ -166,4 +166,4 @@ }); | ||
function edgeCell(view, event, side) { | ||
const buffer = side == 'right' ? -5 : 5; // Fixes finicky bug where posAtCoords could return wrong pos. | ||
function edgeCell(view, event, side, handleWidth) { | ||
const buffer = side == 'right' ? -handleWidth : handleWidth; // Fixes finicky bug where posAtCoords could return wrong pos. | ||
let found = view.posAtCoords({left: event.clientX + buffer, top: event.clientY}) | ||
@@ -180,5 +180,5 @@ if (!found) return -1 | ||
function draggedWidth(dragging, event, cellMinWidth) { | ||
function draggedWidth(dragging, event, cellMinWidth, cellMaxWidth) { | ||
let offset = event.clientX - dragging.startX | ||
return Math.max(cellMinWidth, dragging.startWidth + offset) | ||
return Math.min(Math.max(cellMinWidth, dragging.startWidth + offset), cellMaxWidth) | ||
} | ||
@@ -185,0 +185,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1319948