@atlaskit/editor-plugin-floating-toolbar 8.2.10 → 8.2.12

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,21 @@
1
1
  # @atlaskit/editor-plugin-floating-toolbar
2
2
 
3
+ ## 8.2.12
4
+
5
+ ### Patch Changes
6
+
7
+ - [`e727490d9f62f`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/e727490d9f62f) -
8
+ [ux] EDITOR-2572 Hide floating toolbar when status picker is open
9
+ - Updated dependencies
10
+
11
+ ## 8.2.11
12
+
13
+ ### Patch Changes
14
+
15
+ - [`28ba94dae8f9a`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/28ba94dae8f9a) -
16
+ [ux] EDITOR-2458 Replace usage of \_\_suppressAllToolbars with userIntentPlugin
17
+ - Updated dependencies
18
+
3
19
  ## 8.2.10
4
20
 
5
21
  ### Patch Changes
@@ -25,6 +25,7 @@ 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");
28
29
  var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
29
30
  var _commands = require("./pm-plugins/commands");
30
31
  var _forceFocus = _interopRequireWildcard(require("./pm-plugins/force-focus"));
@@ -38,6 +39,8 @@ var _utils3 = require("./ui/utils");
38
39
  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); }
39
40
  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; }
40
41
  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; }
42
+ var SUPPRESS_TOOLBAR_USER_INTENTS = ['dragging', 'tablePopupOpen', 'commenting', 'resizing', 'blockMenuOpen', 'statusPickerOpen'];
43
+
41
44
  // TODO: AFP-2532 - Fix automatic suppressions below
42
45
  var getRelevantConfig = exports.getRelevantConfig = function getRelevantConfig(selection, configs) {
43
46
  // node selections always take precedence, see if
@@ -147,6 +150,7 @@ var floatingToolbarPlugin = exports.floatingToolbarPlugin = function floatingToo
147
150
  var providerFactory = _ref2.providerFactory,
148
151
  getIntl = _ref2.getIntl;
149
152
  return floatingToolbarPluginFactory({
153
+ api: api,
150
154
  floatingToolbarHandlers: floatingToolbarHandlers,
151
155
  providerFactory: providerFactory,
152
156
  getIntl: getIntl
@@ -253,15 +257,13 @@ function ContentComponent(_ref5) {
253
257
  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)) {
254
258
  return null;
255
259
  }
256
- 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) && (0, _platformFeatureFlags.fg)('platform_editor_block_menu_hide_floating_toolbar')) {
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) && (0, _platformFeatureFlags.fg)('platform_editor_block_menu_hide_floating_toolbar')) && !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) {
257
265
  return null;
258
266
  }
259
-
260
- // TODO: ED-27539 - This feature is unreleased and rendering logic needs to be move userIntentState which is not ready yet
261
- // if (blockControlsState?.isMenuOpen && editorExperiment('platform_editor_controls', 'variant1')) {
262
- // return null;
263
- // }
264
-
265
267
  var config = configWithNodeInfo.config,
266
268
  node = configWithNodeInfo.node;
267
269
 
