UNPKG

@atlaskit/editor-plugin-show-diff

Version:

ShowDiff plugin for @atlaskit/editor-core

23 lines (22 loc) • 852 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.normalizeTextNodes = void 0; var _model = require("@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 = exports.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(_model.Fragment.fromArray(children)); };