@atlaskit/renderer
Version:
Renderer component
66 lines (64 loc) • 3.08 kB
JavaScript
;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _react = require("@emotion/react");
var _reactIntl = require("react-intl");
var _textWrap = _interopRequireDefault(require("@atlaskit/icon/core/text-wrap"));
var _customThemeButton = _interopRequireDefault(require("@atlaskit/button/custom-theme-button"));
var _messages = require("@atlaskit/editor-common/messages");
var _tooltip = _interopRequireDefault(require("@atlaskit/tooltip"));
var _analyticsContext = _interopRequireDefault(require("../../../../analytics/analyticsContext"));
var _enums = require("../../../../analytics/enums");
/**
* @jsxRuntime classic
* @jsx jsx
*/
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
var CodeBlockWrapButton = function CodeBlockWrapButton(_ref) {
var setWrapLongLines = _ref.setWrapLongLines,
wrapLongLines = _ref.wrapLongLines,
intl = _ref.intl;
var wrapMessage = intl.formatMessage(wrapLongLines ? _messages.codeBlockButtonMessages.unwrapCode : _messages.codeBlockButtonMessages.wrapCode);
return (0, _react.jsx)(_analyticsContext.default.Consumer, null, function (_ref2) {
var fireAnalyticsEvent = _ref2.fireAnalyticsEvent;
return (0, _react.jsx)("span", null, (0, _react.jsx)(_tooltip.default, {
content: wrapMessage,
hideTooltipOnClick: false,
position: "top"
}, (0, _react.jsx)(_customThemeButton.default, {
appearance: "subtle",
"aria-haspopup": true,
"aria-label": wrapMessage
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
,
className: "wrap-code ".concat(wrapLongLines ? 'clicked' : ''),
iconBefore: (0, _react.jsx)(_textWrap.default, {
label: ""
}),
isSelected: wrapLongLines
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
,
onClick: function onClick(event) {
fireAnalyticsEvent({
// @ts-expect-error - Type 'ACTION.CLICKED' is not assignable to type 'ACTION.CLICKED | ACTION.MEDIA_LINK_TRANSFORMED | ACTION.STARTED | ACTION.TOGGLE_EXPAND | ACTION.UNSUPPORTED_CONTENT_ENCOUNTERED | ACTION.VISITED | ACTION.RENDERED | ACTION.INVALID_PROSEMIRROR_DOCUMENT | ACTION.CRASHED | ... 6 more ... | AnnotationActionType'
// This error was introduced after upgrading to TypeScript 5
action: _enums.ACTION.CLICKED,
actionSubject: _enums.ACTION_SUBJECT.BUTTON,
actionSubjectId: _enums.ACTION_SUBJECT_ID.CODEBLOCK_WRAP,
attributes: {
wrapped: !wrapLongLines
},
eventType: _enums.EVENT_TYPE.UI
});
setWrapLongLines(!wrapLongLines);
event.stopPropagation();
},
spacing: "compact"
})));
});
};
var _default_1 = (0, _reactIntl.injectIntl)(CodeBlockWrapButton);
var _default = exports.default = _default_1;