@atlaskit/renderer
Version:
Renderer component
51 lines • 2.69 kB
JavaScript
import _extends from "@babel/runtime/helpers/extends";
import _defineProperty from "@babel/runtime/helpers/defineProperty";
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
import React from 'react';
import { buildAnnotationMarkDataAttributes } from '@atlaskit/adf-schema';
import { MarkElement as AnnotationMark } from '../../ui/annotations/element';
export var isAnnotationMark = function isAnnotationMark(mark) {
return mark && mark.type && mark.type.name === 'annotation';
};
var AnnotationComponent = function AnnotationComponent(_ref) {
var id = _ref.id,
annotationType = _ref.annotationType,
children = _ref.children,
dataAttributes = _ref.dataAttributes,
_ref$annotationParent = _ref.annotationParentIds,
annotationParentIds = _ref$annotationParent === void 0 ? [] : _ref$annotationParent,
allowAnnotations = _ref.allowAnnotations,
useBlockLevel = _ref.useBlockLevel,
isMediaInline = _ref.isMediaInline;
var data = _objectSpread(_objectSpread({}, dataAttributes), buildAnnotationMarkDataAttributes({
id: id,
annotationType: annotationType
}));
if (allowAnnotations) {
return isMediaInline ?
/*#__PURE__*/
// Inline comment on mediaInline is not supported as part of comments on media project,
// hence skip any styling/event handling for annotations on mediaInline.
// `id` is still needed so that comment view component can be correct positioned
// when using comment navigation to access comments on mediaInline
React.createElement("span", {
id: id
}, children) : /*#__PURE__*/React.createElement(AnnotationMark, {
id: id,
dataAttributes: data,
annotationParentIds: annotationParentIds,
annotationType: annotationType,
useBlockLevel: useBlockLevel
}, children);
}
return (
/*#__PURE__*/
// Ignored via go/ees005
// eslint-disable-next-line react/jsx-props-no-spreading
React.createElement("span", _extends({
id: id
}, data), children)
);
};
export default AnnotationComponent;