@atlaskit/editor-common
Version:
A package that contains common classes and components for editor and renderer
18 lines (17 loc) • 484 B
JavaScript
// TODO: remove from editor-core utils, re-export from editor-common
import { ReplaceStep } from '@atlaskit/editor-prosemirror/transform';
export const isTextInput = tr => {
const [step] = tr.steps;
if (!step || !(step instanceof ReplaceStep)) {
return false;
}
const {
slice: {
content
},
from,
to
} = step;
const char = content.firstChild;
return from === to && content.childCount === 1 && !!char && !!char.text && char.text.length === 1;
};