@atlaskit/editor-plugin-selection-toolbar 2.0.8 → 2.1.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,26 @@
1
1
  # @atlaskit/editor-plugin-selection-toolbar
2
2
 
3
+ ## 2.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#126588](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/126588)
8
+ [`d4160d5f8b246`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/d4160d5f8b246) -
9
+ ED-26876 implement editor api for user preference
10
+
11
+ ### Patch Changes
12
+
13
+ - [#126588](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/126588)
14
+ [`d4160d5f8b246`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/d4160d5f8b246) -
15
+ ED-26876 add tests for selectionToolbarPlugin
16
+ - Updated dependencies
17
+
18
+ ## 2.0.9
19
+
20
+ ### Patch Changes
21
+
22
+ - Updated dependencies
23
+
3
24
  ## 2.0.8
4
25
 
5
26
  ### Patch Changes
@@ -16,9 +16,12 @@ var toggleToolbar = exports.toggleToolbar = function toggleToolbar(_ref) {
16
16
  };
17
17
  };
18
18
  var setToolbarDocking = exports.setToolbarDocking = function setToolbarDocking(_ref3) {
19
- var toolbarDocking = _ref3.toolbarDocking;
19
+ var toolbarDocking = _ref3.toolbarDocking,
20
+ userPreferencesProvider = _ref3.userPreferencesProvider;
20
21
  return function (_ref4) {
21
22
  var tr = _ref4.tr;
23
+ // We currently ignore any update failures, need to confirm this is the desired behaviour
24
+ userPreferencesProvider === null || userPreferencesProvider === void 0 || userPreferencesProvider.updatePreference('toolbarDockingInitialPosition', toolbarDocking);
22
25
  tr.setMeta(_pluginKey.selectionToolbarPluginKey, {
23
26
  toolbarDocking: toolbarDocking
24
27
  });
@@ -24,6 +24,7 @@ var selectionToolbarPlugin = exports.selectionToolbarPlugin = function selection
24
24
  config = _ref.config;
25
25
  var __selectionToolbarHandlers = [];
26
26
  var primaryToolbarComponent;
27
+ var userPreferencesProvider = config.userPreferencesProvider;
27
28
  if ((0, _experiments.editorExperiment)('platform_editor_controls', 'variant1', {
28
29
  exposure: true
29
30
  })) {
@@ -62,7 +63,8 @@ var selectionToolbarPlugin = exports.selectionToolbarPlugin = function selection
62
63
  setToolbarDocking: function setToolbarDocking(toolbarDocking) {
63
64
  var _api$core$actions$exe3;
64
65
  return (_api$core$actions$exe3 = api === null || api === void 0 ? void 0 : api.core.actions.execute((0, _commands.setToolbarDocking)({
65
- toolbarDocking: toolbarDocking
66
+ toolbarDocking: toolbarDocking,
67
+ userPreferencesProvider: userPreferencesProvider
66
68
  }))) !== null && _api$core$actions$exe3 !== void 0 ? _api$core$actions$exe3 : false;
67
69
  }
68
70
  },
@@ -83,10 +85,14 @@ var selectionToolbarPlugin = exports.selectionToolbarPlugin = function selection
83
85
  key: _pluginKey.selectionToolbarPluginKey,
84
86
  state: {
85
87
  init: function init() {
88
+ var toolbarDocking = 'top';
89
+ if ((0, _experiments.editorExperiment)('platform_editor_controls', 'variant1')) {
90
+ toolbarDocking = (userPreferencesProvider === null || userPreferencesProvider === void 0 ? void 0 : userPreferencesProvider.getPreference('toolbarDockingInitialPosition')) || 'none';
91
+ }
86
92
  return {
87
93
  selectionStable: false,
88
94
  hide: false,
89
- toolbarDocking: (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') ? 'none' : 'top'
95
+ toolbarDocking: toolbarDocking
90
96
  };
91
97
  },
92
98
  apply: function apply(tr, pluginState) {
@@ -1 +1,5 @@
1
- "use strict";
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -10,10 +10,13 @@ export const toggleToolbar = ({
10
10
  return tr;
11
11
  };
12
12
  export const setToolbarDocking = ({
13
- toolbarDocking
13
+ toolbarDocking,
14
+ userPreferencesProvider
14
15
  }) => ({
15
16
  tr
16
17
  }) => {
18
+ // We currently ignore any update failures, need to confirm this is the desired behaviour
19
+ userPreferencesProvider === null || userPreferencesProvider === void 0 ? void 0 : userPreferencesProvider.updatePreference('toolbarDockingInitialPosition', toolbarDocking);
17
20
  tr.setMeta(selectionToolbarPluginKey, {
18
21
  toolbarDocking
19
22
  });
@@ -14,6 +14,9 @@ export const selectionToolbarPlugin = ({
14
14
  }) => {
15
15
  const __selectionToolbarHandlers = [];
16
16
  let primaryToolbarComponent;
17
+ const {
18
+ userPreferencesProvider
19
+ } = config;
17
20
  if (editorExperiment('platform_editor_controls', 'variant1', {
18
21
  exposure: true
19
22
  })) {
@@ -51,7 +54,8 @@ export const selectionToolbarPlugin = ({
51
54
  setToolbarDocking: toolbarDocking => {
52
55
  var _api$core$actions$exe3;
53
56
  return (_api$core$actions$exe3 = api === null || api === void 0 ? void 0 : api.core.actions.execute(setToolbarDocking({
54
- toolbarDocking
57
+ toolbarDocking,
58
+ userPreferencesProvider
55
59
  }))) !== null && _api$core$actions$exe3 !== void 0 ? _api$core$actions$exe3 : false;
56
60
  }
57
61
  },
@@ -72,10 +76,14 @@ export const selectionToolbarPlugin = ({
72
76
  key: selectionToolbarPluginKey,
73
77
  state: {
74
78
  init() {
79
+ let toolbarDocking = 'top';
80
+ if (editorExperiment('platform_editor_controls', 'variant1')) {
81
+ toolbarDocking = (userPreferencesProvider === null || userPreferencesProvider === void 0 ? void 0 : userPreferencesProvider.getPreference('toolbarDockingInitialPosition')) || 'none';
82
+ }
75
83
  return {
76
84
  selectionStable: false,
77
85
  hide: false,
78
- toolbarDocking: editorExperiment('platform_editor_controls', 'variant1') ? 'none' : 'top'
86
+ toolbarDocking
79
87
  };
80
88
  },
81
89
  apply(tr, pluginState) {
@@ -0,0 +1 @@
1
+ export {};
@@ -10,9 +10,12 @@ export var toggleToolbar = function toggleToolbar(_ref) {
10
10
  };
11
11
  };
12
12
  export var setToolbarDocking = function setToolbarDocking(_ref3) {
13
- var toolbarDocking = _ref3.toolbarDocking;
13
+ var toolbarDocking = _ref3.toolbarDocking,
14
+ userPreferencesProvider = _ref3.userPreferencesProvider;
14
15
  return function (_ref4) {
15
16
  var tr = _ref4.tr;
17
+ // We currently ignore any update failures, need to confirm this is the desired behaviour
18
+ userPreferencesProvider === null || userPreferencesProvider === void 0 || userPreferencesProvider.updatePreference('toolbarDockingInitialPosition', toolbarDocking);
16
19
  tr.setMeta(selectionToolbarPluginKey, {
17
20
  toolbarDocking: toolbarDocking
18
21
  });
@@ -17,6 +17,7 @@ export var selectionToolbarPlugin = function selectionToolbarPlugin(_ref) {
17
17
  config = _ref.config;
18
18
  var __selectionToolbarHandlers = [];
19
19
  var primaryToolbarComponent;
20
+ var userPreferencesProvider = config.userPreferencesProvider;
20
21
  if (editorExperiment('platform_editor_controls', 'variant1', {
21
22
  exposure: true
22
23
  })) {
@@ -55,7 +56,8 @@ export var selectionToolbarPlugin = function selectionToolbarPlugin(_ref) {
55
56
  setToolbarDocking: function setToolbarDocking(toolbarDocking) {
56
57
  var _api$core$actions$exe3;
57
58
  return (_api$core$actions$exe3 = api === null || api === void 0 ? void 0 : api.core.actions.execute(_setToolbarDocking({
58
- toolbarDocking: toolbarDocking
59
+ toolbarDocking: toolbarDocking,
60
+ userPreferencesProvider: userPreferencesProvider
59
61
  }))) !== null && _api$core$actions$exe3 !== void 0 ? _api$core$actions$exe3 : false;
60
62
  }
61
63
  },
@@ -76,10 +78,14 @@ export var selectionToolbarPlugin = function selectionToolbarPlugin(_ref) {
76
78
  key: selectionToolbarPluginKey,
77
79
  state: {
78
80
  init: function init() {
81
+ var toolbarDocking = 'top';
82
+ if (editorExperiment('platform_editor_controls', 'variant1')) {
83
+ toolbarDocking = (userPreferencesProvider === null || userPreferencesProvider === void 0 ? void 0 : userPreferencesProvider.getPreference('toolbarDockingInitialPosition')) || 'none';
84
+ }
79
85
  return {
80
86
  selectionStable: false,
81
87
  hide: false,
82
- toolbarDocking: editorExperiment('platform_editor_controls', 'variant1') ? 'none' : 'top'
88
+ toolbarDocking: toolbarDocking
83
89
  };
84
90
  },
85
91
  apply: function apply(tr, pluginState) {
@@ -0,0 +1 @@
1
+ export {};
@@ -1,8 +1,9 @@
1
- import type { EditorCommand } from '@atlaskit/editor-common/types';
1
+ import type { EditorCommand, UserPreferencesProvider } from '@atlaskit/editor-common/types';
2
2
  import type { ToolbarDocking } from '../types';
3
3
  export declare const toggleToolbar: ({ hide }: {
4
4
  hide: boolean;
5
5
  }) => EditorCommand;
6
- export declare const setToolbarDocking: ({ toolbarDocking }: {
6
+ export declare const setToolbarDocking: ({ toolbarDocking, userPreferencesProvider, }: {
7
7
  toolbarDocking: ToolbarDocking;
8
+ userPreferencesProvider?: UserPreferencesProvider | undefined;
8
9
  }) => EditorCommand;
@@ -1,4 +1,4 @@
1
- import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
1
+ import type { NextEditorPlugin, OptionalPlugin, UserPreferencesProvider } from '@atlaskit/editor-common/types';
2
2
  import type { EditorViewModePlugin } from '@atlaskit/editor-plugin-editor-viewmode';
3
3
  import type { PrimaryToolbarPlugin } from '@atlaskit/editor-plugin-primary-toolbar';
4
4
  import type { ToolbarDocking } from './types';
@@ -11,6 +11,7 @@ export type SelectionToolbarPlugin = NextEditorPlugin<'selectionToolbar', {
11
11
  * Defaults to false
12
12
  */
13
13
  preferenceToolbarAboveSelection?: boolean;
14
+ userPreferencesProvider?: UserPreferencesProvider;
14
15
  };
15
16
  dependencies: [OptionalPlugin<EditorViewModePlugin>, OptionalPlugin<PrimaryToolbarPlugin>];
16
17
  actions?: {
@@ -1,7 +1,8 @@
1
+ import { UserPreferences } from '@atlaskit/editor-common/types';
1
2
  export type SelectionToolbarPluginOptions = {
2
3
  /**
3
4
  * When set to true, placing the toolbar above the selection will be preferenced.
4
5
  */
5
6
  preferenceToolbarAboveSelection?: boolean;
6
7
  };
7
- export type ToolbarDocking = 'top' | 'none';
8
+ export type ToolbarDocking = NonNullable<UserPreferences['toolbarDockingInitialPosition']>;
@@ -1,8 +1,9 @@
1
- import type { EditorCommand } from '@atlaskit/editor-common/types';
1
+ import type { EditorCommand, UserPreferencesProvider } from '@atlaskit/editor-common/types';
2
2
  import type { ToolbarDocking } from '../types';
3
3
  export declare const toggleToolbar: ({ hide }: {
4
4
  hide: boolean;
5
5
  }) => EditorCommand;
6
- export declare const setToolbarDocking: ({ toolbarDocking }: {
6
+ export declare const setToolbarDocking: ({ toolbarDocking, userPreferencesProvider, }: {
7
7
  toolbarDocking: ToolbarDocking;
8
+ userPreferencesProvider?: UserPreferencesProvider | undefined;
8
9
  }) => EditorCommand;
@@ -1,4 +1,4 @@
1
- import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
1
+ import type { NextEditorPlugin, OptionalPlugin, UserPreferencesProvider } from '@atlaskit/editor-common/types';
2
2
  import type { EditorViewModePlugin } from '@atlaskit/editor-plugin-editor-viewmode';
3
3
  import type { PrimaryToolbarPlugin } from '@atlaskit/editor-plugin-primary-toolbar';
4
4
  import type { ToolbarDocking } from './types';
@@ -11,6 +11,7 @@ export type SelectionToolbarPlugin = NextEditorPlugin<'selectionToolbar', {
11
11
  * Defaults to false
12
12
  */
13
13
  preferenceToolbarAboveSelection?: boolean;
14
+ userPreferencesProvider?: UserPreferencesProvider;
14
15
  };
15
16
  dependencies: [
16
17
  OptionalPlugin<EditorViewModePlugin>,
@@ -1,7 +1,8 @@
1
+ import { UserPreferences } from '@atlaskit/editor-common/types';
1
2
  export type SelectionToolbarPluginOptions = {
2
3
  /**
3
4
  * When set to true, placing the toolbar above the selection will be preferenced.
4
5
  */
5
6
  preferenceToolbarAboveSelection?: boolean;
6
7
  };
7
- export type ToolbarDocking = 'top' | 'none';
8
+ export type ToolbarDocking = NonNullable<UserPreferences['toolbarDockingInitialPosition']>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-selection-toolbar",
3
- "version": "2.0.8",
3
+ "version": "2.1.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",
@@ -33,14 +33,14 @@
33
33
  ".": "./src/index.ts"
34
34
  },
35
35
  "dependencies": {
36
- "@atlaskit/editor-common": "^102.5.0",
36
+ "@atlaskit/editor-common": "^102.10.0",
37
37
  "@atlaskit/editor-plugin-editor-viewmode": "^3.0.0",
38
38
  "@atlaskit/editor-plugin-primary-toolbar": "^3.0.0",
39
39
  "@atlaskit/editor-prosemirror": "7.0.0",
40
40
  "@atlaskit/icon": "^25.0.0",
41
41
  "@atlaskit/menu": "^3.1.0",
42
42
  "@atlaskit/platform-feature-flags": "^1.1.0",
43
- "@atlaskit/tmp-editor-statsig": "^3.6.0",
43
+ "@atlaskit/tmp-editor-statsig": "^4.1.0",
44
44
  "@atlaskit/tokens": "^4.5.0",
45
45
  "@babel/runtime": "^7.0.0",
46
46
  "@emotion/react": "^11.7.1",