@atlaskit/editor-plugin-block-controls 6.3.5 → 6.3.7

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,22 @@
1
1
  # @atlaskit/editor-plugin-block-controls
2
2
 
3
+ ## 6.3.7
4
+
5
+ ### Patch Changes
6
+
7
+ - [`15efb9ffafdd5`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/15efb9ffafdd5) -
8
+ [ux] Fix for scroll to top that happened when drag handle is clicked at the bottom of a long page
9
+ in Safari.
10
+ - Updated dependencies
11
+
12
+ ## 6.3.6
13
+
14
+ ### Patch Changes
15
+
16
+ - [`ef686b3cfdbff`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/ef686b3cfdbff) -
17
+ ED-29222: Make empty line experiment dependent on block menu
18
+ - Updated dependencies
19
+
3
20
  ## 6.3.5
4
21
 
5
22
  ### Patch Changes
@@ -38,7 +38,7 @@ var moveNodeWithBlockMenu = exports.moveNodeWithBlockMenu = function moveNodeWit
38
38
  (0, _moveNode.moveNode)(api)(currentNodePos, moveToPos, _analytics.INPUT_METHOD.BLOCK_MENU)({
39
39
  tr: tr
40
40
  });
41
- if (tr.selection.empty && (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu_empty_line', 'isEnabled', true)) {
41
+ if (tr.selection.empty && (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu', 'isEnabled', true) && (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu_empty_line', 'isEnabled', true)) {
42
42
  var nodeAtCurrentPos = tr.doc.nodeAt(currentNodePos);
43
43
  var nodeAfter = tr.doc.nodeAt(moveToPos);
44
44
  var isConsecutiveEmptyLineMove = (nodeAtCurrentPos === null || nodeAtCurrentPos === void 0 ? void 0 : nodeAtCurrentPos.content.size) === 0 && (nodeAfter === null || nodeAfter === void 0 ? void 0 : nodeAfter.content.size) === 0;
@@ -13,7 +13,7 @@ var getCurrentNodePosFromDragHandleSelection = exports.getCurrentNodePosFromDrag
13
13
  schema = _ref.schema,
14
14
  resolve = _ref.resolve;
15
15
  var currentNodePos = -1;
16
- if (selection.empty && (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu_empty_line', 'isEnabled', true)) {
16
+ if (selection.empty && (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu', 'isEnabled', true) && (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu_empty_line', 'isEnabled', true)) {
17
17
  currentNodePos = selection.$from.pos;
18
18
  }
19
19
  if ((0, _utils.isTableSelected)(selection)) {
@@ -49,7 +49,7 @@ var getPosWhenMoveNodeDown = exports.getPosWhenMoveNodeDown = function getPosWhe
49
49
  return -1;
50
50
  }
51
51
  var nodeAfter = tr.doc.nodeAt(nodeAfterPos);
52
- if ((0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu_empty_line', 'isEnabled', true)) {
52
+ if ((0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu', 'isEnabled', true) && (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu_empty_line', 'isEnabled', true)) {
53
53
  var nodeAtCurrentPos = tr.doc.nodeAt($currentNodePos.pos);
54
54
  // if move empty line down to another empty line, move to the position of the next empty line
55
55
  if ((nodeAtCurrentPos === null || nodeAtCurrentPos === void 0 ? void 0 : nodeAtCurrentPos.content.size) === 0 && nodeAtCurrentPos.type.name !== 'extension' && (nodeAfter === null || nodeAfter === void 0 ? void 0 : nodeAfter.content.size) === 0 && nodeAfter.type.name !== 'extension') {
@@ -77,11 +77,9 @@ var newGetSelection = function newGetSelection(tr, start) {
77
77
  var isNodeSelection = node && _state.NodeSelection.isSelectable(node);
78
78
  var nodeSize = node ? node.nodeSize : 1;
79
79
  var nodeName = node === null || node === void 0 ? void 0 : node.type.name;
80
- var blockMenuEnabled = (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu', 'isEnabled', true);
81
- var blockMenuEmptyLineEnabled = (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu_empty_line', 'isEnabled', true);
82
80
 
83
81
  // this is a fix for empty paragraph selection - put first to avoid any extra work
84
- if (nodeName === 'paragraph' && tr.selection.empty && (node === null || node === void 0 ? void 0 : node.childCount) === 0 && !blockMenuEnabled) {
82
+ if (nodeName === 'paragraph' && tr.selection.empty && (node === null || node === void 0 ? void 0 : node.childCount) === 0 && !(0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu', 'isEnabled', true)) {
85
83
  return false;
86
84
  }
87
85
  var isParagraphHeadingEmpty = ['paragraph', 'heading'].includes(nodeName || '') && tr.selection.empty && (node === null || node === void 0 ? void 0 : node.childCount) === 0;
@@ -90,13 +88,7 @@ var newGetSelection = function newGetSelection(tr, start) {
90
88
 
91
89
  // if block menu and empty line format menu are enabled,
92
90
  // we want to set the selection to avoid the selection goes to the top of the document
93
- if ((isParagraphHeadingEmpty || isBlockQuoteEmpty || isListEmpty) && blockMenuEnabled && blockMenuEmptyLineEnabled) {
94
- return _state.TextSelection.create(tr.doc, start + 1, start + 1);
95
- }
96
-
97
- // if block menu and empty line format menu are enabled,
98
- // we want to set the selection to avoid the selection goes to the top of the document
99
- if (['paragraph', 'heading', 'orderedList', 'bulletList', 'taskList', 'blockquote'].includes(nodeName || '') && tr.selection.empty && (node === null || node === void 0 ? void 0 : node.childCount) === 0 && blockMenuEnabled && blockMenuEmptyLineEnabled) {
91
+ if ((isParagraphHeadingEmpty || isBlockQuoteEmpty || isListEmpty) && (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu', 'isEnabled', true) && (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu_empty_line', 'isEnabled', true)) {
100
92
  return _state.TextSelection.create(tr.doc, start + 1, start + 1);
101
93
  }
102
94
  var isBlockQuoteWithMediaOrExtension = nodeName === 'blockquote' && isNodeWithMediaOrExtension(tr, start, nodeSize);
@@ -406,7 +406,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
406
406
  // as expected with a node selection. This workaround sets the selection to the node on mouseDown,
407
407
  // but ensures the preview is generated correctly.
408
408
  var handleMouseDown = (0, _react.useCallback)(function () {
409
- if ((0, _experiments.editorExperiment)('advanced_layouts', true)) {
409
+ if ((0, _experiments.editorExperiment)('advanced_layouts', true) && !(0, _platformFeatureFlags.fg)('platform_editor_draghandle_safari_scroll_fix')) {
410
410
  var _buttonRef$current;
411
411
  // prevent native drag and drop.
412
412
  (_buttonRef$current = buttonRef.current) === null || _buttonRef$current === void 0 || _buttonRef$current.focus();
@@ -33,7 +33,7 @@ export const moveNodeWithBlockMenu = (api, direction) => {
33
33
  moveNode(api)(currentNodePos, moveToPos, INPUT_METHOD.BLOCK_MENU)({
34
34
  tr
35
35
  });
36
- if (tr.selection.empty && expValEqualsNoExposure('platform_editor_block_menu_empty_line', 'isEnabled', true)) {
36
+ if (tr.selection.empty && expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true) && expValEqualsNoExposure('platform_editor_block_menu_empty_line', 'isEnabled', true)) {
37
37
  const nodeAtCurrentPos = tr.doc.nodeAt(currentNodePos);
38
38
  const nodeAfter = tr.doc.nodeAt(moveToPos);
39
39
  const isConsecutiveEmptyLineMove = (nodeAtCurrentPos === null || nodeAtCurrentPos === void 0 ? void 0 : nodeAtCurrentPos.content.size) === 0 && (nodeAfter === null || nodeAfter === void 0 ? void 0 : nodeAfter.content.size) === 0;
@@ -8,7 +8,7 @@ export const getCurrentNodePosFromDragHandleSelection = ({
8
8
  resolve
9
9
  }) => {
10
10
  let currentNodePos = -1;
11
- if (selection.empty && expValEqualsNoExposure('platform_editor_block_menu_empty_line', 'isEnabled', true)) {
11
+ if (selection.empty && expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true) && expValEqualsNoExposure('platform_editor_block_menu_empty_line', 'isEnabled', true)) {
12
12
  currentNodePos = selection.$from.pos;
13
13
  }
14
14
  if (isTableSelected(selection)) {
@@ -45,7 +45,7 @@ export const getPosWhenMoveNodeDown = ({
45
45
  return -1;
46
46
  }
47
47
  const nodeAfter = tr.doc.nodeAt(nodeAfterPos);
48
- if (expValEqualsNoExposure('platform_editor_block_menu_empty_line', 'isEnabled', true)) {
48
+ if (expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true) && expValEqualsNoExposure('platform_editor_block_menu_empty_line', 'isEnabled', true)) {
49
49
  const nodeAtCurrentPos = tr.doc.nodeAt($currentNodePos.pos);
50
50
  // if move empty line down to another empty line, move to the position of the next empty line
51
51
  if ((nodeAtCurrentPos === null || nodeAtCurrentPos === void 0 ? void 0 : nodeAtCurrentPos.content.size) === 0 && nodeAtCurrentPos.type.name !== 'extension' && (nodeAfter === null || nodeAfter === void 0 ? void 0 : nodeAfter.content.size) === 0 && nodeAfter.type.name !== 'extension') {
@@ -72,11 +72,9 @@ const newGetSelection = (tr, start) => {
72
72
  const isNodeSelection = node && NodeSelection.isSelectable(node);
73
73
  const nodeSize = node ? node.nodeSize : 1;
74
74
  const nodeName = node === null || node === void 0 ? void 0 : node.type.name;
75
- const blockMenuEnabled = expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true);
76
- const blockMenuEmptyLineEnabled = expValEqualsNoExposure('platform_editor_block_menu_empty_line', 'isEnabled', true);
77
75
 
78
76
  // this is a fix for empty paragraph selection - put first to avoid any extra work
79
- if (nodeName === 'paragraph' && tr.selection.empty && (node === null || node === void 0 ? void 0 : node.childCount) === 0 && !blockMenuEnabled) {
77
+ if (nodeName === 'paragraph' && tr.selection.empty && (node === null || node === void 0 ? void 0 : node.childCount) === 0 && !expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true)) {
80
78
  return false;
81
79
  }
82
80
  const isParagraphHeadingEmpty = ['paragraph', 'heading'].includes(nodeName || '') && tr.selection.empty && (node === null || node === void 0 ? void 0 : node.childCount) === 0;
@@ -85,13 +83,7 @@ const newGetSelection = (tr, start) => {
85
83
 
86
84
  // if block menu and empty line format menu are enabled,
87
85
  // we want to set the selection to avoid the selection goes to the top of the document
88
- if ((isParagraphHeadingEmpty || isBlockQuoteEmpty || isListEmpty) && blockMenuEnabled && blockMenuEmptyLineEnabled) {
89
- return TextSelection.create(tr.doc, start + 1, start + 1);
90
- }
91
-
92
- // if block menu and empty line format menu are enabled,
93
- // we want to set the selection to avoid the selection goes to the top of the document
94
- if (['paragraph', 'heading', 'orderedList', 'bulletList', 'taskList', 'blockquote'].includes(nodeName || '') && tr.selection.empty && (node === null || node === void 0 ? void 0 : node.childCount) === 0 && blockMenuEnabled && blockMenuEmptyLineEnabled) {
86
+ if ((isParagraphHeadingEmpty || isBlockQuoteEmpty || isListEmpty) && expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true) && expValEqualsNoExposure('platform_editor_block_menu_empty_line', 'isEnabled', true)) {
95
87
  return TextSelection.create(tr.doc, start + 1, start + 1);
96
88
  }
97
89
  const isBlockQuoteWithMediaOrExtension = nodeName === 'blockquote' && isNodeWithMediaOrExtension(tr, start, nodeSize);
@@ -386,7 +386,7 @@ export const DragHandle = ({
386
386
  // as expected with a node selection. This workaround sets the selection to the node on mouseDown,
387
387
  // but ensures the preview is generated correctly.
388
388
  const handleMouseDown = useCallback(() => {
389
- if (editorExperiment('advanced_layouts', true)) {
389
+ if (editorExperiment('advanced_layouts', true) && !fg('platform_editor_draghandle_safari_scroll_fix')) {
390
390
  var _buttonRef$current;
391
391
  // prevent native drag and drop.
392
392
  (_buttonRef$current = buttonRef.current) === null || _buttonRef$current === void 0 ? void 0 : _buttonRef$current.focus();
@@ -32,7 +32,7 @@ export var moveNodeWithBlockMenu = function moveNodeWithBlockMenu(api, direction
32
32
  moveNode(api)(currentNodePos, moveToPos, INPUT_METHOD.BLOCK_MENU)({
33
33
  tr: tr
34
34
  });
35
- if (tr.selection.empty && expValEqualsNoExposure('platform_editor_block_menu_empty_line', 'isEnabled', true)) {
35
+ if (tr.selection.empty && expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true) && expValEqualsNoExposure('platform_editor_block_menu_empty_line', 'isEnabled', true)) {
36
36
  var nodeAtCurrentPos = tr.doc.nodeAt(currentNodePos);
37
37
  var nodeAfter = tr.doc.nodeAt(moveToPos);
38
38
  var isConsecutiveEmptyLineMove = (nodeAtCurrentPos === null || nodeAtCurrentPos === void 0 ? void 0 : nodeAtCurrentPos.content.size) === 0 && (nodeAfter === null || nodeAfter === void 0 ? void 0 : nodeAfter.content.size) === 0;
@@ -7,7 +7,7 @@ export var getCurrentNodePosFromDragHandleSelection = function getCurrentNodePos
7
7
  schema = _ref.schema,
8
8
  resolve = _ref.resolve;
9
9
  var currentNodePos = -1;
10
- if (selection.empty && expValEqualsNoExposure('platform_editor_block_menu_empty_line', 'isEnabled', true)) {
10
+ if (selection.empty && expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true) && expValEqualsNoExposure('platform_editor_block_menu_empty_line', 'isEnabled', true)) {
11
11
  currentNodePos = selection.$from.pos;
12
12
  }
13
13
  if (isTableSelected(selection)) {
@@ -43,7 +43,7 @@ export var getPosWhenMoveNodeDown = function getPosWhenMoveNodeDown(_ref2) {
43
43
  return -1;
44
44
  }
45
45
  var nodeAfter = tr.doc.nodeAt(nodeAfterPos);
46
- if (expValEqualsNoExposure('platform_editor_block_menu_empty_line', 'isEnabled', true)) {
46
+ if (expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true) && expValEqualsNoExposure('platform_editor_block_menu_empty_line', 'isEnabled', true)) {
47
47
  var nodeAtCurrentPos = tr.doc.nodeAt($currentNodePos.pos);
48
48
  // if move empty line down to another empty line, move to the position of the next empty line
49
49
  if ((nodeAtCurrentPos === null || nodeAtCurrentPos === void 0 ? void 0 : nodeAtCurrentPos.content.size) === 0 && nodeAtCurrentPos.type.name !== 'extension' && (nodeAfter === null || nodeAfter === void 0 ? void 0 : nodeAfter.content.size) === 0 && nodeAfter.type.name !== 'extension') {
@@ -71,11 +71,9 @@ var newGetSelection = function newGetSelection(tr, start) {
71
71
  var isNodeSelection = node && NodeSelection.isSelectable(node);
72
72
  var nodeSize = node ? node.nodeSize : 1;
73
73
  var nodeName = node === null || node === void 0 ? void 0 : node.type.name;
74
- var blockMenuEnabled = expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true);
75
- var blockMenuEmptyLineEnabled = expValEqualsNoExposure('platform_editor_block_menu_empty_line', 'isEnabled', true);
76
74
 
77
75
  // this is a fix for empty paragraph selection - put first to avoid any extra work
78
- if (nodeName === 'paragraph' && tr.selection.empty && (node === null || node === void 0 ? void 0 : node.childCount) === 0 && !blockMenuEnabled) {
76
+ if (nodeName === 'paragraph' && tr.selection.empty && (node === null || node === void 0 ? void 0 : node.childCount) === 0 && !expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true)) {
79
77
  return false;
80
78
  }
81
79
  var isParagraphHeadingEmpty = ['paragraph', 'heading'].includes(nodeName || '') && tr.selection.empty && (node === null || node === void 0 ? void 0 : node.childCount) === 0;
@@ -84,13 +82,7 @@ var newGetSelection = function newGetSelection(tr, start) {
84
82
 
85
83
  // if block menu and empty line format menu are enabled,
86
84
  // we want to set the selection to avoid the selection goes to the top of the document
87
- if ((isParagraphHeadingEmpty || isBlockQuoteEmpty || isListEmpty) && blockMenuEnabled && blockMenuEmptyLineEnabled) {
88
- return TextSelection.create(tr.doc, start + 1, start + 1);
89
- }
90
-
91
- // if block menu and empty line format menu are enabled,
92
- // we want to set the selection to avoid the selection goes to the top of the document
93
- if (['paragraph', 'heading', 'orderedList', 'bulletList', 'taskList', 'blockquote'].includes(nodeName || '') && tr.selection.empty && (node === null || node === void 0 ? void 0 : node.childCount) === 0 && blockMenuEnabled && blockMenuEmptyLineEnabled) {
85
+ if ((isParagraphHeadingEmpty || isBlockQuoteEmpty || isListEmpty) && expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true) && expValEqualsNoExposure('platform_editor_block_menu_empty_line', 'isEnabled', true)) {
94
86
  return TextSelection.create(tr.doc, start + 1, start + 1);
95
87
  }
96
88
  var isBlockQuoteWithMediaOrExtension = nodeName === 'blockquote' && isNodeWithMediaOrExtension(tr, start, nodeSize);
@@ -403,7 +403,7 @@ export var DragHandle = function DragHandle(_ref) {
403
403
  // as expected with a node selection. This workaround sets the selection to the node on mouseDown,
404
404
  // but ensures the preview is generated correctly.
405
405
  var handleMouseDown = useCallback(function () {
406
- if (editorExperiment('advanced_layouts', true)) {
406
+ if (editorExperiment('advanced_layouts', true) && !fg('platform_editor_draghandle_safari_scroll_fix')) {
407
407
  var _buttonRef$current;
408
408
  // prevent native drag and drop.
409
409
  (_buttonRef$current = buttonRef.current) === null || _buttonRef$current === void 0 || _buttonRef$current.focus();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-controls",
3
- "version": "6.3.5",
3
+ "version": "6.3.7",
4
4
  "description": "Block controls plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -52,7 +52,7 @@
52
52
  "@atlaskit/pragmatic-drag-and-drop-react-drop-indicator": "^3.2.0",
53
53
  "@atlaskit/primitives": "^14.15.0",
54
54
  "@atlaskit/theme": "^21.0.0",
55
- "@atlaskit/tmp-editor-statsig": "^12.27.0",
55
+ "@atlaskit/tmp-editor-statsig": "^12.29.0",
56
56
  "@atlaskit/tokens": "^6.3.0",
57
57
  "@atlaskit/tooltip": "^20.4.0",
58
58
  "@babel/runtime": "^7.0.0",
@@ -64,7 +64,7 @@
64
64
  "uuid": "^3.1.0"
65
65
  },
66
66
  "peerDependencies": {
67
- "@atlaskit/editor-common": "^109.11.0",
67
+ "@atlaskit/editor-common": "^109.13.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"
@@ -164,6 +164,9 @@
164
164
  },
165
165
  "platform_editor_breakout_resizing_widget_fix": {
166
166
  "type": "boolean"
167
+ },
168
+ "platform_editor_draghandle_safari_scroll_fix": {
169
+ "type": "boolean"
167
170
  }
168
171
  }
169
172
  }