@atlaskit/editor-plugin-card
Version:
Card plugin for @atlaskit/editor-core
25 lines • 992 B
JavaScript
import React from 'react';
import { AnalyticsContext } from '@atlaskit/analytics-next';
import { getAnalyticsEditorAppearance } from '@atlaskit/editor-common/utils';
import { getPluginState } from '../pm-plugins/util/state';
/**
* Provides location attribute to child events
*/
export const EditorAnalyticsContext = ({
editorView,
children
}) => {
var _getPluginState;
const editorAppearance = editorView ? (_getPluginState = getPluginState(editorView.state)) === null || _getPluginState === void 0 ? void 0 : _getPluginState.editorAppearance : undefined;
const analyticsEditorAppearance = getAnalyticsEditorAppearance(editorAppearance);
const analyticsData = {
attributes: {
location: analyticsEditorAppearance
},
// Below is added for the future implementation of Linking Platform namespaced analytic context
location: analyticsEditorAppearance
};
return /*#__PURE__*/React.createElement(AnalyticsContext, {
data: analyticsData
}, children);
};