@atlaskit/editor-plugin-show-diff
Version:
ShowDiff plugin for @atlaskit/editor-core
67 lines (64 loc) • 2.95 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.resolveInlineChangedStyleLegacy = exports.getAtomicInlineNodeClassNameLegacy = void 0;
var _isExtendedEnabled = require("../isExtendedEnabled");
var _standard = require("./colorSchemes/standard");
var _traditional = require("./colorSchemes/traditional");
/**
* 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).
*/
/**
* Pre-refactor inline `style` computation for `createInlineChangedDecoration`.
*/
var resolveInlineChangedStyleLegacy = exports.resolveInlineChangedStyleLegacy = function resolveInlineChangedStyleLegacy(_ref) {
var colorScheme = _ref.colorScheme,
diffType = _ref.diffType,
hideAddedDiffsUnderline = _ref.hideAddedDiffsUnderline,
isActive = _ref.isActive,
isInserted = _ref.isInserted;
var style;
if ((0, _isExtendedEnabled.isExtendedEnabled)(diffType)) {
if (isInserted) {
if (colorScheme === 'traditional') {
style = isActive ? _traditional.traditionalInsertStyleActive : _traditional.traditionalInsertStyle;
} else {
style = isActive ? hideAddedDiffsUnderline ? _standard.editingStyleActiveExtendedNoUnderline : _standard.editingStyleActiveExtended : hideAddedDiffsUnderline ? _standard.editingStyleExtendedNoUnderline : _standard.editingStyleExtended;
}
} else {
if (colorScheme === 'traditional') {
style = (0, _traditional.getDeletedTraditionalInlineStyle)(false);
} else {
style = (isActive ? _standard.deletedContentStyleActive : _standard.deletedContentStyle) + _standard.deletedInlineContentStyleExtended;
}
}
} else {
if (colorScheme === 'traditional') {
style = isActive ? _traditional.traditionalInsertStyleActive : _traditional.traditionalInsertStyle;
} else {
style = isActive ? _standard.editingStyleActive : _standard.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.
*/
var getAtomicInlineNodeClassNameLegacy = exports.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(' ');
};