UNPKG

@atlaskit/editor-plugin-show-diff

Version:

ShowDiff plugin for @atlaskit/editor-core

45 lines (43 loc) 955 B
/** * Configurable thresholds for the `smart` diffType. * * See docs/smart-diff-design.md §3 and §6 for the exact semantics of each level. */ export const DEFAULT_SMART_THRESHOLDS = { sentence: { ratio: 0.4, minChanged: 2 }, paragraph: { ratio: 0.4, minChanged: 2 }, node: { ratio: 0.6, textBearingRatio: 0.6 } }; /** * Merge caller overrides onto the defaults. Overrides are shallow-merged per level so a * caller can tune a single field (e.g. only `sentence.ratio`) without re-specifying the * rest. */ export const resolveThresholds = overrides => { if (!overrides) { return DEFAULT_SMART_THRESHOLDS; } return { sentence: { ...DEFAULT_SMART_THRESHOLDS.sentence, ...overrides.sentence }, paragraph: { ...DEFAULT_SMART_THRESHOLDS.paragraph, ...overrides.paragraph }, node: { ...DEFAULT_SMART_THRESHOLDS.node, ...overrides.node } }; };