@atlaskit/editor-plugin-metrics
Version:
Metrics plugin for @atlaskit/editor-core
17 lines • 576 B
JavaScript
import { ActionType } from '../types';
export var checkTextInput = function checkTextInput(step) {
var _ref = step,
content = _ref.slice.content,
from = _ref.from,
to = _ref.to;
var node = content.firstChild;
var isAddingCharacter = from === to && content.childCount === 1 && !!node && !!node.text && node.text.length === 1;
var isDeletingCharacter = to - from === 1 && content.childCount === 0;
var isTextInput = isAddingCharacter || isDeletingCharacter;
if (!isTextInput) {
return undefined;
}
return {
type: ActionType.TEXT_INPUT
};
};