@atlaskit/editor-plugin-selection-toolbar 2.0.3 → 2.0.5

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,19 @@
1
1
  # @atlaskit/editor-plugin-selection-toolbar
2
2
 
3
+ ## 2.0.5
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 2.0.4
10
+
11
+ ### Patch Changes
12
+
13
+ - [#121249](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/121249)
14
+ [`d14ccaecc153a`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/d14ccaecc153a) -
15
+ ED-26862 contextual toolbar minor updates
16
+
3
17
  ## 2.0.3
4
18
 
5
19
  ### Patch Changes
@@ -144,9 +144,10 @@ var selectionToolbarPlugin = exports.selectionToolbarPlugin = function selection
144
144
  },
145
145
  pluginsOptions: {
146
146
  floatingToolbar: function floatingToolbar(state, intl, providerFactory) {
147
- var _selectionToolbarPlug = _pluginKey.selectionToolbarPluginKey.getState(state),
148
- selectionStable = _selectionToolbarPlug.selectionStable,
149
- hide = _selectionToolbarPlug.hide;
147
+ var _ref3 = _pluginKey.selectionToolbarPluginKey.getState(state),
148
+ selectionStable = _ref3.selectionStable,
149
+ hide = _ref3.hide,
150
+ toolbarDocking = _ref3.toolbarDocking;
150
151
  if (state.selection.empty || !selectionStable || hide || state.selection instanceof _state.NodeSelection ||
151
152
  // $anchorCell is only available in CellSelection, this check is to
152
153
  // avoid importing CellSelection from @atlaskit/editor-tables
@@ -167,11 +168,11 @@ var selectionToolbarPlugin = exports.selectionToolbarPlugin = function selection
167
168
  // they add to the selection toolbar.
168
169
  // ie. if you want to have your plugin's group appear first, set rank to -10 if there is currently another
169
170
  // plugin you expect to be run at the same time as with an rank of -9
170
- resolved.sort(function (_ref3, _ref4) {
171
- var _ref3$rank = _ref3.rank,
172
- rankA = _ref3$rank === void 0 ? 0 : _ref3$rank;
171
+ resolved.sort(function (_ref4, _ref5) {
173
172
  var _ref4$rank = _ref4.rank,
174
- rankB = _ref4$rank === void 0 ? 0 : _ref4$rank;
173
+ rankA = _ref4$rank === void 0 ? 0 : _ref4$rank;
174
+ var _ref5$rank = _ref5.rank,
175
+ rankB = _ref5$rank === void 0 ? 0 : _ref5$rank;
175
176
  if (rankA < rankB) {
176
177
  return 1;
177
178
  }
@@ -207,7 +208,8 @@ var selectionToolbarPlugin = exports.selectionToolbarPlugin = function selection
207
208
  }
208
209
  if (items.length > 0 && (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1')) {
209
210
  items.push.apply(items, (0, _toConsumableArray2.default)((0, _overflowToolbarConfig.getOverflowFloatingToolbarConfig)({
210
- api: api
211
+ api: api,
212
+ toolbarDocking: toolbarDocking
211
213
  })));
212
214
  }
213
215
  var calcToolbarPosition = config.preferenceToolbarAboveSelection ? _utils.calculateToolbarPositionAboveSelection : _utils.calculateToolbarPositionTrackHead;
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.getOverflowPrimaryToolbarConfig = exports.getOverflowFloatingToolbarConfig = void 0;
8
8
  var _react = require("@emotion/react");
9
9
  var _checkMark = _interopRequireDefault(require("@atlaskit/icon/utility/check-mark"));
10
+ var _chevronRight = _interopRequireDefault(require("@atlaskit/icon/utility/migration/chevron-right"));
10
11
  var _menu = require("@atlaskit/menu");
11
12
  var _ContextualToolbarIcon = require("./icons/ContextualToolbarIcon");
12
13
  var _FixedToolbarIcon = require("./icons/FixedToolbarIcon");
@@ -19,12 +20,34 @@ var _FixedToolbarIcon = require("./icons/FixedToolbarIcon");
19
20
 
20
21
  // New editor controls
21
22
  var getOverflowFloatingToolbarConfig = exports.getOverflowFloatingToolbarConfig = function getOverflowFloatingToolbarConfig(_ref) {
22
- var api = _ref.api;
23
- return [{
24
- type: 'separator'
23
+ var api = _ref.api,
24
+ toolbarDocking = _ref.toolbarDocking;
25
+ var dropdownOptions = [{
26
+ title: 'Create Jira issue',
27
+ onClick: function onClick() {
28
+ return false;
29
+ },
30
+ elemAfter: (0, _react.jsx)(_chevronRight.default, {
31
+ spacing: "spacious",
32
+ label: ""
33
+ })
25
34
  }, {
26
- type: 'overflow-dropdown',
27
- options: [{
35
+ title: 'Define',
36
+ onClick: function onClick() {
37
+ return false;
38
+ }
39
+ }, {
40
+ title: 'Apps',
41
+ onClick: function onClick() {
42
+ return false;
43
+ },
44
+ elemAfter: (0, _react.jsx)(_chevronRight.default, {
45
+ spacing: "spacious",
46
+ label: ""
47
+ })
48
+ }];
49
+ if (toolbarDocking === 'none') {
50
+ dropdownOptions.push({
28
51
  type: 'overflow-dropdown-heading',
29
52
  title: 'Toolbar appears'
30
53
  }, {
@@ -49,7 +72,14 @@ var getOverflowFloatingToolbarConfig = exports.getOverflowFloatingToolbarConfig
49
72
  icon: (0, _react.jsx)(_FixedToolbarIcon.FixedToolbarIcon, {
50
73
  label: "Fixed toolbar"
51
74
  })
52
- }]
75
+ });
76
+ }
77
+ return [{
78
+ type: 'separator'
79
+ }, {
80
+ type: 'overflow-dropdown',
81
+ dropdownWidth: 240,
82
+ options: dropdownOptions
53
83
  }];
54
84
  };
55
85
  var getOverflowPrimaryToolbarConfig = exports.getOverflowPrimaryToolbarConfig = function getOverflowPrimaryToolbarConfig(_ref2) {
@@ -138,7 +138,8 @@ export const selectionToolbarPlugin = ({
138
138
  floatingToolbar(state, intl, providerFactory) {
139
139
  const {
140
140
  selectionStable,
141
- hide
141
+ hide,
142
+ toolbarDocking
142
143
  } = selectionToolbarPluginKey.getState(state);
143
144
  if (state.selection.empty || !selectionStable || hide || state.selection instanceof NodeSelection ||
144
145
  // $anchorCell is only available in CellSelection, this check is to
@@ -196,7 +197,8 @@ export const selectionToolbarPlugin = ({
196
197
  }
197
198
  if (items.length > 0 && editorExperiment('platform_editor_controls', 'variant1')) {
198
199
  items.push(...getOverflowFloatingToolbarConfig({
199
- api
200
+ api,
201
+ toolbarDocking
200
202
  }));
201
203
  }
202
204
  const calcToolbarPosition = config.preferenceToolbarAboveSelection ? calculateToolbarPositionAboveSelection : calculateToolbarPositionTrackHead;
@@ -6,43 +6,75 @@
6
6
  import { jsx } from '@emotion/react'; // eslint-disable-line @atlaskit/ui-styling-standard/use-compiled
7
7
 
8
8
  import CheckMarkIcon from '@atlaskit/icon/utility/check-mark';
9
+ import ChevronRightIcon from '@atlaskit/icon/utility/migration/chevron-right';
9
10
  import { HeadingItem } from '@atlaskit/menu';
10
11
  import { ContextualToolbarIcon } from './icons/ContextualToolbarIcon';
11
12
  import { FixedToolbarIcon } from './icons/FixedToolbarIcon';
12
13
  // New editor controls
13
14
  export const getOverflowFloatingToolbarConfig = ({
14
- api
15
- }) => [{
16
- type: 'separator'
17
- }, {
18
- type: 'overflow-dropdown',
19
- options: [{
20
- type: 'overflow-dropdown-heading',
21
- title: 'Toolbar appears'
22
- }, {
23
- title: 'In-line with text',
15
+ api,
16
+ toolbarDocking
17
+ }) => {
18
+ const dropdownOptions = [{
19
+ title: 'Create Jira issue',
24
20
  onClick: () => {
25
- var _api$selectionToolbar, _api$selectionToolbar2, _api$selectionToolbar3;
26
- return (_api$selectionToolbar = api === null || api === void 0 ? void 0 : (_api$selectionToolbar2 = api.selectionToolbar.actions) === null || _api$selectionToolbar2 === void 0 ? void 0 : (_api$selectionToolbar3 = _api$selectionToolbar2.setToolbarDocking) === null || _api$selectionToolbar3 === void 0 ? void 0 : _api$selectionToolbar3.call(_api$selectionToolbar2, 'none')) !== null && _api$selectionToolbar !== void 0 ? _api$selectionToolbar : false;
21
+ return false;
27
22
  },
28
- icon: jsx(ContextualToolbarIcon, {
29
- label: "Contextual toolbar"
30
- }),
31
- selected: true,
32
- elemAfter: jsx(CheckMarkIcon, {
23
+ elemAfter: jsx(ChevronRightIcon, {
24
+ spacing: "spacious",
33
25
  label: ""
34
26
  })
35
27
  }, {
36
- title: 'Fixed at top',
28
+ title: 'Define',
37
29
  onClick: () => {
38
- var _api$selectionToolbar4, _api$selectionToolbar5, _api$selectionToolbar6;
39
- return (_api$selectionToolbar4 = api === null || api === void 0 ? void 0 : (_api$selectionToolbar5 = api.selectionToolbar.actions) === null || _api$selectionToolbar5 === void 0 ? void 0 : (_api$selectionToolbar6 = _api$selectionToolbar5.setToolbarDocking) === null || _api$selectionToolbar6 === void 0 ? void 0 : _api$selectionToolbar6.call(_api$selectionToolbar5, 'top')) !== null && _api$selectionToolbar4 !== void 0 ? _api$selectionToolbar4 : false;
30
+ return false;
31
+ }
32
+ }, {
33
+ title: 'Apps',
34
+ onClick: () => {
35
+ return false;
40
36
  },
41
- icon: jsx(FixedToolbarIcon, {
42
- label: "Fixed toolbar"
37
+ elemAfter: jsx(ChevronRightIcon, {
38
+ spacing: "spacious",
39
+ label: ""
43
40
  })
44
- }]
45
- }];
41
+ }];
42
+ if (toolbarDocking === 'none') {
43
+ dropdownOptions.push({
44
+ type: 'overflow-dropdown-heading',
45
+ title: 'Toolbar appears'
46
+ }, {
47
+ title: 'In-line with text',
48
+ onClick: () => {
49
+ var _api$selectionToolbar, _api$selectionToolbar2, _api$selectionToolbar3;
50
+ return (_api$selectionToolbar = api === null || api === void 0 ? void 0 : (_api$selectionToolbar2 = api.selectionToolbar.actions) === null || _api$selectionToolbar2 === void 0 ? void 0 : (_api$selectionToolbar3 = _api$selectionToolbar2.setToolbarDocking) === null || _api$selectionToolbar3 === void 0 ? void 0 : _api$selectionToolbar3.call(_api$selectionToolbar2, 'none')) !== null && _api$selectionToolbar !== void 0 ? _api$selectionToolbar : false;
51
+ },
52
+ icon: jsx(ContextualToolbarIcon, {
53
+ label: "Contextual toolbar"
54
+ }),
55
+ selected: true,
56
+ elemAfter: jsx(CheckMarkIcon, {
57
+ label: ""
58
+ })
59
+ }, {
60
+ title: 'Fixed at top',
61
+ onClick: () => {
62
+ var _api$selectionToolbar4, _api$selectionToolbar5, _api$selectionToolbar6;
63
+ return (_api$selectionToolbar4 = api === null || api === void 0 ? void 0 : (_api$selectionToolbar5 = api.selectionToolbar.actions) === null || _api$selectionToolbar5 === void 0 ? void 0 : (_api$selectionToolbar6 = _api$selectionToolbar5.setToolbarDocking) === null || _api$selectionToolbar6 === void 0 ? void 0 : _api$selectionToolbar6.call(_api$selectionToolbar5, 'top')) !== null && _api$selectionToolbar4 !== void 0 ? _api$selectionToolbar4 : false;
64
+ },
65
+ icon: jsx(FixedToolbarIcon, {
66
+ label: "Fixed toolbar"
67
+ })
68
+ });
69
+ }
70
+ return [{
71
+ type: 'separator'
72
+ }, {
73
+ type: 'overflow-dropdown',
74
+ dropdownWidth: 240,
75
+ options: dropdownOptions
76
+ }];
77
+ };
46
78
  export const getOverflowPrimaryToolbarConfig = ({
47
79
  api
48
80
  }) => [{
@@ -137,9 +137,10 @@ export var selectionToolbarPlugin = function selectionToolbarPlugin(_ref) {
137
137
  },
138
138
  pluginsOptions: {
139
139
  floatingToolbar: function floatingToolbar(state, intl, providerFactory) {
140
- var _selectionToolbarPlug = selectionToolbarPluginKey.getState(state),
141
- selectionStable = _selectionToolbarPlug.selectionStable,
142
- hide = _selectionToolbarPlug.hide;
140
+ var _ref3 = selectionToolbarPluginKey.getState(state),
141
+ selectionStable = _ref3.selectionStable,
142
+ hide = _ref3.hide,
143
+ toolbarDocking = _ref3.toolbarDocking;
143
144
  if (state.selection.empty || !selectionStable || hide || state.selection instanceof NodeSelection ||
144
145
  // $anchorCell is only available in CellSelection, this check is to
145
146
  // avoid importing CellSelection from @atlaskit/editor-tables
@@ -160,11 +161,11 @@ export var selectionToolbarPlugin = function selectionToolbarPlugin(_ref) {
160
161
  // they add to the selection toolbar.
161
162
  // ie. if you want to have your plugin's group appear first, set rank to -10 if there is currently another
162
163
  // plugin you expect to be run at the same time as with an rank of -9
163
- resolved.sort(function (_ref3, _ref4) {
164
- var _ref3$rank = _ref3.rank,
165
- rankA = _ref3$rank === void 0 ? 0 : _ref3$rank;
164
+ resolved.sort(function (_ref4, _ref5) {
166
165
  var _ref4$rank = _ref4.rank,
167
- rankB = _ref4$rank === void 0 ? 0 : _ref4$rank;
166
+ rankA = _ref4$rank === void 0 ? 0 : _ref4$rank;
167
+ var _ref5$rank = _ref5.rank,
168
+ rankB = _ref5$rank === void 0 ? 0 : _ref5$rank;
168
169
  if (rankA < rankB) {
169
170
  return 1;
170
171
  }
@@ -200,7 +201,8 @@ export var selectionToolbarPlugin = function selectionToolbarPlugin(_ref) {
200
201
  }
201
202
  if (items.length > 0 && editorExperiment('platform_editor_controls', 'variant1')) {
202
203
  items.push.apply(items, _toConsumableArray(getOverflowFloatingToolbarConfig({
203
- api: api
204
+ api: api,
205
+ toolbarDocking: toolbarDocking
204
206
  })));
205
207
  }
206
208
  var calcToolbarPosition = config.preferenceToolbarAboveSelection ? calculateToolbarPositionAboveSelection : calculateToolbarPositionTrackHead;
@@ -6,17 +6,40 @@
6
6
  import { jsx } from '@emotion/react'; // eslint-disable-line @atlaskit/ui-styling-standard/use-compiled
7
7
 
8
8
  import CheckMarkIcon from '@atlaskit/icon/utility/check-mark';
9
+ import ChevronRightIcon from '@atlaskit/icon/utility/migration/chevron-right';
9
10
  import { HeadingItem } from '@atlaskit/menu';
10
11
  import { ContextualToolbarIcon } from './icons/ContextualToolbarIcon';
11
12
  import { FixedToolbarIcon } from './icons/FixedToolbarIcon';
12
13
  // New editor controls
13
14
  export var getOverflowFloatingToolbarConfig = function getOverflowFloatingToolbarConfig(_ref) {
14
- var api = _ref.api;
15
- return [{
16
- type: 'separator'
15
+ var api = _ref.api,
16
+ toolbarDocking = _ref.toolbarDocking;
17
+ var dropdownOptions = [{
18
+ title: 'Create Jira issue',
19
+ onClick: function onClick() {
20
+ return false;
21
+ },
22
+ elemAfter: jsx(ChevronRightIcon, {
23
+ spacing: "spacious",
24
+ label: ""
25
+ })
17
26
  }, {
18
- type: 'overflow-dropdown',
19
- options: [{
27
+ title: 'Define',
28
+ onClick: function onClick() {
29
+ return false;
30
+ }
31
+ }, {
32
+ title: 'Apps',
33
+ onClick: function onClick() {
34
+ return false;
35
+ },
36
+ elemAfter: jsx(ChevronRightIcon, {
37
+ spacing: "spacious",
38
+ label: ""
39
+ })
40
+ }];
41
+ if (toolbarDocking === 'none') {
42
+ dropdownOptions.push({
20
43
  type: 'overflow-dropdown-heading',
21
44
  title: 'Toolbar appears'
22
45
  }, {
@@ -41,7 +64,14 @@ export var getOverflowFloatingToolbarConfig = function getOverflowFloatingToolba
41
64
  icon: jsx(FixedToolbarIcon, {
42
65
  label: "Fixed toolbar"
43
66
  })
44
- }]
67
+ });
68
+ }
69
+ return [{
70
+ type: 'separator'
71
+ }, {
72
+ type: 'overflow-dropdown',
73
+ dropdownWidth: 240,
74
+ options: dropdownOptions
45
75
  }];
46
76
  };
47
77
  export var getOverflowPrimaryToolbarConfig = function getOverflowPrimaryToolbarConfig(_ref2) {
@@ -4,8 +4,9 @@ import type { MenuItem } from '@atlaskit/editor-common/ui-menu';
4
4
  import type { SelectionToolbarPlugin } from '../selectionToolbarPluginType';
5
5
  type OverflowToobarConfigOptions = {
6
6
  api?: ExtractInjectionAPI<SelectionToolbarPlugin>;
7
+ toolbarDocking?: 'top' | 'none';
7
8
  };
8
- export declare const getOverflowFloatingToolbarConfig: ({ api, }: OverflowToobarConfigOptions) => FloatingToolbarItem<Command>[];
9
+ export declare const getOverflowFloatingToolbarConfig: ({ api, toolbarDocking, }: OverflowToobarConfigOptions) => FloatingToolbarItem<Command>[];
9
10
  export declare const getOverflowPrimaryToolbarConfig: ({ api, }: OverflowToobarConfigOptions) => {
10
11
  items: MenuItem[];
11
12
  }[];
@@ -4,8 +4,9 @@ import type { MenuItem } from '@atlaskit/editor-common/ui-menu';
4
4
  import type { SelectionToolbarPlugin } from '../selectionToolbarPluginType';
5
5
  type OverflowToobarConfigOptions = {
6
6
  api?: ExtractInjectionAPI<SelectionToolbarPlugin>;
7
+ toolbarDocking?: 'top' | 'none';
7
8
  };
8
- export declare const getOverflowFloatingToolbarConfig: ({ api, }: OverflowToobarConfigOptions) => FloatingToolbarItem<Command>[];
9
+ export declare const getOverflowFloatingToolbarConfig: ({ api, toolbarDocking, }: OverflowToobarConfigOptions) => FloatingToolbarItem<Command>[];
9
10
  export declare const getOverflowPrimaryToolbarConfig: ({ api, }: OverflowToobarConfigOptions) => {
10
11
  items: MenuItem[];
11
12
  }[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-selection-toolbar",
3
- "version": "2.0.3",
3
+ "version": "2.0.5",
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,15 +33,15 @@
33
33
  ".": "./src/index.ts"
34
34
  },
35
35
  "dependencies": {
36
- "@atlaskit/editor-common": "^100.4.0",
36
+ "@atlaskit/editor-common": "^101.0.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": "^24.1.0",
41
41
  "@atlaskit/menu": "^3.0.0",
42
42
  "@atlaskit/platform-feature-flags": "^1.1.0",
43
- "@atlaskit/tmp-editor-statsig": "^3.3.0",
44
- "@atlaskit/tokens": "^4.2.0",
43
+ "@atlaskit/tmp-editor-statsig": "^3.4.0",
44
+ "@atlaskit/tokens": "^4.3.0",
45
45
  "@babel/runtime": "^7.0.0",
46
46
  "@emotion/react": "^11.7.1",
47
47
  "bind-event-listener": "^3.0.0"