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

@udecode/plate-table

Package Overview
Dependencies
Maintainers
2
Versions
216
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 7.0.2 to 8.0.0

dist/onKeyDownTable.d.ts

2

CHANGELOG.md
# @udecode/plate-table
## 8.0.0
## 7.0.2

@@ -4,0 +6,0 @@

7

dist/createTablePlugin.d.ts

@@ -1,6 +0,9 @@

import { PlatePlugin } from '@udecode/plate-core';
export declare const ELEMENT_TABLE = "table";
export declare const ELEMENT_TH = "th";
export declare const ELEMENT_TR = "tr";
export declare const ELEMENT_TD = "td";
/**
* Enables support for tables.
*/
export declare const createTablePlugin: () => PlatePlugin;
export declare const createTablePlugin: <T = {}>(override?: Partial<import("@udecode/plate-core").PlatePlugin<T, {}>> | undefined, overrideByKey?: import("@udecode/plate-core").OverrideByKey<T> | undefined) => import("@udecode/plate-core").PlatePlugin<T, {}>;
//# sourceMappingURL=createTablePlugin.d.ts.map

@@ -5,5 +5,3 @@ /**

export * from './createTablePlugin';
export * from './defaults';
export * from './getTableDeserialize';
export * from './getTableOnKeyDown';
export * from './onKeyDownTable';
export * from './types';

@@ -10,0 +8,0 @@ export * from './withTable';

@@ -1,71 +0,4 @@

import { getPlatePluginOptions, getPlatePluginType, isElement, getRenderElement } from '@udecode/plate-core';
import { getElementDeserializer, someNode, getParent, getAbove, isCollapsed, findNodePath, ELEMENT_DEFAULT, insertNodes, findNode, setNodes } from '@udecode/plate-common';
import { someNode, getPluginType, getParent, getAbove, isCollapsed, isElement, createPluginFactory, findNodePath, ELEMENT_DEFAULT, insertNodes, findNode, setNodes } from '@udecode/plate-core';
import { Editor, Path, Transforms, Node, Point } from 'slate';
const ELEMENT_TABLE = 'table';
const ELEMENT_TH = 'th';
const ELEMENT_TR = 'tr';
const ELEMENT_TD = 'td';
const KEYS_TABLE = [ELEMENT_TABLE, ELEMENT_TH, ELEMENT_TR, ELEMENT_TD];
const DEFAULTS_TH = {
getNodeProps: ({
element
}) => {
var _element$attributes, _element$attributes2;
return {
colSpan: element === null || element === void 0 ? void 0 : (_element$attributes = element.attributes) === null || _element$attributes === void 0 ? void 0 : _element$attributes.colspan,
rowSpan: element === null || element === void 0 ? void 0 : (_element$attributes2 = element.attributes) === null || _element$attributes2 === void 0 ? void 0 : _element$attributes2.rowspan
};
}
};
const DEFAULTS_TD = {
getNodeProps: ({
element
}) => {
var _element$attributes3, _element$attributes4;
return {
colSpan: element === null || element === void 0 ? void 0 : (_element$attributes3 = element.attributes) === null || _element$attributes3 === void 0 ? void 0 : _element$attributes3.colspan,
rowSpan: element === null || element === void 0 ? void 0 : (_element$attributes4 = element.attributes) === null || _element$attributes4 === void 0 ? void 0 : _element$attributes4.rowspan
};
}
};
const getTableDeserialize = () => editor => {
const table = getPlatePluginOptions(editor, ELEMENT_TABLE);
const td = getPlatePluginOptions(editor, ELEMENT_TD);
const th = getPlatePluginOptions(editor, ELEMENT_TH);
const tr = getPlatePluginOptions(editor, ELEMENT_TR);
return {
element: [...getElementDeserializer({
type: table.type,
rules: [{
nodeNames: 'TABLE'
}],
...table.deserialize
}), ...getElementDeserializer({
type: tr.type,
rules: [{
nodeNames: 'TR'
}],
...tr.deserialize
}), ...getElementDeserializer({
type: td.type,
attributeNames: ['rowspan', 'colspan'],
rules: [{
nodeNames: 'TD'
}],
...td.deserialize
}), ...getElementDeserializer({
type: th.type,
attributeNames: ['rowspan', 'colspan'],
rules: [{
nodeNames: 'TH'
}],
...th.deserialize
})]
};
};
function getCellInNextTableRow(editor, currentRowPath) {

@@ -132,3 +65,3 @@ try {

match: {
type: [getPlatePluginType(editor, ELEMENT_TD), getPlatePluginType(editor, ELEMENT_TH)]
type: [getPluginType(editor, ELEMENT_TD), getPluginType(editor, ELEMENT_TH)]
}

@@ -142,3 +75,3 @@ })) {

match: {
type: [getPlatePluginType(editor, ELEMENT_TD), getPlatePluginType(editor, ELEMENT_TH)]
type: [getPluginType(editor, ELEMENT_TD), getPluginType(editor, ELEMENT_TH)]
}

@@ -148,7 +81,7 @@ }) || getParent(editor, paragraphPath);

const [tableCellNode, tableCellPath] = tableCell;
if (tableCellNode.type !== getPlatePluginType(editor, ELEMENT_TD) && tableCellNode.type !== getPlatePluginType(editor, ELEMENT_TH)) return;
if (tableCellNode.type !== getPluginType(editor, ELEMENT_TD) && tableCellNode.type !== getPluginType(editor, ELEMENT_TH)) return;
const tableRow = getParent(editor, tableCellPath);
if (!tableRow) return;
const [tableRowNode, tableRowPath] = tableRow;
if (tableRowNode.type !== getPlatePluginType(editor, ELEMENT_TR)) return;
if (tableRowNode.type !== getPluginType(editor, ELEMENT_TR)) return;
const tableElement = getParent(editor, tableRowPath);

@@ -164,3 +97,5 @@ if (!tableElement) return;

const getTableOnKeyDown = () => editor => e => {
const onKeyDownTable = (editor, {
type
}) => e => {
if (e.key === 'Tab') {

@@ -199,6 +134,5 @@ e.preventDefault();

if (e.key === 'a' && (e.metaKey || e.ctrlKey)) {
const options = getPlatePluginOptions(editor, ELEMENT_TABLE);
const res = getAbove(editor, {
match: {
type: options.type
type
}

@@ -215,5 +149,5 @@ });

const withTable = () => editor => {
const withTable = editor => {
const matchCells = node => {
return isElement(node) && (node.type === getPlatePluginType(editor, ELEMENT_TD) || node.type === getPlatePluginType(editor, ELEMENT_TH));
return isElement(node) && (node.type === getPluginType(editor, ELEMENT_TD) || node.type === getPluginType(editor, ELEMENT_TH));
};

@@ -335,2 +269,6 @@

const ELEMENT_TABLE = 'table';
const ELEMENT_TH = 'th';
const ELEMENT_TR = 'tr';
const ELEMENT_TD = 'td';
/**

@@ -340,8 +278,57 @@ * Enables support for tables.

const createTablePlugin = () => ({
pluginKeys: KEYS_TABLE,
renderElement: getRenderElement(KEYS_TABLE),
deserialize: getTableDeserialize(),
onKeyDown: getTableOnKeyDown(),
withOverrides: withTable()
const createTablePlugin = createPluginFactory({
key: ELEMENT_TABLE,
isElement: true,
handlers: {
onKeyDown: onKeyDownTable
},
deserializeHtml: {
validNodeName: 'TABLE'
},
withOverrides: withTable,
plugins: [{
key: ELEMENT_TR,
isElement: true,
deserializeHtml: {
validNodeName: 'TR'
}
}, {
key: ELEMENT_TD,
isElement: true,
deserializeHtml: {
attributeNames: ['rowspan', 'colspan'],
validNodeName: 'TD'
},
props: ({
element
}) => {
var _element$attributes, _element$attributes2;
return {
nodeProps: {
colSpan: element === null || element === void 0 ? void 0 : (_element$attributes = element.attributes) === null || _element$attributes === void 0 ? void 0 : _element$attributes.colspan,
rowSpan: element === null || element === void 0 ? void 0 : (_element$attributes2 = element.attributes) === null || _element$attributes2 === void 0 ? void 0 : _element$attributes2.rowspan
}
};
}
}, {
key: ELEMENT_TH,
isElement: true,
deserializeHtml: {
attributeNames: ['rowspan', 'colspan'],
validNodeName: 'TH'
},
props: ({
element
}) => {
var _element$attributes3, _element$attributes4;
return {
nodeProps: {
colSpan: element === null || element === void 0 ? void 0 : (_element$attributes3 = element.attributes) === null || _element$attributes3 === void 0 ? void 0 : _element$attributes3.colspan,
rowSpan: element === null || element === void 0 ? void 0 : (_element$attributes4 = element.attributes) === null || _element$attributes4 === void 0 ? void 0 : _element$attributes4.rowspan
}
};
}
}]
});

@@ -383,5 +370,5 @@

return {
type: header ? getPlatePluginType(editor, ELEMENT_TH) : getPlatePluginType(editor, ELEMENT_TD),
type: header ? getPluginType(editor, ELEMENT_TH) : getPluginType(editor, ELEMENT_TD),
children: [{
type: getPlatePluginType(editor, ELEMENT_DEFAULT),
type: getPluginType(editor, ELEMENT_DEFAULT),
children: [{

@@ -399,3 +386,3 @@ text: ''

match: {
type: getPlatePluginType(editor, ELEMENT_TABLE)
type: getPluginType(editor, ELEMENT_TABLE)
}

@@ -405,3 +392,3 @@ })) {

match: {
type: [getPlatePluginType(editor, ELEMENT_TH), getPlatePluginType(editor, ELEMENT_TD)]
type: [getPluginType(editor, ELEMENT_TH), getPluginType(editor, ELEMENT_TD)]
}

@@ -411,3 +398,3 @@ });

match: {
type: getPlatePluginType(editor, ELEMENT_TABLE)
type: getPluginType(editor, ELEMENT_TABLE)
}

@@ -440,3 +427,3 @@ });

return {
type: getPlatePluginType(editor, ELEMENT_TR),
type: getPluginType(editor, ELEMENT_TR),
children: Array(colCount).fill(colCount).map(() => getEmptyCellNode(editor, {

@@ -453,3 +440,3 @@ header

match: {
type: getPlatePluginType(editor, ELEMENT_TABLE)
type: getPluginType(editor, ELEMENT_TABLE)
}

@@ -459,3 +446,3 @@ })) {

match: {
type: getPlatePluginType(editor, ELEMENT_TR)
type: getPluginType(editor, ELEMENT_TR)
}

@@ -480,3 +467,3 @@ });

match: {
type: getPlatePluginType(editor, ELEMENT_TABLE)
type: getPluginType(editor, ELEMENT_TABLE)
}

@@ -486,3 +473,3 @@ })) {

match: {
type: [getPlatePluginType(editor, ELEMENT_TD), getPlatePluginType(editor, ELEMENT_TH)]
type: [getPluginType(editor, ELEMENT_TD), getPluginType(editor, ELEMENT_TH)]
}

@@ -492,3 +479,3 @@ });

match: {
type: getPlatePluginType(editor, ELEMENT_TR)
type: getPluginType(editor, ELEMENT_TR)
}

@@ -498,3 +485,3 @@ });

match: {
type: getPlatePluginType(editor, ELEMENT_TABLE)
type: getPluginType(editor, ELEMENT_TABLE)
}

@@ -521,3 +508,3 @@ });

match: {
type: getPlatePluginType(editor, ELEMENT_TABLE)
type: getPluginType(editor, ELEMENT_TABLE)
}

@@ -527,3 +514,3 @@ })) {

match: {
type: getPlatePluginType(editor, ELEMENT_TABLE)
type: getPluginType(editor, ELEMENT_TABLE)
}

@@ -533,3 +520,3 @@ });

match: {
type: getPlatePluginType(editor, ELEMENT_TR)
type: getPluginType(editor, ELEMENT_TR)
}

@@ -550,3 +537,3 @@ });

match: {
type: getPlatePluginType(editor, ELEMENT_TABLE)
type: getPluginType(editor, ELEMENT_TABLE)
}

@@ -556,3 +543,3 @@ })) {

match: {
type: getPlatePluginType(editor, ELEMENT_TABLE)
type: getPluginType(editor, ELEMENT_TABLE)
}

@@ -573,3 +560,3 @@ });

return {
type: getPlatePluginType(editor, ELEMENT_TABLE),
type: getPluginType(editor, ELEMENT_TABLE),
children: [getEmptyRowNode(editor, {

@@ -590,3 +577,3 @@ header,

match: {
type: getPlatePluginType(editor, ELEMENT_TABLE)
type: getPluginType(editor, ELEMENT_TABLE)
}

@@ -620,3 +607,3 @@ })) {

export { DEFAULTS_TD, DEFAULTS_TH, ELEMENT_TABLE, ELEMENT_TD, ELEMENT_TH, ELEMENT_TR, KEYS_TABLE, addColumn, addRow, createTablePlugin, deleteColumn, deleteRow, deleteTable, getCellInNextTableRow, getCellInPreviousTableRow, getEmptyCellNode, getEmptyRowNode, getEmptyTableNode, getNextTableCell, getPreviousTableCell, getTableCellEntry, getTableColumnCount, getTableColumnIndex, getTableDeserialize, getTableOnKeyDown, insertTable, setTableColSize, withTable };
export { ELEMENT_TABLE, ELEMENT_TD, ELEMENT_TH, ELEMENT_TR, addColumn, addRow, createTablePlugin, deleteColumn, deleteRow, deleteTable, getCellInNextTableRow, getCellInPreviousTableRow, getEmptyCellNode, getEmptyRowNode, getEmptyTableNode, getNextTableCell, getPreviousTableCell, getTableCellEntry, getTableColumnCount, getTableColumnIndex, insertTable, onKeyDownTable, setTableColSize, withTable };
//# sourceMappingURL=index.es.js.map

@@ -6,71 +6,4 @@ 'use strict';

var plateCore = require('@udecode/plate-core');
var plateCommon = require('@udecode/plate-common');
var slate = require('slate');
const ELEMENT_TABLE = 'table';
const ELEMENT_TH = 'th';
const ELEMENT_TR = 'tr';
const ELEMENT_TD = 'td';
const KEYS_TABLE = [ELEMENT_TABLE, ELEMENT_TH, ELEMENT_TR, ELEMENT_TD];
const DEFAULTS_TH = {
getNodeProps: ({
element
}) => {
var _element$attributes, _element$attributes2;
return {
colSpan: element === null || element === void 0 ? void 0 : (_element$attributes = element.attributes) === null || _element$attributes === void 0 ? void 0 : _element$attributes.colspan,
rowSpan: element === null || element === void 0 ? void 0 : (_element$attributes2 = element.attributes) === null || _element$attributes2 === void 0 ? void 0 : _element$attributes2.rowspan
};
}
};
const DEFAULTS_TD = {
getNodeProps: ({
element
}) => {
var _element$attributes3, _element$attributes4;
return {
colSpan: element === null || element === void 0 ? void 0 : (_element$attributes3 = element.attributes) === null || _element$attributes3 === void 0 ? void 0 : _element$attributes3.colspan,
rowSpan: element === null || element === void 0 ? void 0 : (_element$attributes4 = element.attributes) === null || _element$attributes4 === void 0 ? void 0 : _element$attributes4.rowspan
};
}
};
const getTableDeserialize = () => editor => {
const table = plateCore.getPlatePluginOptions(editor, ELEMENT_TABLE);
const td = plateCore.getPlatePluginOptions(editor, ELEMENT_TD);
const th = plateCore.getPlatePluginOptions(editor, ELEMENT_TH);
const tr = plateCore.getPlatePluginOptions(editor, ELEMENT_TR);
return {
element: [...plateCommon.getElementDeserializer({
type: table.type,
rules: [{
nodeNames: 'TABLE'
}],
...table.deserialize
}), ...plateCommon.getElementDeserializer({
type: tr.type,
rules: [{
nodeNames: 'TR'
}],
...tr.deserialize
}), ...plateCommon.getElementDeserializer({
type: td.type,
attributeNames: ['rowspan', 'colspan'],
rules: [{
nodeNames: 'TD'
}],
...td.deserialize
}), ...plateCommon.getElementDeserializer({
type: th.type,
attributeNames: ['rowspan', 'colspan'],
rules: [{
nodeNames: 'TH'
}],
...th.deserialize
})]
};
};
function getCellInNextTableRow(editor, currentRowPath) {

@@ -134,25 +67,25 @@ try {

} = {}) => {
if (at && plateCommon.someNode(editor, {
if (at && plateCore.someNode(editor, {
at,
match: {
type: [plateCore.getPlatePluginType(editor, ELEMENT_TD), plateCore.getPlatePluginType(editor, ELEMENT_TH)]
type: [plateCore.getPluginType(editor, ELEMENT_TD), plateCore.getPluginType(editor, ELEMENT_TH)]
}
})) {
const selectionParent = plateCommon.getParent(editor, at);
const selectionParent = plateCore.getParent(editor, at);
if (!selectionParent) return;
const [, paragraphPath] = selectionParent;
const tableCell = plateCommon.getAbove(editor, {
const tableCell = plateCore.getAbove(editor, {
at,
match: {
type: [plateCore.getPlatePluginType(editor, ELEMENT_TD), plateCore.getPlatePluginType(editor, ELEMENT_TH)]
type: [plateCore.getPluginType(editor, ELEMENT_TD), plateCore.getPluginType(editor, ELEMENT_TH)]
}
}) || plateCommon.getParent(editor, paragraphPath);
}) || plateCore.getParent(editor, paragraphPath);
if (!tableCell) return;
const [tableCellNode, tableCellPath] = tableCell;
if (tableCellNode.type !== plateCore.getPlatePluginType(editor, ELEMENT_TD) && tableCellNode.type !== plateCore.getPlatePluginType(editor, ELEMENT_TH)) return;
const tableRow = plateCommon.getParent(editor, tableCellPath);
if (tableCellNode.type !== plateCore.getPluginType(editor, ELEMENT_TD) && tableCellNode.type !== plateCore.getPluginType(editor, ELEMENT_TH)) return;
const tableRow = plateCore.getParent(editor, tableCellPath);
if (!tableRow) return;
const [tableRowNode, tableRowPath] = tableRow;
if (tableRowNode.type !== plateCore.getPlatePluginType(editor, ELEMENT_TR)) return;
const tableElement = plateCommon.getParent(editor, tableRowPath);
if (tableRowNode.type !== plateCore.getPluginType(editor, ELEMENT_TR)) return;
const tableElement = plateCore.getParent(editor, tableRowPath);
if (!tableElement) return;

@@ -167,3 +100,5 @@ return {

const getTableOnKeyDown = () => editor => e => {
const onKeyDownTable = (editor, {
type
}) => e => {
if (e.key === 'Tab') {

@@ -202,6 +137,5 @@ e.preventDefault();

if (e.key === 'a' && (e.metaKey || e.ctrlKey)) {
const options = plateCore.getPlatePluginOptions(editor, ELEMENT_TABLE);
const res = plateCommon.getAbove(editor, {
const res = plateCore.getAbove(editor, {
match: {
type: options.type
type
}

@@ -218,5 +152,5 @@ });

const withTable = () => editor => {
const withTable = editor => {
const matchCells = node => {
return plateCore.isElement(node) && (node.type === plateCore.getPlatePluginType(editor, ELEMENT_TD) || node.type === plateCore.getPlatePluginType(editor, ELEMENT_TH));
return plateCore.isElement(node) && (node.type === plateCore.getPluginType(editor, ELEMENT_TD) || node.type === plateCore.getPluginType(editor, ELEMENT_TH));
};

@@ -236,3 +170,3 @@

if (plateCommon.isCollapsed(selection)) {
if (plateCore.isCollapsed(selection)) {
const [cell] = slate.Editor.nodes(editor, {

@@ -315,3 +249,3 @@ match: matchCells

if (!plateCommon.isCollapsed(selection) && (start || end) && (start === null || start === void 0 ? void 0 : start[0]) !== (end === null || end === void 0 ? void 0 : end[0])) {
if (!plateCore.isCollapsed(selection) && (start || end) && (start === null || start === void 0 ? void 0 : start[0]) !== (end === null || end === void 0 ? void 0 : end[0])) {
const [cell] = slate.Editor.nodes(editor, {

@@ -340,2 +274,6 @@ match: matchCells

const ELEMENT_TABLE = 'table';
const ELEMENT_TH = 'th';
const ELEMENT_TR = 'tr';
const ELEMENT_TD = 'td';
/**

@@ -345,8 +283,57 @@ * Enables support for tables.

const createTablePlugin = () => ({
pluginKeys: KEYS_TABLE,
renderElement: plateCore.getRenderElement(KEYS_TABLE),
deserialize: getTableDeserialize(),
onKeyDown: getTableOnKeyDown(),
withOverrides: withTable()
const createTablePlugin = plateCore.createPluginFactory({
key: ELEMENT_TABLE,
isElement: true,
handlers: {
onKeyDown: onKeyDownTable
},
deserializeHtml: {
validNodeName: 'TABLE'
},
withOverrides: withTable,
plugins: [{
key: ELEMENT_TR,
isElement: true,
deserializeHtml: {
validNodeName: 'TR'
}
}, {
key: ELEMENT_TD,
isElement: true,
deserializeHtml: {
attributeNames: ['rowspan', 'colspan'],
validNodeName: 'TD'
},
props: ({
element
}) => {
var _element$attributes, _element$attributes2;
return {
nodeProps: {
colSpan: element === null || element === void 0 ? void 0 : (_element$attributes = element.attributes) === null || _element$attributes === void 0 ? void 0 : _element$attributes.colspan,
rowSpan: element === null || element === void 0 ? void 0 : (_element$attributes2 = element.attributes) === null || _element$attributes2 === void 0 ? void 0 : _element$attributes2.rowspan
}
};
}
}, {
key: ELEMENT_TH,
isElement: true,
deserializeHtml: {
attributeNames: ['rowspan', 'colspan'],
validNodeName: 'TH'
},
props: ({
element
}) => {
var _element$attributes3, _element$attributes4;
return {
nodeProps: {
colSpan: element === null || element === void 0 ? void 0 : (_element$attributes3 = element.attributes) === null || _element$attributes3 === void 0 ? void 0 : _element$attributes3.colspan,
rowSpan: element === null || element === void 0 ? void 0 : (_element$attributes4 = element.attributes) === null || _element$attributes4 === void 0 ? void 0 : _element$attributes4.rowspan
}
};
}
}]
});

@@ -368,5 +355,5 @@

const path = plateCommon.findNodePath(editor, node);
const path = plateCore.findNodePath(editor, node);
if (!path) return 0;
const [trNode] = (_getParent = plateCommon.getParent(editor, path)) !== null && _getParent !== void 0 ? _getParent : [];
const [trNode] = (_getParent = plateCore.getParent(editor, path)) !== null && _getParent !== void 0 ? _getParent : [];
if (!trNode) return 0;

@@ -389,5 +376,5 @@ let colIndex = 0;

return {
type: header ? plateCore.getPlatePluginType(editor, ELEMENT_TH) : plateCore.getPlatePluginType(editor, ELEMENT_TD),
type: header ? plateCore.getPluginType(editor, ELEMENT_TH) : plateCore.getPluginType(editor, ELEMENT_TD),
children: [{
type: plateCore.getPlatePluginType(editor, plateCommon.ELEMENT_DEFAULT),
type: plateCore.getPluginType(editor, plateCore.ELEMENT_DEFAULT),
children: [{

@@ -403,15 +390,15 @@ text: ''

}) => {
if (plateCommon.someNode(editor, {
if (plateCore.someNode(editor, {
match: {
type: plateCore.getPlatePluginType(editor, ELEMENT_TABLE)
type: plateCore.getPluginType(editor, ELEMENT_TABLE)
}
})) {
const currentCellItem = plateCommon.getAbove(editor, {
const currentCellItem = plateCore.getAbove(editor, {
match: {
type: [plateCore.getPlatePluginType(editor, ELEMENT_TH), plateCore.getPlatePluginType(editor, ELEMENT_TD)]
type: [plateCore.getPluginType(editor, ELEMENT_TH), plateCore.getPluginType(editor, ELEMENT_TD)]
}
});
const currentTableItem = plateCommon.getAbove(editor, {
const currentTableItem = plateCore.getAbove(editor, {
match: {
type: plateCore.getPlatePluginType(editor, ELEMENT_TABLE)
type: plateCore.getPluginType(editor, ELEMENT_TABLE)
}

@@ -428,3 +415,3 @@ });

const isHeaderRow = header === undefined ? row.children[0].type === ELEMENT_TH : header;
plateCommon.insertNodes(editor, getEmptyCellNode(editor, {
plateCore.insertNodes(editor, getEmptyCellNode(editor, {
header: isHeaderRow

@@ -445,3 +432,3 @@ }), {

return {
type: plateCore.getPlatePluginType(editor, ELEMENT_TR),
type: plateCore.getPluginType(editor, ELEMENT_TR),
children: Array(colCount).fill(colCount).map(() => getEmptyCellNode(editor, {

@@ -456,10 +443,10 @@ header

}) => {
if (plateCommon.someNode(editor, {
if (plateCore.someNode(editor, {
match: {
type: plateCore.getPlatePluginType(editor, ELEMENT_TABLE)
type: plateCore.getPluginType(editor, ELEMENT_TABLE)
}
})) {
const currentRowItem = plateCommon.getAbove(editor, {
const currentRowItem = plateCore.getAbove(editor, {
match: {
type: plateCore.getPlatePluginType(editor, ELEMENT_TR)
type: plateCore.getPluginType(editor, ELEMENT_TR)
}

@@ -470,3 +457,3 @@ });

const [currentRowElem, currentRowPath] = currentRowItem;
plateCommon.insertNodes(editor, getEmptyRowNode(editor, {
plateCore.insertNodes(editor, getEmptyRowNode(editor, {
header,

@@ -483,20 +470,20 @@ colCount: currentRowElem.children.length

const deleteColumn = editor => {
if (plateCommon.someNode(editor, {
if (plateCore.someNode(editor, {
match: {
type: plateCore.getPlatePluginType(editor, ELEMENT_TABLE)
type: plateCore.getPluginType(editor, ELEMENT_TABLE)
}
})) {
const currentCellItem = plateCommon.getAbove(editor, {
const currentCellItem = plateCore.getAbove(editor, {
match: {
type: [plateCore.getPlatePluginType(editor, ELEMENT_TD), plateCore.getPlatePluginType(editor, ELEMENT_TH)]
type: [plateCore.getPluginType(editor, ELEMENT_TD), plateCore.getPluginType(editor, ELEMENT_TH)]
}
});
const currentRowItem = plateCommon.getAbove(editor, {
const currentRowItem = plateCore.getAbove(editor, {
match: {
type: plateCore.getPlatePluginType(editor, ELEMENT_TR)
type: plateCore.getPluginType(editor, ELEMENT_TR)
}
});
const currentTableItem = plateCommon.getAbove(editor, {
const currentTableItem = plateCore.getAbove(editor, {
match: {
type: plateCore.getPlatePluginType(editor, ELEMENT_TABLE)
type: plateCore.getPluginType(editor, ELEMENT_TABLE)
}

@@ -521,15 +508,15 @@ });

const deleteRow = editor => {
if (plateCommon.someNode(editor, {
if (plateCore.someNode(editor, {
match: {
type: plateCore.getPlatePluginType(editor, ELEMENT_TABLE)
type: plateCore.getPluginType(editor, ELEMENT_TABLE)
}
})) {
const currentTableItem = plateCommon.getAbove(editor, {
const currentTableItem = plateCore.getAbove(editor, {
match: {
type: plateCore.getPlatePluginType(editor, ELEMENT_TABLE)
type: plateCore.getPluginType(editor, ELEMENT_TABLE)
}
});
const currentRowItem = plateCommon.getAbove(editor, {
const currentRowItem = plateCore.getAbove(editor, {
match: {
type: plateCore.getPlatePluginType(editor, ELEMENT_TR)
type: plateCore.getPluginType(editor, ELEMENT_TR)
}

@@ -548,10 +535,10 @@ });

const deleteTable = editor => {
if (plateCommon.someNode(editor, {
if (plateCore.someNode(editor, {
match: {
type: plateCore.getPlatePluginType(editor, ELEMENT_TABLE)
type: plateCore.getPluginType(editor, ELEMENT_TABLE)
}
})) {
const tableItem = plateCommon.getAbove(editor, {
const tableItem = plateCore.getAbove(editor, {
match: {
type: plateCore.getPlatePluginType(editor, ELEMENT_TABLE)
type: plateCore.getPluginType(editor, ELEMENT_TABLE)
}

@@ -572,3 +559,3 @@ });

return {
type: plateCore.getPlatePluginType(editor, ELEMENT_TABLE),
type: plateCore.getPluginType(editor, ELEMENT_TABLE),
children: [getEmptyRowNode(editor, {

@@ -587,8 +574,8 @@ header,

}) => {
if (!plateCommon.someNode(editor, {
if (!plateCore.someNode(editor, {
match: {
type: plateCore.getPlatePluginType(editor, ELEMENT_TABLE)
type: plateCore.getPluginType(editor, ELEMENT_TABLE)
}
})) {
plateCommon.insertNodes(editor, getEmptyTableNode(editor, {
plateCore.insertNodes(editor, getEmptyTableNode(editor, {
header

@@ -603,3 +590,3 @@ }));

}, options = {}) => {
const table = plateCommon.findNode(editor, { ...options,
const table = plateCore.findNode(editor, { ...options,
match: {

@@ -613,3 +600,3 @@ type: ELEMENT_TABLE

colSizes[colIndex] = width;
plateCommon.setNodes(editor, {
plateCore.setNodes(editor, {
colSizes

@@ -621,4 +608,2 @@ }, {

exports.DEFAULTS_TD = DEFAULTS_TD;
exports.DEFAULTS_TH = DEFAULTS_TH;
exports.ELEMENT_TABLE = ELEMENT_TABLE;

@@ -628,3 +613,2 @@ exports.ELEMENT_TD = ELEMENT_TD;

exports.ELEMENT_TR = ELEMENT_TR;
exports.KEYS_TABLE = KEYS_TABLE;
exports.addColumn = addColumn;

@@ -646,7 +630,6 @@ exports.addRow = addRow;

exports.getTableColumnIndex = getTableColumnIndex;
exports.getTableDeserialize = getTableDeserialize;
exports.getTableOnKeyDown = getTableOnKeyDown;
exports.insertTable = insertTable;
exports.onKeyDownTable = onKeyDownTable;
exports.setTableColSize = setTableColSize;
exports.withTable = withTable;
//# sourceMappingURL=index.js.map

@@ -7,3 +7,3 @@ import { PlateEditor } from '@udecode/plate-core';

*/
export declare const getTableCellEntry: (editor: PlateEditor, { at }?: {
export declare const getTableCellEntry: <T = {}>(editor: PlateEditor<T>, { at }?: {
at?: Location | null | undefined;

@@ -10,0 +10,0 @@ }) => {

@@ -1,3 +0,2 @@

import { EditorAboveOptions } from '@udecode/plate-common';
import { TEditor } from '@udecode/plate-core';
import { EditorAboveOptions, TEditor } from '@udecode/plate-core';
export declare const setTableColSize: (editor: TEditor, { colIndex, width }: {

@@ -4,0 +3,0 @@ colIndex: number;

import { WithOverride } from '@udecode/plate-core';
export declare const withTable: () => WithOverride;
export declare const withTable: WithOverride;
//# sourceMappingURL=withTable.d.ts.map
{
"name": "@udecode/plate-table",
"version": "7.0.2",
"version": "8.0.0",
"description": "Table plugin for Plate",

@@ -35,4 +35,3 @@ "keywords": [

"dependencies": {
"@udecode/plate-common": "7.0.2",
"@udecode/plate-core": "7.0.2"
"@udecode/plate-core": "8.0.0"
},

@@ -39,0 +38,0 @@ "peerDependencies": {

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 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 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 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 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