@@ -552,7 +554,8 @@ function sanitizeFloatingToolbarConfig(config) {
552
554
  function floatingToolbarPluginFactory(options) {
553
555
  var floatingToolbarHandlers = options.floatingToolbarHandlers,
554
556
  providerFactory = options.providerFactory,
555
- getIntl = options.getIntl;
557
+ getIntl = options.getIntl,
558
+ api = options.api;
556
559
  var intl = getIntl();
557
560
  var getConfigWithNodeInfo = function getConfigWithNodeInfo(editorState) {
558
561
  var activeConfigs = [];
@@ -560,7 +563,13 @@ function floatingToolbarPluginFactory(options) {
560
563
  var handler = floatingToolbarHandlers[index];
561
564
  var config = handler(editorState, intl, providerFactory, activeConfigs);
562
565
  if (config) {
563
- if (config.__suppressAllToolbars && (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1')) {
566
+ var _api$userIntent;
567
+ var userIntentEnabled = Boolean((api === null || api === void 0 ? void 0 : api.userIntent) && (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_lovability_user_intent', 'isEnabled', true));
568
+ if (config.__suppressAllToolbars && (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && !userIntentEnabled) {
569
+ activeConfigs = undefined;
570
+ break;
571
+ }
572
+ 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) || '')) {
564
573
  activeConfigs = undefined;
565
574
  break;
566
575
  }
@@ -14,6 +14,7 @@ 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';
17
18
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
18
19
  import { copyNode } from './pm-plugins/commands';
19
20
  import forceFocusPlugin, { forceFocusSelector } from './pm-plugins/force-focus';
@@ -24,6 +25,7 @@ import { findNode } from './pm-plugins/utils';
24
25
  import { ConfirmationModal } from './ui/ConfirmationModal';
25
26
  import Toolbar from './ui/Toolbar';
26
27
  import { consolidateOverflowDropdownItems } from './ui/utils';
28
+ const SUPPRESS_TOOLBAR_USER_INTENTS = ['dragging', 'tablePopupOpen', 'commenting', 'resizing', 'blockMenuOpen', 'statusPickerOpen'];
27
29
 
28
30
  // TODO: AFP-2532 - Fix automatic suppressions below
29
31
  export const getRelevantConfig = (selection, configs) => {
@@ -136,6 +138,7 @@ export const floatingToolbarPlugin = ({
136
138
  providerFactory,
137
139
  getIntl
138
140
  }) => floatingToolbarPluginFactory({
141
+ api,
139
142
  floatingToolbarHandlers,
140
143
  providerFactory,
141
144
  getIntl
@@ -243,15 +246,13 @@ export function ContentComponent({
243
246
  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)) {
244
247
  return null;
245
248
  }
246
- 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) && fg('platform_editor_block_menu_hide_floating_toolbar')) {
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) && fg('platform_editor_block_menu_hide_floating_toolbar')) && !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) {
247
254
  return null;
248
255
  }
249
-
250
- // TODO: ED-27539 - This feature is unreleased and rendering logic needs to be move userIntentState which is not ready yet
251
- // if (blockControlsState?.isMenuOpen && editorExperiment('platform_editor_controls', 'variant1')) {
252
- // return null;
253
- // }
254
-
255
256
  const {
256
257
  config,
257
258
  node
@@ -537,7 +538,8 @@ export function floatingToolbarPluginFactory(options) {
537
538
  const {
538
539
  floatingToolbarHandlers,
539
540
  providerFactory,
540
- getIntl
541
+ getIntl,
542
+ api
541
543
  } = options;
542
544
  const intl = getIntl();
543
545
  const getConfigWithNodeInfo = editorState => {
@@ -546,7 +548,13 @@ export function floatingToolbarPluginFactory(options) {
546
548
  const handler = floatingToolbarHandlers[index];
547
549
  const config = handler(editorState, intl, providerFactory, activeConfigs);
548
550
  if (config) {
549
- if (config.__suppressAllToolbars && editorExperiment('platform_editor_controls', 'variant1')) {
551
+ var _api$userIntent, _api$userIntent$share;
552
+ const userIntentEnabled = Boolean((api === null || api === void 0 ? void 0 : api.userIntent) && expValEqualsNoExposure('platform_editor_lovability_user_intent', 'isEnabled', true));
553
+ if (config.__suppressAllToolbars && editorExperiment('platform_editor_controls', 'variant1') && !userIntentEnabled) {
554
+ activeConfigs = undefined;
555
+ break;
556
+ }
557
+ 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) || '')) {
550
558
  activeConfigs = undefined;
551
559
  break;
552
560
  }
@@ -18,6 +18,7 @@ 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';
21
22
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
22
23
  import { copyNode as _copyNode } from './pm-plugins/commands';
23
24
  import forceFocusPlugin, { forceFocusSelector } from './pm-plugins/force-focus';
@@ -28,6 +29,7 @@ import { findNode } from './pm-plugins/utils';
28
29
  import { ConfirmationModal } from './ui/ConfirmationModal';
29
30
  import Toolbar from './ui/Toolbar';
30
31
  import { consolidateOverflowDropdownItems } from './ui/utils';
32
+ var SUPPRESS_TOOLBAR_USER_INTENTS = ['dragging', 'tablePopupOpen', 'commenting', 'resizing', 'blockMenuOpen', 'statusPickerOpen'];
31
33
 
32
34
  // TODO: AFP-2532 - Fix automatic suppressions below
33
35
  export var getRelevantConfig = function getRelevantConfig(selection, configs) {
@@ -138,6 +140,7 @@ export var floatingToolbarPlugin = function floatingToolbarPlugin(_ref) {
138
140
  var providerFactory = _ref2.providerFactory,
139
141
  getIntl = _ref2.getIntl;
140
142
  return floatingToolbarPluginFactory({
143
+ api: api,
141
144
  floatingToolbarHandlers: floatingToolbarHandlers,
142
145
  providerFactory: providerFactory,
143
146
  getIntl: getIntl
@@ -244,15 +247,13 @@ export function ContentComponent(_ref5) {
244
247
  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)) {
245
248
  return null;
246
249
  }
247
- 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) && fg('platform_editor_block_menu_hide_floating_toolbar')) {
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) && fg('platform_editor_block_menu_hide_floating_toolbar')) && !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) {
248
255
  return null;
249
256
  }
250
-
251
- // TODO: ED-27539 - This feature is unreleased and rendering logic needs to be move userIntentState which is not ready yet
252
- // if (blockControlsState?.isMenuOpen && editorExperiment('platform_editor_controls', 'variant1')) {
253
- // return null;
254
- // }
255
-
256
257
  var config = configWithNodeInfo.config,
257
258
  node = configWithNodeInfo.node;
258
259
 
@@ -543,7 +544,8 @@ function sanitizeFloatingToolbarConfig(config) {
543
544
  export function floatingToolbarPluginFactory(options) {
544
545
  var floatingToolbarHandlers = options.floatingToolbarHandlers,
545
546
  providerFactory = options.providerFactory,
546
- getIntl = options.getIntl;
547
+ getIntl = options.getIntl,
548
+ api = options.api;
547
549
  var intl = getIntl();
548
550
  var getConfigWithNodeInfo = function getConfigWithNodeInfo(editorState) {
549
551
  var activeConfigs = [];
@@ -551,7 +553,13 @@ export function floatingToolbarPluginFactory(options) {
551
553
  var handler = floatingToolbarHandlers[index];
552
554
  var config = handler(editorState, intl, providerFactory, activeConfigs);
553
555
  if (config) {
554
- if (config.__suppressAllToolbars && editorExperiment('platform_editor_controls', 'variant1')) {
556
+ var _api$userIntent;
557
+ var userIntentEnabled = Boolean((api === null || api === void 0 ? void 0 : api.userIntent) && expValEqualsNoExposure('platform_editor_lovability_user_intent', 'isEnabled', true));
558
+ if (config.__suppressAllToolbars && editorExperiment('platform_editor_controls', 'variant1') && !userIntentEnabled) {
559
+ activeConfigs = undefined;
560
+ break;
561
+ }
562
+ 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) || '')) {
555
563
  activeConfigs = undefined;
556
564
  break;
557
565
  }
@@ -51,6 +51,7 @@ export declare const pluginKey: PluginKey<FloatingToolbarPluginState>;
51
51
  * @returns A SafePlugin instance that manages floating toolbar state and behavior
52
52
  */
53
53
  export declare function floatingToolbarPluginFactory(options: {
54
+ api: ExtractInjectionAPI<FloatingToolbarPlugin> | undefined;
54
55
  floatingToolbarHandlers: Array<FloatingToolbarHandler>;
55
56
  getIntl: () => IntlShape;
56
57
  providerFactory: ProviderFactory;
@@ -51,6 +51,7 @@ export declare const pluginKey: PluginKey<FloatingToolbarPluginState>;
51
51
  * @returns A SafePlugin instance that manages floating toolbar state and behavior
52
52
  */
53
53
  export declare function floatingToolbarPluginFactory(options: {
54
+ api: ExtractInjectionAPI<FloatingToolbarPlugin> | undefined;
54
55
  floatingToolbarHandlers: Array<FloatingToolbarHandler>;
55
56
  getIntl: () => IntlShape;
56
57
  providerFactory: ProviderFactory;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-floating-toolbar",
3
- "version": "8.2.10",
3
+ "version": "8.2.12",
4
4
  "description": "Floating toolbar plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -31,7 +31,7 @@
31
31
  "@atlaskit/editor-plugin-decorations": "^6.1.0",
32
32
  "@atlaskit/editor-plugin-editor-disabled": "^6.1.0",
33
33
  "@atlaskit/editor-plugin-editor-viewmode": "^8.0.0",
34
- "@atlaskit/editor-plugin-emoji": "^7.4.0",
34
+ "@atlaskit/editor-plugin-emoji": "^7.5.0",
35
35
  "@atlaskit/editor-plugin-extension": "^9.2.0",
36
36
  "@atlaskit/editor-plugin-interaction": "^9.0.0",
37
37
  "@atlaskit/editor-plugin-table": "^15.3.0",
@@ -42,12 +42,12 @@
42
42
  "@atlaskit/menu": "^8.4.0",
43
43
  "@atlaskit/modal-dialog": "^14.6.0",
44
44
  "@atlaskit/platform-feature-flags": "^1.1.0",
45
- "@atlaskit/primitives": "^16.0.0",
45
+ "@atlaskit/primitives": "^16.1.0",
46
46
  "@atlaskit/select": "^21.3.0",
47
47
  "@atlaskit/theme": "^21.0.0",
48
- "@atlaskit/tmp-editor-statsig": "^13.19.0",
48
+ "@atlaskit/tmp-editor-statsig": "^13.22.0",
49
49
  "@atlaskit/tokens": "^7.0.0",
50
- "@atlaskit/tooltip": "^20.6.0",
50
+ "@atlaskit/tooltip": "^20.7.0",
51
51
  "@babel/runtime": "^7.0.0",
52
52
  "@emotion/react": "^11.7.1",
53
53
  "bind-event-listener": "^3.0.0",
@@ -57,7 +57,7 @@
57
57
  "react-loadable": "^5.1.0"
58
58
  },
59
59
  "peerDependencies": {
60
- "@atlaskit/editor-common": "^110.18.0",
60
+ "@atlaskit/editor-common": "^110.19.0",
61
61
  "react": "^18.2.0",
62
62
  "react-dom": "^18.2.0"
63
63
  },