@atlaskit/editor-plugin-selection-toolbar 3.1.1 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # @atlaskit/editor-plugin-selection-toolbar
2
2
 
3
+ ## 3.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#138841](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/138841)
8
+ [`d71cc65fae381`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/d71cc65fae381) -
9
+ ED-27489 fix toolbar docking pref
10
+
11
+ ## 3.2.0
12
+
13
+ ### Minor Changes
14
+
15
+ - [#138170](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/138170)
16
+ [`160cf374f7ac1`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/160cf374f7ac1) -
17
+ ED-27441 update docking preference with analytics
18
+
19
+ ### Patch Changes
20
+
21
+ - Updated dependencies
22
+
3
23
  ## 3.1.1
4
24
 
5
25
  ### Patch Changes
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.toggleToolbar = exports.setToolbarDocking = void 0;
7
+ var _analytics = require("@atlaskit/editor-common/analytics");
7
8
  var _state = require("@atlaskit/editor-prosemirror/state");
9
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
8
10
  var _pluginKey = require("./plugin-key");
9
11
  var toggleToolbar = exports.toggleToolbar = function toggleToolbar(_ref) {
10
12
  var hide = _ref.hide;
@@ -18,7 +20,8 @@ var toggleToolbar = exports.toggleToolbar = function toggleToolbar(_ref) {
18
20
  };
19
21
  var setToolbarDocking = exports.setToolbarDocking = function setToolbarDocking(_ref3) {
20
22
  var toolbarDocking = _ref3.toolbarDocking,
21
- userPreferencesProvider = _ref3.userPreferencesProvider;
23
+ userPreferencesProvider = _ref3.userPreferencesProvider,
24
+ editorAnalyticsApi = _ref3.editorAnalyticsApi;
22
25
  return function (_ref4) {
23
26
  var tr = _ref4.tr;
24
27
  // We currently ignore any update failures, need to confirm this is the desired behaviour
@@ -30,6 +33,17 @@ var setToolbarDocking = exports.setToolbarDocking = function setToolbarDocking(_
30
33
  // Remove the selection if the toolbar is docked to the top
31
34
  tr.setSelection(_state.TextSelection.create(tr.doc, tr.selection.head));
32
35
  }
36
+ if ((0, _platformFeatureFlags.fg)('platform_editor_controls_patch_2')) {
37
+ editorAnalyticsApi === null || editorAnalyticsApi === void 0 || editorAnalyticsApi.attachAnalyticsEvent({
38
+ action: _analytics.ACTION.UPDATED,
39
+ actionSubject: _analytics.ACTION_SUBJECT.USER_PREFERENCES,
40
+ actionSubjectId: _analytics.ACTION_SUBJECT_ID.SELECTION_TOOLBAR_PREFERENCES,
41
+ attributes: {
42
+ toolbarDocking: toolbarDocking
43
+ },
44
+ eventType: _analytics.EVENT_TYPE.TRACK
45
+ })(tr);
46
+ }
33
47
  return tr;
34
48
  };
35
49
  };
@@ -73,10 +73,11 @@ var selectionToolbarPlugin = exports.selectionToolbarPlugin = function selection
73
73
  }))) !== null && _api$core$actions$exe2 !== void 0 ? _api$core$actions$exe2 : false;
74
74
  },
75
75
  setToolbarDocking: function setToolbarDocking(toolbarDocking) {
76
- var _api$core$actions$exe3;
76
+ var _api$core$actions$exe3, _api$analytics;
77
77
  return (_api$core$actions$exe3 = api === null || api === void 0 ? void 0 : api.core.actions.execute((0, _commands.setToolbarDocking)({
78
78
  toolbarDocking: toolbarDocking,
79
- userPreferencesProvider: userPreferencesProvider
79
+ userPreferencesProvider: userPreferencesProvider,
80
+ editorAnalyticsApi: api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions
80
81
  }))) !== null && _api$core$actions$exe3 !== void 0 ? _api$core$actions$exe3 : false;
81
82
  }
82
83
  },
@@ -111,7 +112,7 @@ var selectionToolbarPlugin = exports.selectionToolbarPlugin = function selection
111
112
 
112
113
  // if the toolbarDockingInitialPosition preference has changed
113
114
  // update the toolbarDocking state
