Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const onPaste = (event, editor, next) => {
if (!isEditable(editor, 'paste')) {
return false;
}
if (isEditable(editor, 'paste')) {
event.preventDefault();
const transfer = getEventTransfer(event);
if (transfer.type === 'html') {
const htmlTransformer = new HtmlTransformer();
const slateTransformer = new SlateTransformer();
// @ts-ignore
const ciceroMark = htmlTransformer.toCiceroMark(transfer.html, 'json');
const { document } = slateTransformer.fromCiceroMark(ciceroMark);
editor.insertFragment(document);
return;
}
}
return next();
};