UNPKG

@atlaskit/editor-core

Version:

A package contains Atlassian editor core functionality

28 lines (27 loc) 1.23 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.useFireFullWidthEvent = void 0; var _react = require("react"); var _analytics = require("@atlaskit/editor-common/analytics"); var _hooks = require("@atlaskit/editor-common/hooks"); var _formatFullWidthAppearance = require("./formatFullWidthAppearance"); var useFireFullWidthEvent = exports.useFireFullWidthEvent = function useFireFullWidthEvent(appearance, dispatchAnalyticsEvent) { var previousAppearance = (0, _hooks.usePreviousState)(appearance); (0, _react.useEffect)(function () { if (appearance !== previousAppearance) { if (appearance === 'full-width' || previousAppearance === 'full-width') { dispatchAnalyticsEvent({ action: _analytics.ACTION.CHANGED_FULL_WIDTH_MODE, actionSubject: _analytics.ACTION_SUBJECT.EDITOR, eventType: _analytics.EVENT_TYPE.TRACK, attributes: { previousMode: (0, _formatFullWidthAppearance.formatFullWidthAppearance)(previousAppearance), newMode: (0, _formatFullWidthAppearance.formatFullWidthAppearance)(appearance) } }); } } }, [appearance, previousAppearance, dispatchAnalyticsEvent]); };