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

@udecode/plate-table

Package Overview
Dependencies
Maintainers
3
Versions
222
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@udecode/plate-table - npm Package Compare versions

Comparing version 38.0.1 to 38.0.5

7

dist/index.d.ts

@@ -92,7 +92,6 @@ import * as slate from 'slate';

declare function computeCellIndices(editor: SlateEditor, tableEl: TTableElement, cellEl: TTableCellElement): {
declare function computeCellIndices(editor: SlateEditor, tableNode: TTableElement, cellNode?: TTableCellElement): {
col: number;
row: number;
} | null;
declare const computeAllCellIndices: (editor: SlateEditor, tableNode: TTableElement) => void;
} | undefined;

@@ -208,2 +207,2 @@ declare const findCellByIndexes: (editor: SlateEditor, table: TTableElement, searchRowIndex: number, searchColIndex: number) => TTableCellElement | undefined;

export { BaseTableCellHeaderPlugin, BaseTableCellPlugin, BaseTablePlugin, BaseTableRowPlugin, BorderDirection, CreateCellOptions, KEY_SHIFT_EDGES, TTableCellElement, TTableElement, TableConfig, TableStoreCellAttributes, TableStoreSizeOverrides, computeAllCellIndices, computeCellIndices, deleteTable, findCellByIndexes, getCellInNextTableRow, getCellInPreviousTableRow, getCellIndices, getCellIndicesWithSpans, getCellPath, getCellRowIndexByPath, getCellTypes, getColSpan, getEmptyCellNode, getLeftTableCell, getNextTableCell, getPreviousTableCell, getRowSpan, getSelectionWidth, getTableAbove, getTableColumnCount, getTableEntries, getTableMergedColumnCount, getTableOverriddenColSizes, getTopTableCell, insertTableMergeColumn, insertTableMergeRow, isTableBorderHidden, isTableRectangular, setBorderSize, setTableColSize, setTableMarginLeft, setTableRowSize, withNormalizeTable, withTable };
export { BaseTableCellHeaderPlugin, BaseTableCellPlugin, BaseTablePlugin, BaseTableRowPlugin, BorderDirection, CreateCellOptions, KEY_SHIFT_EDGES, TTableCellElement, TTableElement, TableConfig, TableStoreCellAttributes, TableStoreSizeOverrides, computeCellIndices, deleteTable, findCellByIndexes, getCellInNextTableRow, getCellInPreviousTableRow, getCellIndices, getCellIndicesWithSpans, getCellPath, getCellRowIndexByPath, getCellTypes, getColSpan, getEmptyCellNode, getLeftTableCell, getNextTableCell, getPreviousTableCell, getRowSpan, getSelectionWidth, getTableAbove, getTableColumnCount, getTableEntries, getTableMergedColumnCount, getTableOverriddenColSizes, getTopTableCell, insertTableMergeColumn, insertTableMergeRow, isTableBorderHidden, isTableRectangular, setBorderSize, setTableColSize, setTableMarginLeft, setTableRowSize, withNormalizeTable, withTable };
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;

@@ -8,2 +9,3 @@ var __defProps = Object.defineProperties;

var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;

@@ -48,2 +50,10 @@ var __propIsEnum = Object.prototype.propertyIsEnumerable;

};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

@@ -59,3 +69,2 @@

KEY_SHIFT_EDGES: () => KEY_SHIFT_EDGES,
computeAllCellIndices: () => computeAllCellIndices,
computeCellIndices: () => computeCellIndices,

@@ -128,2 +137,3 @@ deleteTable: () => deleteTable,

var import_plate_common14 = require("@udecode/plate-common");
var import_cloneDeep = __toESM(require("lodash/cloneDeep"));
var import_slate5 = require("slate");

@@ -383,61 +393,34 @@

