@atlaskit/editor-plugin-show-diff
Version:
ShowDiff plugin for @atlaskit/editor-core
62 lines (60 loc) • 2.63 kB
JavaScript
/**
* 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 const resolveInlineChangedStyleLegacy = ({
colorScheme,
diffType,
hideAddedDiffsUnderline,
isActive,
isInserted
}) => {
let 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 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(' ');
};