@atlaskit/editor-common
Version:
A package that contains common classes and components for editor and renderer
81 lines (77 loc) • 4.39 kB
JavaScript
;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _react = _interopRequireWildcard(require("react"));
var _react2 = require("@emotion/react");
var _reactIntl = require("react-intl");
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
var _questionCircle = _interopRequireDefault(require("@atlaskit/icon/core/question-circle"));
var _tooltip = _interopRequireDefault(require("@atlaskit/tooltip"));
var _analytics = require("../../analytics");
var _unsupportedContent = require("../../messages/unsupportedContent");
var _trackUnsupportedContent = require("../../utils/track-unsupported-content");
var _unsupportedContentHelper = require("../unsupported-content-helper");
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
/**
* @jsxRuntime classic
* @jsx jsx
*/
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
var blockNodeStyle = (0, _react2.css)({
background: "var(--ds-background-disabled, #17171708)",
border: "var(--ds-border-width, 1px)".concat(" dashed ", "var(--ds-border-disabled, #0515240F)"),
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
borderRadius: "var(--ds-radius-small, 3px)",
boxSizing: 'border-box',
cursor: 'default',
display: 'flex',
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
fontSize: (0, _editorSharedStyles.relativeFontSizeToBase16)(14),
margin: "var(--ds-space-100, 8px)".concat(" 0"),
minHeight: '24px',
padding: "var(--ds-space-150, 12px)",
textAlign: 'center',
verticalAlign: 'text-bottom',
minWidth: '120px',
alignItems: 'center',
justifyContent: 'center'
});
var UnsupportedBlockNode = function UnsupportedBlockNode(_ref) {
var node = _ref.node,
intl = _ref.intl,
dispatchAnalyticsEvent = _ref.dispatchAnalyticsEvent;
var message = (0, _unsupportedContentHelper.getUnsupportedContent)(_unsupportedContent.unsupportedContentMessages.unsupportedBlockContent, _unsupportedContent.unsupportedContentMessages.unsupportedBlockContent.defaultMessage + ':', node, intl);
var tooltipContent = intl.formatMessage(_unsupportedContent.unsupportedContentMessages.unsupportedContentTooltip);
var _useRef = (0, _react.useRef)({
padding: '4px'
}),
style = _useRef.current;
var originalNodeType = node === null || node === void 0 ? void 0 : node.attrs.originalValue.type;
var tooltipOnShowHandler = (0, _react.useCallback)(function () {
return dispatchAnalyticsEvent && (0, _trackUnsupportedContent.trackUnsupportedContentTooltipDisplayedFor)(dispatchAnalyticsEvent, _analytics.ACTION_SUBJECT_ID.ON_UNSUPPORTED_BLOCK, originalNodeType);
}, [dispatchAnalyticsEvent, originalNodeType]);
return (
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
(0, _react2.jsx)("div", {
css: blockNodeStyle,
className: "unsupported"
}, message, (0, _react2.jsx)(_tooltip.default, {
content: tooltipContent,
hideTooltipOnClick: false,
position: "bottom",
onShow: tooltipOnShowHandler,
strategy: "absolute"
}, (0, _react2.jsx)("span", {
style: style
}, (0, _react2.jsx)(_questionCircle.default, {
label: "?"
}))))
);
};
// eslint-disable-next-line @typescript-eslint/ban-types
var _default_1 = (0, _reactIntl.injectIntl)(UnsupportedBlockNode);
var _default = exports.default = _default_1;