UNPKG

@atlaskit/editor-plugin-user-preferences

Version:

UserPreferences plugin for @atlaskit/editor-core

35 lines 1.36 kB
import _defineProperty from "@babel/runtime/helpers/defineProperty"; import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics'; import { logException } from '@atlaskit/editor-common/monitoring'; import { userPreferencesPluginKey } from './main'; export var updateToolbarDockingPosition = function updateToolbarDockingPosition(_ref) { var key = _ref.key, value = _ref.value, userPreferencesProvider = _ref.userPreferencesProvider, editorAnalyticsApi = _ref.editorAnalyticsApi; return function (_ref2) { var tr = _ref2.tr; try { userPreferencesProvider.updatePreference(key, value); } catch (error) { logException(error, { location: 'editor-plugin-user-preferences/userPreferencesPlugin' }); } tr.setMeta(userPreferencesPluginKey, { preferences: _defineProperty({}, key, value) }); if (key === 'toolbarDockingPosition') { editorAnalyticsApi === null || editorAnalyticsApi === void 0 || editorAnalyticsApi.attachAnalyticsEvent({ action: ACTION.UPDATED, actionSubject: ACTION_SUBJECT.USER_PREFERENCES, actionSubjectId: ACTION_SUBJECT_ID.SELECTION_TOOLBAR_PREFERENCES, attributes: { toolbarDocking: value }, eventType: EVENT_TYPE.TRACK })(tr); } return tr; }; };