UNPKG

@atlaskit/renderer

Version:
36 lines 1.6 kB
/* eslint-disable jsdoc/require-jsdoc */ import { fg } from '@atlaskit/platform-feature-flags'; import { useAnnotationRangeState } from '../contexts/AnnotationRangeContext'; export function useInlineAnnotationProps(props) { var _useAnnotationRangeSt = useAnnotationRangeState(), draftPosition = _useAnnotationRangeSt.selectionDraftDocumentPosition; if (!fg('editor_inline_comments_on_inline_nodes')) { return {}; } if (!props.dataAttributes) { // the inlineCard component is currently used by the block card, embed card and card error boundary components // when used via these components, no dataAttributes are passed (and we don't want it setup for inline comments) return {}; } var inlineCardPosition = props.dataAttributes['data-renderer-start-pos'] - 1; var hasDraft = draftPosition && // Ignored via go/ees005 // eslint-disable-next-line @typescript-eslint/no-non-null-assertion (draftPosition === null || draftPosition === void 0 ? void 0 : draftPosition.from) <= inlineCardPosition && // Ignored via go/ees005 // eslint-disable-next-line @typescript-eslint/no-non-null-assertion (draftPosition === null || draftPosition === void 0 ? void 0 : draftPosition.to) >= inlineCardPosition + 1; if (hasDraft) { return { 'data-renderer-mark': true, 'data-annotation-draft-mark': true, 'data-annotation-inline-node': true, 'data-renderer-start-pos': inlineCardPosition }; } return { 'data-annotation-inline-node': true, 'data-annotation-mark': true, 'data-renderer-start-pos': inlineCardPosition }; }