@atlaskit/editor-plugin-block-controls 7.3.0 → 7.4.0

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,17 @@
1
1
  # @atlaskit/editor-plugin-block-controls
2
2
 
3
+ ## 7.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`4f5569bde5e64`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/4f5569bde5e64) -
8
+ Add new 'dragHandleSelected' user intent, use this to control table toolbar when drag handle is
9
+ selected
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies
14
+
3
15
  ## 7.3.0
4
16
 
5
17
  ### Minor Changes
@@ -125,18 +125,26 @@ var blockControlsPlugin = exports.blockControlsPlugin = function blockControlsPl
125
125
  toggleMenu: toggleMenuMeta
126
126
  }));
127
127
  if ((menuTriggerBy === undefined || !!menuTriggerBy && menuTriggerBy === (options === null || options === void 0 ? void 0 : options.anchorName)) && currentUserIntent === 'blockMenuOpen') {
128
- var _api$userIntent4;
129
- // Toggled from drag handle
130
- api === null || api === void 0 || (_api$userIntent4 = api.userIntent) === null || _api$userIntent4 === void 0 || _api$userIntent4.commands.setCurrentUserIntent('default')({
131
- tr: tr
132
- });
128
+ var state = api === null || api === void 0 ? void 0 : api.blockControls.sharedState.currentState();
129
+ if (state !== null && state !== void 0 && state.isSelectedViaDragHandle && (0, _platformFeatureFlags.fg)('platform_editor_toolbar_aifc_user_intent_fix')) {
130
+ var _api$userIntent4;
131
+ api === null || api === void 0 || (_api$userIntent4 = api.userIntent) === null || _api$userIntent4 === void 0 || _api$userIntent4.commands.setCurrentUserIntent('dragHandleSelected')({
132
+ tr: tr
133
+ });
134
+ } else {
135
+ var _api$userIntent5;
136
+ // Toggled from drag handle
137
+ api === null || api === void 0 || (_api$userIntent5 = api.userIntent) === null || _api$userIntent5 === void 0 || _api$userIntent5.commands.setCurrentUserIntent('default')({
138
+ tr: tr
139
+ });
140
+ }
133
141
  }
134
142
  return tr;
135
143
  };
136
144
  },
137
145
  setNodeDragged: function setNodeDragged(getPos, anchorName, nodeType) {
138
146
  return function (_ref5) {
139
- var _api$userIntent5;
147
+ var _api$userIntent6;
140
148
  var tr = _ref5.tr;
141
149
  var pos = getPos();
142
150
  if (pos === undefined) {
@@ -160,7 +168,7 @@ var blockControlsPlugin = exports.blockControlsPlugin = function blockControlsPl
160
168
  tr: tr
161
169
  });
162
170
  }
