@atlaskit/editor-plugin-selection-toolbar 3.6.9 → 3.6.11

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,24 @@
1
1
  # @atlaskit/editor-plugin-selection-toolbar
2
2
 
3
+ ## 3.6.11
4
+
5
+ ### Patch Changes
6
+
7
+ - [#163573](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/163573)
8
+ [`21e93839ec382`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/21e93839ec382) -
9
+ Convert platform_editor_controls_toolbar_pinning fg to
10
+ platform_editor_controls_toolbar_pinning_exp experiment
11
+ - Updated dependencies
12
+
13
+ ## 3.6.10
14
+
15
+ ### Patch Changes
16
+
17
+ - [#162560](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/162560)
18
+ [`2f1b203a00ccf`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/2f1b203a00ccf) -
19
+ [ux] Removes docking options from the overflow menu and converts them into pin/unpin button.
20
+ - Updated dependencies
21
+
3
22
  ## 3.6.9
4
23
 
5
24
  ### Patch Changes
@@ -19,6 +19,7 @@ var _commands = require("./pm-plugins/commands");
19
19
  var _pluginKey = require("./pm-plugins/plugin-key");
20
20
  var _overflowToolbarConfig = require("./ui/overflow-toolbar-config");
21
21
  var _PageVisibilityWatcher = require("./ui/PageVisibilityWatcher");
22
+ var _pinToolbarConfig = require("./ui/pin-toolbar-config");
22
23
  var _PrimaryToolbarComponent = require("./ui/PrimaryToolbarComponent");
23
24
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
24
25
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
@@ -39,22 +40,37 @@ var selectionToolbarPlugin = exports.selectionToolbarPlugin = function selection
39
40
  if ((0, _experiments.editorExperiment)('platform_editor_controls', 'variant1', {
40
41
  exposure: true
41
42
  })) {
42
- var _api$primaryToolbar;
43
- primaryToolbarComponent = function primaryToolbarComponent(_ref2) {
44
- var popupsBoundariesElement = _ref2.popupsBoundariesElement,
45
- popupsMountPoint = _ref2.popupsMountPoint,
46
- popupsScrollableElement = _ref2.popupsScrollableElement;
47
- return /*#__PURE__*/_react.default.createElement(_PrimaryToolbarComponent.PrimaryToolbarComponent, {
48
- api: api,
49
- popupsBoundariesElement: popupsBoundariesElement,
50
- popupsMountPoint: popupsMountPoint,
51
- popupsScrollableElement: popupsScrollableElement
43
+ if ((0, _experiments.editorExperiment)('platform_editor_controls_toolbar_pinning_exp', true)) {
44
+ var _api$primaryToolbar;
45
+ primaryToolbarComponent = function primaryToolbarComponent(_ref2) {
46
+ var disabled = _ref2.disabled;
47
+ return /*#__PURE__*/_react.default.createElement(_PrimaryToolbarComponent.PrimaryToolbarComponentNew, {
48
+ api: api,
49
+ disabled: disabled
50
+ });
51
+ };
52
+ api === null || api === void 0 || (_api$primaryToolbar = api.primaryToolbar) === null || _api$primaryToolbar === void 0 || _api$primaryToolbar.actions.registerComponent({
53
+ name: 'pinToolbar',
54
+ component: primaryToolbarComponent
55
+ });
56
+ } else {
57
+ var _api$primaryToolbar2;
58
+ primaryToolbarComponent = function primaryToolbarComponent(_ref3) {
59
+ var popupsBoundariesElement = _ref3.popupsBoundariesElement,
60
+ popupsMountPoint = _ref3.popupsMountPoint,
61
+ popupsScrollableElement = _ref3.popupsScrollableElement;
62
+ return /*#__PURE__*/_react.default.createElement(_PrimaryToolbarComponent.PrimaryToolbarComponent, {
63
+ api: api,
64
+ popupsBoundariesElement: popupsBoundariesElement,
65
+ popupsMountPoint: popupsMountPoint,
66
+ popupsScrollableElement: popupsScrollableElement
67
+ });
68
+ };
69
+ api === null || api === void 0 || (_api$primaryToolbar2 = api.primaryToolbar) === null || _api$primaryToolbar2 === void 0 || _api$primaryToolbar2.actions.registerComponent({
70
+ name: 'overflowMenu',
71
+ component: primaryToolbarComponent
52
72
  });
53
- };
54
- api === null || api === void 0 || (_api$primaryToolbar = api.primaryToolbar) === null || _api$primaryToolbar === void 0 || _api$primaryToolbar.actions.registerComponent({
55
- name: 'overflowMenu',
56
- component: primaryToolbarComponent
57
- });
73
+ }
58
74
  }
59
75
  var previousToolbarDocking = (userPreferencesProvider === null || userPreferencesProvider === void 0 ? void 0 : userPreferencesProvider.getPreference('toolbarDockingInitialPosition')) || null;
60
76
  var isPreferenceInitialized = false;
@@ -220,10 +236,10 @@ var selectionToolbarPlugin = exports.selectionToolbarPlugin = function selection
220
236
  },
221
237
  pluginsOptions: {
222
238
  floatingToolbar: function floatingToolbar(state, intl, providerFactory) {
223
- var _ref3 = _pluginKey.selectionToolbarPluginKey.getState(state),
224
- selectionStable = _ref3.selectionStable,
225
- hide = _ref3.hide,
226
- toolbarDocking = _ref3.toolbarDocking;
239
+ var _ref4 = _pluginKey.selectionToolbarPluginKey.getState(state),
240
+ selectionStable = _ref4.selectionStable,
241
+ hide = _ref4.hide,
242
+ toolbarDocking = _ref4.toolbarDocking;
227
243
  var isCellSelection = ('$anchorCell' in state.selection);
228
244
  var isEditorControlsEnabled = (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1');
229
245
  if (state.selection.empty || !selectionStable || hide || state.selection instanceof _state.NodeSelection ||
@@ -255,11 +271,11 @@ var selectionToolbarPlugin = exports.selectionToolbarPlugin = function selection
255
271
  // they add to the selection toolbar.
256
272
  // ie. if you want to have your plugin's group appear first, set rank to -10 if there is currently another
257
273
  // plugin you expect to be run at the same time as with an rank of -9
258
- resolved.sort(function (_ref4, _ref5) {
259
- var _ref4$rank = _ref4.rank,
260
- rankA = _ref4$rank === void 0 ? 0 : _ref4$rank;
274
+ resolved.sort(function (_ref5, _ref6) {
261
275
  var _ref5$rank = _ref5.rank,
262
- rankB = _ref5$rank === void 0 ? 0 : _ref5$rank;
276
+ rankA = _ref5$rank === void 0 ? 0 : _ref5$rank;
277
+ var _ref6$rank = _ref6.rank,
278
+ rankB = _ref6$rank === void 0 ? 0 : _ref6$rank;
263
279
  if (rankA < rankB) {
264
280
  return 1;
265
281
  }
@@ -301,11 +317,19 @@ var selectionToolbarPlugin = exports.selectionToolbarPlugin = function selection
301
317
  }
302
318
  }
303
319
  if (items.length > 0 && contextualFormattingEnabled && isEditorControlsEnabled) {
304
- items.push.apply(items, (0, _toConsumableArray2.default)((0, _overflowToolbarConfig.getOverflowFloatingToolbarConfig)({
305
- api: api,
306
- toolbarDocking: toolbarDocking,
307
- intl: intl
308
- })));
320
+ if ((0, _experiments.editorExperiment)('platform_editor_controls_toolbar_pinning_exp', true)) {
321
+ items.push.apply(items, (0, _toConsumableArray2.default)((0, _pinToolbarConfig.getPinOptionToolbarConfig)({
322
+ api: api,
323
+ toolbarDocking: toolbarDocking,
324
+ intl: intl
325
+ })));
326
+ } else {
327
+ items.push.apply(items, (0, _toConsumableArray2.default)((0, _overflowToolbarConfig.getOverflowFloatingToolbarConfig)({
328
+ api: api,
329
+ toolbarDocking: toolbarDocking,
330
+ intl: intl
331
+ })));
332
+ }
309
333
  }
310
334
  var onPositionCalculated;
311
335
  var toolbarTitle = 'Selection toolbar';
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  value: true
8
8
  });
9
9
  exports.PrimaryToolbarComponent = PrimaryToolbarComponent;
10
+ exports.PrimaryToolbarComponentNew = void 0;
10
11
  require("./PrimaryToolbarComponent.compiled.css");
11
12
  var _react = _interopRequireWildcard(require("react"));
12
13
  var React = _react;
@@ -15,15 +16,21 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
15
16
  var _reactIntlNext = require("react-intl-next");
16
17
  var _analytics = require("@atlaskit/editor-common/analytics");
17
18
  var _keymaps = require("@atlaskit/editor-common/keymaps");
18
- var _messages = _interopRequireDefault(require("@atlaskit/editor-common/messages"));
19
+ var _messages = _interopRequireWildcard(require("@atlaskit/editor-common/messages"));
19
20
  var _uiMenu = require("@atlaskit/editor-common/ui-menu");
21
+ var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
22
+ var _pin = _interopRequireDefault(require("@atlaskit/icon/core/pin"));
23
+ var _pinFilled = _interopRequireDefault(require("@atlaskit/icon/core/pin-filled"));
20
24
  var _showMoreHorizontal = _interopRequireDefault(require("@atlaskit/icon/core/show-more-horizontal"));
21
25
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
22
26
  var _overflowToolbarConfig = require("./overflow-toolbar-config");
23
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
24
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
27
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
25
28
  var DROPDOWN_WIDTH = 240;
26
29
  var buttonStyles = null;
30
+ /**
31
+ * A component used to renderer a dropdown with
32
+ * toolbar docking options.
33
+ */
27
34
  function PrimaryToolbarComponent(_ref) {
28
35
  var api = _ref.api,
29
36
  popupsBoundariesElement = _ref.popupsBoundariesElement,
@@ -90,4 +97,54 @@ function PrimaryToolbarComponent(_ref) {
90
97
  }, /*#__PURE__*/React.createElement(_showMoreHorizontal.default, {
91
98
  label: content
92
99
  })));
93
- }
100
+ }
101
+
102
+ /**
103
+ * A component used to renderer a pin/unpin
104
+ * button to the toolbar to the or make it in-line.
105
+ */
106
+ var PrimaryToolbarComponentNew = exports.PrimaryToolbarComponentNew = function PrimaryToolbarComponentNew(_ref3) {
107
+ var _api$selectionToolbar;
108
+ var api = _ref3.api,
109
+ disabled = _ref3.disabled;
110
+ var intl = (0, _reactIntlNext.useIntl)();
111
+ var mode = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'connectivity.mode');
112
+ var isOffline = mode === 'offline' || false;
113
+ var isDockedToTop = (api === null || api === void 0 || (_api$selectionToolbar = api.selectionToolbar.sharedState.currentState()) === null || _api$selectionToolbar === void 0 ? void 0 : _api$selectionToolbar.toolbarDocking) === 'top';
114
+ if (isDockedToTop) {
115
+ return /*#__PURE__*/React.createElement(_uiMenu.ToolbarButton, {
116
+ "aria-label": intl.formatMessage(_messages.selectionToolbarMessages.toolbarPositionPinedAtTop)
117
+ // eslint-disable-next-line @atlaskit/design-system/no-unsafe-style-overrides -- Ignored via go/DSP-18766
118
+ ,
119
+
120
+ disabled: disabled || isOffline,
121
+ iconBefore: /*#__PURE__*/React.createElement(_pinFilled.default, {
122
+ label: "",
123
+ spacing: "spacious"
124
+ }),
125
+ onClick: function onClick() {
126
+ var _api$selectionToolbar2, _api$selectionToolbar3, _api$selectionToolbar4;
127
+ return (_api$selectionToolbar2 = api === null || api === void 0 || (_api$selectionToolbar3 = api.selectionToolbar.actions) === null || _api$selectionToolbar3 === void 0 || (_api$selectionToolbar4 = _api$selectionToolbar3.setToolbarDocking) === null || _api$selectionToolbar4 === void 0 ? void 0 : _api$selectionToolbar4.call(_api$selectionToolbar3, 'none')) !== null && _api$selectionToolbar2 !== void 0 ? _api$selectionToolbar2 : false;
128
+ },
129
+ title: intl.formatMessage(_messages.selectionToolbarMessages.toolbarPositionPinedAtTop),
130
+ className: (0, _runtime.ax)(["_ca0q12x7 _n3td12x7 _19bv12x7 _u5f312x7"])
131
+ });
132
+ }
133
+ return /*#__PURE__*/React.createElement(_uiMenu.ToolbarButton, {
134
+ "aria-label": intl.formatMessage(_messages.selectionToolbarMessages.toolbarPositionUnpined)
135
+ // eslint-disable-next-line @atlaskit/design-system/no-unsafe-style-overrides -- Ignored via go/DSP-18766
136
+ ,
137
+
138
+ disabled: disabled || isOffline,
139
+ iconBefore: /*#__PURE__*/React.createElement(_pin.default, {
140
+ label: "",
141
+ spacing: "spacious"
142
+ }),
143
+ onClick: function onClick() {
144
+ var _api$selectionToolbar5, _api$selectionToolbar6, _api$selectionToolbar7;
145
+ return (_api$selectionToolbar5 = api === null || api === void 0 || (_api$selectionToolbar6 = api.selectionToolbar.actions) === null || _api$selectionToolbar6 === void 0 || (_api$selectionToolbar7 = _api$selectionToolbar6.setToolbarDocking) === null || _api$selectionToolbar7 === void 0 ? void 0 : _api$selectionToolbar7.call(_api$selectionToolbar6, 'top')) !== null && _api$selectionToolbar5 !== void 0 ? _api$selectionToolbar5 : false;
146
+ },
147
+ title: intl.formatMessage(_messages.selectionToolbarMessages.toolbarPositionUnpined),
148
+ className: (0, _runtime.ax)(["_ca0q12x7 _n3td12x7 _19bv12x7 _u5f312x7"])
149
+ });
150
+ };
@@ -15,8 +15,7 @@ var _minus = _interopRequireDefault(require("@atlaskit/icon/core/minus"));
15
15
  var _checkMark = _interopRequireDefault(require("@atlaskit/icon/utility/check-mark"));
16
16
  var _menu = require("@atlaskit/menu");
17
17
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
18
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
19
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
18
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
20
19
  // New editor controls
21
20
  var getOverflowFloatingToolbarConfig = exports.getOverflowFloatingToolbarConfig = function getOverflowFloatingToolbarConfig(_ref) {
22
21
  var api = _ref.api,
@@ -95,8 +94,8 @@ var getOverflowPrimaryToolbarConfig = exports.getOverflowPrimaryToolbarConfig =
95
94
  name: 'fixed'
96
95
  },
97
96
  onClick: function onClick() {
98
- var _api$selectionToolbar10, _api$selectionToolbar11, _api$selectionToolbar12;
99
- return (_api$selectionToolbar10 = api === null || api === void 0 || (_api$selectionToolbar11 = api.selectionToolbar.actions) === null || _api$selectionToolbar11 === void 0 || (_api$selectionToolbar12 = _api$selectionToolbar11.setToolbarDocking) === null || _api$selectionToolbar12 === void 0 ? void 0 : _api$selectionToolbar12.call(_api$selectionToolbar11, 'top')) !== null && _api$selectionToolbar10 !== void 0 ? _api$selectionToolbar10 : false;
97
+ var _api$selectionToolbar0, _api$selectionToolbar1, _api$selectionToolbar10;
98
+ return (_api$selectionToolbar0 = api === null || api === void 0 || (_api$selectionToolbar1 = api.selectionToolbar.actions) === null || _api$selectionToolbar1 === void 0 || (_api$selectionToolbar10 = _api$selectionToolbar1.setToolbarDocking) === null || _api$selectionToolbar10 === void 0 ? void 0 : _api$selectionToolbar10.call(_api$selectionToolbar1, 'top')) !== null && _api$selectionToolbar0 !== void 0 ? _api$selectionToolbar0 : false;
100
99
  },
101
100
  isActive: true,
102
101
  elemBefore: (0, _dockToolbarTop.default)({
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.getPinOptionToolbarConfig = void 0;
8
+ var _react = _interopRequireDefault(require("react"));
9
+ var _messages = require("@atlaskit/editor-common/messages");
10
+ var _pin = _interopRequireDefault(require("@atlaskit/icon/core/pin"));
11
+ var _pinFilled = _interopRequireDefault(require("@atlaskit/icon/core/pin-filled"));
12
+ var getPinOptionToolbarConfig = exports.getPinOptionToolbarConfig = function getPinOptionToolbarConfig(_ref) {
13
+ var _api$connectivity;
14
+ var api = _ref.api,
15
+ toolbarDocking = _ref.toolbarDocking,
16
+ intl = _ref.intl;
17
+ var isOffline = (api === null || api === void 0 || (_api$connectivity = api.connectivity) === null || _api$connectivity === void 0 || (_api$connectivity = _api$connectivity.sharedState.currentState()) === null || _api$connectivity === void 0 ? void 0 : _api$connectivity.mode) === 'offline';
18
+ var pinButton = {
19
+ disabled: isOffline,
20
+ id: 'editor.toolbar.unpined',
21
+ icon: function icon() {
22
+ return /*#__PURE__*/_react.default.createElement(_pin.default, {
23
+ label: ""
24
+ });
25
+ },
26
+ onClick: function onClick() {
27
+ var _api$selectionToolbar, _api$selectionToolbar2, _api$selectionToolbar3;
28
+ return (_api$selectionToolbar = api === null || api === void 0 || (_api$selectionToolbar2 = api.selectionToolbar.actions) === null || _api$selectionToolbar2 === void 0 || (_api$selectionToolbar3 = _api$selectionToolbar2.setToolbarDocking) === null || _api$selectionToolbar3 === void 0 ? void 0 : _api$selectionToolbar3.call(_api$selectionToolbar2, 'top')) !== null && _api$selectionToolbar !== void 0 ? _api$selectionToolbar : false;
29
+ },
30
+ title: intl.formatMessage(_messages.selectionToolbarMessages.toolbarPositionUnpined),
31
+ type: 'button'
32
+ };
33
+ var isDockedToTop = toolbarDocking === 'top';
34
+ if (isDockedToTop) {
35
+ pinButton = {
36
+ disabled: isOffline,
37
+ id: 'editor.toolbar.pinedToTop',
38
+ icon: function icon() {
39
+ return /*#__PURE__*/_react.default.createElement(_pinFilled.default, {
40
+ label: ""
41
+ });
42
+ },
43
+ onClick: function onClick() {
44
+ var _api$selectionToolbar4, _api$selectionToolbar5, _api$selectionToolbar6;
45
+ return (_api$selectionToolbar4 = api === null || api === void 0 || (_api$selectionToolbar5 = api.selectionToolbar.actions) === null || _api$selectionToolbar5 === void 0 || (_api$selectionToolbar6 = _api$selectionToolbar5.setToolbarDocking) === null || _api$selectionToolbar6 === void 0 ? void 0 : _api$selectionToolbar6.call(_api$selectionToolbar5, 'none')) !== null && _api$selectionToolbar4 !== void 0 ? _api$selectionToolbar4 : false;
46
+ },
47
+ type: 'button',
48
+ title: intl.formatMessage(_messages.selectionToolbarMessages.toolbarPositionPinedAtTop)
49
+ };
50
+ }
51
+ return [{
52
+ type: 'separator',
53
+ fullHeight: true
54
+ }, pinButton];
55
+ };
@@ -10,7 +10,8 @@ import { setToolbarDocking, toggleToolbar, updateToolbarDocking, forceToolbarDoc
10
10
  import { selectionToolbarPluginKey } from './pm-plugins/plugin-key';
11
11
  import { getOverflowFloatingToolbarConfig } from './ui/overflow-toolbar-config';
12
12
  import { PageVisibilityWatcher } from './ui/PageVisibilityWatcher';
13
- import { PrimaryToolbarComponent } from './ui/PrimaryToolbarComponent';
13
+ import { getPinOptionToolbarConfig } from './ui/pin-toolbar-config';
14
+ import { PrimaryToolbarComponent, PrimaryToolbarComponentNew } from './ui/PrimaryToolbarComponent';
14
15
  const getToolbarDocking = (contextualFormattingEnabled, userPreferencesProvider) => {
15
16
  if (contextualFormattingEnabled && editorExperiment('platform_editor_controls', 'variant1')) {
16
17
  var _userPreferencesProvi;
@@ -31,21 +32,37 @@ export const selectionToolbarPlugin = ({
31
32
  if (editorExperiment('platform_editor_controls', 'variant1', {
32
33
  exposure: true
33
34
  })) {
34
- var _api$primaryToolbar;
35
- primaryToolbarComponent = ({
36
- popupsBoundariesElement,
37
- popupsMountPoint,
38
- popupsScrollableElement
39
- }) => /*#__PURE__*/React.createElement(PrimaryToolbarComponent, {
40
- api: api,
41
- popupsBoundariesElement: popupsBoundariesElement,
42
- popupsMountPoint: popupsMountPoint,
43
- popupsScrollableElement: popupsScrollableElement
44
- });
45
- api === null || api === void 0 ? void 0 : (_api$primaryToolbar = api.primaryToolbar) === null || _api$primaryToolbar === void 0 ? void 0 : _api$primaryToolbar.actions.registerComponent({
46
- name: 'overflowMenu',
47
- component: primaryToolbarComponent
48
- });
35
+ if (editorExperiment('platform_editor_controls_toolbar_pinning_exp', true)) {
36
+ var _api$primaryToolbar;
37
+ primaryToolbarComponent = ({
38
+ disabled
39
+ }) => {
40
+ return /*#__PURE__*/React.createElement(PrimaryToolbarComponentNew, {
41
+ api: api,
42
+ disabled: disabled
43
+ });
44
+ };
45
+ api === null || api === void 0 ? void 0 : (_api$primaryToolbar = api.primaryToolbar) === null || _api$primaryToolbar === void 0 ? void 0 : _api$primaryToolbar.actions.registerComponent({
46
+ name: 'pinToolbar',
47
+ component: primaryToolbarComponent
48
+ });
49
+ } else {
50
+ var _api$primaryToolbar2;
51
+ primaryToolbarComponent = ({
52
+ popupsBoundariesElement,
53
+ popupsMountPoint,
54
+ popupsScrollableElement
55
+ }) => /*#__PURE__*/React.createElement(PrimaryToolbarComponent, {
56
+ api: api,
57
+ popupsBoundariesElement: popupsBoundariesElement,
58
+ popupsMountPoint: popupsMountPoint,
59
+ popupsScrollableElement: popupsScrollableElement
60
+ });
61
+ api === null || api === void 0 ? void 0 : (_api$primaryToolbar2 = api.primaryToolbar) === null || _api$primaryToolbar2 === void 0 ? void 0 : _api$primaryToolbar2.actions.registerComponent({
62
+ name: 'overflowMenu',
63
+ component: primaryToolbarComponent
64
+ });
65
+ }
49
66
  }
50
67
  let previousToolbarDocking = (userPreferencesProvider === null || userPreferencesProvider === void 0 ? void 0 : userPreferencesProvider.getPreference('toolbarDockingInitialPosition')) || null;
51
68
  let isPreferenceInitialized = false;
@@ -293,11 +310,19 @@ export const selectionToolbarPlugin = ({
293
310
  }
294
311
  }
295
312
  if (items.length > 0 && contextualFormattingEnabled && isEditorControlsEnabled) {
296
- items.push(...getOverflowFloatingToolbarConfig({
297
- api,
298
- toolbarDocking,
299
- intl
300
- }));
313
+ if (editorExperiment('platform_editor_controls_toolbar_pinning_exp', true)) {
314
+ items.push(...getPinOptionToolbarConfig({
315
+ api,
316
+ toolbarDocking,
317
+ intl
318
+ }));
319
+ } else {
320
+ items.push(...getOverflowFloatingToolbarConfig({
321
+ api,
322
+ toolbarDocking,
323
+ intl
324
+ }));
325
+ }
301
326
  }
302
327
  let onPositionCalculated;
303
328
  const toolbarTitle = 'Selection toolbar';
@@ -6,13 +6,20 @@ import { useCallback, useEffect, useMemo, useState } from 'react';
6
6
  import { useIntl } from 'react-intl-next';
7
7
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
8
8
  import { addLink, getAriaKeyshortcuts } from '@atlaskit/editor-common/keymaps';
9
- import messages from '@atlaskit/editor-common/messages';
9
+ import messages, { selectionToolbarMessages } from '@atlaskit/editor-common/messages';
10
10
  import { ArrowKeyNavigationType, DropdownMenu, ToolbarButton } from '@atlaskit/editor-common/ui-menu';
11
+ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
12
+ import PinIcon from '@atlaskit/icon/core/pin';
13
+ import PinFilledIcon from '@atlaskit/icon/core/pin-filled';
11
14
  import ShowMoreHorizontalIcon from '@atlaskit/icon/core/show-more-horizontal';
12
15
  import { fg } from '@atlaskit/platform-feature-flags';
13
16
  import { getOverflowPrimaryToolbarConfig } from './overflow-toolbar-config';
14
17
  const DROPDOWN_WIDTH = 240;
15
18
  const buttonStyles = null;
19
+ /**
20
+ * A component used to renderer a dropdown with
21
+ * toolbar docking options.
22
+ */
16
23
  export function PrimaryToolbarComponent({
17
24
  api,
18
25
  popupsBoundariesElement,
@@ -74,4 +81,55 @@ export function PrimaryToolbarComponent({
74
81
  }, /*#__PURE__*/React.createElement(ShowMoreHorizontalIcon, {
75
82
  label: content
76
83
  })));
77
- }
84
+ }
85
+
86
+ /**
87
+ * A component used to renderer a pin/unpin
88
+ * button to the toolbar to the or make it in-line.
89
+ */
90
+ export const PrimaryToolbarComponentNew = ({
91
+ api,
92
+ disabled
93
+ }) => {
94
+ var _api$selectionToolbar;
95
+ const intl = useIntl();
96
+ const mode = useSharedPluginStateSelector(api, 'connectivity.mode');
97
+ const isOffline = mode === 'offline' || false;
98
+ const isDockedToTop = (api === null || api === void 0 ? void 0 : (_api$selectionToolbar = api.selectionToolbar.sharedState.currentState()) === null || _api$selectionToolbar === void 0 ? void 0 : _api$selectionToolbar.toolbarDocking) === 'top';
99
+ if (isDockedToTop) {
100
+ return /*#__PURE__*/React.createElement(ToolbarButton, {
101
+ "aria-label": intl.formatMessage(selectionToolbarMessages.toolbarPositionPinedAtTop)
102
+ // eslint-disable-next-line @atlaskit/design-system/no-unsafe-style-overrides -- Ignored via go/DSP-18766
103
+ ,
104
+
105
+ disabled: disabled || isOffline,
106
+ iconBefore: /*#__PURE__*/React.createElement(PinFilledIcon, {
107
+ label: "",
108
+ spacing: "spacious"
109
+ }),
110
+ onClick: () => {
111
+ var _api$selectionToolbar2, _api$selectionToolbar3, _api$selectionToolbar4;
112
+ return (_api$selectionToolbar2 = api === null || api === void 0 ? void 0 : (_api$selectionToolbar3 = api.selectionToolbar.actions) === null || _api$selectionToolbar3 === void 0 ? void 0 : (_api$selectionToolbar4 = _api$selectionToolbar3.setToolbarDocking) === null || _api$selectionToolbar4 === void 0 ? void 0 : _api$selectionToolbar4.call(_api$selectionToolbar3, 'none')) !== null && _api$selectionToolbar2 !== void 0 ? _api$selectionToolbar2 : false;
113
+ },
114
+ title: intl.formatMessage(selectionToolbarMessages.toolbarPositionPinedAtTop),
115
+ className: ax(["_ca0q12x7 _n3td12x7 _19bv12x7 _u5f312x7"])
116
+ });
117
+ }
118
+ return /*#__PURE__*/React.createElement(ToolbarButton, {
119
+ "aria-label": intl.formatMessage(selectionToolbarMessages.toolbarPositionUnpined)
120
+ // eslint-disable-next-line @atlaskit/design-system/no-unsafe-style-overrides -- Ignored via go/DSP-18766
121
+ ,
122
+
123
+ disabled: disabled || isOffline,
124
+ iconBefore: /*#__PURE__*/React.createElement(PinIcon, {
125
+ label: "",
126
+ spacing: "spacious"
127
+ }),
128
+ onClick: () => {
129
+ var _api$selectionToolbar5, _api$selectionToolbar6, _api$selectionToolbar7;
130
+ return (_api$selectionToolbar5 = api === null || api === void 0 ? void 0 : (_api$selectionToolbar6 = api.selectionToolbar.actions) === null || _api$selectionToolbar6 === void 0 ? void 0 : (_api$selectionToolbar7 = _api$selectionToolbar6.setToolbarDocking) === null || _api$selectionToolbar7 === void 0 ? void 0 : _api$selectionToolbar7.call(_api$selectionToolbar6, 'top')) !== null && _api$selectionToolbar5 !== void 0 ? _api$selectionToolbar5 : false;
131
+ },
132
+ title: intl.formatMessage(selectionToolbarMessages.toolbarPositionUnpined),
133
+ className: ax(["_ca0q12x7 _n3td12x7 _19bv12x7 _u5f312x7"])
134
+ });
135
+ };
@@ -86,8 +86,8 @@ export const getOverflowPrimaryToolbarConfig = ({
86
86
  name: 'fixed'
87
87
  },
88
88
  onClick: () => {
89
- var _api$selectionToolbar10, _api$selectionToolbar11, _api$selectionToolbar12;
90
- return (_api$selectionToolbar10 = api === null || api === void 0 ? void 0 : (_api$selectionToolbar11 = api.selectionToolbar.actions) === null || _api$selectionToolbar11 === void 0 ? void 0 : (_api$selectionToolbar12 = _api$selectionToolbar11.setToolbarDocking) === null || _api$selectionToolbar12 === void 0 ? void 0 : _api$selectionToolbar12.call(_api$selectionToolbar11, 'top')) !== null && _api$selectionToolbar10 !== void 0 ? _api$selectionToolbar10 : false;
89
+ var _api$selectionToolbar0, _api$selectionToolbar1, _api$selectionToolbar10;
90
+ return (_api$selectionToolbar0 = api === null || api === void 0 ? void 0 : (_api$selectionToolbar1 = api.selectionToolbar.actions) === null || _api$selectionToolbar1 === void 0 ? void 0 : (_api$selectionToolbar10 = _api$selectionToolbar1.setToolbarDocking) === null || _api$selectionToolbar10 === void 0 ? void 0 : _api$selectionToolbar10.call(_api$selectionToolbar1, 'top')) !== null && _api$selectionToolbar0 !== void 0 ? _api$selectionToolbar0 : false;
91
91
  },
92
92
  isActive: true,
93
93
  elemBefore: DockToolbarTopIcon({
@@ -0,0 +1,45 @@
1
+ import React from 'react';
2
+ import { selectionToolbarMessages } from '@atlaskit/editor-common/messages';
3
+ import PinIcon from '@atlaskit/icon/core/pin';
4
+ import PinFilledIcon from '@atlaskit/icon/core/pin-filled';
5
+ export const getPinOptionToolbarConfig = ({
6
+ api,
7
+ toolbarDocking,
8
+ intl
9
+ }) => {
10
+ var _api$connectivity, _api$connectivity$sha;
11
+ const isOffline = (api === null || api === void 0 ? void 0 : (_api$connectivity = api.connectivity) === null || _api$connectivity === void 0 ? void 0 : (_api$connectivity$sha = _api$connectivity.sharedState.currentState()) === null || _api$connectivity$sha === void 0 ? void 0 : _api$connectivity$sha.mode) === 'offline';
12
+ let pinButton = {
13
+ disabled: isOffline,
14
+ id: 'editor.toolbar.unpined',
15
+ icon: () => /*#__PURE__*/React.createElement(PinIcon, {
16
+ label: ""
17
+ }),
18
+ onClick: () => {
19
+ var _api$selectionToolbar, _api$selectionToolbar2, _api$selectionToolbar3;
20
+ 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, 'top')) !== null && _api$selectionToolbar !== void 0 ? _api$selectionToolbar : false;
21
+ },
22
+ title: intl.formatMessage(selectionToolbarMessages.toolbarPositionUnpined),
23
+ type: 'button'
24
+ };
25
+ const isDockedToTop = toolbarDocking === 'top';
26
+ if (isDockedToTop) {
27
+ pinButton = {
28
+ disabled: isOffline,
29
+ id: 'editor.toolbar.pinedToTop',
30
+ icon: () => /*#__PURE__*/React.createElement(PinFilledIcon, {
31
+ label: ""
32
+ }),
33
+ onClick: () => {
34
+ var _api$selectionToolbar4, _api$selectionToolbar5, _api$selectionToolbar6;
35
+ 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, 'none')) !== null && _api$selectionToolbar4 !== void 0 ? _api$selectionToolbar4 : false;
36
+ },
37
+ type: 'button',
38
+ title: intl.formatMessage(selectionToolbarMessages.toolbarPositionPinedAtTop)
39
+ };
40
+ }
41
+ return [{
42
+ type: 'separator',
43
+ fullHeight: true
44
+ }, pinButton];
45
+ };
@@ -14,7 +14,8 @@ import { setToolbarDocking as _setToolbarDocking, toggleToolbar, updateToolbarDo
14
14
  import { selectionToolbarPluginKey } from './pm-plugins/plugin-key';
15
15
  import { getOverflowFloatingToolbarConfig } from './ui/overflow-toolbar-config';
16
16
  import { PageVisibilityWatcher } from './ui/PageVisibilityWatcher';
17
- import { PrimaryToolbarComponent } from './ui/PrimaryToolbarComponent';
17
+ import { getPinOptionToolbarConfig } from './ui/pin-toolbar-config';
18
+ import { PrimaryToolbarComponent, PrimaryToolbarComponentNew } from './ui/PrimaryToolbarComponent';
18
19
  var getToolbarDocking = function getToolbarDocking(contextualFormattingEnabled, userPreferencesProvider) {
19
20
  if (contextualFormattingEnabled && editorExperiment('platform_editor_controls', 'variant1')) {
20
21
  var _userPreferencesProvi;
@@ -32,22 +33,37 @@ export var selectionToolbarPlugin = function selectionToolbarPlugin(_ref) {
32
33
  if (editorExperiment('platform_editor_controls', 'variant1', {
33
34
  exposure: true
34
35
  })) {
35
- var _api$primaryToolbar;
36
- primaryToolbarComponent = function primaryToolbarComponent(_ref2) {
37
- var popupsBoundariesElement = _ref2.popupsBoundariesElement,
38
- popupsMountPoint = _ref2.popupsMountPoint,
39
- popupsScrollableElement = _ref2.popupsScrollableElement;
40
- return /*#__PURE__*/React.createElement(PrimaryToolbarComponent, {
41
- api: api,
42
- popupsBoundariesElement: popupsBoundariesElement,
43
- popupsMountPoint: popupsMountPoint,
44
- popupsScrollableElement: popupsScrollableElement
36
+ if (editorExperiment('platform_editor_controls_toolbar_pinning_exp', true)) {
37
+ var _api$primaryToolbar;
38
+ primaryToolbarComponent = function primaryToolbarComponent(_ref2) {
39
+ var disabled = _ref2.disabled;
40
+ return /*#__PURE__*/React.createElement(PrimaryToolbarComponentNew, {
41
+ api: api,
42
+ disabled: disabled
43
+ });
44
+ };
45
+ api === null || api === void 0 || (_api$primaryToolbar = api.primaryToolbar) === null || _api$primaryToolbar === void 0 || _api$primaryToolbar.actions.registerComponent({
46
+ name: 'pinToolbar',
47
+ component: primaryToolbarComponent
48
+ });
49
+ } else {
50
+ var _api$primaryToolbar2;
51
+ primaryToolbarComponent = function primaryToolbarComponent(_ref3) {
52
+ var popupsBoundariesElement = _ref3.popupsBoundariesElement,
53
+ popupsMountPoint = _ref3.popupsMountPoint,
54
+ popupsScrollableElement = _ref3.popupsScrollableElement;
55
+ return /*#__PURE__*/React.createElement(PrimaryToolbarComponent, {
56
+ api: api,
57
+ popupsBoundariesElement: popupsBoundariesElement,
58
+ popupsMountPoint: popupsMountPoint,
59
+ popupsScrollableElement: popupsScrollableElement
60
+ });
61
+ };
62
+ api === null || api === void 0 || (_api$primaryToolbar2 = api.primaryToolbar) === null || _api$primaryToolbar2 === void 0 || _api$primaryToolbar2.actions.registerComponent({
63
+ name: 'overflowMenu',
64
+ component: primaryToolbarComponent
45
65
  });
46
- };
47
- api === null || api === void 0 || (_api$primaryToolbar = api.primaryToolbar) === null || _api$primaryToolbar === void 0 || _api$primaryToolbar.actions.registerComponent({
48
- name: 'overflowMenu',
49
- component: primaryToolbarComponent
50
- });
66
+ }
51
67
  }
52
68
  var previousToolbarDocking = (userPreferencesProvider === null || userPreferencesProvider === void 0 ? void 0 : userPreferencesProvider.getPreference('toolbarDockingInitialPosition')) || null;
53
69
  var isPreferenceInitialized = false;
@@ -213,10 +229,10 @@ export var selectionToolbarPlugin = function selectionToolbarPlugin(_ref) {
213
229
  },
214
230
  pluginsOptions: {
215
231
  floatingToolbar: function floatingToolbar(state, intl, providerFactory) {
216
- var _ref3 = selectionToolbarPluginKey.getState(state),
217
- selectionStable = _ref3.selectionStable,
218
- hide = _ref3.hide,
219
- toolbarDocking = _ref3.toolbarDocking;
232
+ var _ref4 = selectionToolbarPluginKey.getState(state),
233
+ selectionStable = _ref4.selectionStable,
234
+ hide = _ref4.hide,
235
+ toolbarDocking = _ref4.toolbarDocking;
220
236
  var isCellSelection = ('$anchorCell' in state.selection);
221
237
  var isEditorControlsEnabled = editorExperiment('platform_editor_controls', 'variant1');
222
238
  if (state.selection.empty || !selectionStable || hide || state.selection instanceof NodeSelection ||
@@ -248,11 +264,11 @@ export var selectionToolbarPlugin = function selectionToolbarPlugin(_ref) {
248
264
  // they add to the selection toolbar.
249
265
  // ie. if you want to have your plugin's group appear first, set rank to -10 if there is currently another
250
266
  // plugin you expect to be run at the same time as with an rank of -9
251
- resolved.sort(function (_ref4, _ref5) {
252
- var _ref4$rank = _ref4.rank,
253
- rankA = _ref4$rank === void 0 ? 0 : _ref4$rank;
267
+ resolved.sort(function (_ref5, _ref6) {
254
268
  var _ref5$rank = _ref5.rank,
255
- rankB = _ref5$rank === void 0 ? 0 : _ref5$rank;
269
+ rankA = _ref5$rank === void 0 ? 0 : _ref5$rank;
270
+ var _ref6$rank = _ref6.rank,
271
+ rankB = _ref6$rank === void 0 ? 0 : _ref6$rank;
256
272
  if (rankA < rankB) {
257
273
  return 1;
258
274
  }
@@ -294,11 +310,19 @@ export var selectionToolbarPlugin = function selectionToolbarPlugin(_ref) {
294
310
  }
295
311
  }
296
312
  if (items.length > 0 && contextualFormattingEnabled && isEditorControlsEnabled) {
297
- items.push.apply(items, _toConsumableArray(getOverflowFloatingToolbarConfig({
298
- api: api,
299
- toolbarDocking: toolbarDocking,
300
- intl: intl
301
- })));
313
+ if (editorExperiment('platform_editor_controls_toolbar_pinning_exp', true)) {
314
+ items.push.apply(items, _toConsumableArray(getPinOptionToolbarConfig({
315
+ api: api,
316
+ toolbarDocking: toolbarDocking,
317
+ intl: intl
318
+ })));
319
+ } else {
320
+ items.push.apply(items, _toConsumableArray(getOverflowFloatingToolbarConfig({
321
+ api: api,
322
+ toolbarDocking: toolbarDocking,
323
+ intl: intl
324
+ })));
325
+ }
302
326
  }
303
327
  var onPositionCalculated;
304
328
  var toolbarTitle = 'Selection toolbar';
@@ -7,13 +7,20 @@ import { useCallback, useEffect, useMemo, useState } from 'react';
7
7
  import { useIntl } from 'react-intl-next';
8
8
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
9
9
  import { addLink, getAriaKeyshortcuts } from '@atlaskit/editor-common/keymaps';
10
- import messages from '@atlaskit/editor-common/messages';
10
+ import messages, { selectionToolbarMessages } from '@atlaskit/editor-common/messages';
11
11
  import { ArrowKeyNavigationType, DropdownMenu, ToolbarButton } from '@atlaskit/editor-common/ui-menu';
12
+ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
13
+ import PinIcon from '@atlaskit/icon/core/pin';
14
+ import PinFilledIcon from '@atlaskit/icon/core/pin-filled';
12
15
  import ShowMoreHorizontalIcon from '@atlaskit/icon/core/show-more-horizontal';
13
16
  import { fg } from '@atlaskit/platform-feature-flags';
14
17
  import { getOverflowPrimaryToolbarConfig } from './overflow-toolbar-config';
15
18
  var DROPDOWN_WIDTH = 240;
16
19
  var buttonStyles = null;
20
+ /**
21
+ * A component used to renderer a dropdown with
22
+ * toolbar docking options.
23
+ */
17
24
  export function PrimaryToolbarComponent(_ref) {
18
25
  var api = _ref.api,
19
26
  popupsBoundariesElement = _ref.popupsBoundariesElement,
@@ -80,4 +87,54 @@ export function PrimaryToolbarComponent(_ref) {
80
87
  }, /*#__PURE__*/React.createElement(ShowMoreHorizontalIcon, {
81
88
  label: content
82
89
  })));
83
- }
90
+ }
91
+
92
+ /**
93
+ * A component used to renderer a pin/unpin
94
+ * button to the toolbar to the or make it in-line.
95
+ */
96
+ export var PrimaryToolbarComponentNew = function PrimaryToolbarComponentNew(_ref3) {
97
+ var _api$selectionToolbar;
98
+ var api = _ref3.api,
99
+ disabled = _ref3.disabled;
100
+ var intl = useIntl();
101
+ var mode = useSharedPluginStateSelector(api, 'connectivity.mode');
102
+ var isOffline = mode === 'offline' || false;
103
+ var isDockedToTop = (api === null || api === void 0 || (_api$selectionToolbar = api.selectionToolbar.sharedState.currentState()) === null || _api$selectionToolbar === void 0 ? void 0 : _api$selectionToolbar.toolbarDocking) === 'top';
104
+ if (isDockedToTop) {
105
+ return /*#__PURE__*/React.createElement(ToolbarButton, {
106
+ "aria-label": intl.formatMessage(selectionToolbarMessages.toolbarPositionPinedAtTop)
107
+ // eslint-disable-next-line @atlaskit/design-system/no-unsafe-style-overrides -- Ignored via go/DSP-18766
108
+ ,
109
+
110
+ disabled: disabled || isOffline,
111
+ iconBefore: /*#__PURE__*/React.createElement(PinFilledIcon, {
112
+ label: "",
113
+ spacing: "spacious"
114
+ }),
115
+ onClick: function onClick() {
116
+ var _api$selectionToolbar2, _api$selectionToolbar3, _api$selectionToolbar4;
117
+ return (_api$selectionToolbar2 = api === null || api === void 0 || (_api$selectionToolbar3 = api.selectionToolbar.actions) === null || _api$selectionToolbar3 === void 0 || (_api$selectionToolbar4 = _api$selectionToolbar3.setToolbarDocking) === null || _api$selectionToolbar4 === void 0 ? void 0 : _api$selectionToolbar4.call(_api$selectionToolbar3, 'none')) !== null && _api$selectionToolbar2 !== void 0 ? _api$selectionToolbar2 : false;
118
+ },
119
+ title: intl.formatMessage(selectionToolbarMessages.toolbarPositionPinedAtTop),
120
+ className: ax(["_ca0q12x7 _n3td12x7 _19bv12x7 _u5f312x7"])
121
+ });
122
+ }
123
+ return /*#__PURE__*/React.createElement(ToolbarButton, {
124
+ "aria-label": intl.formatMessage(selectionToolbarMessages.toolbarPositionUnpined)
125
+ // eslint-disable-next-line @atlaskit/design-system/no-unsafe-style-overrides -- Ignored via go/DSP-18766
126
+ ,
127
+
128
+ disabled: disabled || isOffline,
129
+ iconBefore: /*#__PURE__*/React.createElement(PinIcon, {
130
+ label: "",
131
+ spacing: "spacious"
132
+ }),
133
+ onClick: function onClick() {
134
+ var _api$selectionToolbar5, _api$selectionToolbar6, _api$selectionToolbar7;
135
+ return (_api$selectionToolbar5 = api === null || api === void 0 || (_api$selectionToolbar6 = api.selectionToolbar.actions) === null || _api$selectionToolbar6 === void 0 || (_api$selectionToolbar7 = _api$selectionToolbar6.setToolbarDocking) === null || _api$selectionToolbar7 === void 0 ? void 0 : _api$selectionToolbar7.call(_api$selectionToolbar6, 'top')) !== null && _api$selectionToolbar5 !== void 0 ? _api$selectionToolbar5 : false;
136
+ },
137
+ title: intl.formatMessage(selectionToolbarMessages.toolbarPositionUnpined),
138
+ className: ax(["_ca0q12x7 _n3td12x7 _19bv12x7 _u5f312x7"])
139
+ });
140
+ };
@@ -85,8 +85,8 @@ export var getOverflowPrimaryToolbarConfig = function getOverflowPrimaryToolbarC
85
85
  name: 'fixed'
86
86
  },
87
87
  onClick: function onClick() {
88
- var _api$selectionToolbar10, _api$selectionToolbar11, _api$selectionToolbar12;
89
- return (_api$selectionToolbar10 = api === null || api === void 0 || (_api$selectionToolbar11 = api.selectionToolbar.actions) === null || _api$selectionToolbar11 === void 0 || (_api$selectionToolbar12 = _api$selectionToolbar11.setToolbarDocking) === null || _api$selectionToolbar12 === void 0 ? void 0 : _api$selectionToolbar12.call(_api$selectionToolbar11, 'top')) !== null && _api$selectionToolbar10 !== void 0 ? _api$selectionToolbar10 : false;
88
+ var _api$selectionToolbar0, _api$selectionToolbar1, _api$selectionToolbar10;
89
+ return (_api$selectionToolbar0 = api === null || api === void 0 || (_api$selectionToolbar1 = api.selectionToolbar.actions) === null || _api$selectionToolbar1 === void 0 || (_api$selectionToolbar10 = _api$selectionToolbar1.setToolbarDocking) === null || _api$selectionToolbar10 === void 0 ? void 0 : _api$selectionToolbar10.call(_api$selectionToolbar1, 'top')) !== null && _api$selectionToolbar0 !== void 0 ? _api$selectionToolbar0 : false;
90
90
  },
91
91
  isActive: true,
92
92
  elemBefore: DockToolbarTopIcon({
@@ -0,0 +1,48 @@
1
+ import React from 'react';
2
+ import { selectionToolbarMessages } from '@atlaskit/editor-common/messages';
3
+ import PinIcon from '@atlaskit/icon/core/pin';
4
+ import PinFilledIcon from '@atlaskit/icon/core/pin-filled';
5
+ export var getPinOptionToolbarConfig = function getPinOptionToolbarConfig(_ref) {
6
+ var _api$connectivity;
7
+ var api = _ref.api,
8
+ toolbarDocking = _ref.toolbarDocking,
9
+ intl = _ref.intl;
10
+ var isOffline = (api === null || api === void 0 || (_api$connectivity = api.connectivity) === null || _api$connectivity === void 0 || (_api$connectivity = _api$connectivity.sharedState.currentState()) === null || _api$connectivity === void 0 ? void 0 : _api$connectivity.mode) === 'offline';
11
+ var pinButton = {
12
+ disabled: isOffline,
13
+ id: 'editor.toolbar.unpined',
14
+ icon: function icon() {
15
+ return /*#__PURE__*/React.createElement(PinIcon, {
16
+ label: ""
17
+ });
18
+ },
19
+ onClick: function onClick() {
20
+ var _api$selectionToolbar, _api$selectionToolbar2, _api$selectionToolbar3;
21
+ return (_api$selectionToolbar = api === null || api === void 0 || (_api$selectionToolbar2 = api.selectionToolbar.actions) === null || _api$selectionToolbar2 === void 0 || (_api$selectionToolbar3 = _api$selectionToolbar2.setToolbarDocking) === null || _api$selectionToolbar3 === void 0 ? void 0 : _api$selectionToolbar3.call(_api$selectionToolbar2, 'top')) !== null && _api$selectionToolbar !== void 0 ? _api$selectionToolbar : false;
22
+ },
23
+ title: intl.formatMessage(selectionToolbarMessages.toolbarPositionUnpined),
24
+ type: 'button'
25
+ };
26
+ var isDockedToTop = toolbarDocking === 'top';
27
+ if (isDockedToTop) {
28
+ pinButton = {
29
+ disabled: isOffline,
30
+ id: 'editor.toolbar.pinedToTop',
31
+ icon: function icon() {
32
+ return /*#__PURE__*/React.createElement(PinFilledIcon, {
33
+ label: ""
34
+ });
35
+ },
36
+ onClick: function onClick() {
37
+ var _api$selectionToolbar4, _api$selectionToolbar5, _api$selectionToolbar6;
38
+ return (_api$selectionToolbar4 = api === null || api === void 0 || (_api$selectionToolbar5 = api.selectionToolbar.actions) === null || _api$selectionToolbar5 === void 0 || (_api$selectionToolbar6 = _api$selectionToolbar5.setToolbarDocking) === null || _api$selectionToolbar6 === void 0 ? void 0 : _api$selectionToolbar6.call(_api$selectionToolbar5, 'none')) !== null && _api$selectionToolbar4 !== void 0 ? _api$selectionToolbar4 : false;
39
+ },
40
+ type: 'button',
41
+ title: intl.formatMessage(selectionToolbarMessages.toolbarPositionPinedAtTop)
42
+ };
43
+ }
44
+ return [{
45
+ type: 'separator',
46
+ fullHeight: true
47
+ }, pinButton];
48
+ };
@@ -1,6 +1,7 @@
1
1
  import type { NextEditorPlugin, OptionalPlugin, UserPreferencesProvider } from '@atlaskit/editor-common/types';
2
2
  import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
3
3
  import type { BlockControlsPlugin } from '@atlaskit/editor-plugin-block-controls';
4
+ import type { ConnectivityPlugin } from '@atlaskit/editor-plugin-connectivity';
4
5
  import type { EditorViewModePlugin } from '@atlaskit/editor-plugin-editor-viewmode';
5
6
  import type { PrimaryToolbarPlugin } from '@atlaskit/editor-plugin-primary-toolbar';
6
7
  import type { ToolbarDocking } from './types';
@@ -19,7 +20,8 @@ export type SelectionToolbarPlugin = NextEditorPlugin<'selectionToolbar', {
19
20
  OptionalPlugin<EditorViewModePlugin>,
20
21
  OptionalPlugin<PrimaryToolbarPlugin>,
21
22
  OptionalPlugin<AnalyticsPlugin>,
22
- OptionalPlugin<BlockControlsPlugin>
23
+ OptionalPlugin<BlockControlsPlugin>,
24
+ OptionalPlugin<ConnectivityPlugin>
23
25
  ];
24
26
  actions?: {
25
27
  suppressToolbar?: () => boolean;
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @jsxRuntime classic
3
+ * @jsx jsx
4
+ */
1
5
  /// <reference types="react" />
2
6
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
7
  import type { SelectionToolbarPlugin } from '../selectionToolbarPluginType';
@@ -7,5 +11,18 @@ type Props = {
7
11
  popupsMountPoint?: HTMLElement;
8
12
  popupsScrollableElement?: HTMLElement;
9
13
  };
14
+ type PrimaryToolbarComponentNewProps = {
15
+ api?: ExtractInjectionAPI<SelectionToolbarPlugin>;
16
+ disabled?: boolean;
17
+ };
18
+ /**
19
+ * A component used to renderer a dropdown with
20
+ * toolbar docking options.
21
+ */
10
22
  export declare function PrimaryToolbarComponent({ api, popupsBoundariesElement, popupsMountPoint, popupsScrollableElement, }: Props): JSX.Element;
23
+ /**
24
+ * A component used to renderer a pin/unpin
25
+ * button to the toolbar to the or make it in-line.
26
+ */
27
+ export declare const PrimaryToolbarComponentNew: ({ api, disabled }: PrimaryToolbarComponentNewProps) => JSX.Element;
11
28
  export {};
@@ -0,0 +1,11 @@
1
+ import { type IntlShape } from 'react-intl-next';
2
+ import { type ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
+ import type { Command, FloatingToolbarItem } from '@atlaskit/editor-common/types';
4
+ import type { SelectionToolbarPlugin } from '../selectionToolbarPluginType';
5
+ type PinToobarConfig = {
6
+ api?: ExtractInjectionAPI<SelectionToolbarPlugin>;
7
+ toolbarDocking?: 'top' | 'none';
8
+ intl: IntlShape;
9
+ };
10
+ export declare const getPinOptionToolbarConfig: ({ api, toolbarDocking, intl, }: PinToobarConfig) => FloatingToolbarItem<Command>[];
11
+ export {};
@@ -1,6 +1,7 @@
1
1
  import type { NextEditorPlugin, OptionalPlugin, UserPreferencesProvider } from '@atlaskit/editor-common/types';
2
2
  import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
3
3
  import type { BlockControlsPlugin } from '@atlaskit/editor-plugin-block-controls';
4
+ import type { ConnectivityPlugin } from '@atlaskit/editor-plugin-connectivity';
4
5
  import type { EditorViewModePlugin } from '@atlaskit/editor-plugin-editor-viewmode';
5
6
  import type { PrimaryToolbarPlugin } from '@atlaskit/editor-plugin-primary-toolbar';
6
7
  import type { ToolbarDocking } from './types';
@@ -19,7 +20,8 @@ export type SelectionToolbarPlugin = NextEditorPlugin<'selectionToolbar', {
19
20
  OptionalPlugin<EditorViewModePlugin>,
20
21
  OptionalPlugin<PrimaryToolbarPlugin>,
21
22
  OptionalPlugin<AnalyticsPlugin>,
22
- OptionalPlugin<BlockControlsPlugin>
23
+ OptionalPlugin<BlockControlsPlugin>,
24
+ OptionalPlugin<ConnectivityPlugin>
23
25
  ];
24
26
  actions?: {
25
27
  suppressToolbar?: () => boolean;
@@ -1,4 +1,8 @@
1
1
  /// <reference types="react" />
2
+ /**
3
+ * @jsxRuntime classic
4
+ * @jsx jsx
5
+ */
2
6
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
7
  import type { SelectionToolbarPlugin } from '../selectionToolbarPluginType';
4
8
  type Props = {
@@ -7,5 +11,18 @@ type Props = {
7
11
  popupsMountPoint?: HTMLElement;
8
12
  popupsScrollableElement?: HTMLElement;
9
13
  };
14
+ type PrimaryToolbarComponentNewProps = {
15
+ api?: ExtractInjectionAPI<SelectionToolbarPlugin>;
16
+ disabled?: boolean;
17
+ };
18
+ /**
19
+ * A component used to renderer a dropdown with
20
+ * toolbar docking options.
21
+ */
10
22
  export declare function PrimaryToolbarComponent({ api, popupsBoundariesElement, popupsMountPoint, popupsScrollableElement, }: Props): JSX.Element;
23
+ /**
24
+ * A component used to renderer a pin/unpin
25
+ * button to the toolbar to the or make it in-line.
26
+ */
27
+ export declare const PrimaryToolbarComponentNew: ({ api, disabled }: PrimaryToolbarComponentNewProps) => JSX.Element;
11
28
  export {};
@@ -0,0 +1,11 @@
1
+ import { type IntlShape } from 'react-intl-next';
2
+ import { type ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
+ import type { Command, FloatingToolbarItem } from '@atlaskit/editor-common/types';
4
+ import type { SelectionToolbarPlugin } from '../selectionToolbarPluginType';
5
+ type PinToobarConfig = {
6
+ api?: ExtractInjectionAPI<SelectionToolbarPlugin>;
7
+ toolbarDocking?: 'top' | 'none';
8
+ intl: IntlShape;
9
+ };
10
+ export declare const getPinOptionToolbarConfig: ({ api, toolbarDocking, intl, }: PinToobarConfig) => FloatingToolbarItem<Command>[];
11
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-selection-toolbar",
3
- "version": "3.6.9",
3
+ "version": "3.6.11",
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,9 +34,10 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "@atlaskit/css": "^0.10.0",
37
- "@atlaskit/editor-common": "^106.0.0",
37
+ "@atlaskit/editor-common": "^106.1.0",
38
38
  "@atlaskit/editor-plugin-analytics": "^2.3.0",
39
39
  "@atlaskit/editor-plugin-block-controls": "^3.15.0",
40
+ "@atlaskit/editor-plugin-connectivity": "^2.0.0",
40
41
  "@atlaskit/editor-plugin-editor-viewmode": "^4.0.0",
41
42
  "@atlaskit/editor-plugin-primary-toolbar": "^3.2.0",
42
43
  "@atlaskit/editor-prosemirror": "7.0.0",
@@ -44,7 +45,7 @@
44
45
  "@atlaskit/icon-lab": "^4.17.0",
45
46
  "@atlaskit/menu": "^8.0.0",
46
47
  "@atlaskit/platform-feature-flags": "^1.1.0",
47
- "@atlaskit/tmp-editor-statsig": "^5.4.0",
48
+ "@atlaskit/tmp-editor-statsig": "^5.7.0",
48
49
  "@atlaskit/tokens": "^4.9.0",
49
50
  "@babel/runtime": "^7.0.0",
50
51
  "bind-event-listener": "^3.0.0"