@atlaskit/renderer
Version:
Renderer component
43 lines (41 loc) • 1.8 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.useInlineAnnotationProps = useInlineAnnotationProps;
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
var _AnnotationRangeContext = require("../contexts/AnnotationRangeContext");
/* eslint-disable jsdoc/require-jsdoc */
function useInlineAnnotationProps(props) {
var _useAnnotationRangeSt = (0, _AnnotationRangeContext.useAnnotationRangeState)(),
draftPosition = _useAnnotationRangeSt.selectionDraftDocumentPosition;
if (!(0, _platformFeatureFlags.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
};
}