163
- api === null || api === void 0 || (_api$userIntent5 = api.userIntent) === null || _api$userIntent5 === void 0 || _api$userIntent5.commands.setCurrentUserIntent('dragging')({
171
+ api === null || api === void 0 || (_api$userIntent6 = api.userIntent) === null || _api$userIntent6 === void 0 || _api$userIntent6.commands.setCurrentUserIntent('dragging')({
164
172
  tr: tr
165
173
  });
166
174
  return tr;
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.handleMouseDown = void 0;
7
7
  var _styles = require("@atlaskit/editor-common/styles");
8
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
8
9
  var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
9
10
  var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
10
11
  var handleMouseDown = exports.handleMouseDown = function handleMouseDown(api) {
@@ -35,7 +36,33 @@ var handleMouseDown = exports.handleMouseDown = function handleMouseDown(api) {
35
36
  }
36
37
  } else {
37
38
  var isDragHandle = event.target.closest((0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu', 'isEnabled', true) ? _styles.DRAG_HANDLE_SELECTOR : '[data-editor-block-ctrl-drag-handle]') !== null;
38
- api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.setSelectedViaDragHandle(isDragHandle));
39
+ api === null || api === void 0 || api.core.actions.execute(function (_ref) {
40
+ var tr = _ref.tr;
41
+ api === null || api === void 0 || api.blockControls.commands.setSelectedViaDragHandle(isDragHandle)({
42
+ tr: tr
43
+ });
44
+ /**
45
+ * When block menu is enabled, reset intent back to 'default' as editor-plugin-block-menu sets the user intent to 'blockMenuOpen', and setting here
46
+ * causes flickering as this runs before editor-plugin-block-menu.
47
+ */
48
+ if ((0, _platformFeatureFlags.fg)('platform_editor_toolbar_aifc_user_intent_fix')) {
49
+ if ((0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu', 'isEnabled', true)) {
50
+ // if target is drag handle, block menu will be opened
51
+ if (!isDragHandle) {
52
+ var _api$userIntent;
53
+ api === null || api === void 0 || (_api$userIntent = api.userIntent) === null || _api$userIntent === void 0 || _api$userIntent.commands.setCurrentUserIntent('default')({
54
+ tr: tr
55
+ });
56
+ }
57
+ } else {
58
+ var _api$userIntent2;
59
+ (_api$userIntent2 = api.userIntent) === null || _api$userIntent2 === void 0 || _api$userIntent2.commands.setCurrentUserIntent(isDragHandle ? 'dragHandleSelected' : 'default')({
60
+ tr: tr
61
+ });
62
+ }
63
+ }
64
+ return tr;
65
+ });
39
66
  }
40
67
  return false;
41
68
  };
@@ -119,18 +119,26 @@ export const blockControlsPlugin = ({
119
119
  toggleMenu: toggleMenuMeta
120
120
  });
121
121
  if ((menuTriggerBy === undefined || !!menuTriggerBy && menuTriggerBy === (options === null || options === void 0 ? void 0 : options.anchorName)) && currentUserIntent === 'blockMenuOpen') {
122
- var _api$userIntent4;
123
- // Toggled from drag handle
124
- api === null || api === void 0 ? void 0 : (_api$userIntent4 = api.userIntent) === null || _api$userIntent4 === void 0 ? void 0 : _api$userIntent4.commands.setCurrentUserIntent('default')({
125
- tr
126
- });
122
+ const state = api === null || api === void 0 ? void 0 : api.blockControls.sharedState.currentState();
123
+ if (state !== null && state !== void 0 && state.isSelectedViaDragHandle && fg('platform_editor_toolbar_aifc_user_intent_fix')) {
124
+ var _api$userIntent4;
125
+ api === null || api === void 0 ? void 0 : (_api$userIntent4 = api.userIntent) === null || _api$userIntent4 === void 0 ? void 0 : _api$userIntent4.commands.setCurrentUserIntent('dragHandleSelected')({
126
+ tr
127
+ });
128
+ } else {
129
+ var _api$userIntent5;
130
+ // Toggled from drag handle
131
+ api === null || api === void 0 ? void 0 : (_api$userIntent5 = api.userIntent) === null || _api$userIntent5 === void 0 ? void 0 : _api$userIntent5.commands.setCurrentUserIntent('default')({
132
+ tr
133
+ });
134
+ }
127
135
  }
128
136
  return tr;
129
137
  },
130
138
  setNodeDragged: (getPos, anchorName, nodeType) => ({
131
139
  tr
132
140
  }) => {
133
- var _api$userIntent5;
141
+ var _api$userIntent6;
134
142
  const pos = getPos();
135
143
  if (pos === undefined) {
136
144
  return tr;
@@ -154,7 +162,7 @@ export const blockControlsPlugin = ({
154
162
  tr
155
163
  });
156
164
  }
157
- api === null || api === void 0 ? void 0 : (_api$userIntent5 = api.userIntent) === null || _api$userIntent5 === void 0 ? void 0 : _api$userIntent5.commands.setCurrentUserIntent('dragging')({
165
+ api === null || api === void 0 ? void 0 : (_api$userIntent6 = api.userIntent) === null || _api$userIntent6 === void 0 ? void 0 : _api$userIntent6.commands.setCurrentUserIntent('dragging')({
158
166
  tr
159
167
  });
160
168
  return tr;
@@ -1,4 +1,5 @@
1
1
  import { DRAG_HANDLE_SELECTOR } from '@atlaskit/editor-common/styles';
2
+ import { fg } from '@atlaskit/platform-feature-flags';
2
3
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
3
4
  import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
4
5
  export const handleMouseDown = api => (view, event) => {
@@ -28,7 +29,34 @@ export const handleMouseDown = api => (view, event) => {
28
29
  }
29
30
  } else {
30
31
  const isDragHandle = event.target.closest(expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true) ? DRAG_HANDLE_SELECTOR : '[data-editor-block-ctrl-drag-handle]') !== null;
31
- api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.setSelectedViaDragHandle(isDragHandle));
32
+ api === null || api === void 0 ? void 0 : api.core.actions.execute(({
33
+ tr
34
+ }) => {
35
+ api === null || api === void 0 ? void 0 : api.blockControls.commands.setSelectedViaDragHandle(isDragHandle)({
36
+ tr
37
+ });
38
+ /**
39
+ * When block menu is enabled, reset intent back to 'default' as editor-plugin-block-menu sets the user intent to 'blockMenuOpen', and setting here
40
+ * causes flickering as this runs before editor-plugin-block-menu.
41
+ */
42
+ if (fg('platform_editor_toolbar_aifc_user_intent_fix')) {
43
+ if (expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true)) {
44
+ // if target is drag handle, block menu will be opened
45
+ if (!isDragHandle) {
46
+ var _api$userIntent;
47
+ api === null || api === void 0 ? void 0 : (_api$userIntent = api.userIntent) === null || _api$userIntent === void 0 ? void 0 : _api$userIntent.commands.setCurrentUserIntent('default')({
48
+ tr
49
+ });
50
+ }
51
+ } else {
52
+ var _api$userIntent2;
53
+ (_api$userIntent2 = api.userIntent) === null || _api$userIntent2 === void 0 ? void 0 : _api$userIntent2.commands.setCurrentUserIntent(isDragHandle ? 'dragHandleSelected' : 'default')({
54
+ tr
55
+ });
56
+ }
57
+ }
58
+ return tr;
59
+ });
32
60
  }
33
61
  return false;
34
62
  };
@@ -118,18 +118,26 @@ export var blockControlsPlugin = function blockControlsPlugin(_ref) {
118
118
  toggleMenu: toggleMenuMeta
119
119
  }));
