@atlaskit/editor-plugin-floating-toolbar 8.2.1 → 8.2.3

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-floating-toolbar
2
2
 
3
+ ## 8.2.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [`ff53e1bfc6c25`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/ff53e1bfc6c25) -
8
+ [ED-29482] clean up references to platform_editor_toolbar_rerender_optimization_exp
9
+ - [`663926469ec70`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/663926469ec70) -
10
+ Switch to use fg() to check feature gate platform_editor_update_modal_close_button
11
+ - Updated dependencies
12
+
13
+ ## 8.2.2
14
+
15
+ ### Patch Changes
16
+
17
+ - [`94b21013815ad`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/94b21013815ad) -
18
+ [ux] ensure confirmation is required when removing a table with an associated chart (fixes bug
19
+ when platform_editor_controls is set to variant1)
20
+ - Updated dependencies
21
+
3
22
  ## 8.2.1
4
23
 
5
24
  ### Patch Changes
@@ -228,7 +228,7 @@ var floatingToolbarPlugin = exports.floatingToolbarPlugin = function floatingToo
228
228
  * @returns JSX element representing the floating toolbar or null if not visible
229
229
  */
230
230
  function ContentComponent(_ref5) {
231
- var _configWithNodeInfo$c, _configWithNodeInfo$c2, _items, _pluginInjectionApi$c, _pluginInjectionApi$d;
231
+ var _configWithNodeInfo$c, _configWithNodeInfo$c2, _items, _pluginInjectionApi$c, _pluginInjectionApi$d, _confirmButtonItem, _confirmButtonItem2, _confirmButtonItem3;
232
232
  var pluginInjectionApi = _ref5.pluginInjectionApi,
233
233
  editorView = _ref5.editorView,
234
234
  popupsMountPoint = _ref5.popupsMountPoint,
@@ -389,14 +389,33 @@ function ContentComponent(_ref5) {
389
389
  };
390
390
 
391
391
  // Confirm dialog
392
- var _ref7 = floatingToolbarData || {},
393
- confirmDialogForItem = _ref7.confirmDialogForItem;
394
- var confirmButtonItem = confirmDialogForItem ?
395
- // Ignored via go/ees005
396
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
397
- toolbarItems[confirmDialogForItem] : undefined;
392
+ var confirmButtonItem;
393
+ if ((0, _platformFeatureFlags.fg)('platform_editor_fix_confirm_table_removal')) {
394
+ var _ref7 = floatingToolbarData || {},
395
+ confirmDialogForItem = _ref7.confirmDialogForItem,
396
+ confirmDialogForItemOption = _ref7.confirmDialogForItemOption;
397
+ var matchingItem = confirmDialogForItem ? toolbarItems === null || toolbarItems === void 0 ? void 0 : toolbarItems[confirmDialogForItem] : undefined;
398
+ if ((matchingItem === null || matchingItem === void 0 ? void 0 : matchingItem.type) === 'button') {
399
+ confirmButtonItem = matchingItem;
400
+ }
401
+ if ((matchingItem === null || matchingItem === void 0 ? void 0 : matchingItem.type) === 'overflow-dropdown' && confirmDialogForItemOption !== undefined) {
402
+ var matchingItemOption = matchingItem.options[confirmDialogForItemOption];
403
+
404
+ // OverflowDropdownOption is the only member of the union that does not have a 'type' property
405
+ if (!('type' in matchingItemOption)) {
406
+ confirmButtonItem = matchingItemOption;
407
+ }
408
+ }
409
+ } else {
410
+ var _ref8 = floatingToolbarData || {},
411
+ _confirmDialogForItem = _ref8.confirmDialogForItem;
412
+ confirmButtonItem = _confirmDialogForItem ?
413
+ // Ignored via go/ees005
414
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
415
+ toolbarItems[_confirmDialogForItem] : undefined;
416
+ }
398
417
  var scrollable = config.scrollable;
399
- var confirmDialogOptions = typeof (confirmButtonItem === null || confirmButtonItem === void 0 ? void 0 : confirmButtonItem.confirmDialog) === 'function' ? confirmButtonItem === null || confirmButtonItem === void 0 ? void 0 : confirmButtonItem.confirmDialog() : confirmButtonItem === null || confirmButtonItem === void 0 ? void 0 : confirmButtonItem.confirmDialog;
418
+ var confirmDialogOptions = typeof ((_confirmButtonItem = confirmButtonItem) === null || _confirmButtonItem === void 0 ? void 0 : _confirmButtonItem.confirmDialog) === 'function' ? (_confirmButtonItem2 = confirmButtonItem) === null || _confirmButtonItem2 === void 0 ? void 0 : _confirmButtonItem2.confirmDialog() : (_confirmButtonItem3 = confirmButtonItem) === null || _confirmButtonItem3 === void 0 ? void 0 : _confirmButtonItem3.confirmDialog;
400
419
  return /*#__PURE__*/_react.default.createElement(_errorBoundary.ErrorBoundary, {
401
420
  component: _analytics.ACTION_SUBJECT.FLOATING_TOOLBAR_PLUGIN,
402
421
  componentId: (0, _camelCase.default)(title),
@@ -5,11 +5,12 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.showConfirmDialog = exports.hideConfirmDialog = void 0;
7
7
  var _pluginFactory = require("./plugin-factory");
8
- var showConfirmDialog = exports.showConfirmDialog = function showConfirmDialog(buttonIndex) {
8
+ var showConfirmDialog = exports.showConfirmDialog = function showConfirmDialog(buttonIndex, optionIndex) {
9
9
  return (0, _pluginFactory.createCommand)({
10
10
  type: 'SHOW_CONFIRM_DIALOG',
11
11
  data: {
12
- buttonIndex: buttonIndex
12
+ buttonIndex: buttonIndex,
13
+ optionIndex: optionIndex
13
14
  }
14
15
  }, function (tr) {
15
16
  return tr.setMeta('addToHistory', false);
@@ -12,7 +12,8 @@ var reducer = exports.reducer = function reducer(pluginState, action) {
12
12
  switch (action.type) {
13
13
  case 'SHOW_CONFIRM_DIALOG':
14
14
  return _objectSpread(_objectSpread({}, pluginState), {}, {
15
- confirmDialogForItem: action.data.buttonIndex
15
+ confirmDialogForItem: action.data.buttonIndex,
16
+ confirmDialogForItemOption: action.data.optionIndex
16
17
  });
17
18
  case 'HIDE_CONFIRM_DIALOG':
18
19
  return _objectSpread(_objectSpread({}, pluginState), {}, {
@@ -13,8 +13,8 @@ var _new = _interopRequireDefault(require("@atlaskit/button/new"));
13
13
  var _checkbox = require("@atlaskit/checkbox");
14
14
  var _floatingToolbar = require("@atlaskit/editor-common/floating-toolbar");
15
15
  var _modalDialog = _interopRequireWildcard(require("@atlaskit/modal-dialog"));
16
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
16
17
  var _compiled = require("@atlaskit/primitives/compiled");
17
- var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
18
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); }
19
19
  var CheckboxModal = exports.CheckboxModal = function CheckboxModal(props) {
20
20
  var _options$getChildrenI;
@@ -63,7 +63,7 @@ var CheckboxModal = exports.CheckboxModal = function CheckboxModal(props) {
63
63
  onClose: onClose,
64
64
  testId: testId
65
65
  }, /*#__PURE__*/_react.default.createElement(_modalDialog.ModalHeader, {
66
- hasCloseButton: (0, _expValEquals.expValEquals)('platform_editor_update_modal_close_button', 'isEnabled', true)
66
+ hasCloseButton: (0, _platformFeatureFlags.fg)('platform_editor_update_modal_close_button')
67
67
  }, /*#__PURE__*/_react.default.createElement(_modalDialog.ModalTitle, {
68
68
  appearance: "warning"
69
69
  }, heading)), /*#__PURE__*/_react.default.createElement(_modalDialog.ModalBody, null, /*#__PURE__*/_react.default.createElement(_compiled.Text, {
@@ -10,8 +10,8 @@ var _react = _interopRequireDefault(require("react"));
10
10
  var _new = _interopRequireDefault(require("@atlaskit/button/new"));
11
11
  var _floatingToolbar = require("@atlaskit/editor-common/floating-toolbar");
12
12
  var _modalDialog = _interopRequireWildcard(require("@atlaskit/modal-dialog"));
13
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
13
14
  var _compiled = require("@atlaskit/primitives/compiled");
14
- var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
15
15
  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); }
16
16
  var SimpleModal = exports.SimpleModal = function SimpleModal(props) {
17
17
  var onConfirm = props.onConfirm,
@@ -26,7 +26,7 @@ var SimpleModal = exports.SimpleModal = function SimpleModal(props) {
26
26
  onClose: onClose,
27
27
  testId: testId
28
28
  }, /*#__PURE__*/_react.default.createElement(_modalDialog.ModalHeader, {
29
- hasCloseButton: (0, _expValEquals.expValEquals)('platform_editor_update_modal_close_button', 'isEnabled', true)
29
+ hasCloseButton: (0, _platformFeatureFlags.fg)('platform_editor_update_modal_close_button')
30
30
  }, /*#__PURE__*/_react.default.createElement(_modalDialog.ModalTitle, {
31
31
  appearance: "warning"
32
32
  }, heading)), /*#__PURE__*/_react.default.createElement(_modalDialog.ModalBody, null, /*#__PURE__*/_react.default.createElement(_compiled.Text, {
@@ -26,8 +26,8 @@ var _uiColor = require("@atlaskit/editor-common/ui-color");
26
26
  var _uiMenu = require("@atlaskit/editor-common/ui-menu");
27
27
  var _editorPalette = require("@atlaskit/editor-palette");
28
28
  var _showMoreHorizontal = _interopRequireDefault(require("@atlaskit/icon/core/show-more-horizontal"));
29
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
29
30
  var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
30
- var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
31
31
  var _forceFocus = require("../pm-plugins/force-focus");
32
32
  var _commands = require("../pm-plugins/toolbar-data/commands");
33
33
  var _Dropdown = _interopRequireDefault(require("./Dropdown"));
@@ -39,7 +39,9 @@ var _ScrollButtons = require("./ScrollButtons");
39
39
  var _Select = _interopRequireDefault(require("./Select"));
40
40
  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); }
41
41
  function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
42
- function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } /* eslint-disable @atlaskit/design-system/no-css-tagged-template-expression -- needs manual remediation */ /**
42
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
43
+ 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; }
44
+ 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; } /* eslint-disable @atlaskit/design-system/no-css-tagged-template-expression -- needs manual remediation */ /**
43
45
  * @jsxRuntime classic
44
46
  * @jsx jsx
45
47
  */ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
@@ -200,6 +202,25 @@ var ToolbarItems = /*#__PURE__*/_react.default.memo(function (_ref) {
200
202
  return item.render(editorView, idx, dispatchAnalyticsEvent);
201
203
  }
202
204
  case 'overflow-dropdown':
205
+ var options;
206
+ if ((0, _platformFeatureFlags.fg)('platform_editor_fix_confirm_table_removal')) {
207
+ // if an option has a confirmDialog, we need to replace its onClick handler
208
+ // to set the state to show the confirm dialog
209
+
210
+ // crudely done here to avoid greater coupling with DropdownMenuItem from `floating-toolbar`
211
+ // which would need knowledge of indexes, showConfirmDialog etc.
212
+ options = item.options.map(function (option, optionIndex) {
213
+ if (!('type' in option) && option.confirmDialog) {
214
+ var onClick = option.confirmDialog ? (0, _commands.showConfirmDialog)(idx, optionIndex) : option.onClick;
215
+ return _objectSpread(_objectSpread({}, option), {}, {
216
+ onClick: onClick
217
+ });
218
+ }
219
+ return option;
220
+ });
221
+ } else {
222
+ options = item.options;
223
+ }
203
224
  return (0, _react2.jsx)(_Dropdown.default, {
204
225
  alignX: areAnyNewToolbarFlagsEnabled ? 'right' : undefined,
205
226
  key: idx,
@@ -209,7 +230,7 @@ var ToolbarItems = /*#__PURE__*/_react.default.memo(function (_ref) {
209
230
  spacing: "spacious"
210
231
  }),
211
232
  dispatchCommand: dispatchCommand,
212
- options: item.options,
233
+ options: options,
213
234
  disabled: item.disabled,
214
235
  tooltip: item.tooltip,
215
236
  hideExpandIcon: true,
@@ -677,16 +698,12 @@ var Toolbar = /*#__PURE__*/function (_Component) {
677
698
  var hasSelect = items.find(function (item) {
678
699
  return item.type === 'select' && item.selectType === 'list';
679
700
  });
680
- var isShortcutToFocusToolbar = function isShortcutToFocusToolbar(event) {
681
- //Alt + F10 to reach first element in this floating toolbar
682
- return event.altKey && (event.key === 'F10' || event.keyCode === 121);
683
- };
684
701
  return (0, _react2.jsx)(_react.default.Fragment, null, (0, _react2.jsx)(_uiMenu.ToolbarArrowKeyNavigationProvider, {
685
702
  editorView: this.props.editorView,
686
703
  handleEscape: this.handleEscape,
687
704
  disableArrowKeyNavigation: !this.shouldHandleArrowKeys(),
688
705
  childComponentSelector: "[data-testid='editor-floating-toolbar']",
689
- isShortcutToFocusToolbar: (0, _experiments.editorExperiment)('platform_editor_toolbar_rerender_optimization_exp', true) ? this.isShortcutToFocusToolbar : isShortcutToFocusToolbar,
706
+ isShortcutToFocusToolbar: this.isShortcutToFocusToolbar,
690
707
  intl: intl
691
708
  }, (0, _react2.jsx)("div", {
692
709
  ref: this.toolbarContainerRef,
@@ -222,7 +222,7 @@ export function ContentComponent({
222
222
  providerFactory,
223
223
  dispatchAnalyticsEvent
224
224
  }) {
225
- var _configWithNodeInfo$c, _configWithNodeInfo$c2, _items, _pluginInjectionApi$c, _pluginInjectionApi$d;
225
+ var _configWithNodeInfo$c, _configWithNodeInfo$c2, _items, _pluginInjectionApi$c, _pluginInjectionApi$d, _confirmButtonItem, _confirmButtonItem2, _confirmButtonItem3;
226
226
  const {
227
227
  floatingToolbarState,
228
228
  editorDisabledState,
@@ -373,15 +373,35 @@ export function ContentComponent({
373
373
  const dispatchCommand = fn => fn && fn(editorView.state, editorView.dispatch, editorView);
374
374
 
375
375
  // Confirm dialog
376
- const {
377
- confirmDialogForItem
378
- } = floatingToolbarData || {};
379
- const confirmButtonItem = confirmDialogForItem ?
380
- // Ignored via go/ees005
381
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
382
- toolbarItems[confirmDialogForItem] : undefined;
376
+ let confirmButtonItem;
377
+ if (fg('platform_editor_fix_confirm_table_removal')) {
378
+ const {
379
+ confirmDialogForItem,
380
+ confirmDialogForItemOption
381
+ } = floatingToolbarData || {};
382
+ const matchingItem = confirmDialogForItem ? toolbarItems === null || toolbarItems === void 0 ? void 0 : toolbarItems[confirmDialogForItem] : undefined;
383
+ if ((matchingItem === null || matchingItem === void 0 ? void 0 : matchingItem.type) === 'button') {
384
+ confirmButtonItem = matchingItem;
385
+ }
386
+ if ((matchingItem === null || matchingItem === void 0 ? void 0 : matchingItem.type) === 'overflow-dropdown' && confirmDialogForItemOption !== undefined) {
387
+ const matchingItemOption = matchingItem.options[confirmDialogForItemOption];
388
+
389
+ // OverflowDropdownOption is the only member of the union that does not have a 'type' property
390
+ if (!('type' in matchingItemOption)) {
391
+ confirmButtonItem = matchingItemOption;
392
+ }
393
+ }
394
+ } else {
395
+ const {
396
+ confirmDialogForItem
397
+ } = floatingToolbarData || {};
398
+ confirmButtonItem = confirmDialogForItem ?
399
+ // Ignored via go/ees005
400
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
401
+ toolbarItems[confirmDialogForItem] : undefined;
402
+ }
383
403
  const scrollable = config.scrollable;
384
- const confirmDialogOptions = typeof (confirmButtonItem === null || confirmButtonItem === void 0 ? void 0 : confirmButtonItem.confirmDialog) === 'function' ? confirmButtonItem === null || confirmButtonItem === void 0 ? void 0 : confirmButtonItem.confirmDialog() : confirmButtonItem === null || confirmButtonItem === void 0 ? void 0 : confirmButtonItem.confirmDialog;
404
+ const confirmDialogOptions = typeof ((_confirmButtonItem = confirmButtonItem) === null || _confirmButtonItem === void 0 ? void 0 : _confirmButtonItem.confirmDialog) === 'function' ? (_confirmButtonItem2 = confirmButtonItem) === null || _confirmButtonItem2 === void 0 ? void 0 : _confirmButtonItem2.confirmDialog() : (_confirmButtonItem3 = confirmButtonItem) === null || _confirmButtonItem3 === void 0 ? void 0 : _confirmButtonItem3.confirmDialog;
385
405
  return /*#__PURE__*/React.createElement(ErrorBoundary, {
386
406
  component: ACTION_SUBJECT.FLOATING_TOOLBAR_PLUGIN,
387
407
  componentId: camelCase(title),
@@ -1,8 +1,9 @@
1
1
  import { createCommand } from './plugin-factory';
2
- export const showConfirmDialog = buttonIndex => createCommand({
2
+ export const showConfirmDialog = (buttonIndex, optionIndex) => createCommand({
3
3
  type: 'SHOW_CONFIRM_DIALOG',
4
4
  data: {
5
- buttonIndex
5
+ buttonIndex,
6
+ optionIndex
6
7
  }
7
8
  }, tr => tr.setMeta('addToHistory', false));
8
9
  export const hideConfirmDialog = () => createCommand({
@@ -3,7 +3,8 @@ export const reducer = (pluginState, action) => {
3
3
  case 'SHOW_CONFIRM_DIALOG':
4
4
  return {
5
5
  ...pluginState,
6
- confirmDialogForItem: action.data.buttonIndex
6
+ confirmDialogForItem: action.data.buttonIndex,
7
+ confirmDialogForItemOption: action.data.optionIndex
7
8
  };
8
9
  case 'HIDE_CONFIRM_DIALOG':
9
10
  return {
@@ -4,8 +4,8 @@ import Button from '@atlaskit/button/new';
4
4
  import { Checkbox } from '@atlaskit/checkbox';
5
5
  import { messages } from '@atlaskit/editor-common/floating-toolbar';
6
6
  import Modal, { ModalBody, ModalFooter, ModalHeader, ModalTitle } from '@atlaskit/modal-dialog';
7
+ import { fg } from '@atlaskit/platform-feature-flags';
7
8
  import { Text } from '@atlaskit/primitives/compiled';
8
- import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
9
9
  export const CheckboxModal = props => {
10
10
  var _options$getChildrenI;
11
11
  const [isChecked, setCheckbox] = useState(false);
@@ -54,7 +54,7 @@ export const CheckboxModal = props => {
54
54
  onClose: onClose,
55
55
  testId: testId
56
56
  }, /*#__PURE__*/React.createElement(ModalHeader, {
57
- hasCloseButton: expValEquals('platform_editor_update_modal_close_button', 'isEnabled', true)
57
+ hasCloseButton: fg('platform_editor_update_modal_close_button')
58
58
  }, /*#__PURE__*/React.createElement(ModalTitle, {
59
59
  appearance: "warning"
60
60
  }, heading)), /*#__PURE__*/React.createElement(ModalBody, null, /*#__PURE__*/React.createElement(Text, {
@@ -2,8 +2,8 @@ import React from 'react';
2
2
  import Button from '@atlaskit/button/new';
3
3
  import { messages } from '@atlaskit/editor-common/floating-toolbar';
4
4
  import Modal, { ModalBody, ModalFooter, ModalHeader, ModalTitle } from '@atlaskit/modal-dialog';
5
+ import { fg } from '@atlaskit/platform-feature-flags';
5
6
  import { Text } from '@atlaskit/primitives/compiled';
6
- import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
7
7
  export const SimpleModal = props => {
8
8
  const {
9
9
  onConfirm,
@@ -21,7 +21,7 @@ export const SimpleModal = props => {
21
21
  onClose: onClose,
22
22
  testId: testId
23
23
  }, /*#__PURE__*/React.createElement(ModalHeader, {
24
- hasCloseButton: expValEquals('platform_editor_update_modal_close_button', 'isEnabled', true)
24
+ hasCloseButton: fg('platform_editor_update_modal_close_button')
25
25
  }, /*#__PURE__*/React.createElement(ModalTitle, {
26
26
  appearance: "warning"
27
27
  }, heading)), /*#__PURE__*/React.createElement(ModalBody, null, /*#__PURE__*/React.createElement(Text, {
@@ -19,8 +19,8 @@ import { backgroundPaletteTooltipMessages } from '@atlaskit/editor-common/ui-col
19
19
  import { ColorPickerButton, ToolbarArrowKeyNavigationProvider } from '@atlaskit/editor-common/ui-menu';
20
20
  import { hexToEditorBackgroundPaletteColor } from '@atlaskit/editor-palette';
21
21
  import ShowMoreHorizontalIcon from '@atlaskit/icon/core/show-more-horizontal';
22
+ import { fg } from '@atlaskit/platform-feature-flags';
22
23
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
23
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
24
24
  import { checkShouldForceFocusAndApply, forceFocusSelector } from '../pm-plugins/force-focus';
25
25
  import { showConfirmDialog } from '../pm-plugins/toolbar-data/commands';
26
26
  import Dropdown from './Dropdown';
@@ -178,6 +178,26 @@ const ToolbarItems = /*#__PURE__*/React.memo(({
178
178
  return item.render(editorView, idx, dispatchAnalyticsEvent);
179
179
  }
180
180
  case 'overflow-dropdown':
181
+ let options;
182
+ if (fg('platform_editor_fix_confirm_table_removal')) {
183
+ // if an option has a confirmDialog, we need to replace its onClick handler
184
+ // to set the state to show the confirm dialog
185
+
186
+ // crudely done here to avoid greater coupling with DropdownMenuItem from `floating-toolbar`
187
+ // which would need knowledge of indexes, showConfirmDialog etc.
188
+ options = item.options.map((option, optionIndex) => {
189
+ if (!('type' in option) && option.confirmDialog) {
190
+ const onClick = option.confirmDialog ? showConfirmDialog(idx, optionIndex) : option.onClick;
191
+ return {
192
+ ...option,
193
+ onClick
194
+ };
195
+ }
196
+ return option;
197
+ });
198
+ } else {
199
+ options = item.options;
200
+ }
181
201
  return jsx(Dropdown, {
182
202
  alignX: areAnyNewToolbarFlagsEnabled ? 'right' : undefined,
183
203
  key: idx,
@@ -187,7 +207,7 @@ const ToolbarItems = /*#__PURE__*/React.memo(({
187
207
  spacing: "spacious"
188
208
  }),
189
209
  dispatchCommand: dispatchCommand,
190
- options: item.options,
210
+ options: options,
191
211
  disabled: item.disabled,
192
212
  tooltip: item.tooltip,
193
213
  hideExpandIcon: true,
@@ -629,16 +649,12 @@ class Toolbar extends Component {
629
649
  // Select has left padding of 4px to the border, everything else 8px
630
650
  const firstElementIsSelect = items[0].type === 'select';
631
651
  const hasSelect = items.find(item => item.type === 'select' && item.selectType === 'list');
632
- const isShortcutToFocusToolbar = event => {
633
- //Alt + F10 to reach first element in this floating toolbar
634
- return event.altKey && (event.key === 'F10' || event.keyCode === 121);
635
- };
636
652
  return jsx(React.Fragment, null, jsx(ToolbarArrowKeyNavigationProvider, {
637
653
  editorView: this.props.editorView,
638
654
  handleEscape: this.handleEscape,
639
655
  disableArrowKeyNavigation: !this.shouldHandleArrowKeys(),
640
656
  childComponentSelector: "[data-testid='editor-floating-toolbar']",
641
- isShortcutToFocusToolbar: editorExperiment('platform_editor_toolbar_rerender_optimization_exp', true) ? this.isShortcutToFocusToolbar : isShortcutToFocusToolbar,
657
+ isShortcutToFocusToolbar: this.isShortcutToFocusToolbar,
642
658
  intl: intl
643
659
  }, jsx("div", {
644
660
  ref: this.toolbarContainerRef,
@@ -219,7 +219,7 @@ export var floatingToolbarPlugin = function floatingToolbarPlugin(_ref) {
219
219
  * @returns JSX element representing the floating toolbar or null if not visible
220
220
  */
221
221
  export function ContentComponent(_ref5) {
222
- var _configWithNodeInfo$c, _configWithNodeInfo$c2, _items, _pluginInjectionApi$c, _pluginInjectionApi$d;
222
+ var _configWithNodeInfo$c, _configWithNodeInfo$c2, _items, _pluginInjectionApi$c, _pluginInjectionApi$d, _confirmButtonItem, _confirmButtonItem2, _confirmButtonItem3;
223
223
  var pluginInjectionApi = _ref5.pluginInjectionApi,
224
224
  editorView = _ref5.editorView,
225
225
  popupsMountPoint = _ref5.popupsMountPoint,
@@ -380,14 +380,33 @@ export function ContentComponent(_ref5) {
380
380
  };
381
381
 
382
382
  // Confirm dialog
383
- var _ref7 = floatingToolbarData || {},
384
- confirmDialogForItem = _ref7.confirmDialogForItem;
385
- var confirmButtonItem = confirmDialogForItem ?
386
- // Ignored via go/ees005
387
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
388
- toolbarItems[confirmDialogForItem] : undefined;
383
+ var confirmButtonItem;
384
+ if (fg('platform_editor_fix_confirm_table_removal')) {
385
+ var _ref7 = floatingToolbarData || {},
386
+ confirmDialogForItem = _ref7.confirmDialogForItem,
387
+ confirmDialogForItemOption = _ref7.confirmDialogForItemOption;
388
+ var matchingItem = confirmDialogForItem ? toolbarItems === null || toolbarItems === void 0 ? void 0 : toolbarItems[confirmDialogForItem] : undefined;
389
+ if ((matchingItem === null || matchingItem === void 0 ? void 0 : matchingItem.type) === 'button') {
390
+ confirmButtonItem = matchingItem;
391
+ }
392
+ if ((matchingItem === null || matchingItem === void 0 ? void 0 : matchingItem.type) === 'overflow-dropdown' && confirmDialogForItemOption !== undefined) {
393
+ var matchingItemOption = matchingItem.options[confirmDialogForItemOption];
394
+
395
+ // OverflowDropdownOption is the only member of the union that does not have a 'type' property
396
+ if (!('type' in matchingItemOption)) {
397
+ confirmButtonItem = matchingItemOption;
398
+ }
399
+ }
400
+ } else {
401
+ var _ref8 = floatingToolbarData || {},
402
+ _confirmDialogForItem = _ref8.confirmDialogForItem;
403
+ confirmButtonItem = _confirmDialogForItem ?
404
+ // Ignored via go/ees005
405
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
406
+ toolbarItems[_confirmDialogForItem] : undefined;
407
+ }
389
408
  var scrollable = config.scrollable;
390
- var confirmDialogOptions = typeof (confirmButtonItem === null || confirmButtonItem === void 0 ? void 0 : confirmButtonItem.confirmDialog) === 'function' ? confirmButtonItem === null || confirmButtonItem === void 0 ? void 0 : confirmButtonItem.confirmDialog() : confirmButtonItem === null || confirmButtonItem === void 0 ? void 0 : confirmButtonItem.confirmDialog;
409
+ var confirmDialogOptions = typeof ((_confirmButtonItem = confirmButtonItem) === null || _confirmButtonItem === void 0 ? void 0 : _confirmButtonItem.confirmDialog) === 'function' ? (_confirmButtonItem2 = confirmButtonItem) === null || _confirmButtonItem2 === void 0 ? void 0 : _confirmButtonItem2.confirmDialog() : (_confirmButtonItem3 = confirmButtonItem) === null || _confirmButtonItem3 === void 0 ? void 0 : _confirmButtonItem3.confirmDialog;
391
410
  return /*#__PURE__*/React.createElement(ErrorBoundary, {
392
411
  component: ACTION_SUBJECT.FLOATING_TOOLBAR_PLUGIN,
393
412
  componentId: camelCase(title),
@@ -1,9 +1,10 @@
1
1
  import { createCommand } from './plugin-factory';
2
- export var showConfirmDialog = function showConfirmDialog(buttonIndex) {
2
+ export var showConfirmDialog = function showConfirmDialog(buttonIndex, optionIndex) {
3
3
  return createCommand({
4
4
  type: 'SHOW_CONFIRM_DIALOG',
5
5
  data: {
6
- buttonIndex: buttonIndex
6
+ buttonIndex: buttonIndex,
7
+ optionIndex: optionIndex
7
8
  }
8
9
  }, function (tr) {
9
10
  return tr.setMeta('addToHistory', false);
@@ -5,7 +5,8 @@ export var reducer = function reducer(pluginState, action) {
5
5
  switch (action.type) {
6
6
  case 'SHOW_CONFIRM_DIALOG':
7
7
  return _objectSpread(_objectSpread({}, pluginState), {}, {
8
- confirmDialogForItem: action.data.buttonIndex
8
+ confirmDialogForItem: action.data.buttonIndex,
9
+ confirmDialogForItemOption: action.data.optionIndex
9
10
  });
10
11
  case 'HIDE_CONFIRM_DIALOG':
11
12
  return _objectSpread(_objectSpread({}, pluginState), {}, {
@@ -5,8 +5,8 @@ import Button from '@atlaskit/button/new';
5
5
  import { Checkbox } from '@atlaskit/checkbox';
6
6
  import { messages } from '@atlaskit/editor-common/floating-toolbar';
7
7
  import Modal, { ModalBody, ModalFooter, ModalHeader, ModalTitle } from '@atlaskit/modal-dialog';
8
+ import { fg } from '@atlaskit/platform-feature-flags';
8
9
  import { Text } from '@atlaskit/primitives/compiled';
9
- import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
10
10
  export var CheckboxModal = function CheckboxModal(props) {
11
11
  var _options$getChildrenI;
12
12
  var _useState = useState(false),
@@ -54,7 +54,7 @@ export var CheckboxModal = function CheckboxModal(props) {
54
54
  onClose: onClose,
55
55
  testId: testId
56
56
  }, /*#__PURE__*/React.createElement(ModalHeader, {
57
- hasCloseButton: expValEquals('platform_editor_update_modal_close_button', 'isEnabled', true)
57
+ hasCloseButton: fg('platform_editor_update_modal_close_button')
58
58
  }, /*#__PURE__*/React.createElement(ModalTitle, {
59
59
  appearance: "warning"
60
60
  }, heading)), /*#__PURE__*/React.createElement(ModalBody, null, /*#__PURE__*/React.createElement(Text, {
@@ -2,8 +2,8 @@ import React from 'react';
2
2
  import Button from '@atlaskit/button/new';
3
3
  import { messages } from '@atlaskit/editor-common/floating-toolbar';
4
4
  import Modal, { ModalBody, ModalFooter, ModalHeader, ModalTitle } from '@atlaskit/modal-dialog';
5
+ import { fg } from '@atlaskit/platform-feature-flags';
5
6
  import { Text } from '@atlaskit/primitives/compiled';
6
- import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
7
7
  export var SimpleModal = function SimpleModal(props) {
8
8
  var onConfirm = props.onConfirm,
9
9
  onClose = props.onClose,
@@ -17,7 +17,7 @@ export var SimpleModal = function SimpleModal(props) {
17
17
  onClose: onClose,
18
18
  testId: testId
19
19
  }, /*#__PURE__*/React.createElement(ModalHeader, {
20
- hasCloseButton: expValEquals('platform_editor_update_modal_close_button', 'isEnabled', true)
20
+ hasCloseButton: fg('platform_editor_update_modal_close_button')
21
21
  }, /*#__PURE__*/React.createElement(ModalTitle, {
22
22
  appearance: "warning"
23
23
  }, heading)), /*#__PURE__*/React.createElement(ModalBody, null, /*#__PURE__*/React.createElement(Text, {
@@ -7,6 +7,8 @@ import _inherits from "@babel/runtime/helpers/inherits";
7
7
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
8
8
  function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
9
9
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
10
+ 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; }
11
+ 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) { _defineProperty(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; }
10
12
  /* eslint-disable @atlaskit/design-system/no-css-tagged-template-expression -- needs manual remediation */
11
13
  /**
12
14
  * @jsxRuntime classic
@@ -26,8 +28,8 @@ import { backgroundPaletteTooltipMessages } from '@atlaskit/editor-common/ui-col
26
28
  import { ColorPickerButton, ToolbarArrowKeyNavigationProvider } from '@atlaskit/editor-common/ui-menu';
27
29
  import { hexToEditorBackgroundPaletteColor } from '@atlaskit/editor-palette';
28
30
  import ShowMoreHorizontalIcon from '@atlaskit/icon/core/show-more-horizontal';
31
+ import { fg } from '@atlaskit/platform-feature-flags';
29
32
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
30
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
31
33
  import { checkShouldForceFocusAndApply, forceFocusSelector } from '../pm-plugins/force-focus';
32
34
  import { showConfirmDialog } from '../pm-plugins/toolbar-data/commands';
33
35
  import Dropdown from './Dropdown';
@@ -194,6 +196,25 @@ var ToolbarItems = /*#__PURE__*/React.memo(function (_ref) {
194
196
  return item.render(editorView, idx, dispatchAnalyticsEvent);
195
197
  }
196
198
  case 'overflow-dropdown':
199
+ var options;
200
+ if (fg('platform_editor_fix_confirm_table_removal')) {
201
+ // if an option has a confirmDialog, we need to replace its onClick handler
202
+ // to set the state to show the confirm dialog
203
+
204
+ // crudely done here to avoid greater coupling with DropdownMenuItem from `floating-toolbar`
205
+ // which would need knowledge of indexes, showConfirmDialog etc.
206
+ options = item.options.map(function (option, optionIndex) {
207
+ if (!('type' in option) && option.confirmDialog) {
208
+ var onClick = option.confirmDialog ? showConfirmDialog(idx, optionIndex) : option.onClick;
209
+ return _objectSpread(_objectSpread({}, option), {}, {
210
+ onClick: onClick
211
+ });
212
+ }
213
+ return option;
214
+ });
215
+ } else {
216
+ options = item.options;
217
+ }
197
218
  return jsx(Dropdown, {
198
219
  alignX: areAnyNewToolbarFlagsEnabled ? 'right' : undefined,
199
220
  key: idx,
@@ -203,7 +224,7 @@ var ToolbarItems = /*#__PURE__*/React.memo(function (_ref) {
203
224
  spacing: "spacious"
204
225
  }),
205
226
  dispatchCommand: dispatchCommand,
206
- options: item.options,
227
+ options: options,
207
228
  disabled: item.disabled,
208
229
  tooltip: item.tooltip,
209
230
  hideExpandIcon: true,
@@ -671,16 +692,12 @@ var Toolbar = /*#__PURE__*/function (_Component) {
671
692
  var hasSelect = items.find(function (item) {
672
693
  return item.type === 'select' && item.selectType === 'list';
673
694
  });
674
- var isShortcutToFocusToolbar = function isShortcutToFocusToolbar(event) {
675
- //Alt + F10 to reach first element in this floating toolbar
676
- return event.altKey && (event.key === 'F10' || event.keyCode === 121);
677
- };
678
695
  return jsx(React.Fragment, null, jsx(ToolbarArrowKeyNavigationProvider, {
679
696
  editorView: this.props.editorView,
680
697
  handleEscape: this.handleEscape,
681
698
  disableArrowKeyNavigation: !this.shouldHandleArrowKeys(),
682
699
  childComponentSelector: "[data-testid='editor-floating-toolbar']",
683
- isShortcutToFocusToolbar: editorExperiment('platform_editor_toolbar_rerender_optimization_exp', true) ? this.isShortcutToFocusToolbar : isShortcutToFocusToolbar,
700
+ isShortcutToFocusToolbar: this.isShortcutToFocusToolbar,
684
701
  intl: intl
685
702
  }, jsx("div", {
686
703
  ref: this.toolbarContainerRef,
@@ -24,6 +24,7 @@ export type FloatingToolbarPluginState = {
24
24
  };
25
25
  export type FloatingToolbarPluginData = {
26
26
  confirmDialogForItem?: number;
27
+ confirmDialogForItemOption?: number;
27
28
  };
28
29
  export type ForceFocusSelector = (selector: string | null) => (tr: Transaction) => Transaction;
29
30
  /**
@@ -1,3 +1,3 @@
1
1
  import type { Command } from '@atlaskit/editor-common/types';
2
- export declare const showConfirmDialog: (buttonIndex: number) => Command;
2
+ export declare const showConfirmDialog: (buttonIndex: number, optionIndex?: number) => Command;
3
3
  export declare const hideConfirmDialog: () => Command;
@@ -1,6 +1,7 @@
1
1
  export type FloatingToolbarPluginAction = {
2
2
  data: {
3
3
  buttonIndex: number;
4
+ optionIndex?: number;
4
5
  };
5
6
  type: 'SHOW_CONFIRM_DIALOG';
6
7
  } | {
@@ -24,6 +24,7 @@ export type FloatingToolbarPluginState = {
24
24
  };
25
25
  export type FloatingToolbarPluginData = {
26
26
  confirmDialogForItem?: number;
27
+ confirmDialogForItemOption?: number;
27
28
  };
28
29
  export type ForceFocusSelector = (selector: string | null) => (tr: Transaction) => Transaction;
29
30
  /**
@@ -1,3 +1,3 @@
1
1
  import type { Command } from '@atlaskit/editor-common/types';
2
- export declare const showConfirmDialog: (buttonIndex: number) => Command;
2
+ export declare const showConfirmDialog: (buttonIndex: number, optionIndex?: number) => Command;
3
3
  export declare const hideConfirmDialog: () => Command;
@@ -1,6 +1,7 @@
1
1
  export type FloatingToolbarPluginAction = {
2
2
  data: {
3
3
  buttonIndex: number;
4
+ optionIndex?: number;
4
5
  };
5
6
  type: 'SHOW_CONFIRM_DIALOG';
6
7
  } | {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-floating-toolbar",
3
- "version": "8.2.1",
3
+ "version": "8.2.3",
4
4
  "description": "Floating toolbar plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -38,14 +38,14 @@
38
38
  "@atlaskit/editor-plugin-user-intent": "^4.0.0",
39
39
  "@atlaskit/editor-prosemirror": "7.0.0",
40
40
  "@atlaskit/emoji": "^69.5.0",
41
- "@atlaskit/icon": "^28.3.0",
41
+ "@atlaskit/icon": "^28.5.0",
42
42
  "@atlaskit/menu": "^8.4.0",
43
43
  "@atlaskit/modal-dialog": "^14.4.0",
44
44
  "@atlaskit/platform-feature-flags": "^1.1.0",
45
45
  "@atlaskit/primitives": "^14.15.0",
46
46
  "@atlaskit/select": "^21.3.0",
47
47
  "@atlaskit/theme": "^21.0.0",
48
- "@atlaskit/tmp-editor-statsig": "^13.1.0",
48
+ "@atlaskit/tmp-editor-statsig": "^13.5.0",
49
49
  "@atlaskit/tokens": "^6.4.0",
50
50
  "@atlaskit/tooltip": "^20.5.0",
51
51
  "@babel/runtime": "^7.0.0",
@@ -57,7 +57,7 @@
57
57
  "react-loadable": "^5.1.0"
58
58
  },
59
59
  "peerDependencies": {
60
- "@atlaskit/editor-common": "^110.4.0",
60
+ "@atlaskit/editor-common": "^110.7.0",
61
61
  "react": "^18.2.0",
62
62
  "react-dom": "^18.2.0"
63
63
  },
@@ -121,6 +121,12 @@
121
121
  },
122
122
  "platform_editor_block_menu_hide_floating_toolbar": {
123
123
  "type": "boolean"
124
+ },
125
+ "platform_editor_fix_confirm_table_removal": {
126
+ "type": "boolean"
127
+ },
128
+ "platform_editor_update_modal_close_button": {
129
+ "type": "boolean"
124
130
  }
125
131
  }
126
132
  }