@atlaskit/editor-plugin-metrics
Version:
Metrics plugin for @atlaskit/editor-core
24 lines • 590 B
JavaScript
import { ReplaceStep } from '@atlaskit/editor-prosemirror/transform';
export const isNonTextUndo = tr => {
if (tr.getMeta('undoRedoPlugin$') === undefined) {
return false;
}
let hasNonTextChange = false;
tr.steps.forEach(step => {
if (step instanceof ReplaceStep) {
const {
slice
} = step;
if (slice.content) {
slice.content.forEach(node => {
if (node.type.name !== 'text') {
hasNonTextChange = true;
}
});
}
} else {
hasNonTextChange = true;
}
});
return hasNonTextChange;
};