114
- if (!previousToolbarDocking && !(0, _platformFeatureFlags.fg)('platform_editor_controls_patch_2')) {
115
+ if (!previousToolbarDocking && (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_4')) {
115
116
  // we currently only check for the initial value
116
117
  var toolbarDockingPreference = userPreferencesProvider === null || userPreferencesProvider === void 0 ? void 0 : userPreferencesProvider.getPreference('toolbarDockingInitialPosition');
117
118
  if (toolbarDockingPreference && toolbarDockingPreference !== previousToolbarDocking) {
@@ -162,13 +163,16 @@ var selectionToolbarPlugin = exports.selectionToolbarPlugin = function selection
162
163
  if (!isPreferenceInitialized && (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_2')) {
163
164
  var toolbarDockingPreference = userPreferencesProvider === null || userPreferencesProvider === void 0 ? void 0 : userPreferencesProvider.getPreference('toolbarDockingInitialPosition');
164
165
  if (toolbarDockingPreference !== undefined) {
165
- var _api$analytics;
166
+ var _api$analytics2;
166
167
  isPreferenceInitialized = true;
167
168
  var userToolbarDockingPref = getInitialToolbarDocking(contextualFormattingEnabled, userPreferencesProvider);
168
- var tr = newState.tr.setMeta(_pluginKey.selectionToolbarPluginKey, {
169
- toolbarDocking: userToolbarDockingPref
170
- });
171
- api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.attachAnalyticsEvent({
169
+ var tr = newState.tr;
170
+ if (!(0, _platformFeatureFlags.fg)('platform_editor_controls_patch_4')) {
171
+ tr.setMeta(_pluginKey.selectionToolbarPluginKey, {
172
+ toolbarDocking: userToolbarDockingPref
173
+ });
174
+ }
175
+ api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 || _api$analytics2.actions.attachAnalyticsEvent({
172
176
  action: _analytics.ACTION.INITIALISED,
173
177
  actionSubject: _analytics.ACTION_SUBJECT.USER_PREFERENCES,
174
178
  actionSubjectId: _analytics.ACTION_SUBJECT_ID.SELECTION_TOOLBAR_PREFERENCES,
@@ -1,4 +1,6 @@
1
+ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
1
2
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
3
+ import { fg } from '@atlaskit/platform-feature-flags';
2
4
  import { selectionToolbarPluginKey } from './plugin-key';
3
5
  export const toggleToolbar = ({
4
6
  hide
@@ -12,7 +14,8 @@ export const toggleToolbar = ({
12
14
  };
13
15
  export const setToolbarDocking = ({
14
16
  toolbarDocking,
15
- userPreferencesProvider
17
+ userPreferencesProvider,
18
+ editorAnalyticsApi
16
19
  }) => ({
17
20
  tr
18
21
  }) => {
@@ -25,5 +28,16 @@ export const setToolbarDocking = ({
25
28
  // Remove the selection if the toolbar is docked to the top
26
29
  tr.setSelection(TextSelection.create(tr.doc, tr.selection.head));
27
30
  }
31
+ if (fg('platform_editor_controls_patch_2')) {
32
+ editorAnalyticsApi === null || editorAnalyticsApi === void 0 ? void 0 : editorAnalyticsApi.attachAnalyticsEvent({
33
+ action: ACTION.UPDATED,
34
+ actionSubject: ACTION_SUBJECT.USER_PREFERENCES,
35
+ actionSubjectId: ACTION_SUBJECT_ID.SELECTION_TOOLBAR_PREFERENCES,
36
+ attributes: {
37
+ toolbarDocking
38
+ },
39
+ eventType: EVENT_TYPE.TRACK
40
+ })(tr);
41
+ }
28
42
  return tr;
29
43
  };
@@ -64,10 +64,11 @@ export const selectionToolbarPlugin = ({
64
64
  }))) !== null && _api$core$actions$exe2 !== void 0 ? _api$core$actions$exe2 : false;
65
65
  },
66
66
  setToolbarDocking: toolbarDocking => {
67
- var _api$core$actions$exe3;
67
+ var _api$core$actions$exe3, _api$analytics;
68
68
  return (_api$core$actions$exe3 = api === null || api === void 0 ? void 0 : api.core.actions.execute(setToolbarDocking({
69
69
  toolbarDocking,
70
- userPreferencesProvider
70
+ userPreferencesProvider,
71
+ editorAnalyticsApi: api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions
71
72
  }))) !== null && _api$core$actions$exe3 !== void 0 ? _api$core$actions$exe3 : false;
72
73
  }
73
74
  },
@@ -105,7 +106,7 @@ export const selectionToolbarPlugin = ({
105
106
 
106
107
  // if the toolbarDockingInitialPosition preference has changed
107
108
  // update the toolbarDocking state
108
- if (!previousToolbarDocking && !fg('platform_editor_controls_patch_2')) {
109
+ if (!previousToolbarDocking && fg('platform_editor_controls_patch_4')) {
109
110
  // we currently only check for the initial value
110
111
  const toolbarDockingPreference = userPreferencesProvider === null || userPreferencesProvider === void 0 ? void 0 : userPreferencesProvider.getPreference('toolbarDockingInitialPosition');
111
112
  if (toolbarDockingPreference && toolbarDockingPreference !== previousToolbarDocking) {
@@ -157,13 +158,16 @@ export const selectionToolbarPlugin = ({
157
158
  if (!isPreferenceInitialized && editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_2')) {
158
159
  const toolbarDockingPreference = userPreferencesProvider === null || userPreferencesProvider === void 0 ? void 0 : userPreferencesProvider.getPreference('toolbarDockingInitialPosition');
159
160
  if (toolbarDockingPreference !== undefined) {
160
- var _api$analytics;
161
+ var _api$analytics2;
161
162
  isPreferenceInitialized = true;
162
163
  const userToolbarDockingPref = getInitialToolbarDocking(contextualFormattingEnabled, userPreferencesProvider);
163
- const tr = newState.tr.setMeta(selectionToolbarPluginKey, {
164
- toolbarDocking: userToolbarDockingPref
165
- });
166
- api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions.attachAnalyticsEvent({
164
+ const tr = newState.tr;
165
+ if (!fg('platform_editor_controls_patch_4')) {
166
+ tr.setMeta(selectionToolbarPluginKey, {
167
+ toolbarDocking: userToolbarDockingPref
168
+ });
169
+ }
170
+ api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions.attachAnalyticsEvent({
167
171
  action: ACTION.INITIALISED,
168
172
  actionSubject: ACTION_SUBJECT.USER_PREFERENCES,
169
173
  actionSubjectId: ACTION_SUBJECT_ID.SELECTION_TOOLBAR_PREFERENCES,
@@ -1,4 +1,6 @@
1
+ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
1
2
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
3
+ import { fg } from '@atlaskit/platform-feature-flags';
2
4
  import { selectionToolbarPluginKey } from './plugin-key';
3
5
  export var toggleToolbar = function toggleToolbar(_ref) {
4
6
  var hide = _ref.hide;
@@ -12,7 +14,8 @@ export var toggleToolbar = function toggleToolbar(_ref) {
12
14
  };
13
15
  export var setToolbarDocking = function setToolbarDocking(_ref3) {
14
16
  var toolbarDocking = _ref3.toolbarDocking,
15
- userPreferencesProvider = _ref3.userPreferencesProvider;
17
+ userPreferencesProvider = _ref3.userPreferencesProvider,
18
+ editorAnalyticsApi = _ref3.editorAnalyticsApi;
16
19
  return function (_ref4) {
17
20
  var tr = _ref4.tr;
18
21
  // We currently ignore any update failures, need to confirm this is the desired behaviour
@@ -24,6 +27,17 @@ export var setToolbarDocking = function setToolbarDocking(_ref3) {
24
27
  // Remove the selection if the toolbar is docked to the top
25
28
  tr.setSelection(TextSelection.create(tr.doc, tr.selection.head));
26
29
  }
30
+ if (fg('platform_editor_controls_patch_2')) {
31
+ editorAnalyticsApi === null || editorAnalyticsApi === void 0 || editorAnalyticsApi.attachAnalyticsEvent({
32
+ action: ACTION.UPDATED,
33
+ actionSubject: ACTION_SUBJECT.USER_PREFERENCES,
34
+ actionSubjectId: ACTION_SUBJECT_ID.SELECTION_TOOLBAR_PREFERENCES,
35
+ attributes: {
36
+ toolbarDocking: toolbarDocking
37
+ },
38
+ eventType: EVENT_TYPE.TRACK
39
+ })(tr);
40
+ }
27
41
  return tr;
28
42
  };
29
43
  };
@@ -66,10 +66,11 @@ export var selectionToolbarPlugin = function selectionToolbarPlugin(_ref) {
66
66
  }))) !== null && _api$core$actions$exe2 !== void 0 ? _api$core$actions$exe2 : false;
67
67
  },
68
68
  setToolbarDocking: function setToolbarDocking(toolbarDocking) {
69
- var _api$core$actions$exe3;
69
+ var _api$core$actions$exe3, _api$analytics;
70
70
  return (_api$core$actions$exe3 = api === null || api === void 0 ? void 0 : api.core.actions.execute(_setToolbarDocking({
71
71
  toolbarDocking: toolbarDocking,
72
- userPreferencesProvider: userPreferencesProvider
72
+ userPreferencesProvider: userPreferencesProvider,
73
+ editorAnalyticsApi: api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions
73
74
  }))) !== null && _api$core$actions$exe3 !== void 0 ? _api$core$actions$exe3 : false;
74
75
  }
75
76
  },
@@ -104,7 +105,7 @@ export var selectionToolbarPlugin = function selectionToolbarPlugin(_ref) {
104
105
 
105
106
  // if the toolbarDockingInitialPosition preference has changed
106
107
  // update the toolbarDocking state
107
- if (!previousToolbarDocking && !fg('platform_editor_controls_patch_2')) {
108
+ if (!previousToolbarDocking && fg('platform_editor_controls_patch_4')) {
108
109
  // we currently only check for the initial value
109
110
  var toolbarDockingPreference = userPreferencesProvider === null || userPreferencesProvider === void 0 ? void 0 : userPreferencesProvider.getPreference('toolbarDockingInitialPosition');
110
111
  if (toolbarDockingPreference && toolbarDockingPreference !== previousToolbarDocking) {
@@ -155,13 +156,16 @@ export var selectionToolbarPlugin = function selectionToolbarPlugin(_ref) {
155
156
  if (!isPreferenceInitialized && editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_2')) {
156
157
  var toolbarDockingPreference = userPreferencesProvider === null || userPreferencesProvider === void 0 ? void 0 : userPreferencesProvider.getPreference('toolbarDockingInitialPosition');
157
158
  if (toolbarDockingPreference !== undefined) {
158
- var _api$analytics;
159
+ var _api$analytics2;
159
160
  isPreferenceInitialized = true;
160
161
  var userToolbarDockingPref = getInitialToolbarDocking(contextualFormattingEnabled, userPreferencesProvider);
161
- var tr = newState.tr.setMeta(selectionToolbarPluginKey, {
162
- toolbarDocking: userToolbarDockingPref
163
- });
164
- api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.attachAnalyticsEvent({
162
+ var tr = newState.tr;
163
+ if (!fg('platform_editor_controls_patch_4')) {
164
+ tr.setMeta(selectionToolbarPluginKey, {
165
+ toolbarDocking: userToolbarDockingPref
166
+ });
167
+ }
168
+ api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 || _api$analytics2.actions.attachAnalyticsEvent({
165
169
  action: ACTION.INITIALISED,
166
170
  actionSubject: ACTION_SUBJECT.USER_PREFERENCES,
167
171
  actionSubjectId: ACTION_SUBJECT_ID.SELECTION_TOOLBAR_PREFERENCES,
@@ -1,9 +1,11 @@
1
+ import { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
1
2
  import type { EditorCommand, UserPreferencesProvider } from '@atlaskit/editor-common/types';
2
3
  import type { ToolbarDocking } from '../types';
3
4
  export declare const toggleToolbar: ({ hide }: {
4
5
  hide: boolean;
5
6
  }) => EditorCommand;
6
- export declare const setToolbarDocking: ({ toolbarDocking, userPreferencesProvider, }: {
7
+ export declare const setToolbarDocking: ({ toolbarDocking, userPreferencesProvider, editorAnalyticsApi, }: {
7
8
  toolbarDocking: ToolbarDocking;
8
9
  userPreferencesProvider?: UserPreferencesProvider | undefined;
10
+ editorAnalyticsApi?: EditorAnalyticsAPI | undefined;
9
11
  }) => EditorCommand;
@@ -1,9 +1,11 @@
1
+ import { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
1
2
  import type { EditorCommand, UserPreferencesProvider } from '@atlaskit/editor-common/types';
2
3
  import type { ToolbarDocking } from '../types';
3
4
  export declare const toggleToolbar: ({ hide }: {
4
5
  hide: boolean;
5
6
  }) => EditorCommand;
6
- export declare const setToolbarDocking: ({ toolbarDocking, userPreferencesProvider, }: {
7
+ export declare const setToolbarDocking: ({ toolbarDocking, userPreferencesProvider, editorAnalyticsApi, }: {
7
8
  toolbarDocking: ToolbarDocking;
8
9
  userPreferencesProvider?: UserPreferencesProvider | undefined;
10
+ editorAnalyticsApi?: EditorAnalyticsAPI | undefined;
9
11
  }) => EditorCommand;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-selection-toolbar",
3
- "version": "3.1.1",
3
+ "version": "3.3.0",
4
4
  "description": "@atlaskit/editor-plugin-selection-toolbar for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -34,7 +34,7 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "@atlaskit/css": "^0.10.0",
37
- "@atlaskit/editor-common": "^103.0.0",
37
+ "@atlaskit/editor-common": "^103.2.0",
38
38
  "@atlaskit/editor-plugin-analytics": "^2.2.0",
39
39
  "@atlaskit/editor-plugin-editor-viewmode": "^3.0.0",
40
40
  "@atlaskit/editor-plugin-primary-toolbar": "^3.1.0",
@@ -96,6 +96,9 @@
96
96
  "platform-feature-flags": {
97
97
  "platform_editor_controls_patch_2": {
98
98
  "type": "boolean"
99
+ },
100
+ "platform_editor_controls_patch_4": {
101
+ "type": "boolean"
99
102
  }
100
103
  }
101
104
  }