refactor(remove-nodes): check if target has contenteditable attr closes #560

This commit is contained in:
moklick
2020-10-07 17:40:35 +02:00
parent 926a03d052
commit d8ae6bd9a2

View File

@@ -2,8 +2,11 @@ import { DraggableEvent } from 'react-draggable';
import { MouseEvent as ReactMouseEvent } from 'react';
export const isInputDOMNode = (e: ReactMouseEvent | DraggableEvent | KeyboardEvent) => {
const target = e.target as HTMLElement;
return e && target && ['INPUT', 'SELECT', 'TEXTAREA', 'BUTTON'].includes(target.nodeName);
const target = e?.target as HTMLElement;
return (
['INPUT', 'SELECT', 'TEXTAREA', 'BUTTON'].includes(target?.nodeName) || target?.hasAttribute('contenteditable')
);
};
export const getDimensions = (node: HTMLDivElement) => ({