UNPKG

@atlaskit/editor-plugin-metrics

Version:

Metrics plugin for @atlaskit/editor-core

26 lines 605 B
import { ActionType } from '../types'; export const checkEmptyLineAddedOrDeleted = step => { const { slice: { content }, from, to } = step; const isEmptyLineDeleted = to - from === 2 && content.size === 0; if (isEmptyLineDeleted) { return { type: ActionType.EMPTY_LINE_ADDED_OR_DELETED }; } let isEmptyLineAdded = false; content.forEach(node => { isEmptyLineAdded = node.type.name === 'paragraph' && node.content.size === 0; }); if (!isEmptyLineAdded) { return undefined; } return { type: ActionType.EMPTY_LINE_ADDED_OR_DELETED }; };