@atlaskit/editor-plugin-show-diff
Version:
ShowDiff plugin for @atlaskit/editor-core
48 lines (46 loc) • 2.35 kB
JavaScript
/**
* Pre-refactor `createInlineChangedDecoration` styling code, preserved verbatim for the OFF cohort
* of `platform_editor_show_diff_color_scheme_refactor`.
*
* This module exists so the OFF cohort keeps running the code that shipped before the
* `colorSchemeRegistry` + `factory.ts` migration. Standard deleted styles are resolved at runtime
* only so the ADF-safety gate can select the equivalent longhand; with that gate off, their CSS
* remains unchanged. Delete the whole file at experiment cleanup (EDITOR-8281).
*/
import { deletedInlineContentStyleExtended, editingStyleActiveExtended, editingStyleActiveExtendedNoUnderline, editingStyleExtended, editingStyleExtendedNoUnderline, getStandardDeletedContentStyle, getStandardDeletedContentStyleActive } from './colorSchemes/standard';
import { getDeletedTraditionalInlineStyle, traditionalInsertStyle, traditionalInsertStyleActive } from './colorSchemes/traditional';
/**
* Pre-refactor inline `style` computation for `createInlineChangedDecoration`.
*/
export const resolveInlineChangedStyleLegacy = ({
colorScheme,
hideAddedDiffsUnderline,
isActive,
isInserted
}) => {
if (isInserted) {
if (colorScheme === 'traditional') {
return isActive ? traditionalInsertStyleActive : traditionalInsertStyle;
}
return isActive ? hideAddedDiffsUnderline ? editingStyleActiveExtendedNoUnderline : editingStyleActiveExtended : hideAddedDiffsUnderline ? editingStyleExtendedNoUnderline : editingStyleExtended;
}
if (colorScheme === 'traditional') {
return getDeletedTraditionalInlineStyle(false);
}
return (isActive ? getStandardDeletedContentStyleActive() : getStandardDeletedContentStyle()) + deletedInlineContentStyleExtended;
};
/**
* 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 const getAtomicInlineNodeClassNameLegacy = (inlineNodeName, colorScheme) => {
const classNames = ['show-diff-atomic-inline-changed'];
if (inlineNodeName) {
classNames.push(`show-diff-atomic-inline-changed-${inlineNodeName}`);
}
if (colorScheme === 'traditional') {
classNames.push('show-diff-atomic-inline-changed-traditional');
}
return classNames.join(' ');
};