UNPKG

@atlaskit/editor-plugin-show-diff

Version:

ShowDiff plugin for @atlaskit/editor-core

19 lines (18 loc) • 757 B
import { Fragment } from '@atlaskit/editor-prosemirror/model'; /** * Returns a copy of `node` in which adjacent text nodes with identical marks are joined, the same * normalisation ProseMirror applies whenever it rebuilds a node's content. A document parsed straight * from ADF keeps such split runs, so two documents with identical content and positions can still * differ in child count. */ var _normalizeTextNodes = function normalizeTextNodes(node) { if (node.isText || node.childCount === 0) { return node; } var children = []; node.content.forEach(function (child) { return children.push(_normalizeTextNodes(child)); }); return node.copy(Fragment.fromArray(children)); }; export { _normalizeTextNodes as normalizeTextNodes };