@atlaskit/editor-plugin-block-menu 5.2.16 → 5.2.17

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,15 @@
1
1
  # @atlaskit/editor-plugin-block-menu
2
2
 
3
+ ## 5.2.17
4
+
5
+ ### Patch Changes
6
+
7
+ - [`1da3868c8f709`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/1da3868c8f709) -
8
+ EDITOR-3916 Fix block menu alternating on drag handle click
9
+ - [`722f272e8b78f`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/722f272e8b78f) -
10
+ Editor-2778: Smartlink card and embed transform
11
+ - Updated dependencies
12
+
3
13
  ## 5.2.16
4
14
 
5
15
  ### Patch Changes
@@ -129,6 +129,12 @@ var TRANSFORM_STEPS_OVERRIDE = {
129
129
  orderedList: [_decisionListToListStep.decisionListToListStep],
130
130
  taskList: [_decisionListToListStep.decisionListToListStep],
131
131
  layoutSection: [_wrapIntoLayoutStep.wrapIntoLayoutStep]
132
+ },
133
+ blockCard: {
134
+ layoutSection: [_wrapIntoLayoutStep.wrapIntoLayoutStep]
135
+ },
136
+ embedCard: {
137
+ layoutSection: [_wrapIntoLayoutStep.wrapIntoLayoutStep]
132
138
  }
133
139
  };
134
140
  var getTransformStepsForNodeTypes = function getTransformStepsForNodeTypes(selectedNodeTypeName, targetNodeTypeName) {
@@ -26,8 +26,9 @@ var transformNode = exports.transformNode = function transformNode(api) {
26
26
  var _expandSelectionToBlo = (0, _selection.expandSelectionToBlockRange)(preservedSelection),
27
27
  $from = _expandSelectionToBlo.$from,
28
28
  $to = _expandSelectionToBlo.$to;
29
- var isNested = (0, _isNestedNode.isNestedNode)(preservedSelection, '');
30
29
  var selectedParent = $from.parent;
30
+ var isParentLayout = selectedParent.type === nodes.layoutColumn;
31
+ var isNestedExceptLayout = (0, _isNestedNode.isNestedNode)(preservedSelection, '') && !isParentLayout;
31
32
  var fragment = _model.Fragment.empty;
32
33
  var isList = (0, _utils.isListNode)(selectedParent);
33
34
  var slice = tr.doc.slice(isList ? $from.pos - 1 : $from.pos, isList ? $to.pos + 1 : $to.pos);
@@ -36,7 +37,7 @@ var transformNode = exports.transformNode = function transformNode(api) {
36
37
  sourceNode: node,
37
38
  targetNodeType: targetType,
38
39
  schema: tr.doc.type.schema,
39
- isNested: isNested
40
+ isNested: isNestedExceptLayout
40
41
  });
41
42
  if (outputNode) {
42
43
  fragment = fragment.append(_model.Fragment.fromArray(outputNode));
@@ -127,7 +127,7 @@ var BlockMenuContent = function BlockMenuContent(_ref3) {
127
127
  })));
128
128
  };
129
129
  var BlockMenu = function BlockMenu(_ref4) {
130
- var _editorView$dom, _ref5;
130
+ var _editorView$dom, _ref5, _api$analytics3;
131
131
  var editorView = _ref4.editorView,
132
132
  api = _ref4.api,
133
133
  mountTo = _ref4.mountTo,
@@ -202,6 +202,13 @@ var BlockMenu = function BlockMenu(_ref4) {
202
202
  return tr;
203
203
  });
204
204
  };
