UNPKG

@atlaskit/editor-plugin-show-diff

Version:

ShowDiff plugin for @atlaskit/editor-core

61 lines (59 loc) 2.82 kB
/** * Pre-refactor `createInlineChangedDecoration` styling code, preserved verbatim for the OFF cohort * of `platform_editor_show_diff_color_scheme_refactor`. * * Do not modify — this module exists purely so the OFF cohort keeps running the exact code that * shipped before the `colorSchemeRegistry` + `factory.ts` migration. Delete the whole file at * experiment cleanup (EDITOR-8281). */ import { isExtendedEnabled } from '../isExtendedEnabled'; import { deletedContentStyle, deletedContentStyleActive, deletedInlineContentStyleExtended, editingStyle, editingStyleActive, editingStyleActiveExtended, editingStyleActiveExtendedNoUnderline, editingStyleExtended, editingStyleExtendedNoUnderline } from './colorSchemes/standard'; import { getDeletedTraditionalInlineStyle, traditionalInsertStyle, traditionalInsertStyleActive } from './colorSchemes/traditional'; /** * Pre-refactor inline `style` computation for `createInlineChangedDecoration`. */ export var resolveInlineChangedStyleLegacy = function resolveInlineChangedStyleLegacy(_ref) { var colorScheme = _ref.colorScheme, diffType = _ref.diffType, hideAddedDiffsUnderline = _ref.hideAddedDiffsUnderline, isActive = _ref.isActive, isInserted = _ref.isInserted; var style; if (isExtendedEnabled(diffType)) { if (isInserted) { if (colorScheme === 'traditional') { style = isActive ? traditionalInsertStyleActive : traditionalInsertStyle; } else { style = isActive ? hideAddedDiffsUnderline ? editingStyleActiveExtendedNoUnderline : editingStyleActiveExtended : hideAddedDiffsUnderline ? editingStyleExtendedNoUnderline : editingStyleExtended; } } else { if (colorScheme === 'traditional') { style = getDeletedTraditionalInlineStyle(false); } else { style = (isActive ? deletedContentStyleActive : deletedContentStyle) + deletedInlineContentStyleExtended; } } } else { if (colorScheme === 'traditional') { style = isActive ? traditionalInsertStyleActive : traditionalInsertStyle; } else { style = isActive ? editingStyleActive : editingStyle; } } return style; }; /** * Pre-refactor class names for an atomic inline node decoration (date, emoji, mention, status). * The colour was carried by the per-scheme `-traditional` class rather than by an inline CSS * variable on the same element. */ export var getAtomicInlineNodeClassNameLegacy = function getAtomicInlineNodeClassNameLegacy(inlineNodeName, colorScheme) { var classNames = ['show-diff-atomic-inline-changed']; if (inlineNodeName) { classNames.push("show-diff-atomic-inline-changed-".concat(inlineNodeName)); } if (colorScheme === 'traditional') { classNames.push('show-diff-atomic-inline-changed-traditional'); } return classNames.join(' '); };