@atlaskit/editor-plugin-block-controls 27.0.8 → 28.0.1

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,32 @@
1
1
  # @atlaskit/editor-plugin-block-controls
2
2
 
3
+ ## 28.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 28.0.0
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies
14
+
15
+ ## 27.0.9
16
+
17
+ ### Patch Changes
18
+
19
+ - [`d79264682f5bb`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/d79264682f5bb) -
20
+ Clean up feature gate `platform_editor_column_count_analytics`. The `columnCount` attribute is now
21
+ always included in layout insertion analytics events.
22
+ - [`d98414f1f1017`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/d98414f1f1017) -
23
+ Behind platform_editor_controls_reliable_anchor and
24
+ platform_editor_controls_reliable_anchor_patch_2, ignore the mouseover fired when the editor
25
+ mounts under a stationary pointer so anchor-name is not applied during edit-page and live-doc
26
+ load. This legacy event handling is skipped when platform_editor_block_control_migration is
27
+ enabled.
28
+ - Updated dependencies
29
+
3
30
  ## 27.0.8
4
31
 
5
32
  ### Patch Changes
@@ -293,12 +293,9 @@ var moveToLayout = exports.moveToLayout = function moveToLayout(api) {
293
293
  mode: breakoutMode,
294
294
  width: breakoutWidth
295
295
  })]);
296
- if ((0, _fg.fg)('platform_editor_column_count_analytics')) {
297
- // layout created via drag and drop will always be 2 columns
298
- (0, _analytics.fireInsertLayoutAnalytics)(tr, api, sourceNodeTypes, hasSelectedMultipleNodes, 2);
299
- } else {
300
- (0, _analytics.fireInsertLayoutAnalytics)(tr, api, sourceNodeTypes, hasSelectedMultipleNodes);
301
- }
296
+
297
+ // layout created via drag and drop will always be 2 columns
298
+ (0, _analytics.fireInsertLayoutAnalytics)(tr, api, sourceNodeTypes, hasSelectedMultipleNodes, 2);
302
299
  }
303
300
  return tr;
304
301
  }
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.key = exports.getDecorations = exports.getBlockControlsMeta = exports.createPlugin = exports.apply = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
+ var _bindEventListener = require("bind-event-listener");
9
10
  var _rafSchd = _interopRequireDefault(require("raf-schd"));
10
11
  var _browserApis = require("@atlaskit/browser-apis");
11
12
  var _enums = require("@atlaskit/editor-common/analytics/types/enums");
@@ -998,6 +999,37 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
998
999
  var limitedModeTeardown = {
999
1000
  done: false
1000
1001
  };
