UNPKG

@atlaskit/editor-plugin-metrics

Version:

Metrics plugin for @atlaskit/editor-core

22 lines 611 B
import { ReplaceStep } from '@atlaskit/editor-prosemirror/transform'; export var isNonTextUndo = function isNonTextUndo(tr) { if (tr.getMeta('undoRedoPlugin$') === undefined) { return false; } var hasNonTextChange = false; tr.steps.forEach(function (step) { if (step instanceof ReplaceStep) { var slice = step.slice; if (slice.content) { slice.content.forEach(function (node) { if (node.type.name !== 'text') { hasNonTextChange = true; } }); } } else { hasNonTextChange = true; } }); return hasNonTextChange; };