@atlaskit/editor-plugin-block-controls 2.1.8 → 2.1.10

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
+ ## 2.1.10
4
+
5
+ ### Patch Changes
6
+
7
+ - [#147228](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/147228)
8
+ [`ff45a3671e9a6`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/ff45a3671e9a6) -
9
+ Remove the handle from decorations when hovering on empty paragraphs.
10
+
11
+ ## 2.1.9
12
+
13
+ ### Patch Changes
14
+
15
+ - [#147660](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/147660)
16
+ [`bc7f5f6bfe9ff`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/bc7f5f6bfe9ff) -
17
+ Remove nested dnd gating from analytics events
18
+ - Updated dependencies
19
+
3
20
  ## 2.1.8
4
21
 
5
22
  ### Patch Changes
@@ -175,12 +175,11 @@ var moveNode = exports.moveNode = function moveNode(api) {
175
175
  action: _analytics.ACTION.MOVED,
176
176
  actionSubject: _analytics.ACTION_SUBJECT.ELEMENT,
177
177
  actionSubjectId: _analytics.ACTION_SUBJECT_ID.ELEMENT_DRAG_HANDLE,
178
- attributes: _objectSpread(_objectSpread({
178
+ attributes: _objectSpread({
179
179
  nodeDepth: resolvedNode.depth,
180
- nodeType: node.type.name
181
- }, (0, _experiments.editorExperiment)('nested-dnd', true) && {
180
+ nodeType: node.type.name,
182
181
  destinationNodeDepth: $mappedTo === null || $mappedTo === void 0 ? void 0 : $mappedTo.depth
183
- }), (0, _platformFeatureFlags.fg)('platform_editor_element_drag_and_drop_ed_23873') && {
182
+ }, (0, _platformFeatureFlags.fg)('platform_editor_element_drag_and_drop_ed_23873') && {
184
183
  inputMethod: inputMethod
185
184
  })
186
185
  })(tr);
@@ -52,9 +52,20 @@ var blockControlsPlugin = exports.blockControlsPlugin = function blockControlsPl
52
52
  return tr;
53
53
  };
54
54
  },
55
- setNodeDragged: function setNodeDragged(getPos, anchorName, nodeType) {
55
+ hideDragHandle: function hideDragHandle() {
56
56
  return function (_ref5) {
57
57
  var tr = _ref5.tr;
58
+ if ((0, _platformFeatureFlags.fg)('confluence_frontend_page_title_enter_improvements')) {
59
+ tr.setMeta(_main.key, {
60
+ hideDragHandle: true
61
+ });
62
+ }
63
+ return tr;
64
+ };
65
+ },
66
+ setNodeDragged: function setNodeDragged(getPos, anchorName, nodeType) {
67
+ return function (_ref6) {
68
+ var tr = _ref6.tr;
58
69
  var pos = getPos();
59
70
  if (pos === undefined) {
60
71
  return tr;
@@ -13,6 +13,11 @@ var isEmptyNestedParagraphOrHeading = function isEmptyNestedParagraphOrHeading(t
13
13
  }
14
14
  return false;
15
15
  };
16
+ var isDocFirstChildEmptyLine = function isDocFirstChildEmptyLine(elem) {
17
+ var _elem$firstElementChi;
18
+ var parentElement = elem.parentElement;
19
+ return (parentElement === null || parentElement === void 0 ? void 0 : parentElement.firstElementChild) === elem && ['P', 'H1', 'H2', 'H3', 'H4', 'H5', 'H6'].includes(elem.nodeName) && elem.childNodes.length === 1 && ((_elem$firstElementChi = elem.firstElementChild) === null || _elem$firstElementChi === void 0 ? void 0 : _elem$firstElementChi.classList.contains('ProseMirror-trailingBreak'));
20
+ };
16
21
  var handleMouseOver = exports.handleMouseOver = function handleMouseOver(view, event, api) {
17
22
  var _api$blockControls;
18
23
  var _ref = (api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.sharedState.currentState()) || {},
@@ -31,6 +36,11 @@ var handleMouseOver = exports.handleMouseOver = function handleMouseOver(view, e
31
36
  var rootElement = target === null || target === void 0 ? void 0 : target.closest('[data-drag-handler-anchor-name]');
32
37
  if (rootElement) {
33
38
  var _rootElement$parentEl;
39
+ if (isDocFirstChildEmptyLine(rootElement) && (0, _platformFeatureFlags.fg)('confluence_frontend_page_title_enter_improvements')) {
40
+ var _api$core, _api$blockControls2;
41
+ api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 ? void 0 : _api$blockControls2.commands.hideDragHandle());
42
+ return;
43
+ }
34
44
  // We want to exlude handles from showing for empty paragraph and heading nodes
35
45
  if ((0, _experiments.editorExperiment)('nested-dnd', true) && isEmptyNestedParagraphOrHeading(rootElement)) {
36
46
  return false;
@@ -79,8 +89,8 @@ var handleMouseOver = exports.handleMouseOver = function handleMouseOver(view, e
79
89
  }
80
90
  var nodeType = rootElement.getAttribute('data-drag-handler-node-type');
81
91
  if (nodeType) {
82
- var _api$core, _api$blockControls2;
83
- api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 ? void 0 : _api$blockControls2.commands.showDragHandleAt(rootPos, anchorName, nodeType));
92
+ var _api$core2, _api$blockControls3;
93
+ api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 || _api$core2.actions.execute(api === null || api === void 0 || (_api$blockControls3 = api.blockControls) === null || _api$blockControls3 === void 0 ? void 0 : _api$blockControls3.commands.showDragHandleAt(rootPos, anchorName, nodeType));
84
94
  }
85
95
  }
86
96
  };
@@ -144,7 +144,7 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl) {
144
144
  // During resize, remove the drag handle widget so its dom positioning doesn't need to be maintained
145
145
  // Also remove the handle when the node is moved or the node count changes. This helps prevent incorrect positioning
146
146
  // Don't remove the handle if remote changes are changing the node count, its prosemirror position can be mapped instead
147
- if (isResizerResizing || maybeNodeCountChanged && shouldRemoveHandle || meta !== null && meta !== void 0 && meta.nodeMoved) {
147
+ if (meta !== null && meta !== void 0 && meta.hideDragHandle && (0, _platformFeatureFlags.fg)('confluence_frontend_page_title_enter_improvements') || isResizerResizing || maybeNodeCountChanged && shouldRemoveHandle || meta !== null && meta !== void 0 && meta.nodeMoved) {
148
148
  var oldHandle = decorations.find(undefined, undefined, function (spec) {
149
149
  return spec.id === 'drag-handle';
150
150
  });
@@ -172,9 +172,7 @@ export const moveNode = api => (start, to, inputMethod = INPUT_METHOD.DRAG_AND_D
172
172
  attributes: {
173
173
  nodeDepth: resolvedNode.depth,
174
174
  nodeType: node.type.name,
175
- ...(editorExperiment('nested-dnd', true) && {
176
- destinationNodeDepth: $mappedTo === null || $mappedTo === void 0 ? void 0 : $mappedTo.depth
177
- }),
175
+ destinationNodeDepth: $mappedTo === null || $mappedTo === void 0 ? void 0 : $mappedTo.depth,
178
176
  ...(fg('platform_editor_element_drag_and_drop_ed_23873') && {
179
177
  inputMethod
180
178
  })
@@ -41,6 +41,16 @@ export const blockControlsPlugin = ({
41
41
  });
42
42
  return tr;
43
43
  },
44
+ hideDragHandle: () => ({
45
+ tr
46
+ }) => {
47
+ if (fg('confluence_frontend_page_title_enter_improvements')) {
48
+ tr.setMeta(key, {
49
+ hideDragHandle: true
50
+ });
51
+ }
52
+ return tr;
53
+ },
44
54
  setNodeDragged: (getPos, anchorName, nodeType) => ({
45
55
  tr
46
56
  }) => {
@@ -7,6 +7,11 @@ const isEmptyNestedParagraphOrHeading = target => {
7
7
  }
8
8
  return false;
9
9
  };
10
+ const isDocFirstChildEmptyLine = elem => {
11
+ var _elem$firstElementChi;
12
+ const parentElement = elem.parentElement;
13
+ return (parentElement === null || parentElement === void 0 ? void 0 : parentElement.firstElementChild) === elem && ['P', 'H1', 'H2', 'H3', 'H4', 'H5', 'H6'].includes(elem.nodeName) && elem.childNodes.length === 1 && ((_elem$firstElementChi = elem.firstElementChild) === null || _elem$firstElementChi === void 0 ? void 0 : _elem$firstElementChi.classList.contains('ProseMirror-trailingBreak'));
14
+ };
10
15
  export const handleMouseOver = (view, event, api) => {
11
16
  var _api$blockControls;
12
17
  const {
@@ -26,6 +31,11 @@ export const handleMouseOver = (view, event, api) => {
26
31
  let rootElement = target === null || target === void 0 ? void 0 : target.closest('[data-drag-handler-anchor-name]');
27
32
  if (rootElement) {
28
33
  var _rootElement$parentEl;
34
+ if (isDocFirstChildEmptyLine(rootElement) && fg('confluence_frontend_page_title_enter_improvements')) {
35
+ var _api$core, _api$blockControls2;
36
+ api === null || api === void 0 ? void 0 : (_api$core = api.core) === null || _api$core === void 0 ? void 0 : _api$core.actions.execute(api === null || api === void 0 ? void 0 : (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 ? void 0 : _api$blockControls2.commands.hideDragHandle());
37
+ return;
38
+ }
29
39
  // We want to exlude handles from showing for empty paragraph and heading nodes
30
40
  if (editorExperiment('nested-dnd', true) && isEmptyNestedParagraphOrHeading(rootElement)) {
31
41
  return false;
@@ -74,8 +84,8 @@ export const handleMouseOver = (view, event, api) => {
74
84
  }
75
85
  const nodeType = rootElement.getAttribute('data-drag-handler-node-type');
76
86
  if (nodeType) {
77
- var _api$core, _api$blockControls2;
78
- api === null || api === void 0 ? void 0 : (_api$core = api.core) === null || _api$core === void 0 ? void 0 : _api$core.actions.execute(api === null || api === void 0 ? void 0 : (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 ? void 0 : _api$blockControls2.commands.showDragHandleAt(rootPos, anchorName, nodeType));
87
+ var _api$core2, _api$blockControls3;
88
+ api === null || api === void 0 ? void 0 : (_api$core2 = api.core) === null || _api$core2 === void 0 ? void 0 : _api$core2.actions.execute(api === null || api === void 0 ? void 0 : (_api$blockControls3 = api.blockControls) === null || _api$blockControls3 === void 0 ? void 0 : _api$blockControls3.commands.showDragHandleAt(rootPos, anchorName, nodeType));
79
89
  }
80
90
  }
81
91
  };
@@ -137,7 +137,7 @@ export const createPlugin = (api, getIntl) => {
137
137
  // During resize, remove the drag handle widget so its dom positioning doesn't need to be maintained
138
138
  // Also remove the handle when the node is moved or the node count changes. This helps prevent incorrect positioning
139
139
  // Don't remove the handle if remote changes are changing the node count, its prosemirror position can be mapped instead
140
- if (isResizerResizing || maybeNodeCountChanged && shouldRemoveHandle || meta !== null && meta !== void 0 && meta.nodeMoved) {
140
+ if (meta !== null && meta !== void 0 && meta.hideDragHandle && fg('confluence_frontend_page_title_enter_improvements') || isResizerResizing || maybeNodeCountChanged && shouldRemoveHandle || meta !== null && meta !== void 0 && meta.nodeMoved) {
141
141
  const oldHandle = decorations.find(undefined, undefined, spec => spec.id === 'drag-handle');
142
142
  decorations = decorations.remove(oldHandle);
143
143
  }
@@ -169,12 +169,11 @@ export var moveNode = function moveNode(api) {
169
169
  action: ACTION.MOVED,
170
170
  actionSubject: ACTION_SUBJECT.ELEMENT,
171
171
  actionSubjectId: ACTION_SUBJECT_ID.ELEMENT_DRAG_HANDLE,
172
- attributes: _objectSpread(_objectSpread({
172
+ attributes: _objectSpread({
173
173
  nodeDepth: resolvedNode.depth,
174
- nodeType: node.type.name
175
- }, editorExperiment('nested-dnd', true) && {
174
+ nodeType: node.type.name,
176
175
  destinationNodeDepth: $mappedTo === null || $mappedTo === void 0 ? void 0 : $mappedTo.depth
177
- }), fg('platform_editor_element_drag_and_drop_ed_23873') && {
176
+ }, fg('platform_editor_element_drag_and_drop_ed_23873') && {
178
177
  inputMethod: inputMethod
179
178
  })
180
179
  })(tr);
@@ -45,9 +45,20 @@ export var blockControlsPlugin = function blockControlsPlugin(_ref) {
45
45
  return tr;
46
46
  };
47
47
  },
48
- setNodeDragged: function setNodeDragged(getPos, anchorName, nodeType) {
48
+ hideDragHandle: function hideDragHandle() {
49
49
  return function (_ref5) {
50
50
  var tr = _ref5.tr;
51
+ if (fg('confluence_frontend_page_title_enter_improvements')) {
52
+ tr.setMeta(key, {
53
+ hideDragHandle: true
54
+ });
55
+ }
56
+ return tr;
57
+ };
58
+ },
59
+ setNodeDragged: function setNodeDragged(getPos, anchorName, nodeType) {
60
+ return function (_ref6) {
61
+ var tr = _ref6.tr;
51
62
  var pos = getPos();
52
63
  if (pos === undefined) {
53
64
  return tr;
@@ -7,6 +7,11 @@ var isEmptyNestedParagraphOrHeading = function isEmptyNestedParagraphOrHeading(t
7
7
  }
8
8
  return false;
9
9
  };
10
+ var isDocFirstChildEmptyLine = function isDocFirstChildEmptyLine(elem) {
11
+ var _elem$firstElementChi;
12
+ var parentElement = elem.parentElement;
13
+ return (parentElement === null || parentElement === void 0 ? void 0 : parentElement.firstElementChild) === elem && ['P', 'H1', 'H2', 'H3', 'H4', 'H5', 'H6'].includes(elem.nodeName) && elem.childNodes.length === 1 && ((_elem$firstElementChi = elem.firstElementChild) === null || _elem$firstElementChi === void 0 ? void 0 : _elem$firstElementChi.classList.contains('ProseMirror-trailingBreak'));
14
+ };
10
15
  export var handleMouseOver = function handleMouseOver(view, event, api) {
11
16
  var _api$blockControls;
12
17
  var _ref = (api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.sharedState.currentState()) || {},
@@ -25,6 +30,11 @@ export var handleMouseOver = function handleMouseOver(view, event, api) {
25
30
  var rootElement = target === null || target === void 0 ? void 0 : target.closest('[data-drag-handler-anchor-name]');
26
31
  if (rootElement) {
27
32
  var _rootElement$parentEl;
33
+ if (isDocFirstChildEmptyLine(rootElement) && fg('confluence_frontend_page_title_enter_improvements')) {
34
+ var _api$core, _api$blockControls2;
35
+ api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 ? void 0 : _api$blockControls2.commands.hideDragHandle());
36
+ return;
37
+ }
28
38
  // We want to exlude handles from showing for empty paragraph and heading nodes
29
39
  if (editorExperiment('nested-dnd', true) && isEmptyNestedParagraphOrHeading(rootElement)) {
30
40
  return false;
@@ -73,8 +83,8 @@ export var handleMouseOver = function handleMouseOver(view, event, api) {
73
83
  }
74
84
  var nodeType = rootElement.getAttribute('data-drag-handler-node-type');
75
85
  if (nodeType) {
76
- var _api$core, _api$blockControls2;
77
- api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 ? void 0 : _api$blockControls2.commands.showDragHandleAt(rootPos, anchorName, nodeType));
86
+ var _api$core2, _api$blockControls3;
87
+ api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 || _api$core2.actions.execute(api === null || api === void 0 || (_api$blockControls3 = api.blockControls) === null || _api$blockControls3 === void 0 ? void 0 : _api$blockControls3.commands.showDragHandleAt(rootPos, anchorName, nodeType));
78
88
  }
79
89
  }
80
90
  };
@@ -137,7 +137,7 @@ export var createPlugin = function createPlugin(api, getIntl) {
137
137
  // During resize, remove the drag handle widget so its dom positioning doesn't need to be maintained
138
138
  // Also remove the handle when the node is moved or the node count changes. This helps prevent incorrect positioning
139
139
  // Don't remove the handle if remote changes are changing the node count, its prosemirror position can be mapped instead
140
- if (isResizerResizing || maybeNodeCountChanged && shouldRemoveHandle || meta !== null && meta !== void 0 && meta.nodeMoved) {
140
+ if (meta !== null && meta !== void 0 && meta.hideDragHandle && fg('confluence_frontend_page_title_enter_improvements') || isResizerResizing || maybeNodeCountChanged && shouldRemoveHandle || meta !== null && meta !== void 0 && meta.nodeMoved) {
141
141
  var oldHandle = decorations.find(undefined, undefined, function (spec) {
142
142
  return spec.id === 'drag-handle';
143
143
  });
@@ -60,6 +60,7 @@ export type BlockControlsPlugin = NextEditorPlugin<'blockControls', {
60
60
  commands: {
61
61
  moveNode: (start: number, to: number, inputMethod?: MoveNodeMethod, formatMessage?: IntlShape['formatMessage']) => EditorCommand;
62
62
  showDragHandleAt: (pos: number, anchorName: string, nodeType: string, handleOptions?: HandleOptions) => EditorCommand;
63
+ hideDragHandle: () => EditorCommand;
63
64
  setNodeDragged: (getPos: () => number | undefined, anchorName: string, nodeType: string) => EditorCommand;
64
65
  };
65
66
  }>;
@@ -60,6 +60,7 @@ export type BlockControlsPlugin = NextEditorPlugin<'blockControls', {
60
60
  commands: {
61
61
  moveNode: (start: number, to: number, inputMethod?: MoveNodeMethod, formatMessage?: IntlShape['formatMessage']) => EditorCommand;
62
62
  showDragHandleAt: (pos: number, anchorName: string, nodeType: string, handleOptions?: HandleOptions) => EditorCommand;
63
+ hideDragHandle: () => EditorCommand;
63
64
  setNodeDragged: (getPos: () => number | undefined, anchorName: string, nodeType: string) => EditorCommand;
64
65
  };
65
66
  }>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-controls",
3
- "version": "2.1.8",
3
+ "version": "2.1.10",
4
4
  "description": "Block controls plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -31,7 +31,7 @@
31
31
  },
32
32
  "dependencies": {
33
33
  "@atlaskit/adf-schema": "^40.9.0",
34
- "@atlaskit/editor-common": "^92.0.0",
34
+ "@atlaskit/editor-common": "^92.1.0",
35
35
  "@atlaskit/editor-plugin-accessibility-utils": "^1.2.0",
36
36
  "@atlaskit/editor-plugin-analytics": "^1.8.0",
37
37
  "@atlaskit/editor-plugin-editor-disabled": "^1.3.0",
@@ -48,7 +48,7 @@
48
48
  "@atlaskit/pragmatic-drag-and-drop-react-drop-indicator": "^1.1.0",
49
49
  "@atlaskit/primitives": "^12.2.0",
50
50
  "@atlaskit/theme": "^13.0.0",
51
- "@atlaskit/tmp-editor-statsig": "^2.1.0",
51
+ "@atlaskit/tmp-editor-statsig": "^2.2.0",
52
52
  "@atlaskit/tokens": "^2.0.0",
53
53
  "@atlaskit/tooltip": "^18.7.0",
54
54
  "@babel/runtime": "^7.0.0",
@@ -144,6 +144,9 @@
144
144
  },
145
145
  "platform_editor_element_dnd_nested_type_error_fix": {
146
146
  "type": "boolean"
147
+ },
148
+ "confluence_frontend_page_title_enter_improvements": {
149
+ "type": "boolean"
147
150
  }
148
151
  }
149
152
  }