205
+ var handleClickOutside = function handleClickOutside(e) {
206
+ // check if the clicked element was another drag handle, if so don't close the menu
207
+ if (e.target instanceof HTMLElement && e.target.closest(_styles.DRAG_HANDLE_SELECTOR)) {
208
+ return;
209
+ }
210
+ closeMenu();
211
+ };
205
212
  var closeMenu = function closeMenu() {
206
213
  api === null || api === void 0 || api.core.actions.execute(function (_ref7) {
207
214
  var _api$blockControls3, _api$userIntent3;
@@ -227,39 +234,37 @@ var BlockMenu = function BlockMenu(_ref4) {
227
234
  popupRef.current = el;
228
235
  }
229
236
  };
230
- if (targetHandleRef instanceof HTMLElement) {
231
- var _api$analytics3;
232
- return /*#__PURE__*/_react.default.createElement(_errorBoundary.ErrorBoundary, {
233
- component: _analytics.ACTION_SUBJECT.BLOCK_MENU,
234
- dispatchAnalyticsEvent: api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions.fireAnalyticsEvent,
235
- fallbackComponent: null
236
- }, /*#__PURE__*/_react.default.createElement(PopupWithListeners, {
237
- alignX: 'right',
238
- alignY: 'start',
239
- handleClickOutside: closeMenu,
240
- handleEscapeKeydown: closeMenu,
241
- handleBackspaceDeleteKeydown: handleBackspaceDeleteKeydown,
242
- mountTo: mountTo,
243
- boundariesElement: boundariesElement,
244
- scrollableElement: scrollableElement,
245
- target: targetHandleRef,
246
- zIndex: _editorSharedStyles.akEditorFloatingOverlapPanelZIndex,
247
- fitWidth: DEFAULT_MENU_WIDTH,
248
- fitHeight: menuHeight,
249
- preventOverflow: true,
250
- stick: true,
251
- offset: [_styles.DRAG_HANDLE_WIDTH + DRAG_HANDLE_OFFSET_PADDING, targetHandleHeightOffset],
252
- focusTrap: openedViaKeyboard ?
253
- // Only enable focus trap when opened via keyboard to make sure the focus is on the first focusable menu item
254
- {
255
- initialFocus: undefined
256
- } : undefined
257
- }, /*#__PURE__*/_react.default.createElement(BlockMenuContent, {
258
- api: api,
259
- setRef: setRef
260
- })));
261
- } else {
237
+ if (!(targetHandleRef instanceof HTMLElement)) {
262
238
  return null;
263
239
  }
240
+ return /*#__PURE__*/_react.default.createElement(_errorBoundary.ErrorBoundary, {
241
+ component: _analytics.ACTION_SUBJECT.BLOCK_MENU,
242
+ dispatchAnalyticsEvent: api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions.fireAnalyticsEvent,
243
+ fallbackComponent: null
244
+ }, /*#__PURE__*/_react.default.createElement(PopupWithListeners, {
245
+ alignX: 'right',
246
+ alignY: 'start',
247
+ handleClickOutside: handleClickOutside,
248
+ handleEscapeKeydown: closeMenu,
249
+ handleBackspaceDeleteKeydown: handleBackspaceDeleteKeydown,
250
+ mountTo: mountTo,
251
+ boundariesElement: boundariesElement,
252
+ scrollableElement: scrollableElement,
253
+ target: targetHandleRef,
254
+ zIndex: _editorSharedStyles.akEditorFloatingOverlapPanelZIndex,
255
+ fitWidth: DEFAULT_MENU_WIDTH,
256
+ fitHeight: menuHeight,
257
+ preventOverflow: true,
258
+ stick: true,
259
+ offset: [_styles.DRAG_HANDLE_WIDTH + DRAG_HANDLE_OFFSET_PADDING, targetHandleHeightOffset],
260
+ focusTrap: openedViaKeyboard ?
261
+ // Only enable focus trap when opened via keyboard to make sure the focus is on the first focusable menu item
262
+ {
263
+ initialFocus: undefined
264
+ } : undefined
265
+ }, /*#__PURE__*/_react.default.createElement(BlockMenuContent, {
266
+ api: api,
267
+ setRef: setRef
268
+ })));
264
269
  };
265
270
  var _default = exports.default = (0, _reactIntlNext.injectIntl)(BlockMenu);
@@ -124,6 +124,12 @@ const TRANSFORM_STEPS_OVERRIDE = {
124
124
  orderedList: [decisionListToListStep],
125
125
  taskList: [decisionListToListStep],
126
126
  layoutSection: [wrapIntoLayoutStep]
127
+ },
128
+ blockCard: {
129
+ layoutSection: [wrapIntoLayoutStep]
130
+ },
131
+ embedCard: {
132
+ layoutSection: [wrapIntoLayoutStep]
127
133
  }
128
134
  };
129
135
  const getTransformStepsForNodeTypes = (selectedNodeTypeName, targetNodeTypeName) => {
@@ -23,8 +23,9 @@ export const transformNode = api =>
23
23
  $from,
24
24
  $to
25
25
  } = expandSelectionToBlockRange(preservedSelection);
26
- const isNested = isNestedNode(preservedSelection, '');
27
26
  const selectedParent = $from.parent;
27
+ const isParentLayout = selectedParent.type === nodes.layoutColumn;
28
+ const isNestedExceptLayout = isNestedNode(preservedSelection, '') && !isParentLayout;
28
29
  let fragment = Fragment.empty;
29
30
  const isList = isListNode(selectedParent);
30
31
  const slice = tr.doc.slice(isList ? $from.pos - 1 : $from.pos, isList ? $to.pos + 1 : $to.pos);
@@ -33,7 +34,7 @@ export const transformNode = api =>
33
34
  sourceNode: node,
34
35
  targetNodeType: targetType,
35
36
  schema: tr.doc.type.schema,
36
- isNested
37
+ isNested: isNestedExceptLayout
37
38
  });
