@atlaskit/editor-plugin-floating-toolbar 9.1.14 → 9.1.16

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,20 @@
1
1
  # @atlaskit/editor-plugin-floating-toolbar
2
2
 
3
+ ## 9.1.16
4
+
5
+ ### Patch Changes
6
+
7
+ - [`7ef3027df8198`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/7ef3027df8198) -
8
+ remove platform_editor_lovability_user_intent experiment
9
+ - Updated dependencies
10
+
11
+ ## 9.1.15
12
+
13
+ ### Patch Changes
14
+
15
+ - [`34c3a60cb9325`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/34c3a60cb9325) -
16
+ Cleanup FG platform_editor_fix_confirm_table_removal
17
+
3
18
  ## 9.1.14
4
19
 
5
20
  ### Patch Changes
@@ -25,8 +25,6 @@ var _state = require("@atlaskit/editor-prosemirror/state");
25
25
  var _utils = require("@atlaskit/editor-prosemirror/utils");
26
26
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
27
27
  var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
28
- var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
29
- var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
30
28
  var _commands = require("./pm-plugins/commands");
31
29
  var _forceFocus = _interopRequireWildcard(require("./pm-plugins/force-focus"));
32
30
  var _commands2 = require("./pm-plugins/toolbar-data/commands");
@@ -240,14 +238,11 @@ function ContentComponent(_ref5) {
240
238
  popupsScrollableElement = _ref5.popupsScrollableElement,
241
239
  providerFactory = _ref5.providerFactory,
242
240
  dispatchAnalyticsEvent = _ref5.dispatchAnalyticsEvent;
243
- var _useSharedPluginState = (0, _hooks.useSharedPluginState)(pluginInjectionApi, ['floatingToolbar', 'editorDisabled', 'editorViewMode', 'userIntent',
244
- // @ts-expect-error - excluded from FloatingToolbarPlugin dependencies to avoid circular dependency
245
- 'blockControls']),
241
+ var _useSharedPluginState = (0, _hooks.useSharedPluginState)(pluginInjectionApi, ['floatingToolbar', 'editorDisabled', 'editorViewMode', 'userIntent']),
246
242
  floatingToolbarState = _useSharedPluginState.floatingToolbarState,
247
243
  editorDisabledState = _useSharedPluginState.editorDisabledState,
248
244
  editorViewModeState = _useSharedPluginState.editorViewModeState,
249
- userIntentState = _useSharedPluginState.userIntentState,
250
- blockControlsState = _useSharedPluginState.blockControlsState;
245
+ userIntentState = _useSharedPluginState.userIntentState;
251
246
  var _ref6 = floatingToolbarState !== null && floatingToolbarState !== void 0 ? floatingToolbarState : {},
252
247
  configWithNodeInfo = _ref6.configWithNodeInfo,
253
248
  floatingToolbarData = _ref6.floatingToolbarData;
@@ -257,11 +252,7 @@ function ContentComponent(_ref5) {
257
252
  if (!configWithNodeInfo || !configWithNodeInfo.config || typeof ((_configWithNodeInfo$c = configWithNodeInfo.config) === null || _configWithNodeInfo$c === void 0 ? void 0 : _configWithNodeInfo$c.visible) !== 'undefined' && !((_configWithNodeInfo$c2 = configWithNodeInfo.config) !== null && _configWithNodeInfo$c2 !== void 0 && _configWithNodeInfo$c2.visible)) {
258
253
  return null;
259
254
  }
260
- var userIntentEnabled = Boolean((pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.userIntent) && (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_lovability_user_intent', 'isEnabled', true));
261
- if (((userIntentState === null || userIntentState === void 0 ? void 0 : userIntentState.currentUserIntent) === 'dragging' || (userIntentState === null || userIntentState === void 0 ? void 0 : userIntentState.currentUserIntent) === 'blockMenuOpen' && (0, _expValEquals.expValEquals)('platform_editor_block_menu', 'isEnabled', true)) && !userIntentEnabled) {
262
- return null;
263
- }
264
- if (userIntentState !== null && userIntentState !== void 0 && userIntentState.currentUserIntent && SUPPRESS_TOOLBAR_USER_INTENTS.includes(userIntentState === null || userIntentState === void 0 ? void 0 : userIntentState.currentUserIntent) && userIntentEnabled) {
255
+ if (userIntentState !== null && userIntentState !== void 0 && userIntentState.currentUserIntent && SUPPRESS_TOOLBAR_USER_INTENTS.includes(userIntentState === null || userIntentState === void 0 ? void 0 : userIntentState.currentUserIntent)) {
265
256
  return null;
266
257
  }
267
258
  var config = configWithNodeInfo.config,
@@ -394,29 +385,20 @@ function ContentComponent(_ref5) {
394
385
 
395
386
  // Confirm dialog
396
387
  var confirmButtonItem;
397
- if ((0, _platformFeatureFlags.fg)('platform_editor_fix_confirm_table_removal')) {
398
- var _ref7 = floatingToolbarData || {},
399
- confirmDialogForItem = _ref7.confirmDialogForItem,
400
- confirmDialogForItemOption = _ref7.confirmDialogForItemOption;
401
- var matchingItem = confirmDialogForItem ? toolbarItems === null || toolbarItems === void 0 ? void 0 : toolbarItems[confirmDialogForItem] : undefined;
402
- if ((matchingItem === null || matchingItem === void 0 ? void 0 : matchingItem.type) === 'button') {
403
- confirmButtonItem = matchingItem;
404
- }
405
- if ((matchingItem === null || matchingItem === void 0 ? void 0 : matchingItem.type) === 'overflow-dropdown' && confirmDialogForItemOption !== undefined) {
406
- var matchingItemOption = matchingItem.options[confirmDialogForItemOption];
388
+ var _ref7 = floatingToolbarData || {},
389
+ confirmDialogForItem = _ref7.confirmDialogForItem,
390
+ confirmDialogForItemOption = _ref7.confirmDialogForItemOption;
391
+ var matchingItem = confirmDialogForItem ? toolbarItems === null || toolbarItems === void 0 ? void 0 : toolbarItems[confirmDialogForItem] : undefined;
392
+ if ((matchingItem === null || matchingItem === void 0 ? void 0 : matchingItem.type) === 'button') {
393
+ confirmButtonItem = matchingItem;
394
+ }
395
+ if ((matchingItem === null || matchingItem === void 0 ? void 0 : matchingItem.type) === 'overflow-dropdown' && confirmDialogForItemOption !== undefined) {
396
+ var matchingItemOption = matchingItem.options[confirmDialogForItemOption];
407
397
 
408
- // OverflowDropdownOption is the only member of the union that does not have a 'type' property
409
- if (!('type' in matchingItemOption)) {
410
- confirmButtonItem = matchingItemOption;
411
- }
398
+ // OverflowDropdownOption is the only member of the union that does not have a 'type' property
399
+ if (!('type' in matchingItemOption)) {
400
+ confirmButtonItem = matchingItemOption;
412
401
  }
413
- } else {
414
- var _ref8 = floatingToolbarData || {},
415
- _confirmDialogForItem = _ref8.confirmDialogForItem;
416
- confirmButtonItem = _confirmDialogForItem ?
417
- // Ignored via go/ees005
418
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
419
- toolbarItems[_confirmDialogForItem] : undefined;
420
402
  }
421
403
  var scrollable = config.scrollable;
422
404
  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;
@@ -558,12 +540,7 @@ function floatingToolbarPluginFactory(options) {
558
540
  var config = handler(editorState, intl, providerFactory, activeConfigs);
559
541
  if (config) {
560
542
  var _api$userIntent;
561
- var userIntentEnabled = Boolean((api === null || api === void 0 ? void 0 : api.userIntent) && (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_lovability_user_intent', 'isEnabled', true));
562
- if (config.__suppressAllToolbars && (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && !userIntentEnabled) {
563
- activeConfigs = undefined;
564
- break;
565
- }
566
- if (userIntentEnabled && SUPPRESS_TOOLBAR_USER_INTENTS.includes((api === null || api === void 0 || (_api$userIntent = api.userIntent) === null || _api$userIntent === void 0 || (_api$userIntent = _api$userIntent.sharedState.currentState()) === null || _api$userIntent === void 0 ? void 0 : _api$userIntent.currentUserIntent) || '')) {
543
+ if (SUPPRESS_TOOLBAR_USER_INTENTS.includes((api === null || api === void 0 || (_api$userIntent = api.userIntent) === null || _api$userIntent === void 0 || (_api$userIntent = _api$userIntent.sharedState.currentState()) === null || _api$userIntent === void 0 ? void 0 : _api$userIntent.currentUserIntent) || '')) {
567
544
  activeConfigs = undefined;
568
545
  break;
569
546
  }
@@ -573,18 +550,7 @@ function floatingToolbarPluginFactory(options) {
573
550
  var relevantConfig = activeConfigs && getRelevantConfig(editorState.selection, activeConfigs);
574
551
  return relevantConfig;
575
552
  };
576
- var getIsToolbarSuppressed = function getIsToolbarSuppressed(editorState) {
577
- var userIntentEnabled = Boolean((api === null || api === void 0 ? void 0 : api.userIntent) && (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_lovability_user_intent', 'isEnabled', true));
578
- if (userIntentEnabled) {
579
- return false;
580
- }
581
- for (var index = 0; index < floatingToolbarHandlers.length; index++) {
582
- var handler = floatingToolbarHandlers[index];
583
- var config = handler(editorState, intl, providerFactory);
584
- if (config !== null && config !== void 0 && config.__suppressAllToolbars) {
585
- return true;
586
- }
587
- }
553
+ var getIsToolbarSuppressed = function getIsToolbarSuppressed() {
588
554
  return false;
589
555
  };
590
556
  var apply = function apply() {
@@ -601,8 +567,8 @@ function floatingToolbarPluginFactory(options) {
601
567
  getConfigWithNodeInfo: getConfigWithNodeInfo
602
568
  };
603
569
  },
604
- apply: (0, _expValEquals.expValEquals)('platform_editor_lovability_suppress_toolbar_event', 'isEnabled', true) ? function (_tr, _pluginState, __oldEditorState, newEditorState) {
605
- var suppressedToolbar = getIsToolbarSuppressed(newEditorState);
570
+ apply: (0, _expValEquals.expValEquals)('platform_editor_lovability_suppress_toolbar_event', 'isEnabled', true) ? function (_tr, _pluginState, __oldEditorState) {
571
+ var suppressedToolbar = getIsToolbarSuppressed();
606
572
  var newPluginState = {
607
573
  getConfigWithNodeInfo: getConfigWithNodeInfo,
608
574
  suppressedToolbar: suppressedToolbar
@@ -26,7 +26,6 @@ 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");
30
29
  var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
31
30
  var _forceFocus = require("../pm-plugins/force-focus");
32
31
  var _commands = require("../pm-plugins/toolbar-data/commands");
@@ -195,25 +194,20 @@ var ToolbarItems = /*#__PURE__*/_react.default.memo(function (_ref) {
195
194
  return item.render(editorView, idx, dispatchAnalyticsEvent);
196
195
  }
197
196
  case 'overflow-dropdown':
198
- var options;
199
- if ((0, _platformFeatureFlags.fg)('platform_editor_fix_confirm_table_removal')) {
200
- // if an option has a confirmDialog, we need to replace its onClick handler
201
- // to set the state to show the confirm dialog
197
+ // if an option has a confirmDialog, we need to replace its onClick handler
198
+ // to set the state to show the confirm dialog
202
199
 
203
- // crudely done here to avoid greater coupling with DropdownMenuItem from `floating-toolbar`
204
- // which would need knowledge of indexes, showConfirmDialog etc.
205
- options = item.options.map(function (option, optionIndex) {
206
- if (!('type' in option) && option.confirmDialog) {
207
- var onClick = option.confirmDialog ? (0, _commands.showConfirmDialog)(idx, optionIndex) : option.onClick;
208
- return _objectSpread(_objectSpread({}, option), {}, {
209
- onClick: onClick
210
- });
211
- }
212
- return option;
213
- });
214
- } else {
215
- options = item.options;
216
- }
200
+ // crudely done here to avoid greater coupling with DropdownMenuItem from `floating-toolbar`
201
+ // which would need knowledge of indexes, showConfirmDialog etc.
202
+ var options = item.options.map(function (option, optionIndex) {
203
+ if (!('type' in option) && option.confirmDialog) {
204
+ var onClick = option.confirmDialog ? (0, _commands.showConfirmDialog)(idx, optionIndex) : option.onClick;
205
+ return _objectSpread(_objectSpread({}, option), {}, {
206
+ onClick: onClick
207
+ });
208
+ }
209
+ return option;
210
+ });
217
211
  return (0, _react2.jsx)(_Dropdown.default, {
218
212
  alignX: areAnyNewToolbarFlagsEnabled ? 'right' : undefined,
219
213
  key: idx,
@@ -14,8 +14,6 @@ import { AllSelection, PluginKey, TextSelection } from '@atlaskit/editor-prosemi
14
14
  import { findDomRefAtPos, findSelectedNodeOfType } from '@atlaskit/editor-prosemirror/utils';
15
15
  import { fg } from '@atlaskit/platform-feature-flags';
16
16
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
17
- import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
18
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
19
17
  import { copyNode } from './pm-plugins/commands';
20
18
  import forceFocusPlugin, { forceFocusSelector } from './pm-plugins/force-focus';
21
19
  import { hideConfirmDialog } from './pm-plugins/toolbar-data/commands';
@@ -230,12 +228,8 @@ export function ContentComponent({
230
228
  floatingToolbarState,
231
229
  editorDisabledState,
232
230
  editorViewModeState,
233
- userIntentState,
234
- // @ts-expect-error - excluded from FloatingToolbarPlugin dependencies to avoid circular dependency
235
- blockControlsState
236
- } = useSharedPluginState(pluginInjectionApi, ['floatingToolbar', 'editorDisabled', 'editorViewMode', 'userIntent',
237
- // @ts-expect-error - excluded from FloatingToolbarPlugin dependencies to avoid circular dependency
238
- 'blockControls']);
231
+ userIntentState
232
+ } = useSharedPluginState(pluginInjectionApi, ['floatingToolbar', 'editorDisabled', 'editorViewMode', 'userIntent']);
239
233
  const {
240
234
  configWithNodeInfo,
241
235
  floatingToolbarData
@@ -246,11 +240,7 @@ export function ContentComponent({
246
240
  if (!configWithNodeInfo || !configWithNodeInfo.config || typeof ((_configWithNodeInfo$c = configWithNodeInfo.config) === null || _configWithNodeInfo$c === void 0 ? void 0 : _configWithNodeInfo$c.visible) !== 'undefined' && !((_configWithNodeInfo$c2 = configWithNodeInfo.config) !== null && _configWithNodeInfo$c2 !== void 0 && _configWithNodeInfo$c2.visible)) {
247
241
  return null;
248
242
  }
249
- const userIntentEnabled = Boolean((pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.userIntent) && expValEqualsNoExposure('platform_editor_lovability_user_intent', 'isEnabled', true));
250
- if (((userIntentState === null || userIntentState === void 0 ? void 0 : userIntentState.currentUserIntent) === 'dragging' || (userIntentState === null || userIntentState === void 0 ? void 0 : userIntentState.currentUserIntent) === 'blockMenuOpen' && expValEquals('platform_editor_block_menu', 'isEnabled', true)) && !userIntentEnabled) {
251
- return null;
252
- }
253
- if (userIntentState !== null && userIntentState !== void 0 && userIntentState.currentUserIntent && SUPPRESS_TOOLBAR_USER_INTENTS.includes(userIntentState === null || userIntentState === void 0 ? void 0 : userIntentState.currentUserIntent) && userIntentEnabled) {
243
+ if (userIntentState !== null && userIntentState !== void 0 && userIntentState.currentUserIntent && SUPPRESS_TOOLBAR_USER_INTENTS.includes(userIntentState === null || userIntentState === void 0 ? void 0 : userIntentState.currentUserIntent)) {
254
244
  return null;
255
245
  }
256
246
  const {
@@ -377,31 +367,21 @@ export function ContentComponent({
377
367
 
378
368
  // Confirm dialog
379
369
  let confirmButtonItem;
380
- if (fg('platform_editor_fix_confirm_table_removal')) {
381
- const {
382
- confirmDialogForItem,
383
- confirmDialogForItemOption
384
- } = floatingToolbarData || {};
385
- const matchingItem = confirmDialogForItem ? toolbarItems === null || toolbarItems === void 0 ? void 0 : toolbarItems[confirmDialogForItem] : undefined;
386
- if ((matchingItem === null || matchingItem === void 0 ? void 0 : matchingItem.type) === 'button') {
387
- confirmButtonItem = matchingItem;
388
- }
389
- if ((matchingItem === null || matchingItem === void 0 ? void 0 : matchingItem.type) === 'overflow-dropdown' && confirmDialogForItemOption !== undefined) {
390
- const matchingItemOption = matchingItem.options[confirmDialogForItemOption];
370
+ const {
371
+ confirmDialogForItem,
372
+ confirmDialogForItemOption
373
+ } = floatingToolbarData || {};
374
+ const matchingItem = confirmDialogForItem ? toolbarItems === null || toolbarItems === void 0 ? void 0 : toolbarItems[confirmDialogForItem] : undefined;
375
+ if ((matchingItem === null || matchingItem === void 0 ? void 0 : matchingItem.type) === 'button') {
376
+ confirmButtonItem = matchingItem;
377
+ }
378
+ if ((matchingItem === null || matchingItem === void 0 ? void 0 : matchingItem.type) === 'overflow-dropdown' && confirmDialogForItemOption !== undefined) {
379
+ const matchingItemOption = matchingItem.options[confirmDialogForItemOption];
391
380
 
392
- // OverflowDropdownOption is the only member of the union that does not have a 'type' property
393
- if (!('type' in matchingItemOption)) {
394
- confirmButtonItem = matchingItemOption;
395
- }
381
+ // OverflowDropdownOption is the only member of the union that does not have a 'type' property
382
+ if (!('type' in matchingItemOption)) {
383
+ confirmButtonItem = matchingItemOption;
396
384
  }
397
- } else {
398
- const {
399
- confirmDialogForItem
400
- } = floatingToolbarData || {};
401
- confirmButtonItem = confirmDialogForItem ?
402
- // Ignored via go/ees005
403
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
404
- toolbarItems[confirmDialogForItem] : undefined;
405
385
  }
406
386
  const scrollable = config.scrollable;
407
387
  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;
@@ -543,12 +523,7 @@ export function floatingToolbarPluginFactory(options) {
543
523
  const config = handler(editorState, intl, providerFactory, activeConfigs);
544
524
  if (config) {
545
525
  var _api$userIntent, _api$userIntent$share;
546
- const userIntentEnabled = Boolean((api === null || api === void 0 ? void 0 : api.userIntent) && expValEqualsNoExposure('platform_editor_lovability_user_intent', 'isEnabled', true));
547
- if (config.__suppressAllToolbars && editorExperiment('platform_editor_controls', 'variant1') && !userIntentEnabled) {
548
- activeConfigs = undefined;
549
- break;
550
- }
551
- if (userIntentEnabled && SUPPRESS_TOOLBAR_USER_INTENTS.includes((api === null || api === void 0 ? void 0 : (_api$userIntent = api.userIntent) === null || _api$userIntent === void 0 ? void 0 : (_api$userIntent$share = _api$userIntent.sharedState.currentState()) === null || _api$userIntent$share === void 0 ? void 0 : _api$userIntent$share.currentUserIntent) || '')) {
526
+ if (SUPPRESS_TOOLBAR_USER_INTENTS.includes((api === null || api === void 0 ? void 0 : (_api$userIntent = api.userIntent) === null || _api$userIntent === void 0 ? void 0 : (_api$userIntent$share = _api$userIntent.sharedState.currentState()) === null || _api$userIntent$share === void 0 ? void 0 : _api$userIntent$share.currentUserIntent) || '')) {
552
527
  activeConfigs = undefined;
553
528
  break;
554
529
  }
@@ -558,18 +533,7 @@ export function floatingToolbarPluginFactory(options) {
558
533
  const relevantConfig = activeConfigs && getRelevantConfig(editorState.selection, activeConfigs);
559
534
  return relevantConfig;
560
535
  };
561
- const getIsToolbarSuppressed = editorState => {
562
- const userIntentEnabled = Boolean((api === null || api === void 0 ? void 0 : api.userIntent) && expValEqualsNoExposure('platform_editor_lovability_user_intent', 'isEnabled', true));
563
- if (userIntentEnabled) {
564
- return false;
565
- }
566
- for (let index = 0; index < floatingToolbarHandlers.length; index++) {
567
- const handler = floatingToolbarHandlers[index];
568
- const config = handler(editorState, intl, providerFactory);
569
- if (config !== null && config !== void 0 && config.__suppressAllToolbars) {
570
- return true;
571
- }
572
- }
536
+ const getIsToolbarSuppressed = () => {
573
537
  return false;
574
538
  };
575
539
  const apply = () => {
@@ -586,8 +550,8 @@ export function floatingToolbarPluginFactory(options) {
586
550
  getConfigWithNodeInfo
587
551
  };
588
552
  },
589
- apply: expValEquals('platform_editor_lovability_suppress_toolbar_event', 'isEnabled', true) ? (_tr, _pluginState, __oldEditorState, newEditorState) => {
590
- const suppressedToolbar = getIsToolbarSuppressed(newEditorState);
553
+ apply: expValEquals('platform_editor_lovability_suppress_toolbar_event', 'isEnabled', true) ? (_tr, _pluginState, __oldEditorState) => {
554
+ const suppressedToolbar = getIsToolbarSuppressed();
591
555
  const newPluginState = {
592
556
  getConfigWithNodeInfo,
593
557
  suppressedToolbar
@@ -19,7 +19,6 @@ 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';
23
22
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
24
23
  import { checkShouldForceFocusAndApply, forceFocusSelector } from '../pm-plugins/force-focus';
25
24
  import { showConfirmDialog } from '../pm-plugins/toolbar-data/commands';
@@ -171,26 +170,21 @@ const ToolbarItems = /*#__PURE__*/React.memo(({
171
170
  return item.render(editorView, idx, dispatchAnalyticsEvent);
172
171
  }
173
172
  case 'overflow-dropdown':
174
- let options;
175
- if (fg('platform_editor_fix_confirm_table_removal')) {
176
- // if an option has a confirmDialog, we need to replace its onClick handler
177
- // to set the state to show the confirm dialog
173
+ // if an option has a confirmDialog, we need to replace its onClick handler
174
+ // to set the state to show the confirm dialog
178
175
 
179
- // crudely done here to avoid greater coupling with DropdownMenuItem from `floating-toolbar`
180
- // which would need knowledge of indexes, showConfirmDialog etc.
181
- options = item.options.map((option, optionIndex) => {
182
- if (!('type' in option) && option.confirmDialog) {
183
- const onClick = option.confirmDialog ? showConfirmDialog(idx, optionIndex) : option.onClick;
184
- return {
185
- ...option,
186
- onClick
187
- };
188
- }
189
- return option;
190
- });
191
- } else {
192
- options = item.options;
193
- }
176
+ // crudely done here to avoid greater coupling with DropdownMenuItem from `floating-toolbar`
177
+ // which would need knowledge of indexes, showConfirmDialog etc.
178
+ const options = item.options.map((option, optionIndex) => {
179
+ if (!('type' in option) && option.confirmDialog) {
180
+ const onClick = option.confirmDialog ? showConfirmDialog(idx, optionIndex) : option.onClick;
181
+ return {
182
+ ...option,
183
+ onClick
184
+ };
185
+ }
186
+ return option;
187
+ });
194
188
  return jsx(Dropdown, {
195
189
  alignX: areAnyNewToolbarFlagsEnabled ? 'right' : undefined,
196
190
  key: idx,
@@ -18,8 +18,6 @@ import { AllSelection, PluginKey, TextSelection } from '@atlaskit/editor-prosemi
18
18
  import { findDomRefAtPos, findSelectedNodeOfType } from '@atlaskit/editor-prosemirror/utils';
19
19
  import { fg } from '@atlaskit/platform-feature-flags';
20
20
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
21
- import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
22
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
23
21
  import { copyNode as _copyNode } from './pm-plugins/commands';
24
22
  import forceFocusPlugin, { forceFocusSelector } from './pm-plugins/force-focus';
25
23
  import { hideConfirmDialog } from './pm-plugins/toolbar-data/commands';
@@ -230,14 +228,11 @@ export function ContentComponent(_ref5) {
230
228
  popupsScrollableElement = _ref5.popupsScrollableElement,
231
229
  providerFactory = _ref5.providerFactory,
232
230
  dispatchAnalyticsEvent = _ref5.dispatchAnalyticsEvent;
233
- var _useSharedPluginState = useSharedPluginState(pluginInjectionApi, ['floatingToolbar', 'editorDisabled', 'editorViewMode', 'userIntent',
234
- // @ts-expect-error - excluded from FloatingToolbarPlugin dependencies to avoid circular dependency
235
- 'blockControls']),
231
+ var _useSharedPluginState = useSharedPluginState(pluginInjectionApi, ['floatingToolbar', 'editorDisabled', 'editorViewMode', 'userIntent']),
236
232
  floatingToolbarState = _useSharedPluginState.floatingToolbarState,
237
233
  editorDisabledState = _useSharedPluginState.editorDisabledState,
238
234
  editorViewModeState = _useSharedPluginState.editorViewModeState,
239
- userIntentState = _useSharedPluginState.userIntentState,
240
- blockControlsState = _useSharedPluginState.blockControlsState;
235
+ userIntentState = _useSharedPluginState.userIntentState;
241
236
  var _ref6 = floatingToolbarState !== null && floatingToolbarState !== void 0 ? floatingToolbarState : {},
242
237
  configWithNodeInfo = _ref6.configWithNodeInfo,
243
238
  floatingToolbarData = _ref6.floatingToolbarData;
@@ -247,11 +242,7 @@ export function ContentComponent(_ref5) {
247
242
  if (!configWithNodeInfo || !configWithNodeInfo.config || typeof ((_configWithNodeInfo$c = configWithNodeInfo.config) === null || _configWithNodeInfo$c === void 0 ? void 0 : _configWithNodeInfo$c.visible) !== 'undefined' && !((_configWithNodeInfo$c2 = configWithNodeInfo.config) !== null && _configWithNodeInfo$c2 !== void 0 && _configWithNodeInfo$c2.visible)) {
248
243
  return null;
249
244
  }
250
- var userIntentEnabled = Boolean((pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.userIntent) && expValEqualsNoExposure('platform_editor_lovability_user_intent', 'isEnabled', true));
251
- if (((userIntentState === null || userIntentState === void 0 ? void 0 : userIntentState.currentUserIntent) === 'dragging' || (userIntentState === null || userIntentState === void 0 ? void 0 : userIntentState.currentUserIntent) === 'blockMenuOpen' && expValEquals('platform_editor_block_menu', 'isEnabled', true)) && !userIntentEnabled) {
252
- return null;
253
- }
254
- if (userIntentState !== null && userIntentState !== void 0 && userIntentState.currentUserIntent && SUPPRESS_TOOLBAR_USER_INTENTS.includes(userIntentState === null || userIntentState === void 0 ? void 0 : userIntentState.currentUserIntent) && userIntentEnabled) {
245
+ if (userIntentState !== null && userIntentState !== void 0 && userIntentState.currentUserIntent && SUPPRESS_TOOLBAR_USER_INTENTS.includes(userIntentState === null || userIntentState === void 0 ? void 0 : userIntentState.currentUserIntent)) {
255
246
  return null;
256
247
  }
257
248
  var config = configWithNodeInfo.config,
@@ -384,29 +375,20 @@ export function ContentComponent(_ref5) {
384
375
 
385
376
  // Confirm dialog
386
377
  var confirmButtonItem;
387
- if (fg('platform_editor_fix_confirm_table_removal')) {
388
- var _ref7 = floatingToolbarData || {},
389
- confirmDialogForItem = _ref7.confirmDialogForItem,
390
- confirmDialogForItemOption = _ref7.confirmDialogForItemOption;
391
- var matchingItem = confirmDialogForItem ? toolbarItems === null || toolbarItems === void 0 ? void 0 : toolbarItems[confirmDialogForItem] : undefined;
392
- if ((matchingItem === null || matchingItem === void 0 ? void 0 : matchingItem.type) === 'button') {
393
- confirmButtonItem = matchingItem;
394
- }
395
- if ((matchingItem === null || matchingItem === void 0 ? void 0 : matchingItem.type) === 'overflow-dropdown' && confirmDialogForItemOption !== undefined) {
396
- var matchingItemOption = matchingItem.options[confirmDialogForItemOption];
378
+ var _ref7 = floatingToolbarData || {},
379
+ confirmDialogForItem = _ref7.confirmDialogForItem,
380
+ confirmDialogForItemOption = _ref7.confirmDialogForItemOption;
381
+ var matchingItem = confirmDialogForItem ? toolbarItems === null || toolbarItems === void 0 ? void 0 : toolbarItems[confirmDialogForItem] : undefined;
382
+ if ((matchingItem === null || matchingItem === void 0 ? void 0 : matchingItem.type) === 'button') {
383
+ confirmButtonItem = matchingItem;
384
+ }
385
+ if ((matchingItem === null || matchingItem === void 0 ? void 0 : matchingItem.type) === 'overflow-dropdown' && confirmDialogForItemOption !== undefined) {
386
+ var matchingItemOption = matchingItem.options[confirmDialogForItemOption];
397
387
 
398
- // OverflowDropdownOption is the only member of the union that does not have a 'type' property
399
- if (!('type' in matchingItemOption)) {
400
- confirmButtonItem = matchingItemOption;
401
- }
388
+ // OverflowDropdownOption is the only member of the union that does not have a 'type' property
389
+ if (!('type' in matchingItemOption)) {
390
+ confirmButtonItem = matchingItemOption;
402
391
  }
403
- } else {
404
- var _ref8 = floatingToolbarData || {},
405
- _confirmDialogForItem = _ref8.confirmDialogForItem;
406
- confirmButtonItem = _confirmDialogForItem ?
407
- // Ignored via go/ees005
408
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
409
- toolbarItems[_confirmDialogForItem] : undefined;
410
392
  }
411
393
  var scrollable = config.scrollable;
412
394
  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;
@@ -548,12 +530,7 @@ export function floatingToolbarPluginFactory(options) {
548
530
  var config = handler(editorState, intl, providerFactory, activeConfigs);
549
531
  if (config) {
550
532
  var _api$userIntent;
551
- var userIntentEnabled = Boolean((api === null || api === void 0 ? void 0 : api.userIntent) && expValEqualsNoExposure('platform_editor_lovability_user_intent', 'isEnabled', true));
552
- if (config.__suppressAllToolbars && editorExperiment('platform_editor_controls', 'variant1') && !userIntentEnabled) {
553
- activeConfigs = undefined;
554
- break;
555
- }
556
- if (userIntentEnabled && SUPPRESS_TOOLBAR_USER_INTENTS.includes((api === null || api === void 0 || (_api$userIntent = api.userIntent) === null || _api$userIntent === void 0 || (_api$userIntent = _api$userIntent.sharedState.currentState()) === null || _api$userIntent === void 0 ? void 0 : _api$userIntent.currentUserIntent) || '')) {
533
+ if (SUPPRESS_TOOLBAR_USER_INTENTS.includes((api === null || api === void 0 || (_api$userIntent = api.userIntent) === null || _api$userIntent === void 0 || (_api$userIntent = _api$userIntent.sharedState.currentState()) === null || _api$userIntent === void 0 ? void 0 : _api$userIntent.currentUserIntent) || '')) {
557
534
  activeConfigs = undefined;
558
535
  break;
559
536
  }
@@ -563,18 +540,7 @@ export function floatingToolbarPluginFactory(options) {
563
540
  var relevantConfig = activeConfigs && getRelevantConfig(editorState.selection, activeConfigs);
564
541
  return relevantConfig;
565
542
  };
566
- var getIsToolbarSuppressed = function getIsToolbarSuppressed(editorState) {
567
- var userIntentEnabled = Boolean((api === null || api === void 0 ? void 0 : api.userIntent) && expValEqualsNoExposure('platform_editor_lovability_user_intent', 'isEnabled', true));
568
- if (userIntentEnabled) {
569
- return false;
570
- }
571
- for (var index = 0; index < floatingToolbarHandlers.length; index++) {
572
- var handler = floatingToolbarHandlers[index];
573
- var config = handler(editorState, intl, providerFactory);
574
- if (config !== null && config !== void 0 && config.__suppressAllToolbars) {
575
- return true;
576
- }
577
- }
543
+ var getIsToolbarSuppressed = function getIsToolbarSuppressed() {
578
544
  return false;
579
545
  };
580
546
  var apply = function apply() {
@@ -591,8 +557,8 @@ export function floatingToolbarPluginFactory(options) {
591
557
  getConfigWithNodeInfo: getConfigWithNodeInfo
592
558
  };
593
559
  },
594
- apply: expValEquals('platform_editor_lovability_suppress_toolbar_event', 'isEnabled', true) ? function (_tr, _pluginState, __oldEditorState, newEditorState) {
595
- var suppressedToolbar = getIsToolbarSuppressed(newEditorState);
560
+ apply: expValEquals('platform_editor_lovability_suppress_toolbar_event', 'isEnabled', true) ? function (_tr, _pluginState, __oldEditorState) {
561
+ var suppressedToolbar = getIsToolbarSuppressed();
596
562
  var newPluginState = {
597
563
  getConfigWithNodeInfo: getConfigWithNodeInfo,
598
564
  suppressedToolbar: suppressedToolbar
@@ -28,7 +28,6 @@ import { backgroundPaletteTooltipMessages } from '@atlaskit/editor-common/ui-col
28
28
  import { ColorPickerButton, ToolbarArrowKeyNavigationProvider } from '@atlaskit/editor-common/ui-menu';
29
29
  import { hexToEditorBackgroundPaletteColor } from '@atlaskit/editor-palette';
30
30
  import ShowMoreHorizontalIcon from '@atlaskit/icon/core/show-more-horizontal';
31
- import { fg } from '@atlaskit/platform-feature-flags';
32
31
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
33
32
  import { checkShouldForceFocusAndApply, forceFocusSelector } from '../pm-plugins/force-focus';
34
33
  import { showConfirmDialog } from '../pm-plugins/toolbar-data/commands';
@@ -189,25 +188,20 @@ var ToolbarItems = /*#__PURE__*/React.memo(function (_ref) {
189
188
  return item.render(editorView, idx, dispatchAnalyticsEvent);
190
189
  }
191
190
  case 'overflow-dropdown':
192
- var options;
193
- if (fg('platform_editor_fix_confirm_table_removal')) {
194
- // if an option has a confirmDialog, we need to replace its onClick handler
195
- // to set the state to show the confirm dialog
191
+ // if an option has a confirmDialog, we need to replace its onClick handler
192
+ // to set the state to show the confirm dialog
196
193
 
197
- // crudely done here to avoid greater coupling with DropdownMenuItem from `floating-toolbar`
198
- // which would need knowledge of indexes, showConfirmDialog etc.
199
- options = item.options.map(function (option, optionIndex) {
200
- if (!('type' in option) && option.confirmDialog) {
201
- var onClick = option.confirmDialog ? showConfirmDialog(idx, optionIndex) : option.onClick;
202
- return _objectSpread(_objectSpread({}, option), {}, {
203
- onClick: onClick
204
- });
205
- }
206
- return option;
207
- });
208
- } else {
209
- options = item.options;
210
- }
194
+ // crudely done here to avoid greater coupling with DropdownMenuItem from `floating-toolbar`
195
+ // which would need knowledge of indexes, showConfirmDialog etc.
196
+ var options = item.options.map(function (option, optionIndex) {
197
+ if (!('type' in option) && option.confirmDialog) {
198
+ var onClick = option.confirmDialog ? showConfirmDialog(idx, optionIndex) : option.onClick;
199
+ return _objectSpread(_objectSpread({}, option), {}, {
200
+ onClick: onClick
201
+ });
202
+ }
203
+ return option;
204
+ });
211
205
  return jsx(Dropdown, {
212
206
  alignX: areAnyNewToolbarFlagsEnabled ? 'right' : undefined,
213
207
  key: idx,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-floating-toolbar",
3
- "version": "9.1.14",
3
+ "version": "9.1.16",
4
4
  "description": "Floating toolbar plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -27,12 +27,12 @@
27
27
  "@atlaskit/editor-palette": "^2.1.0",
28
28
  "@atlaskit/editor-plugin-analytics": "^7.0.0",
29
29
  "@atlaskit/editor-plugin-context-panel": "^9.0.0",
30
- "@atlaskit/editor-plugin-copy-button": "^7.0.0",
30
+ "@atlaskit/editor-plugin-copy-button": "^7.1.0",
31
31
  "@atlaskit/editor-plugin-decorations": "^7.0.0",
32
32
  "@atlaskit/editor-plugin-editor-disabled": "^7.0.0",
33
33
  "@atlaskit/editor-plugin-editor-viewmode": "^9.0.0",
34
34
  "@atlaskit/editor-plugin-emoji": "^8.1.0",
35
- "@atlaskit/editor-plugin-extension": "^10.0.0",
35
+ "@atlaskit/editor-plugin-extension": "^10.1.0",
36
36
  "@atlaskit/editor-plugin-interaction": "^14.0.0",
37
37
  "@atlaskit/editor-plugin-user-intent": "^5.0.0",
38
38
  "@atlaskit/editor-prosemirror": "^7.3.0",
@@ -44,7 +44,7 @@
44
44
  "@atlaskit/primitives": "^18.0.0",
45
45
  "@atlaskit/select": "^21.7.0",
46
46
  "@atlaskit/theme": "^21.0.0",
47
- "@atlaskit/tmp-editor-statsig": "^25.0.0",
47
+ "@atlaskit/tmp-editor-statsig": "^25.6.0",
48
48
  "@atlaskit/tokens": "^11.0.0",
49
49
  "@atlaskit/tooltip": "^20.14.0",
50
50
  "@babel/runtime": "^7.0.0",
@@ -56,7 +56,7 @@
56
56
  "react-loadable": "^5.1.0"
57
57
  },
58
58
  "peerDependencies": {
59
- "@atlaskit/editor-common": "^111.12.0",
59
+ "@atlaskit/editor-common": "^111.15.0",
60
60
  "react": "^18.2.0",
61
61
  "react-dom": "^18.2.0"
62
62
  },
@@ -112,9 +112,6 @@
112
112
  "platform-visual-refresh-icons": {
113
113
  "type": "boolean"
114
114
  },
115
- "platform_editor_fix_confirm_table_removal": {
116
- "type": "boolean"
117
- },
118
115
  "platform_editor_a11y_add_role_to_popup": {
119
116
  "type": "boolean"
120
117
  }