Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
handleEvent: (event, editor) => {
let td = cacheGetTableCell(event, editor);
let vtable = new VTable(td);
let isUp = event.rawEvent.which == Keys.UP;
let step = isUp ? -1 : 1;
let targetTd: HTMLTableCellElement = null;
let hasShiftKey = event.rawEvent.shiftKey;
let { anchorNode, anchorOffset } = editor.getSelection();
for (let row = vtable.row; row >= 0 && row < vtable.cells.length; row += step) {
let cell = vtable.getCell(row, vtable.col);
if (cell.td && cell.td != td) {
targetTd = cell.td;
break;
}
}
editor.runAsync(() => {
let newContainer = editor.getElementAtCursor();
if (
let cell = vtable.getCell(row, col);
if (cell.td) {
editor.select(cell.td, PositionType.Begin);
break;
}
}
event.rawEvent.preventDefault();
},
};
/**
* UpDownInTable edit feature, provides the ability to jump to cell above/below when user press UP/DOWN
* in table
*/
export const UpDownInTable: ContentEditFeature = {
keys: [Keys.UP, Keys.DOWN],
shouldHandleEvent: cacheGetTableCell,
handleEvent: (event, editor) => {
let td = cacheGetTableCell(event, editor);
let vtable = new VTable(td);
let isUp = event.rawEvent.which == Keys.UP;
let step = isUp ? -1 : 1;
let targetTd: HTMLTableCellElement = null;
let hasShiftKey = event.rawEvent.shiftKey;
let { anchorNode, anchorOffset } = editor.getSelection();
for (let row = vtable.row; row >= 0 && row < vtable.cells.length; row += step) {
let cell = vtable.getCell(row, vtable.col);
if (cell.td && cell.td != td) {
targetTd = cell.td;
break;
}