120
120
  if ((menuTriggerBy === undefined || !!menuTriggerBy && menuTriggerBy === (options === null || options === void 0 ? void 0 : options.anchorName)) && currentUserIntent === 'blockMenuOpen') {
121
- var _api$userIntent4;
122
- // Toggled from drag handle
123
- api === null || api === void 0 || (_api$userIntent4 = api.userIntent) === null || _api$userIntent4 === void 0 || _api$userIntent4.commands.setCurrentUserIntent('default')({
124
- tr: tr
125
- });
121
+ var state = api === null || api === void 0 ? void 0 : api.blockControls.sharedState.currentState();
122
+ if (state !== null && state !== void 0 && state.isSelectedViaDragHandle && fg('platform_editor_toolbar_aifc_user_intent_fix')) {
123
+ var _api$userIntent4;
124
+ api === null || api === void 0 || (_api$userIntent4 = api.userIntent) === null || _api$userIntent4 === void 0 || _api$userIntent4.commands.setCurrentUserIntent('dragHandleSelected')({
125
+ tr: tr
126
+ });
127
+ } else {
128
+ var _api$userIntent5;
129
+ // Toggled from drag handle
130
+ api === null || api === void 0 || (_api$userIntent5 = api.userIntent) === null || _api$userIntent5 === void 0 || _api$userIntent5.commands.setCurrentUserIntent('default')({
131
+ tr: tr
132
+ });
133
+ }
126
134
  }
127
135
  return tr;
128
136
  };
129
137
  },
