Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const extractSelected = function (cells) {
// Assume for now that we only have one table (also handles the case where we multi select outside a table)
return TableLookup.table(cells[0]).map(Replication.deep).map(function (replica) {
return [ CopySelected.extract(replica, Ephemera.attributeSelector()) ];
});
};
return TableSelection.getSelectionStartCellOrCaption(editor).bind((cellOrCaption) => {
const table = TableLookup.table(cellOrCaption);
return table.map((table) => {
if (Node.name(cellOrCaption) === 'caption') {
return TableTargets.notCell(cellOrCaption);
} else {
return TableTargets.forMenu(selections, table, cellOrCaption);
}
});
});
};
cellOpt.each(function (domCell) {
const cell = Element.fromDom(domCell);
TableLookup.table(cell).each((table) => {
const elements = Arr.filter(Elements.fromHtml(e.content), function (content) {
return Node.name(content) !== 'meta';
});
if (elements.length === 1 && Node.name(elements[0]) === 'table') {
e.preventDefault();
const doc = Element.fromDom(editor.getDoc());
const generators = TableFill.paste(doc);
const targets = TableTargets.paste(cell, elements[0], generators);
actions.pasteCells(table, targets).each(function (rng) {
editor.selection.setRng(rng);
editor.focus();
cellSelection.clear(table);
});
}, function (current) {
return TableLookup.table(current, isRoot).bind(function (table) {
const targets = TableTargets.noMenu(current);
editor.undoManager.transact(function () {
actions.insertRowsAfter(table, targets);
});
return getNewRowCursorPosition(editor, table);
});
});
};