38
39
  if (outputNode) {
39
40
  fragment = fragment.append(Fragment.fromArray(outputNode));
@@ -124,7 +124,7 @@ const BlockMenu = ({
124
124
  boundariesElement,
125
125
  scrollableElement
126
126
  }) => {
127
- var _editorView$dom, _ref;
127
+ var _editorView$dom, _ref, _api$analytics3;
128
128
  const {
129
129
  menuTriggerBy,
130
130
  isSelectedViaDragHandle,
@@ -194,6 +194,13 @@ const BlockMenu = ({
194
194
  return tr;
195
195
  });
196
196
  };
197
+ const handleClickOutside = e => {
198
+ // check if the clicked element was another drag handle, if so don't close the menu
199
+ if (e.target instanceof HTMLElement && e.target.closest(DRAG_HANDLE_SELECTOR)) {
200
+ return;
201
+ }
202
+ closeMenu();
203
+ };
197
204
  const closeMenu = () => {
198
205
  api === null || api === void 0 ? void 0 : api.core.actions.execute(({
199
206
  tr
@@ -220,39 +227,37 @@ const BlockMenu = ({
220
227
  popupRef.current = el;
221
228
  }
222
229
  };
223
- if (targetHandleRef instanceof HTMLElement) {
224
- var _api$analytics3;
225
- return /*#__PURE__*/React.createElement(ErrorBoundary, {
226
- component: ACTION_SUBJECT.BLOCK_MENU,
227
- dispatchAnalyticsEvent: api === null || api === void 0 ? void 0 : (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions.fireAnalyticsEvent,
228
- fallbackComponent: null
229
- }, /*#__PURE__*/React.createElement(PopupWithListeners, {
230
- alignX: 'right',
231
- alignY: 'start',
232
- handleClickOutside: closeMenu,
233
- handleEscapeKeydown: closeMenu,
234
- handleBackspaceDeleteKeydown: handleBackspaceDeleteKeydown,
235
- mountTo: mountTo,
236
- boundariesElement: boundariesElement,
237
- scrollableElement: scrollableElement,
238
- target: targetHandleRef,
239
- zIndex: akEditorFloatingOverlapPanelZIndex,
240
- fitWidth: DEFAULT_MENU_WIDTH,
241
- fitHeight: menuHeight,
242
- preventOverflow: true,
243
- stick: true,
244
- offset: [DRAG_HANDLE_WIDTH + DRAG_HANDLE_OFFSET_PADDING, targetHandleHeightOffset],
245
- focusTrap: openedViaKeyboard ?
246
- // Only enable focus trap when opened via keyboard to make sure the focus is on the first focusable menu item
247
- {
248
- initialFocus: undefined
249
- } : undefined
250
- }, /*#__PURE__*/React.createElement(BlockMenuContent, {
251
- api: api,
252
- setRef: setRef
253
- })));
254
- } else {
230
+ if (!(targetHandleRef instanceof HTMLElement)) {
255
231
  return null;
256
232
  }
233
+ return /*#__PURE__*/React.createElement(ErrorBoundary, {
234
+ component: ACTION_SUBJECT.BLOCK_MENU,
235
+ dispatchAnalyticsEvent: api === null || api === void 0 ? void 0 : (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions.fireAnalyticsEvent,
236
+ fallbackComponent: null
237
+ }, /*#__PURE__*/React.createElement(PopupWithListeners, {
238
+ alignX: 'right',
239
+ alignY: 'start',
240
+ handleClickOutside: handleClickOutside,
241
+ handleEscapeKeydown: closeMenu,
242
+ handleBackspaceDeleteKeydown: handleBackspaceDeleteKeydown,
243
+ mountTo: mountTo,
244
+ boundariesElement: boundariesElement,
245
+ scrollableElement: scrollableElement,
246
+ target: targetHandleRef,
247
+ zIndex: akEditorFloatingOverlapPanelZIndex,
248
+ fitWidth: DEFAULT_MENU_WIDTH,
249
+ fitHeight: menuHeight,
250
+ preventOverflow: true,
251
+ stick: true,
252
+ offset: [DRAG_HANDLE_WIDTH + DRAG_HANDLE_OFFSET_PADDING, targetHandleHeightOffset],
253
+ focusTrap: openedViaKeyboard ?
254
+ // Only enable focus trap when opened via keyboard to make sure the focus is on the first focusable menu item
255
+ {
256
+ initialFocus: undefined
257
+ } : undefined
258
+ }, /*#__PURE__*/React.createElement(BlockMenuContent, {
259
+ api: api,
260
+ setRef: setRef
261
+ })));
257
262
  };
258
263
  export default injectIntl(BlockMenu);
@@ -124,6 +124,12 @@ var TRANSFORM_STEPS_OVERRIDE = {
124
124
  orderedList: [decisionListToListStep],
125
125
  taskList: [decisionListToListStep],
126
126
  layoutSection: [wrapIntoLayoutStep]
127
+ },
128
+ blockCard: {
129
+ layoutSection: [wrapIntoLayoutStep]
130
+ },
131
+ embedCard: {
132
+ layoutSection: [wrapIntoLayoutStep]
127
133
  }
128
134
  };
129
135
  var getTransformStepsForNodeTypes = function getTransformStepsForNodeTypes(selectedNodeTypeName, targetNodeTypeName) {
@@ -20,8 +20,9 @@ export var transformNode = function transformNode(api) {
20
20
  var _expandSelectionToBlo = expandSelectionToBlockRange(preservedSelection),
21
21
  $from = _expandSelectionToBlo.$from,
22
22
  $to = _expandSelectionToBlo.$to;
23
- var isNested = isNestedNode(preservedSelection, '');
24
23
  var selectedParent = $from.parent;
24
+ var isParentLayout = selectedParent.type === nodes.layoutColumn;
25
+ var isNestedExceptLayout = isNestedNode(preservedSelection, '') && !isParentLayout;
25
26
  var fragment = Fragment.empty;
26
27
  var isList = isListNode(selectedParent);
27
28
  var slice = tr.doc.slice(isList ? $from.pos - 1 : $from.pos, isList ? $to.pos + 1 : $to.pos);
@@ -30,7 +31,7 @@ export var transformNode = function transformNode(api) {
30
31
  sourceNode: node,
31
32
  targetNodeType: targetType,
32
33
  schema: tr.doc.type.schema,
33
- isNested: isNested
34
+ isNested: isNestedExceptLayout
34
35
  });
35
36
  if (outputNode) {
36
37
  fragment = fragment.append(Fragment.fromArray(outputNode));
@@ -118,7 +118,7 @@ var BlockMenuContent = function BlockMenuContent(_ref3) {
118
118
  })));
119
119
  };
120
120
  var BlockMenu = function BlockMenu(_ref4) {
121
- var _editorView$dom, _ref5;
121
+ var _editorView$dom, _ref5, _api$analytics3;
122
122
  var editorView = _ref4.editorView,
123
123
  api = _ref4.api,
124
124
  mountTo = _ref4.mountTo,
@@ -193,6 +193,13 @@ var BlockMenu = function BlockMenu(_ref4) {
193
193
  return tr;
194
194
  });
195
195
  };
196
+ var handleClickOutside = function handleClickOutside(e) {
197
+ // check if the clicked element was another drag handle, if so don't close the menu
198
+ if (e.target instanceof HTMLElement && e.target.closest(DRAG_HANDLE_SELECTOR)) {
199
+ return;
200
+ }
201
+ closeMenu();
202
+ };
196
203
  var closeMenu = function closeMenu() {
197
204
  api === null || api === void 0 || api.core.actions.execute(function (_ref7) {
198
205
  var _api$blockControls3, _api$userIntent3;
@@ -218,39 +225,37 @@ var BlockMenu = function BlockMenu(_ref4) {
218
225
  popupRef.current = el;
219
226
  }
220
227
  };
221
- if (targetHandleRef instanceof HTMLElement) {
222
- var _api$analytics3;
223
- return /*#__PURE__*/React.createElement(ErrorBoundary, {
224
- component: ACTION_SUBJECT.BLOCK_MENU,
225
- dispatchAnalyticsEvent: api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions.fireAnalyticsEvent,
226
- fallbackComponent: null
227
- }, /*#__PURE__*/React.createElement(PopupWithListeners, {
228
- alignX: 'right',
229
- alignY: 'start',
230
- handleClickOutside: closeMenu,
231
- handleEscapeKeydown: closeMenu,
232
- handleBackspaceDeleteKeydown: handleBackspaceDeleteKeydown,
233
- mountTo: mountTo,
234
- boundariesElement: boundariesElement,
235
- scrollableElement: scrollableElement,
236
- target: targetHandleRef,
237
- zIndex: akEditorFloatingOverlapPanelZIndex,
238
- fitWidth: DEFAULT_MENU_WIDTH,
239
- fitHeight: menuHeight,
240
- preventOverflow: true,
241
- stick: true,
242
- offset: [DRAG_HANDLE_WIDTH + DRAG_HANDLE_OFFSET_PADDING, targetHandleHeightOffset],
243
- focusTrap: openedViaKeyboard ?
244
- // Only enable focus trap when opened via keyboard to make sure the focus is on the first focusable menu item
245
- {
246
- initialFocus: undefined
247
- } : undefined
248
- }, /*#__PURE__*/React.createElement(BlockMenuContent, {
249
- api: api,
250
- setRef: setRef
251
- })));
252
- } else {
228
+ if (!(targetHandleRef instanceof HTMLElement)) {
253
229
  return null;
254
230
  }
231
+ return /*#__PURE__*/React.createElement(ErrorBoundary, {
232
+ component: ACTION_SUBJECT.BLOCK_MENU,
233
+ dispatchAnalyticsEvent: api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions.fireAnalyticsEvent,
234
+ fallbackComponent: null
235
+ }, /*#__PURE__*/React.createElement(PopupWithListeners, {
236
+ alignX: 'right',
237
+ alignY: 'start',
238
+ handleClickOutside: handleClickOutside,
239
+ handleEscapeKeydown: closeMenu,
240
+ handleBackspaceDeleteKeydown: handleBackspaceDeleteKeydown,
241
+ mountTo: mountTo,
242
+ boundariesElement: boundariesElement,
243
+ scrollableElement: scrollableElement,
244
+ target: targetHandleRef,
245
+ zIndex: akEditorFloatingOverlapPanelZIndex,
246
+ fitWidth: DEFAULT_MENU_WIDTH,
247
+ fitHeight: menuHeight,
248
+ preventOverflow: true,
249
+ stick: true,
250
+ offset: [DRAG_HANDLE_WIDTH + DRAG_HANDLE_OFFSET_PADDING, targetHandleHeightOffset],
251
+ focusTrap: openedViaKeyboard ?
252
+ // Only enable focus trap when opened via keyboard to make sure the focus is on the first focusable menu item
253
+ {
254
+ initialFocus: undefined
255
+ } : undefined
256
+ }, /*#__PURE__*/React.createElement(BlockMenuContent, {
257
+ api: api,
258
+ setRef: setRef
259
+ })));
255
260
  };
256
261
  export default injectIntl(BlockMenu);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-menu",
3
- "version": "5.2.16",
3
+ "version": "5.2.17",
4
4
  "description": "BlockMenu plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -44,7 +44,7 @@
44
44
  "@atlaskit/platform-feature-flags": "^1.1.0",
45
45
  "@atlaskit/platform-feature-flags-react": "^0.4.0",
46
46
  "@atlaskit/primitives": "^16.4.0",
47
- "@atlaskit/tmp-editor-statsig": "^15.13.0",
47
+ "@atlaskit/tmp-editor-statsig": "^15.16.0",
48
48
  "@atlaskit/tokens": "^8.6.0",
49
49
  "@babel/runtime": "^7.0.0"
50
50
  },