UNPKG

@atlaskit/editor-plugin-show-diff

Version:

ShowDiff plugin for @atlaskit/editor-core

19 lines (16 loc) • 1.09 kB
import { getDiffableAttrNames } from './diffableAttrs'; /** * A cell background as it renders: absent, empty and `"null"` — the string agent payloads send for * no background — all mean the cell has none. */ export const normalizeCellBackground = background => typeof background === 'string' && background !== '' && background !== 'null' ? background : null; /** Whether two cells render different backgrounds. */ export const isCellBackgroundChanged = (left, right) => normalizeCellBackground(left.attrs.background) !== normalizeCellBackground(right.attrs.background); /** * Whether two cells differ by an attribute that represents a change, such as their background or * span, as opposed to only their content. */ export const isCellAttrChanged = (left, right) => { var _getDiffableAttrNames; return ((_getDiffableAttrNames = getDiffableAttrNames(left.type.name, left.attrs)) !== null && _getDiffableAttrNames !== void 0 ? _getDiffableAttrNames : []).some(name => name === 'background' ? isCellBackgroundChanged(left, right) : left.attrs[name] !== right.attrs[name]); };