@atlaskit/editor-plugin-block-controls 2.0.3 → 2.0.4

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-controls
2
2
 
3
+ ## 2.0.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [#141778](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/141778)
8
+ [`1c6f578277694`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/1c6f578277694) -
9
+ ED-24870 & ED-24864 - Add the logic to gate the nested media in quotes functionality behind the
10
+ nest-media-and-codeblock-in-quote experiment. Also adjust the logic so the nested expands are now
11
+ behind the nested-expand-in-expand experiment.
12
+
3
13
  ## 2.0.3
4
14
 
5
15
  ### Patch Changes
@@ -100,6 +100,28 @@ var DropTarget = exports.DropTarget = function DropTarget(_ref3) {
100
100
  if (!element) {
101
101
  return;
102
102
  }
103
+
104
+ // Place experiments here instead of just inside move-node.ts as it stops the drag marker from appearing.
105
+ if ((0, _experiments.editorExperiment)('nest-media-and-codeblock-in-quote', false)) {
106
+ var _api$blockControls;
107
+ var _ref4 = (api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.sharedState.currentState()) || {},
108
+ activeNode = _ref4.activeNode;
109
+ var parentNodeType = parentNode === null || parentNode === void 0 ? void 0 : parentNode.type.name;
110
+ var activeNodeType = activeNode === null || activeNode === void 0 ? void 0 : activeNode.nodeType;
111
+ if (parentNodeType === 'blockquote' && (activeNodeType === 'mediaGroup' || activeNodeType === 'mediaSingle' || activeNodeType === 'codeBlock')) {
112
+ return;
113
+ }
114
+ }
115
+ if ((0, _experiments.editorExperiment)('nested-expand-in-expand', false)) {
116
+ var _api$blockControls2;
117
+ var _ref5 = (api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 ? void 0 : _api$blockControls2.sharedState.currentState()) || {},
118
+ _activeNode = _ref5.activeNode;
119
+ var _parentNodeType = parentNode === null || parentNode === void 0 ? void 0 : parentNode.type.name;
120
+ var _activeNodeType = _activeNode === null || _activeNode === void 0 ? void 0 : _activeNode.nodeType;
121
+ if (_parentNodeType === 'expand' && (_activeNodeType === 'expand' || _activeNodeType === 'nestedExpand')) {
122
+ return;
123
+ }
124
+ }
103
125
  return (0, _adapter.dropTargetForElements)({
104
126
  element: element,
105
127
  getIsSticky: function getIsSticky() {
@@ -112,21 +134,21 @@ var DropTarget = exports.DropTarget = function DropTarget(_ref3) {
112
134
  setIsDraggedOver(false);
113
135
  },
114
136
  onDrop: function onDrop() {
115
- var _api$blockControls;
116
- var _ref4 = (api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.sharedState.currentState()) || {},
117
- activeNode = _ref4.activeNode;
137
+ var _api$blockControls3;
138
+ var _ref6 = (api === null || api === void 0 || (_api$blockControls3 = api.blockControls) === null || _api$blockControls3 === void 0 ? void 0 : _api$blockControls3.sharedState.currentState()) || {},
139
+ activeNode = _ref6.activeNode;
118
140
  if (!activeNode) {
119
141
  return;
120
142
  }
121
143
  var pos = getPos();
122
144
  if (activeNode && pos !== undefined) {
123
- var _api$core, _api$blockControls2;
145
+ var _api$core, _api$blockControls4;
124
146
  var start = activeNode.pos;
125
- 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 || (_api$blockControls2 = _api$blockControls2.commands) === null || _api$blockControls2 === void 0 ? void 0 : _api$blockControls2.moveNode(start, pos, undefined, formatMessage));
147
+ api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(api === null || api === void 0 || (_api$blockControls4 = api.blockControls) === null || _api$blockControls4 === void 0 || (_api$blockControls4 = _api$blockControls4.commands) === null || _api$blockControls4 === void 0 ? void 0 : _api$blockControls4.moveNode(start, pos, undefined, formatMessage));
126
148
  }
127
149
  }
128
150
  });
129
- }, [api, formatMessage, getPos]);
151
+ }, [api, formatMessage, getPos, parentNode]);
130
152
  var dropTargetOffsetStyle = (0, _react.useMemo)(function () {
131
153
  /**
132
154
  * First child of a nested node.
@@ -83,6 +83,30 @@ export const DropTarget = ({
83
83
  if (!element) {
84
84
  return;
85
85
  }
86
+
87
+ // Place experiments here instead of just inside move-node.ts as it stops the drag marker from appearing.
88
+ if (editorExperiment('nest-media-and-codeblock-in-quote', false)) {
89
+ var _api$blockControls;
90
+ const {
91
+ activeNode
92
+ } = (api === null || api === void 0 ? void 0 : (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.sharedState.currentState()) || {};
93
+ const parentNodeType = parentNode === null || parentNode === void 0 ? void 0 : parentNode.type.name;
94
+ const activeNodeType = activeNode === null || activeNode === void 0 ? void 0 : activeNode.nodeType;
95
+ if (parentNodeType === 'blockquote' && (activeNodeType === 'mediaGroup' || activeNodeType === 'mediaSingle' || activeNodeType === 'codeBlock')) {
96
+ return;
97
+ }
98
+ }
99
+ if (editorExperiment('nested-expand-in-expand', false)) {
100
+ var _api$blockControls2;
101
+ const {
102
+ activeNode
103
+ } = (api === null || api === void 0 ? void 0 : (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 ? void 0 : _api$blockControls2.sharedState.currentState()) || {};
104
+ const parentNodeType = parentNode === null || parentNode === void 0 ? void 0 : parentNode.type.name;
105
+ const activeNodeType = activeNode === null || activeNode === void 0 ? void 0 : activeNode.nodeType;
106
+ if (parentNodeType === 'expand' && (activeNodeType === 'expand' || activeNodeType === 'nestedExpand')) {
107
+ return;
108
+ }
109
+ }
86
110
  return dropTargetForElements({
87
111
  element,
88
112
  getIsSticky: () => true,
@@ -93,24 +117,24 @@ export const DropTarget = ({
93
117
  setIsDraggedOver(false);
94
118
  },
95
119
  onDrop: () => {
96
- var _api$blockControls;
120
+ var _api$blockControls3;
97
121
  const {
98
122
  activeNode
99
- } = (api === null || api === void 0 ? void 0 : (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.sharedState.currentState()) || {};
123
+ } = (api === null || api === void 0 ? void 0 : (_api$blockControls3 = api.blockControls) === null || _api$blockControls3 === void 0 ? void 0 : _api$blockControls3.sharedState.currentState()) || {};
100
124
  if (!activeNode) {
101
125
  return;
102
126
  }
103
127
  const pos = getPos();
104
128
  if (activeNode && pos !== undefined) {
105
- var _api$core, _api$blockControls2, _api$blockControls2$c;
129
+ var _api$core, _api$blockControls4, _api$blockControls4$c;
106
130
  const {
107
131
  pos: start
108
132
  } = activeNode;
109
- 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$c = _api$blockControls2.commands) === null || _api$blockControls2$c === void 0 ? void 0 : _api$blockControls2$c.moveNode(start, pos, undefined, formatMessage));
133
+ 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$blockControls4 = api.blockControls) === null || _api$blockControls4 === void 0 ? void 0 : (_api$blockControls4$c = _api$blockControls4.commands) === null || _api$blockControls4$c === void 0 ? void 0 : _api$blockControls4$c.moveNode(start, pos, undefined, formatMessage));
110
134
  }
111
135
  }
112
136
  });
113
- }, [api, formatMessage, getPos]);
137
+ }, [api, formatMessage, getPos, parentNode]);
114
138
  const dropTargetOffsetStyle = useMemo(() => {
115
139
  /**
116
140
  * First child of a nested node.
@@ -92,6 +92,28 @@ export var DropTarget = function DropTarget(_ref3) {
92
92
  if (!element) {
93
93
  return;
94
94
  }
95
+
96
+ // Place experiments here instead of just inside move-node.ts as it stops the drag marker from appearing.
97
+ if (editorExperiment('nest-media-and-codeblock-in-quote', false)) {
98
+ var _api$blockControls;
99
+ var _ref4 = (api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.sharedState.currentState()) || {},
100
+ activeNode = _ref4.activeNode;
101
+ var parentNodeType = parentNode === null || parentNode === void 0 ? void 0 : parentNode.type.name;
102
+ var activeNodeType = activeNode === null || activeNode === void 0 ? void 0 : activeNode.nodeType;
103
+ if (parentNodeType === 'blockquote' && (activeNodeType === 'mediaGroup' || activeNodeType === 'mediaSingle' || activeNodeType === 'codeBlock')) {
104
+ return;
105
+ }
106
+ }
107
+ if (editorExperiment('nested-expand-in-expand', false)) {
108
+ var _api$blockControls2;
109
+ var _ref5 = (api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 ? void 0 : _api$blockControls2.sharedState.currentState()) || {},
110
+ _activeNode = _ref5.activeNode;
111
+ var _parentNodeType = parentNode === null || parentNode === void 0 ? void 0 : parentNode.type.name;
112
+ var _activeNodeType = _activeNode === null || _activeNode === void 0 ? void 0 : _activeNode.nodeType;
113
+ if (_parentNodeType === 'expand' && (_activeNodeType === 'expand' || _activeNodeType === 'nestedExpand')) {
114
+ return;
115
+ }
116
+ }
95
117
  return dropTargetForElements({
96
118
  element: element,
97
119
  getIsSticky: function getIsSticky() {
@@ -104,21 +126,21 @@ export var DropTarget = function DropTarget(_ref3) {
104
126
  setIsDraggedOver(false);
105
127
  },
106
128
  onDrop: function onDrop() {
107
- var _api$blockControls;
108
- var _ref4 = (api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.sharedState.currentState()) || {},
109
- activeNode = _ref4.activeNode;
129
+ var _api$blockControls3;
130
+ var _ref6 = (api === null || api === void 0 || (_api$blockControls3 = api.blockControls) === null || _api$blockControls3 === void 0 ? void 0 : _api$blockControls3.sharedState.currentState()) || {},
131
+ activeNode = _ref6.activeNode;
110
132
  if (!activeNode) {
111
133
  return;
112
134
  }
113
135
  var pos = getPos();
114
136
  if (activeNode && pos !== undefined) {
115
- var _api$core, _api$blockControls2;
137
+ var _api$core, _api$blockControls4;
116
138
  var start = activeNode.pos;
117
- 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 || (_api$blockControls2 = _api$blockControls2.commands) === null || _api$blockControls2 === void 0 ? void 0 : _api$blockControls2.moveNode(start, pos, undefined, formatMessage));
139
+ api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(api === null || api === void 0 || (_api$blockControls4 = api.blockControls) === null || _api$blockControls4 === void 0 || (_api$blockControls4 = _api$blockControls4.commands) === null || _api$blockControls4 === void 0 ? void 0 : _api$blockControls4.moveNode(start, pos, undefined, formatMessage));
118
140
  }
119
141
  }
120
142
  });
121
- }, [api, formatMessage, getPos]);
143
+ }, [api, formatMessage, getPos, parentNode]);
122
144
  var dropTargetOffsetStyle = useMemo(function () {
123
145
  /**
124
146
  * First child of a nested node.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-controls",
3
- "version": "2.0.3",
3
+ "version": "2.0.4",
4
4
  "description": "Block controls plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",