@atlaskit/editor-plugin-annotation
Version:
Annotation plugin for @atlaskit/editor-core
45 lines (44 loc) • 2.17 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.useCommentButtonMount = void 0;
var _react = require("react");
var _utils = require("@atlaskit/editor-common/utils");
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
var _utils2 = require("../../pm-plugins/utils");
var _utils3 = require("./utils");
var useCommentButtonMount = exports.useCommentButtonMount = function useCommentButtonMount(_ref) {
var state = _ref.state,
annotationProviders = _ref.annotationProviders,
api = _ref.api,
annotationSelectionType = _ref.annotationSelectionType,
bookmark = _ref.bookmark;
(0, _react.useEffect)(function () {
var _getRangeInlineNodeNa;
if (!state) {
return;
}
if (annotationProviders !== null && annotationProviders !== void 0 && annotationProviders.inlineComment && (0, _platformFeatureFlags.fg)('confluence_frontend_preload_inline_comment_editor')) {
var _annotationProviders$, _annotationProviders$2;
(_annotationProviders$ = (_annotationProviders$2 = annotationProviders.inlineComment).onCommentButtonMount) === null || _annotationProviders$ === void 0 || _annotationProviders$.call(_annotationProviders$2);
}
// Check if the selection includes an non-text inline node
var inlineNodeNames = (_getRangeInlineNodeNa = (0, _utils.getRangeInlineNodeNames)({
doc: state.doc,
pos: (0, _utils2.resolveDraftBookmark)(state, bookmark)
})) !== null && _getRangeInlineNodeNa !== void 0 ? _getRangeInlineNodeNa : [];
var isNonTextInlineNodeInludedInComment =
// eslint-disable-next-line @atlassian/perf-linting/no-expensive-computations-in-render -- Ignored via go/ees017 (to be fixed)
inlineNodeNames.filter(function (nodeName) {
return nodeName !== 'text';
}).length > 0;
(0, _utils3.fireCommentButtonViewedAnalyticsEvent)({
api: api,
isNonTextInlineNodeInludedInComment: isNonTextInlineNodeInludedInComment,
annotationSelectionType: annotationSelectionType
});
// for now trying to replicate current onMount logic
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
};