UNPKG

@atlaskit/editor-plugin-user-preferences

Version:

UserPreferences plugin for @atlaskit/editor-core

36 lines 1.08 kB
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 const updateToolbarDockingPosition = ({ key, value, userPreferencesProvider, editorAnalyticsApi }) => ({ tr }) => { try { userPreferencesProvider.updatePreference(key, value); } catch (error) { logException(error, { location: 'editor-plugin-user-preferences/userPreferencesPlugin' }); } tr.setMeta(userPreferencesPluginKey, { preferences: { [key]: value } }); if (key === 'toolbarDockingPosition') { editorAnalyticsApi === null || editorAnalyticsApi === void 0 ? 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; };