@atlaskit/renderer
Version:
Renderer component
51 lines • 1.58 kB
JavaScript
import _extends from "@babel/runtime/helpers/extends";
import React from 'react';
import { buildAnnotationMarkDataAttributes } from '@atlaskit/adf-schema';
import { MarkElement as AnnotationMark } from '../../ui/annotations/element';
export const isAnnotationMark = mark => {
return mark && mark.type && mark.type.name === 'annotation';
};
const AnnotationComponent = ({
id,
annotationType,
children,
dataAttributes,
annotationParentIds = [],
allowAnnotations,
useBlockLevel,
isMediaInline
}) => {
const data = {
...dataAttributes,
...buildAnnotationMarkDataAttributes({
id,
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;