// src/lib/merge/computeCellIndices.ts
function computeCellIndices(editor, tableEl, cellEl) {
var _a;
function computeCellIndices(editor, tableNode, cellNode) {
var _a, _b;
const options = editor.getOptions(BaseTablePlugin);
const tableNodes = tableEl.children;
let rowIndex = -1;
let colIndex = -1;
for (let r = 0; r < tableNodes.length; r++) {
const row = tableNodes[r];
let cIndex = 0;
for (const item of row.children) {
const cell = item;
if (cellEl === cell) {
colIndex = cIndex;
rowIndex = r;
const skipCells = [];
let targetIndices;
for (let rowIndex = 0; rowIndex < tableNode.children.length; rowIndex++) {
const row = tableNode.children[rowIndex];
let colIndex = 0;
for (const cellElement of row.children) {
while ((_a = skipCells[rowIndex]) == null ? void 0 : _a[colIndex]) {
colIndex++;
}
const currentIndices = { col: colIndex, row: rowIndex };
(_b = options._cellIndices) == null ? void 0 : _b.set(cellElement, currentIndices);
if (cellElement === cellNode) {
targetIndices = currentIndices;
break;
}
cIndex += getColSpan(cell);
}
}
tableNodes.slice(0, rowIndex).forEach((pR, _rowIndex) => {
const prevRow = pR;
prevRow.children.forEach((pC) => {
var _a2;
const prevCell = pC;
const prevIndices = (_a2 = options == null ? void 0 : options._cellIndices) == null ? void 0 : _a2.get(prevCell);
const _rowSpan = getRowSpan(prevCell);
if (prevIndices) {
const { col: prevColIndex } = prevIndices;
if (
// colIndex affects
prevColIndex <= colIndex && // rowSpan affects
_rowSpan && _rowSpan > 1 && rowIndex - _rowIndex < _rowSpan
) {
colIndex += getColSpan(prevCell);
const colSpan = getColSpan(cellElement);
const rowSpan = getRowSpan(cellElement);
for (let r = 0; r < rowSpan; r++) {
skipCells[rowIndex + r] = skipCells[rowIndex + r] || [];
for (let c = 0; c < colSpan; c++) {
skipCells[rowIndex + r][colIndex + c] = true;
}
}
});
});
if (rowIndex === -1 || colIndex === -1) {
return null;
colIndex += colSpan;
}
if (targetIndices) break;
}
const indices = { col: colIndex, row: rowIndex };
(_a = options == null ? void 0 : options._cellIndices) == null ? void 0 : _a.set(cellEl, indices);
return indices;
return targetIndices;
}
var computeAllCellIndices = (editor, tableNode) => {
var _a;
const options = editor.getOptions(BaseTablePlugin);
for (const tableChild of tableNode.children) {
const row = tableChild;
for (const rowChild of row.children) {
const cell = rowChild;
const indices = computeCellIndices(editor, tableNode, cell);
if (indices) {
(_a = options._cellIndices) == null ? void 0 : _a.set(cell, indices);
}
}
}
};

@@ -546,2 +529,3 @@ // src/lib/merge/getCellIndices.ts

affectedCells.forEach((cur) => {
var _a;
const curCell = cur;

@@ -559,7 +543,8 @@ const { col: curColIndex, row: curRowIndex } = getCellIndices(cellIndices, curCell) || computeCellIndices(editor, tableNode, curCell);

if (endCurI >= nextColIndex && !firstCol) {
(0, import_plate_common13.setNodes)(
editor,
__spreadProps(__spreadValues({}, curCell), { colSpan: curColSpan + 1 }),
{ at: currentCellPath }
);
const colSpan = curColSpan + 1;
const newCell = (0, import_cloneDeep.default)(__spreadProps(__spreadValues({}, curCell), { colSpan }));
if ((_a = newCell.attributes) == null ? void 0 : _a.colspan) {
newCell.attributes.colspan = colSpan.toString();
}
(0, import_plate_common13.setNodes)(editor, newCell, { at: currentCellPath });
} else {

@@ -708,2 +693,3 @@ const curRowPath = currentCellPath.slice(0, -1);

var import_plate_common16 = require("@udecode/plate-common");
var import_cloneDeep2 = __toESM(require("lodash/cloneDeep"));
var import_slate7 = require("slate");

@@ -769,2 +755,3 @@ var insertTableMergeRow = (editor, {

affectedCells.forEach((cur) => {
var _a;
if (!cur) return;

@@ -783,7 +770,8 @@ const curCell = cur;

if (endCurI >= nextRowIndex && !firstRow) {
(0, import_plate_common16.setNodes)(
editor,
__spreadProps(__spreadValues({}, curCell), { rowSpan: curRowSpan + 1 }),
{ at: currentCellPath }
);
const rowSpan = curRowSpan + 1;
const newCell = (0, import_cloneDeep2.default)(__spreadProps(__spreadValues({}, curCell), { rowSpan }));
if ((_a = newCell.attributes) == null ? void 0 : _a.rowspan) {
newCell.attributes.rowspan = rowSpan.toString();
}
(0, import_plate_common16.setNodes)(editor, newCell, { at: currentCellPath });
} else {

@@ -1252,3 +1240,2 @@ const row = (0, import_plate_common16.getParentNode)(editor, currentCellPath);

KEY_SHIFT_EDGES,
computeAllCellIndices,
computeCellIndices,

@@ -1255,0 +1242,0 @@ deleteTable,

{
"name": "@udecode/plate-table",
"version": "38.0.1",
"version": "38.0.5",
"description": "Table plugin for Plate",

@@ -60,3 +60,3 @@ "keywords": [

"peerDependencies": {
"@udecode/plate-common": ">=38.0.1",
"@udecode/plate-common": ">=38.0.4",
"react": ">=16.8.0",

@@ -63,0 +63,0 @@ "react-dom": ">=16.8.0",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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

Sorry, the diff of this file is not supported yet

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