Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
onDeleteKeyDown (event) {
const { onMerge, onRemove } = this.props;
if (! onMerge && ! onRemove) {
return;
}
const { keyCode } = event;
const isReverse = keyCode === BACKSPACE;
// User is using the Remove Block shortcut, so allow the event to bubble
// up to the BlockSettingsMenu component
if (isKeyboardEvent.primaryAlt(event, 'Backspace')) {
return;
}
const { isCollapsed } = getSelection();
// Only process delete if the key press occurs at uncollapsed edge.
if (! isCollapsed) {
return;
}
// It is important to consider emptiness because an empty container
// will include a bogus TinyMCE BR node _after_ the caret, so in a
// forward deletion the isHorizontalEdge function will incorrectly
// interpret the presence of the bogus node as not being at the edge.
const isEmpty = this.isEmpty();
const isEdge = (