@atlaskit/editor-plugin-metrics
Version:
Metrics plugin for @atlaskit/editor-core
23 lines (22 loc) • 709 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.checkTextInput = void 0;
var _types = require("../types");
var checkTextInput = exports.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: _types.ActionType.TEXT_INPUT
};
};