UNPKG

@atlaskit/editor-common

Version:

A package that contains common classes and components for editor and renderer

17 lines (16 loc) 631 B
import _slicedToArray from "@babel/runtime/helpers/slicedToArray"; // TODO: remove from editor-core utils, re-export from editor-common import { ReplaceStep } from '@atlaskit/editor-prosemirror/transform'; export var isTextInput = function isTextInput(tr) { var _tr$steps = _slicedToArray(tr.steps, 1), step = _tr$steps[0]; if (!step || !(step instanceof ReplaceStep)) { return false; } var _ref = step, content = _ref.slice.content, from = _ref.from, to = _ref.to; var char = content.firstChild; return from === to && content.childCount === 1 && !!char && !!char.text && char.text.length === 1; };