130
138
  setNodeDragged: function setNodeDragged(getPos, anchorName, nodeType) {
131
139
  return function (_ref5) {
132
- var _api$userIntent5;
140
+ var _api$userIntent6;
133
141
  var tr = _ref5.tr;
134
142
  var pos = getPos();
135
143
  if (pos === undefined) {
@@ -153,7 +161,7 @@ export var blockControlsPlugin = function blockControlsPlugin(_ref) {
153
161
  tr: tr
154
162
  });
155
163
  }
156
- api === null || api === void 0 || (_api$userIntent5 = api.userIntent) === null || _api$userIntent5 === void 0 || _api$userIntent5.commands.setCurrentUserIntent('dragging')({
164
+ api === null || api === void 0 || (_api$userIntent6 = api.userIntent) === null || _api$userIntent6 === void 0 || _api$userIntent6.commands.setCurrentUserIntent('dragging')({
157
165
  tr: tr
158
166
  });
159
167
  return tr;
@@ -1,4 +1,5 @@
1
1
  import { DRAG_HANDLE_SELECTOR } from '@atlaskit/editor-common/styles';
2
+ import { fg } from '@atlaskit/platform-feature-flags';
2
3
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
3
4
  import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
4
5
  export var handleMouseDown = function handleMouseDown(api) {
@@ -29,7 +30,33 @@ export var handleMouseDown = function handleMouseDown(api) {
29
30
  }
30
31
  } else {
31
32
  var isDragHandle = event.target.closest(expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true) ? DRAG_HANDLE_SELECTOR : '[data-editor-block-ctrl-drag-handle]') !== null;
32
- api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.setSelectedViaDragHandle(isDragHandle));
33
+ api === null || api === void 0 || api.core.actions.execute(function (_ref) {
34
+ var tr = _ref.tr;
35
+ api === null || api === void 0 || api.blockControls.commands.setSelectedViaDragHandle(isDragHandle)({
36
+ tr: tr
37
+ });
38
+ /**
39
+ * When block menu is enabled, reset intent back to 'default' as editor-plugin-block-menu sets the user intent to 'blockMenuOpen', and setting here
40
+ * causes flickering as this runs before editor-plugin-block-menu.
41
+ */
42
+ if (fg('platform_editor_toolbar_aifc_user_intent_fix')) {
43
+ if (expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true)) {
44
+ // if target is drag handle, block menu will be opened
45
+ if (!isDragHandle) {
46
+ var _api$userIntent;
47
+ api === null || api === void 0 || (_api$userIntent = api.userIntent) === null || _api$userIntent === void 0 || _api$userIntent.commands.setCurrentUserIntent('default')({
48
+ tr: tr
49
+ });
50
+ }
51
+ } else {
52
+ var _api$userIntent2;
53
+ (_api$userIntent2 = api.userIntent) === null || _api$userIntent2 === void 0 || _api$userIntent2.commands.setCurrentUserIntent(isDragHandle ? 'dragHandleSelected' : 'default')({
54
+ tr: tr
55
+ });
56
+ }
57
+ }
58
+ return tr;
59
+ });
33
60
  }
34
61
  return false;
35
62
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-controls",
3
- "version": "7.3.0",
3
+ "version": "7.4.0",
4
4
  "description": "Block controls plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -42,7 +42,7 @@
42
42
  "@atlaskit/editor-plugin-user-intent": "^4.0.0",
43
43
  "@atlaskit/editor-plugin-width": "^7.0.0",
44
44
  "@atlaskit/editor-prosemirror": "7.0.0",
45
- "@atlaskit/editor-shared-styles": "^3.7.0",
45
+ "@atlaskit/editor-shared-styles": "^3.8.0",
46
46
  "@atlaskit/editor-tables": "^2.9.0",
47
47
  "@atlaskit/icon": "^28.5.0",
48
48
  "@atlaskit/link": "^3.2.0",
@@ -52,9 +52,9 @@
52
52
  "@atlaskit/pragmatic-drag-and-drop-react-drop-indicator": "^3.2.0",
53
53
  "@atlaskit/primitives": "^16.0.0",
54
54
  "@atlaskit/theme": "^21.0.0",
55
- "@atlaskit/tmp-editor-statsig": "^13.13.0",
55
+ "@atlaskit/tmp-editor-statsig": "^13.16.0",
56
56
  "@atlaskit/tokens": "^7.0.0",
57
- "@atlaskit/tooltip": "^20.5.0",
57
+ "@atlaskit/tooltip": "^20.6.0",
58
58
  "@babel/runtime": "^7.0.0",
59
59
  "@emotion/react": "^11.7.1",
60
60
  "@popperjs/core": "^2.11.8",
@@ -64,7 +64,7 @@
64
64
  "uuid": "^3.1.0"
65
65
  },
66
66
  "peerDependencies": {
67
- "@atlaskit/editor-common": "^110.14.0",
67
+ "@atlaskit/editor-common": "^110.15.0",
68
68
  "react": "^18.2.0",
69
69
  "react-dom": "^18.2.0",
70
70
  "react-intl-next": "npm:react-intl@^5.18.1"
@@ -158,6 +158,9 @@
158
158
  },
159
159
  "platform_editor_content_mode_button_mvp": {
160
160
  "type": "boolean"
161
+ },
162
+ "platform_editor_toolbar_aifc_user_intent_fix": {
163
+ "type": "boolean"
161
164
  }
162
165
  }
163
166
  }