1002
+
1003
+ // Edit transition and live-doc load paint the editor under a stationary pointer, which fires
1004
+ // mouseover before VC and never a mousemove. Ignore hover until the pointer moves.
1005
+ var ignoreRestingPointerHover = !(0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_block_control_migration') && (0, _expValEquals.expValEquals)('platform_editor_controls_reliable_anchor', 'isEnabled', true) && (0, _fg.fg)('platform_editor_controls_reliable_anchor_patch_2');
1006
+
1007
+ // When ignoreRestingPointerHover is false, this is always true, so hover is never suppressed.
1008
+ var pointerHasMoved = !ignoreRestingPointerHover;
1009
+ var onMouseOver = function onMouseOver(view, event) {
1010
+ var _api$limitedMode3, _getNodeIdProvider;
1011
+ if (ignoreRestingPointerHover && !pointerHasMoved) {
1012
+ return false;
1013
+ }
1014
+
1015
+ // Sparse surfaces handle all hover in bindSparseGutterHover, which also covers the gutters
1016
+ // outside view.dom.
1017
+ if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_block_control_migration')) {
1018
+ return false;
1019
+ }
1020
+ if (api !== null && api !== void 0 && (_api$limitedMode3 = api.limitedMode) !== null && _api$limitedMode3 !== void 0 && (_api$limitedMode3 = _api$limitedMode3.sharedState.currentState()) !== null && _api$limitedMode3 !== void 0 && _api$limitedMode3.enabled) {
1021
+ return;
1022
+ }
1023
+
1024
+ // another layer of protection to prevent handling mouseover
1025
+ // when native anchor with dnd is enabled in limited mode
1026
+ // in case there are descripancies between getNodeIdProvider limited mode state
1027
+ if ((_getNodeIdProvider = (0, _nodeAnchorProvider.getNodeIdProvider)(view)) !== null && _getNodeIdProvider !== void 0 && _getNodeIdProvider.isLimitedMode() && (0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true)) {
1028
+ return;
1029
+ }
1030
+ (0, _handleMouseOver.handleMouseOver)(view, event, api);
1031
+ return false;
1032
+ };
1001
1033
  return new _safePlugin.SafePlugin({
1002
1034
  key: key,
1003
1035
  state: {
@@ -1010,8 +1042,8 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
1010
1042
  },
1011
1043
  props: {
1012
1044
  decorations: function decorations(state) {
1013
- var _api$limitedMode3, _api$editorDisabled, _key$getState2, _api$editorViewMode3;
1014
- if (api !== null && api !== void 0 && (_api$limitedMode3 = api.limitedMode) !== null && _api$limitedMode3 !== void 0 && (_api$limitedMode3 = _api$limitedMode3.sharedState.currentState()) !== null && _api$limitedMode3 !== void 0 && _api$limitedMode3.enabled) {
1045
+ var _api$limitedMode4, _api$editorDisabled, _key$getState2, _api$editorViewMode3;
1046
+ if (api !== null && api !== void 0 && (_api$limitedMode4 = api.limitedMode) !== null && _api$limitedMode4 !== void 0 && (_api$limitedMode4 = _api$limitedMode4.sharedState.currentState()) !== null && _api$limitedMode4 !== void 0 && _api$limitedMode4.enabled) {
1015
1047
  return;
1016
1048
  }
1017
1049
  var isDisabled = api === null || api === void 0 || (_api$editorDisabled = api.editorDisabled) === null || _api$editorDisabled === void 0 || (_api$editorDisabled = _api$editorDisabled.sharedState.currentState()) === null || _api$editorDisabled === void 0 ? void 0 : _api$editorDisabled.editorDisabled;
@@ -1084,8 +1116,8 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
1084
1116
  return false;
1085
1117
  },
1086
1118
  dragenter: function dragenter(view, event) {
1087
- var _api$limitedMode4, _key$getState3;
1088
- if (api !== null && api !== void 0 && (_api$limitedMode4 = api.limitedMode) !== null && _api$limitedMode4 !== void 0 && (_api$limitedMode4 = _api$limitedMode4.sharedState.currentState()) !== null && _api$limitedMode4 !== void 0 && _api$limitedMode4.enabled) {
1119
+ var _api$limitedMode5, _key$getState3;
1120
+ if (api !== null && api !== void 0 && (_api$limitedMode5 = api.limitedMode) !== null && _api$limitedMode5 !== void 0 && (_api$limitedMode5 = _api$limitedMode5.sharedState.currentState()) !== null && _api$limitedMode5 !== void 0 && _api$limitedMode5.enabled) {
1089
1121
  return;
1090
1122
  }
1091
1123
 
@@ -1125,8 +1157,8 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
1125
1157
  }
1126
1158
  },
1127
1159
  dragstart: function dragstart(view) {
1128
- var _api$limitedMode5, _anchorRectCache2;
1129
- if (api !== null && api !== void 0 && (_api$limitedMode5 = api.limitedMode) !== null && _api$limitedMode5 !== void 0 && (_api$limitedMode5 = _api$limitedMode5.sharedState.currentState()) !== null && _api$limitedMode5 !== void 0 && _api$limitedMode5.enabled) {
1160
+ var _api$limitedMode6, _anchorRectCache2;
1161
+ if (api !== null && api !== void 0 && (_api$limitedMode6 = api.limitedMode) !== null && _api$limitedMode6 !== void 0 && (_api$limitedMode6 = _api$limitedMode6.sharedState.currentState()) !== null && _api$limitedMode6 !== void 0 && _api$limitedMode6.enabled) {
1130
1162
  return;
1131
1163
  }
1132
1164
  if (!(0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_remove_legacy_perf_events')) {
@@ -1145,8 +1177,8 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
1145
1177
  })));
1146
1178
  },
1147
1179
  dragend: function dragend(view) {
1148
- var _api$limitedMode6, _key$getState4;
1149
- if (api !== null && api !== void 0 && (_api$limitedMode6 = api.limitedMode) !== null && _api$limitedMode6 !== void 0 && (_api$limitedMode6 = _api$limitedMode6.sharedState.currentState()) !== null && _api$limitedMode6 !== void 0 && _api$limitedMode6.enabled) {
1180
+ var _api$limitedMode7, _key$getState4;
1181
+ if (api !== null && api !== void 0 && (_api$limitedMode7 = api.limitedMode) !== null && _api$limitedMode7 !== void 0 && (_api$limitedMode7 = _api$limitedMode7.sharedState.currentState()) !== null && _api$limitedMode7 !== void 0 && _api$limitedMode7.enabled) {
1150
1182
  return;
1151
1183
  }
1152
1184
  var state = view.state,
@@ -1165,26 +1197,7 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
1165
1197
  dispatch(tr);
1166
1198
  }
1167
1199
  },
1168
- mouseover: function mouseover(view, event) {
1169
- var _api$limitedMode7, _getNodeIdProvider;
1170
- // Sparse surfaces handle all hover in bindSparseGutterHover, which also covers the gutters
1171
- // outside view.dom.
1172
- if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_block_control_migration')) {
1173
- return false;
1174
- }
1175
- if (api !== null && api !== void 0 && (_api$limitedMode7 = api.limitedMode) !== null && _api$limitedMode7 !== void 0 && (_api$limitedMode7 = _api$limitedMode7.sharedState.currentState()) !== null && _api$limitedMode7 !== void 0 && _api$limitedMode7.enabled) {
1176
- return;
1177
- }
1178
-
1179
- // another layer of protection to prevent handling mouseover
1180
- // when native anchor with dnd is enabled in limited mode
1181
- // in case there are descripancies between getNodeIdProvider limited mode state
1182
- if ((_getNodeIdProvider = (0, _nodeAnchorProvider.getNodeIdProvider)(view)) !== null && _getNodeIdProvider !== void 0 && _getNodeIdProvider.isLimitedMode() && (0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true)) {
1183
- return;
1184
- }
1185
- (0, _handleMouseOver.handleMouseOver)(view, event, api);
1186
- return false;
1187
- },
1200
+ mouseover: onMouseOver,
1188
1201
  mousedown: function mousedown(view, event) {
1189
1202
  var _api$limitedMode8;
1190
1203
  if (api !== null && api !== void 0 && (_api$limitedMode8 = api.limitedMode) !== null && _api$limitedMode8 !== void 0 && (_api$limitedMode8 = _api$limitedMode8.sharedState.currentState()) !== null && _api$limitedMode8 !== void 0 && _api$limitedMode8.enabled) {
@@ -1293,9 +1306,29 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
1293
1306
 
1294
1307
  // Start pragmatic monitors
1295
1308
  pragmaticCleanup = destroyFn(api, editorView);
1309
+ var unbindMouseMove;
1310
+
1311
+ // When ignoreRestingPointerHover is false, pointerHasMoved is always true, so we never
1312
+ // bind. Once the pointer has moved there is nothing left to un-latch.
1313
+ if (!pointerHasMoved) {
1314
+ unbindMouseMove = (0, _bindEventListener.bind)(editorView.dom, {
1315
+ type: 'mousemove',
1316
+ listener: function listener(event) {
1317
+ var _unbindMouseMove;
1318
+ pointerHasMoved = true;
1319
+ (_unbindMouseMove = unbindMouseMove) === null || _unbindMouseMove === void 0 || _unbindMouseMove();
1320
+ onMouseOver(editorView, event);
1321
+ },
1322
+ options: {
1323
+ once: true,
1324
+ passive: true
1325
+ }
1326
+ });
1327
+ }
1296
1328
  return {
1297
1329
  destroy: function destroy() {
1298
- var _pragmaticCleanup;
1330
+ var _unbindMouseMove2, _pragmaticCleanup;
1331
+ (_unbindMouseMove2 = unbindMouseMove) === null || _unbindMouseMove2 === void 0 || _unbindMouseMove2();
1299
1332
  if (editorContentArea) {
1300
1333
  resizeObserverWidth.unobserve(editorContentArea);
1301
1334
  }
@@ -290,12 +290,9 @@ export const moveToLayout = api => (from, to, options) => ({
290
290
  mode: breakoutMode,
291
291
  width: breakoutWidth
292
292
  })]);
293
- if (fg('platform_editor_column_count_analytics')) {
294
- // layout created via drag and drop will always be 2 columns
295
- fireInsertLayoutAnalytics(tr, api, sourceNodeTypes, hasSelectedMultipleNodes, 2);
296
- } else {
297
- fireInsertLayoutAnalytics(tr, api, sourceNodeTypes, hasSelectedMultipleNodes);
298
- }
293
+
294
+ // layout created via drag and drop will always be 2 columns
295
+ fireInsertLayoutAnalytics(tr, api, sourceNodeTypes, hasSelectedMultipleNodes, 2);
299
296
  }
300
297
  return tr;
301
298
  }
@@ -1,3 +1,4 @@
1
+ import { bind } from 'bind-event-listener';
1
2
  import rafSchedule from 'raf-schd';
2
3
  import { getDocument } from '@atlaskit/browser-apis';
3
4
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics/types/enums';
@@ -901,6 +902,37 @@ export const createPlugin = (api, getIntl, nodeViewPortalProviderAPI, nodeDecora
901
902
  const limitedModeTeardown = {
902
903
  done: false
903
904
  };
905
+
906
+ // Edit transition and live-doc load paint the editor under a stationary pointer, which fires
907
+ // mouseover before VC and never a mousemove. Ignore hover until the pointer moves.
908
+ const ignoreRestingPointerHover = !isExperimentEnabled('platform_editor_block_control_migration') && expValEquals('platform_editor_controls_reliable_anchor', 'isEnabled', true) && fg('platform_editor_controls_reliable_anchor_patch_2');
909
+
910
+ // When ignoreRestingPointerHover is false, this is always true, so hover is never suppressed.
911
+ let pointerHasMoved = !ignoreRestingPointerHover;
912
+ const onMouseOver = (view, event) => {
913
+ var _api$limitedMode3, _api$limitedMode3$sha, _getNodeIdProvider;
914
+ if (ignoreRestingPointerHover && !pointerHasMoved) {
915
+ return false;
916
+ }
917
+
918
+ // Sparse surfaces handle all hover in bindSparseGutterHover, which also covers the gutters
919
+ // outside view.dom.
920
+ if (isExperimentEnabled('platform_editor_block_control_migration')) {
921
+ return false;
922
+ }
923
+ if (api !== null && api !== void 0 && (_api$limitedMode3 = api.limitedMode) !== null && _api$limitedMode3 !== void 0 && (_api$limitedMode3$sha = _api$limitedMode3.sharedState.currentState()) !== null && _api$limitedMode3$sha !== void 0 && _api$limitedMode3$sha.enabled) {
924
+ return;
925
+ }
926
+
927
+ // another layer of protection to prevent handling mouseover
928
+ // when native anchor with dnd is enabled in limited mode
929
+ // in case there are descripancies between getNodeIdProvider limited mode state
930
+ if ((_getNodeIdProvider = getNodeIdProvider(view)) !== null && _getNodeIdProvider !== void 0 && _getNodeIdProvider.isLimitedMode() && expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true)) {
931
+ return;
932
+ }
933
+ handleMouseOver(view, event, api);
934
+ return false;
935
+ };
904
936
  return new SafePlugin({
905
937
  key,
906
938
  state: {
@@ -911,8 +943,8 @@ export const createPlugin = (api, getIntl, nodeViewPortalProviderAPI, nodeDecora
911
943
  },
912
944
  props: {
913
945
  decorations: state => {
914
- var _api$limitedMode3, _api$limitedMode3$sha, _api$editorDisabled, _api$editorDisabled$s, _key$getState2, _api$editorViewMode3, _api$editorViewMode3$;
915
- if (api !== null && api !== void 0 && (_api$limitedMode3 = api.limitedMode) !== null && _api$limitedMode3 !== void 0 && (_api$limitedMode3$sha = _api$limitedMode3.sharedState.currentState()) !== null && _api$limitedMode3$sha !== void 0 && _api$limitedMode3$sha.enabled) {
946
+ var _api$limitedMode4, _api$limitedMode4$sha, _api$editorDisabled, _api$editorDisabled$s, _key$getState2, _api$editorViewMode3, _api$editorViewMode3$;
947
+ if (api !== null && api !== void 0 && (_api$limitedMode4 = api.limitedMode) !== null && _api$limitedMode4 !== void 0 && (_api$limitedMode4$sha = _api$limitedMode4.sharedState.currentState()) !== null && _api$limitedMode4$sha !== void 0 && _api$limitedMode4$sha.enabled) {
916
948
  return;
917
949
  }
918
950
  const isDisabled = api === null || api === void 0 ? void 0 : (_api$editorDisabled = api.editorDisabled) === null || _api$editorDisabled === void 0 ? void 0 : (_api$editorDisabled$s = _api$editorDisabled.sharedState.currentState()) === null || _api$editorDisabled$s === void 0 ? void 0 : _api$editorDisabled$s.editorDisabled;
@@ -988,8 +1020,8 @@ export const createPlugin = (api, getIntl, nodeViewPortalProviderAPI, nodeDecora
988
1020
  return false;
989
1021
  },
990
1022
  dragenter(view, event) {
991
- var _api$limitedMode4, _api$limitedMode4$sha, _key$getState3;
992
- if (api !== null && api !== void 0 && (_api$limitedMode4 = api.limitedMode) !== null && _api$limitedMode4 !== void 0 && (_api$limitedMode4$sha = _api$limitedMode4.sharedState.currentState()) !== null && _api$limitedMode4$sha !== void 0 && _api$limitedMode4$sha.enabled) {
1023
+ var _api$limitedMode5, _api$limitedMode5$sha, _key$getState3;
1024
+ if (api !== null && api !== void 0 && (_api$limitedMode5 = api.limitedMode) !== null && _api$limitedMode5 !== void 0 && (_api$limitedMode5$sha = _api$limitedMode5.sharedState.currentState()) !== null && _api$limitedMode5$sha !== void 0 && _api$limitedMode5$sha.enabled) {
993
1025
  return;
994
1026
  }
995
1027
 
@@ -1029,8 +1061,8 @@ export const createPlugin = (api, getIntl, nodeViewPortalProviderAPI, nodeDecora
1029
1061
  }
1030
1062
  },
1031
1063
  dragstart(view) {
1032
- var _api$limitedMode5, _api$limitedMode5$sha, _anchorRectCache2;
1033
- if (api !== null && api !== void 0 && (_api$limitedMode5 = api.limitedMode) !== null && _api$limitedMode5 !== void 0 && (_api$limitedMode5$sha = _api$limitedMode5.sharedState.currentState()) !== null && _api$limitedMode5$sha !== void 0 && _api$limitedMode5$sha.enabled) {
1064
+ var _api$limitedMode6, _api$limitedMode6$sha, _anchorRectCache2;
1065
+ if (api !== null && api !== void 0 && (_api$limitedMode6 = api.limitedMode) !== null && _api$limitedMode6 !== void 0 && (_api$limitedMode6$sha = _api$limitedMode6.sharedState.currentState()) !== null && _api$limitedMode6$sha !== void 0 && _api$limitedMode6$sha.enabled) {
1034
1066
  return;
1035
1067
  }
1036
1068
  if (!isExperimentEnabled('platform_editor_remove_legacy_perf_events')) {
@@ -1050,8 +1082,8 @@ export const createPlugin = (api, getIntl, nodeViewPortalProviderAPI, nodeDecora
1050
1082
  }));
1051
1083
  },
1052
1084
  dragend(view) {
1053
- var _api$limitedMode6, _api$limitedMode6$sha, _key$getState4;
1054
- if (api !== null && api !== void 0 && (_api$limitedMode6 = api.limitedMode) !== null && _api$limitedMode6 !== void 0 && (_api$limitedMode6$sha = _api$limitedMode6.sharedState.currentState()) !== null && _api$limitedMode6$sha !== void 0 && _api$limitedMode6$sha.enabled) {
1085
+ var _api$limitedMode7, _api$limitedMode7$sha, _key$getState4;
1086
+ if (api !== null && api !== void 0 && (_api$limitedMode7 = api.limitedMode) !== null && _api$limitedMode7 !== void 0 && (_api$limitedMode7$sha = _api$limitedMode7.sharedState.currentState()) !== null && _api$limitedMode7$sha !== void 0 && _api$limitedMode7$sha.enabled) {
1055
1087
  return;
1056
1088
  }
1057
1089
  const {
@@ -1073,26 +1105,7 @@ export const createPlugin = (api, getIntl, nodeViewPortalProviderAPI, nodeDecora
1073
1105
  dispatch(tr);
1074
1106
  }
1075
1107
  },
1076
- mouseover: (view, event) => {
1077
- var _api$limitedMode7, _api$limitedMode7$sha, _getNodeIdProvider;
1078
- // Sparse surfaces handle all hover in bindSparseGutterHover, which also covers the gutters
1079
- // outside view.dom.
1080
- if (isExperimentEnabled('platform_editor_block_control_migration')) {
1081
- return false;
1082
- }
1083
- if (api !== null && api !== void 0 && (_api$limitedMode7 = api.limitedMode) !== null && _api$limitedMode7 !== void 0 && (_api$limitedMode7$sha = _api$limitedMode7.sharedState.currentState()) !== null && _api$limitedMode7$sha !== void 0 && _api$limitedMode7$sha.enabled) {
1084
- return;
1085
- }
1086
-
1087
- // another layer of protection to prevent handling mouseover
1088
- // when native anchor with dnd is enabled in limited mode
1089
- // in case there are descripancies between getNodeIdProvider limited mode state
1090
- if ((_getNodeIdProvider = getNodeIdProvider(view)) !== null && _getNodeIdProvider !== void 0 && _getNodeIdProvider.isLimitedMode() && expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true)) {
1091
- return;
1092
- }
1093
- handleMouseOver(view, event, api);
1094
- return false;
1095
- },
1108
+ mouseover: onMouseOver,
1096
1109
  mousedown: (view, event) => {
1097
1110
  var _api$limitedMode8, _api$limitedMode8$sha;
1098
1111
  if (api !== null && api !== void 0 && (_api$limitedMode8 = api.limitedMode) !== null && _api$limitedMode8 !== void 0 && (_api$limitedMode8$sha = _api$limitedMode8.sharedState.currentState()) !== null && _api$limitedMode8$sha !== void 0 && _api$limitedMode8$sha.enabled) {
@@ -1204,9 +1217,29 @@ export const createPlugin = (api, getIntl, nodeViewPortalProviderAPI, nodeDecora
1204
1217
 
1205
1218
  // Start pragmatic monitors
1206
1219
  pragmaticCleanup = destroyFn(api, editorView);
1220
+ let unbindMouseMove;
1221
+
1222
+ // When ignoreRestingPointerHover is false, pointerHasMoved is always true, so we never
1223
+ // bind. Once the pointer has moved there is nothing left to un-latch.
1224
+ if (!pointerHasMoved) {
1225
+ unbindMouseMove = bind(editorView.dom, {
1226
+ type: 'mousemove',
1227
+ listener: event => {
1228
+ var _unbindMouseMove;
1229
+ pointerHasMoved = true;
1230
+ (_unbindMouseMove = unbindMouseMove) === null || _unbindMouseMove === void 0 ? void 0 : _unbindMouseMove();
1231
+ onMouseOver(editorView, event);
1232
+ },
1233
+ options: {
1234
+ once: true,
1235
+ passive: true
1236
+ }
1237
+ });
1238
+ }
1207
1239
  return {
1208
1240
  destroy() {
1209
- var _pragmaticCleanup;
1241
+ var _unbindMouseMove2, _pragmaticCleanup;
1242
+ (_unbindMouseMove2 = unbindMouseMove) === null || _unbindMouseMove2 === void 0 ? void 0 : _unbindMouseMove2();
1210
1243
  if (editorContentArea) {
1211
1244
  resizeObserverWidth.unobserve(editorContentArea);
1212
1245
  }
@@ -287,12 +287,9 @@ export var moveToLayout = function moveToLayout(api) {
287
287
  mode: breakoutMode,
288
288
  width: breakoutWidth
289
289
  })]);
290
- if (fg('platform_editor_column_count_analytics')) {
291
- // layout created via drag and drop will always be 2 columns
292
- fireInsertLayoutAnalytics(tr, api, sourceNodeTypes, hasSelectedMultipleNodes, 2);
293
- } else {
294
- fireInsertLayoutAnalytics(tr, api, sourceNodeTypes, hasSelectedMultipleNodes);
295
- }
290
+
291
+ // layout created via drag and drop will always be 2 columns
292
+ fireInsertLayoutAnalytics(tr, api, sourceNodeTypes, hasSelectedMultipleNodes, 2);
296
293
  }
297
294
  return tr;
298
295
  }
@@ -4,6 +4,7 @@ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r)
4
4
  function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
5
5
  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; }
6
6
  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; }
7
+ import { bind } from 'bind-event-listener';
7
8
  import rafSchedule from 'raf-schd';
8
9
  import { getDocument } from '@atlaskit/browser-apis';
9
10
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics/types/enums';
@@ -992,6 +993,37 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
992
993
  var limitedModeTeardown = {
993
994
  done: false
994
995
  };
996
+
997
+ // Edit transition and live-doc load paint the editor under a stationary pointer, which fires
998
+ // mouseover before VC and never a mousemove. Ignore hover until the pointer moves.
999
+ var ignoreRestingPointerHover = !isExperimentEnabled('platform_editor_block_control_migration') && expValEquals('platform_editor_controls_reliable_anchor', 'isEnabled', true) && fg('platform_editor_controls_reliable_anchor_patch_2');
1000
+
1001
+ // When ignoreRestingPointerHover is false, this is always true, so hover is never suppressed.
1002
+ var pointerHasMoved = !ignoreRestingPointerHover;
1003
+ var onMouseOver = function onMouseOver(view, event) {
1004
+ var _api$limitedMode3, _getNodeIdProvider;
1005
+ if (ignoreRestingPointerHover && !pointerHasMoved) {
1006
+ return false;
1007
+ }
1008
+
1009
+ // Sparse surfaces handle all hover in bindSparseGutterHover, which also covers the gutters
1010
+ // outside view.dom.
1011
+ if (isExperimentEnabled('platform_editor_block_control_migration')) {
1012
+ return false;
1013
+ }
1014
+ if (api !== null && api !== void 0 && (_api$limitedMode3 = api.limitedMode) !== null && _api$limitedMode3 !== void 0 && (_api$limitedMode3 = _api$limitedMode3.sharedState.currentState()) !== null && _api$limitedMode3 !== void 0 && _api$limitedMode3.enabled) {
1015
+ return;
1016
+ }
1017
+
1018
+ // another layer of protection to prevent handling mouseover
1019
+ // when native anchor with dnd is enabled in limited mode
1020
+ // in case there are descripancies between getNodeIdProvider limited mode state
1021
+ if ((_getNodeIdProvider = getNodeIdProvider(view)) !== null && _getNodeIdProvider !== void 0 && _getNodeIdProvider.isLimitedMode() && expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true)) {
1022
+ return;
1023
+ }
1024
+ handleMouseOver(view, event, api);
1025
+ return false;
1026
+ };
995
1027
  return new SafePlugin({
996
1028
  key: key,
997
1029
  state: {
@@ -1004,8 +1036,8 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
1004
1036
  },
1005
1037
  props: {
1006
1038
  decorations: function decorations(state) {
1007
- var _api$limitedMode3, _api$editorDisabled, _key$getState2, _api$editorViewMode3;
1008
- if (api !== null && api !== void 0 && (_api$limitedMode3 = api.limitedMode) !== null && _api$limitedMode3 !== void 0 && (_api$limitedMode3 = _api$limitedMode3.sharedState.currentState()) !== null && _api$limitedMode3 !== void 0 && _api$limitedMode3.enabled) {
1039
+ var _api$limitedMode4, _api$editorDisabled, _key$getState2, _api$editorViewMode3;
1040
+ if (api !== null && api !== void 0 && (_api$limitedMode4 = api.limitedMode) !== null && _api$limitedMode4 !== void 0 && (_api$limitedMode4 = _api$limitedMode4.sharedState.currentState()) !== null && _api$limitedMode4 !== void 0 && _api$limitedMode4.enabled) {
1009
1041
  return;
1010
1042
  }
1011
1043
  var isDisabled = api === null || api === void 0 || (_api$editorDisabled = api.editorDisabled) === null || _api$editorDisabled === void 0 || (_api$editorDisabled = _api$editorDisabled.sharedState.currentState()) === null || _api$editorDisabled === void 0 ? void 0 : _api$editorDisabled.editorDisabled;
@@ -1078,8 +1110,8 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
1078
1110
  return false;
1079
1111
  },
1080
1112
  dragenter: function dragenter(view, event) {
1081
- var _api$limitedMode4, _key$getState3;
1082
- if (api !== null && api !== void 0 && (_api$limitedMode4 = api.limitedMode) !== null && _api$limitedMode4 !== void 0 && (_api$limitedMode4 = _api$limitedMode4.sharedState.currentState()) !== null && _api$limitedMode4 !== void 0 && _api$limitedMode4.enabled) {
1113
+ var _api$limitedMode5, _key$getState3;
1114
+ if (api !== null && api !== void 0 && (_api$limitedMode5 = api.limitedMode) !== null && _api$limitedMode5 !== void 0 && (_api$limitedMode5 = _api$limitedMode5.sharedState.currentState()) !== null && _api$limitedMode5 !== void 0 && _api$limitedMode5.enabled) {
1083
1115
  return;
1084
1116
  }
1085
1117
 
@@ -1119,8 +1151,8 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
1119
1151
  }
1120
1152
  },
1121
1153
  dragstart: function dragstart(view) {
1122
- var _api$limitedMode5, _anchorRectCache2;
1123
- if (api !== null && api !== void 0 && (_api$limitedMode5 = api.limitedMode) !== null && _api$limitedMode5 !== void 0 && (_api$limitedMode5 = _api$limitedMode5.sharedState.currentState()) !== null && _api$limitedMode5 !== void 0 && _api$limitedMode5.enabled) {
1154
+ var _api$limitedMode6, _anchorRectCache2;
1155
+ if (api !== null && api !== void 0 && (_api$limitedMode6 = api.limitedMode) !== null && _api$limitedMode6 !== void 0 && (_api$limitedMode6 = _api$limitedMode6.sharedState.currentState()) !== null && _api$limitedMode6 !== void 0 && _api$limitedMode6.enabled) {
1124
1156
  return;
1125
1157
  }
1126
1158
  if (!isExperimentEnabled('platform_editor_remove_legacy_perf_events')) {
@@ -1139,8 +1171,8 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
1139
1171
  })));
1140
1172
  },
1141
1173
  dragend: function dragend(view) {
1142
- var _api$limitedMode6, _key$getState4;
1143
- if (api !== null && api !== void 0 && (_api$limitedMode6 = api.limitedMode) !== null && _api$limitedMode6 !== void 0 && (_api$limitedMode6 = _api$limitedMode6.sharedState.currentState()) !== null && _api$limitedMode6 !== void 0 && _api$limitedMode6.enabled) {
1174
+ var _api$limitedMode7, _key$getState4;
1175
+ if (api !== null && api !== void 0 && (_api$limitedMode7 = api.limitedMode) !== null && _api$limitedMode7 !== void 0 && (_api$limitedMode7 = _api$limitedMode7.sharedState.currentState()) !== null && _api$limitedMode7 !== void 0 && _api$limitedMode7.enabled) {
1144
1176
  return;
1145
1177
  }
1146
1178
  var state = view.state,
@@ -1159,26 +1191,7 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
1159
1191
  dispatch(tr);
1160
1192
  }
1161
1193
  },
1162
- mouseover: function mouseover(view, event) {
1163
- var _api$limitedMode7, _getNodeIdProvider;
1164
- // Sparse surfaces handle all hover in bindSparseGutterHover, which also covers the gutters
1165
- // outside view.dom.
1166
- if (isExperimentEnabled('platform_editor_block_control_migration')) {
1167
- return false;
1168
- }
1169
- if (api !== null && api !== void 0 && (_api$limitedMode7 = api.limitedMode) !== null && _api$limitedMode7 !== void 0 && (_api$limitedMode7 = _api$limitedMode7.sharedState.currentState()) !== null && _api$limitedMode7 !== void 0 && _api$limitedMode7.enabled) {
1170
- return;
1171
- }
1172
-
1173
- // another layer of protection to prevent handling mouseover
1174
- // when native anchor with dnd is enabled in limited mode
1175
- // in case there are descripancies between getNodeIdProvider limited mode state
1176
- if ((_getNodeIdProvider = getNodeIdProvider(view)) !== null && _getNodeIdProvider !== void 0 && _getNodeIdProvider.isLimitedMode() && expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true)) {
1177
- return;
1178
- }
1179
- handleMouseOver(view, event, api);
1180
- return false;
1181
- },
1194
+ mouseover: onMouseOver,
1182
1195
  mousedown: function mousedown(view, event) {
1183
1196
  var _api$limitedMode8;
1184
1197
  if (api !== null && api !== void 0 && (_api$limitedMode8 = api.limitedMode) !== null && _api$limitedMode8 !== void 0 && (_api$limitedMode8 = _api$limitedMode8.sharedState.currentState()) !== null && _api$limitedMode8 !== void 0 && _api$limitedMode8.enabled) {
@@ -1287,9 +1300,29 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
1287
1300
 
1288
1301
  // Start pragmatic monitors
1289
1302
  pragmaticCleanup = destroyFn(api, editorView);
1303
+ var unbindMouseMove;
1304
+
1305
+ // When ignoreRestingPointerHover is false, pointerHasMoved is always true, so we never
1306
+ // bind. Once the pointer has moved there is nothing left to un-latch.
1307
+ if (!pointerHasMoved) {
1308
+ unbindMouseMove = bind(editorView.dom, {
1309
+ type: 'mousemove',
1310
+ listener: function listener(event) {
1311
+ var _unbindMouseMove;
1312
+ pointerHasMoved = true;
1313
+ (_unbindMouseMove = unbindMouseMove) === null || _unbindMouseMove === void 0 || _unbindMouseMove();
1314
+ onMouseOver(editorView, event);
1315
+ },
1316
+ options: {
1317
+ once: true,
1318
+ passive: true
1319
+ }
1320
+ });
1321
+ }
1290
1322
  return {
1291
1323
  destroy: function destroy() {
1292
- var _pragmaticCleanup;
1324
+ var _unbindMouseMove2, _pragmaticCleanup;
1325
+ (_unbindMouseMove2 = unbindMouseMove) === null || _unbindMouseMove2 === void 0 || _unbindMouseMove2();
1293
1326
  if (editorContentArea) {
1294
1327
  resizeObserverWidth.unobserve(editorContentArea);
1295
1328
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-controls",
3
- "version": "27.0.8",
3
+ "version": "28.0.1",
4
4
  "description": "Block controls plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -29,23 +29,23 @@
29
29
  "@atlaskit/button": "^25.4.0",
30
30
  "@atlaskit/css": "^1.1.0",
31
31
  "@atlaskit/docs": "^12.3.0",
32
- "@atlaskit/editor-plugin-accessibility-utils": "^26.0.0",
33
- "@atlaskit/editor-plugin-analytics": "^26.0.0",
34
- "@atlaskit/editor-plugin-block-collapse": "^12.0.0",
35
- "@atlaskit/editor-plugin-editor-disabled": "^26.0.0",
36
- "@atlaskit/editor-plugin-editor-viewmode": "^28.0.0",
37
- "@atlaskit/editor-plugin-feature-flags": "^25.0.0",
38
- "@atlaskit/editor-plugin-interaction": "^40.0.0",
39
- "@atlaskit/editor-plugin-limited-mode": "^23.0.0",
40
- "@atlaskit/editor-plugin-metrics": "^27.0.0",
41
- "@atlaskit/editor-plugin-quick-insert": "^26.1.0",
42
- "@atlaskit/editor-plugin-selection": "^26.0.0",
43
- "@atlaskit/editor-plugin-show-diff": "^24.1.0",
44
- "@atlaskit/editor-plugin-toolbar": "^23.0.0",
45
- "@atlaskit/editor-plugin-type-ahead": "^27.0.0",
46
- "@atlaskit/editor-plugin-ui-control-registry": "^20.0.0",
47
- "@atlaskit/editor-plugin-user-intent": "^24.0.0",
48
- "@atlaskit/editor-plugin-width": "^27.0.0",
32
+ "@atlaskit/editor-plugin-accessibility-utils": "^27.0.0",
33
+ "@atlaskit/editor-plugin-analytics": "^27.0.0",
34
+ "@atlaskit/editor-plugin-block-collapse": "^13.0.0",
35
+ "@atlaskit/editor-plugin-editor-disabled": "^27.0.0",
36
+ "@atlaskit/editor-plugin-editor-viewmode": "^29.0.0",
37
+ "@atlaskit/editor-plugin-feature-flags": "^26.0.0",
38
+ "@atlaskit/editor-plugin-interaction": "^41.0.0",
39
+ "@atlaskit/editor-plugin-limited-mode": "^24.0.0",
40
+ "@atlaskit/editor-plugin-metrics": "^28.0.0",
41
+ "@atlaskit/editor-plugin-quick-insert": "^27.0.0",
42
+ "@atlaskit/editor-plugin-selection": "^27.0.0",
43
+ "@atlaskit/editor-plugin-show-diff": "^25.0.0",
44
+ "@atlaskit/editor-plugin-toolbar": "^24.0.0",
45
+ "@atlaskit/editor-plugin-type-ahead": "^28.0.0",
46
+ "@atlaskit/editor-plugin-ui-control-registry": "^21.0.0",
47
+ "@atlaskit/editor-plugin-user-intent": "^25.0.0",
48
+ "@atlaskit/editor-plugin-width": "^28.0.0",
49
49
  "@atlaskit/editor-prosemirror": "^9.0.0",
50
50
  "@atlaskit/editor-shared-styles": "^4.4.0",
51
51
  "@atlaskit/editor-tables": "^3.2.0",
@@ -61,8 +61,8 @@
61
61
  "@atlaskit/primitives": "^22.5.0",
62
62
  "@atlaskit/section-message": "^10.2.0",
63
63
  "@atlaskit/theme": "^28.2.0",
64
- "@atlaskit/tmp-editor-statsig": "^234.0.0",
65
- "@atlaskit/tokens": "^20.4.0",
64
+ "@atlaskit/tmp-editor-statsig": "^236.0.0",
65
+ "@atlaskit/tokens": "^20.5.0",
66
66
  "@atlaskit/tooltip": "^24.4.0",
67
67
  "@babel/runtime": "^7.0.0",
68
68
  "@compiled/react": "^1.0.2",
@@ -73,7 +73,7 @@
73
73
  "uuid": "^11.1.1"
74
74
  },
75
75
  "peerDependencies": {
76
- "@atlaskit/editor-common": "^130.5.0",
76
+ "@atlaskit/editor-common": "^131.0.0",
77
77
  "react": "^18.2.0 || ^19.2.0",
78
78
  "react-dom": "^18.2.0 || ^19.2.0",
79
79
  "react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
@@ -85,9 +85,6 @@
85
85
  "platform_editor_drag_and_drop_perf_analytics": {
86
86
  "type": "boolean"
87
87
  },
88
- "platform_editor_column_count_analytics": {
89
- "type": "boolean"
90
- },
91
88
  "platform_editor_content_mode_button_mvp": {
92
89
  "type": "boolean"
93
90
  },
@@ -100,6 +97,9 @@
100
97
  "platform_editor_controls_reliable_anchor_patch_1": {
101
98
  "type": "boolean"
102
99
  },
100
+ "platform_editor_controls_reliable_anchor_patch_2": {
101
+ "type": "boolean"
102
+ },
103
103
  "platform-dst-top-layer-tooltip": {
104
104
  "type": "boolean",
105
105
  "referenceOnly": true