@atlaskit/editor-common
Version:
A package that contains common classes and components for editor and renderer
57 lines (54 loc) • 4.61 kB
JavaScript
;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.wrapperStyle = exports.selectedStyle = exports.mediaInlineImageStyles = exports.interactiveStyle = exports.borderStyle = exports.INLINE_IMAGE_WRAPPER_CLASS_NAME = exports.INLINE_IMAGE_BORDER_SIZE_CSS_VAR_KEY = exports.INLINE_IMAGE_BORDER_COLOR_CSS_VAR_KEY = exports.INLINE_IMAGE_ASPECT_RATIO_CSS_VAR_KEY = void 0;
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
var _react = require("@emotion/react");
var _colors = require("@atlaskit/theme/colors");
var _constants = require("./constants");
var _templateObject, _templateObject2;
var INLINE_IMAGE_WRAPPER_CLASS_NAME = exports.INLINE_IMAGE_WRAPPER_CLASS_NAME = 'media-inline-image-wrapper';
var INLINE_IMAGE_ASPECT_RATIO_CSS_VAR_KEY = exports.INLINE_IMAGE_ASPECT_RATIO_CSS_VAR_KEY = '--editor-media-inline-image-aspect-ratio';
var INLINE_IMAGE_BORDER_SIZE_CSS_VAR_KEY = exports.INLINE_IMAGE_BORDER_SIZE_CSS_VAR_KEY = '--editor-media-inline-image-border-size';
var INLINE_IMAGE_BORDER_COLOR_CSS_VAR_KEY = exports.INLINE_IMAGE_BORDER_COLOR_CSS_VAR_KEY = '--editor-media-inline-image-border-color';
// We implemented such selectors to ensure specificity:
// eslint-disable-next-line @atlaskit/design-system/no-css-tagged-template-expression -- Nested and dynamic css calls are violations, needs manual remediation
var inlineImageHeight = function inlineImageHeight(height) {
var margin = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
return (0, _react.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n /* Editor style */\n > .mediaInlineView-content-wrap > .", ",\n > :is(a, span[data-mark-type='border']) .mediaInlineView-content-wrap > .", ",\n /* Renderer style */\n > .", ",\n > :is(a, span[data-mark-type='border']) .", " {\n height: ", "px;\n transform: translateY(", "px);\n }\n"])), INLINE_IMAGE_WRAPPER_CLASS_NAME, INLINE_IMAGE_WRAPPER_CLASS_NAME, INLINE_IMAGE_WRAPPER_CLASS_NAME, INLINE_IMAGE_WRAPPER_CLASS_NAME, height, margin);
};
/**
* Shifting the mediaInline image component (renders image) to align nicely with
* mediaInline (renders text) is a bit of a testing ground. This numbers represent
* shift in top and bottom and size adjustments to make up for lack of 1to1 size
* mapping
*/
// eslint-disable-next-line @atlaskit/design-system/no-css-tagged-template-expression -- Nested and dynamic css calls are violations, needs manual remediation
var mediaInlineImageStyles = exports.mediaInlineImageStyles = (0, _react.css)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n // p, h3, and action items\n .", " {\n height: ", "px;\n transform: translateY(-2px);\n }\n\n h1 {\n ", "\n }\n\n h2 {\n ", "\n }\n\n h3 {\n ", "\n }\n\n h4 {\n ", "\n }\n\n h5 {\n ", "\n }\n\n h6 {\n ", "\n }\n"])), INLINE_IMAGE_WRAPPER_CLASS_NAME, _constants.referenceHeights['p'], inlineImageHeight(_constants.referenceHeights['h1'], -3), inlineImageHeight(_constants.referenceHeights['h2'], -3), inlineImageHeight(_constants.referenceHeights['h3'], -2), inlineImageHeight(_constants.referenceHeights['h4'], -2), inlineImageHeight(_constants.referenceHeights['h5'], -2), inlineImageHeight(_constants.referenceHeights['h6'], -2));
var wrapperStyle = exports.wrapperStyle = (0, _react.css)({
display: 'inline-flex',
justifyContent: 'center',
alignItems: 'center',
verticalAlign: 'middle',
overflow: 'hidden',
borderRadius: "var(--ds-border-radius, 3px)",
aspectRatio: "var(".concat(INLINE_IMAGE_ASPECT_RATIO_CSS_VAR_KEY, ", ").concat(_constants.DEFAULT_INLINE_IMAGE_ASPECT_RATIO, ")"),
maxWidth: '100%'
});
var selectedStyle = exports.selectedStyle = (0, _react.css)({
cursor: 'pointer',
boxShadow: "0 0 0 1px ".concat("var(--ds-border-selected, ".concat(_colors.B300, ")")),
outline: 'none'
});
var interactiveStyle = exports.interactiveStyle = (0, _react.css)({
cursor: 'pointer'
});
var borderStyle = exports.borderStyle = (0, _react.css)({
borderColor: "var(".concat(INLINE_IMAGE_BORDER_COLOR_CSS_VAR_KEY, ")"),
borderStyle: 'solid',
borderRadius: "calc(var(".concat(INLINE_IMAGE_BORDER_SIZE_CSS_VAR_KEY, ", ").concat(_constants.DEFAULT_INLINE_IMAGE_BORDER_SIZE, ") * 2px)"),
borderWidth: "calc(var(".concat(INLINE_IMAGE_BORDER_SIZE_CSS_VAR_KEY, ", ").concat(_constants.DEFAULT_INLINE_IMAGE_BORDER_SIZE, ") * 1px)"),
boxSizing: "border-box"
});