@atlaskit/editor-plugin-block-controls 3.1.9 → 3.2.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,27 @@
1
1
  # @atlaskit/editor-plugin-block-controls
2
2
 
3
+ ## 3.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 3.2.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [#120472](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/120472)
14
+ [`73c800ab5f2fc`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/73c800ab5f2fc) -
15
+ ED-26766 update adf-schema from 47.2.1 to 47.6.0 and adf-schema-json from 1.27.0 to 1.31.0
16
+
17
+ ### Patch Changes
18
+
19
+ - [#121077](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/121077)
20
+ [`a41495c81457e`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/a41495c81457e) -
21
+ remap root anchor name and node type when document changes to fix quick insert button positioning
22
+ issues
23
+ - Updated dependencies
24
+
3
25
  ## 3.1.9
4
26
 
5
27
  ### Patch Changes
@@ -98,7 +98,9 @@ var nodeDecorations = exports.nodeDecorations = function nodeDecorations(newStat
98
98
  return shouldDescend; //skip over, don't consider it a valid depth
99
99
  }
100
100
  }
101
- var anchorStyles = "anchor-name: ".concat(anchorName, ";");
101
+ var anchorStyles = pos === 0 && (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') ? // why margin-top:0? well it's not possible using CSS to select the first node in the document while excluding n number of nodes, in this case
102
+ // we're rendering quick insert button and drag handle. For now override margin-top to 0
103
+ "anchor-name: ".concat(anchorName, ";margin-top:0px;") : "anchor-name: ".concat(anchorName, ";");
102
104
  decs.push(_view.Decoration.node(pos, pos + node.nodeSize, (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({
103
105
  style: anchorStyles
104
106
  }, 'data-drag-handler-anchor-name', anchorName), 'data-drag-handler-node-type', nodeTypeWithLevel), 'data-drag-handler-anchor-depth', "".concat(depth)), {
@@ -75,7 +75,7 @@ var dragHandleDecoration = exports.dragHandleDecoration = function dragHandleDec
75
75
  // temporarily re-instating ReactDOM.render to fix drag handle focus issue, fix to
76
76
  // follow via ED-26546
77
77
 
78
- // if (fg('platform_editor_react18_plugin_portalprovider')) {
78
+ // previous under platform_editor_react18_plugin_portalprovider
79
79
  // nodeViewPortalProviderAPI.render(
80
80
  // () =>
81
81
  // createElement(DragHandle, {
@@ -91,7 +91,7 @@ var dragHandleDecoration = exports.dragHandleDecoration = function dragHandleDec
91
91
  // element,
92
92
  // key,
93
93
  // );
94
- // } else {
94
+
95
95
  _reactDom.default.render( /*#__PURE__*/(0, _react.createElement)(_dragHandle.DragHandle, {
96
96
  view: view,
97
97
  api: api,
@@ -20,6 +20,7 @@ var quickInsertButtonDecoration = exports.quickInsertButtonDecoration = function
20
20
  return _view.Decoration.widget(rootPos, function (view, getPos) {
21
21
  var element = document.createElement('span');
22
22
  element.contentEditable = 'false';
23
+ element.setAttribute('data-blocks-quick-insert-container', 'true');
23
24
  nodeViewPortalProviderAPI.render(function () {
24
25
  return /*#__PURE__*/(0, _react.createElement)(_quickInsertButton.TypeAheadControl, {
25
26
  api: api,
@@ -166,6 +166,19 @@ var getDecorations = exports.getDecorations = function getDecorations(state) {
166
166
  var _key$getState;
167
167
  return (_key$getState = key.getState(state)) === null || _key$getState === void 0 ? void 0 : _key$getState.decorations;
168
168
  };
169
+ var getDecorationAtPos = function getDecorationAtPos(decorations, pos, to) {
170
+ // Find the newly minted node decs that touch the active node
171
+ var findNewNodeDecs = (0, _decorationsAnchor.findNodeDecs)(decorations, pos - 1, to);
172
+
173
+ // Find the specific dec that the active node corresponds to
174
+ var nodeDecsAtActivePos = findNewNodeDecs.filter(function (dec) {
175
+ return (dec === null || dec === void 0 ? void 0 : dec.from) === pos;
176
+ });
177
+
178
+ // If multiple decorations at the active node pos, we want the last one
179
+ var nodeDecAtActivePos = nodeDecsAtActivePos.pop();
180
+ return nodeDecAtActivePos;
181
+ };
169
182
  var newApply = exports.newApply = function newApply(api, formatMessage, tr, currentState, newState, flags, nodeViewPortalProviderAPI, anchorRectCache) {
170
183
  var _meta$multiSelectDnD, _meta$activeNode, _activeNode, _activeNode2, _meta$activeNode$hand, _meta$isDragging, _meta$isDragging2, _meta$toggleMenu, _meta$editorHeight, _meta$editorWidthLeft, _meta$editorWidthRigh, _meta$isPMDragging, _meta$isShiftDown, _meta$lastDragCancell;
171
184
  var activeNode = currentState.activeNode,
@@ -189,14 +202,28 @@ var newApply = exports.newApply = function newApply(api, formatMessage, tr, curr
189
202
  if (activeNode) {
190
203
  var mappedPos = tr.mapping.mapResult(activeNode.pos);
191
204
  isActiveNodeDeleted = mappedPos.deleted;
192
- activeNode = {
193
- pos: mappedPos.pos,
194
- anchorName: activeNode.anchorName,
195
- nodeType: activeNode.nodeType,
196
- rootPos: activeNode.rootPos,
197
- rootAnchorName: activeNode.rootAnchorName,
198
- rootNodeType: activeNode.rootNodeType
199
- };
205
+ if ((0, _experiments.editorExperiment)('platform_editor_controls', 'control')) {
206
+ activeNode = {
207
+ pos: mappedPos.pos,
208
+ anchorName: activeNode.anchorName,
209
+ nodeType: activeNode.nodeType
210
+ };
211
+ } else {
212
+ var _mappedRootPos$pos, _mappedRootPos;
213
+ // for editor controls, remap the rootPos as well
214
+ var mappedRootPos;
215
+ if (activeNode.rootPos !== undefined) {
216
+ mappedRootPos = tr.mapping.mapResult(activeNode.rootPos);
217
+ }
218
+ activeNode = {
219
+ pos: mappedPos.pos,
220
+ anchorName: activeNode.anchorName,
221
+ nodeType: activeNode.nodeType,
222
+ rootPos: (_mappedRootPos$pos = (_mappedRootPos = mappedRootPos) === null || _mappedRootPos === void 0 ? void 0 : _mappedRootPos.pos) !== null && _mappedRootPos$pos !== void 0 ? _mappedRootPos$pos : activeNode.rootPos,
223
+ rootAnchorName: activeNode.rootAnchorName,
224
+ rootNodeType: activeNode.rootNodeType
225
+ };
226
+ }
200
227
  }
201
228
  if (multiSelectDnD && flags.isMultiSelectEnabled) {
202
229
  multiSelectDnD.anchor = tr.mapping.map(multiSelectDnD.anchor);
@@ -229,22 +256,40 @@ var newApply = exports.newApply = function newApply(api, formatMessage, tr, curr
229
256
  var newNodeDecs = (0, _decorationsAnchor.nodeDecorations)(newState, isDecSetEmpty ? undefined : from, isDecSetEmpty ? undefined : to);
230
257
  decorations = decorations.add(newState.doc, newNodeDecs);
231
258
  if (latestActiveNode && !isActiveNodeDeleted) {
232
- // Find the newly minted node decs that touch the active node
233
- var findNewNodeDecs = (0, _decorationsAnchor.findNodeDecs)(decorations, latestActiveNode.pos - 1, to);
259
+ if ((0, _experiments.editorExperiment)('platform_editor_controls', 'control')) {
260
+ // Find the newly minted node decs that touch the active node
261
+ var findNewNodeDecs = (0, _decorationsAnchor.findNodeDecs)(decorations, latestActiveNode.pos - 1, to);
234
262
 
235
- // Find the specific dec that the active node corresponds to
236
- var nodeDecsAtActivePos = findNewNodeDecs.filter(function (dec) {
237
- return (dec === null || dec === void 0 ? void 0 : dec.from) === latestActiveNode.pos;
238
- });
263
+ // Find the specific dec that the active node corresponds to
264
+ var nodeDecsAtActivePos = findNewNodeDecs.filter(function (dec) {
265
+ return (dec === null || dec === void 0 ? void 0 : dec.from) === latestActiveNode.pos;
266
+ });
239
267
 
240
- // If multiple decorations at the active node pos, we want the last one
241
- var nodeDecAtActivePos = nodeDecsAtActivePos.pop();
268
+ // If multiple decorations at the active node pos, we want the last one
269
+ var nodeDecAtActivePos = nodeDecsAtActivePos.pop();
242
270
 
243
- // Update the active node anchor-name and type for accurate positioning
244
- if (nodeDecAtActivePos) {
245
- isActiveNodeModified = true;
246
- latestActiveNode.anchorName = nodeDecAtActivePos.spec.anchorName;
247
- latestActiveNode.nodeType = nodeDecAtActivePos.spec.nodeType;
271
+ // Update the active node anchor-name and type for accurate positioning
272
+ if (nodeDecAtActivePos) {
273
+ isActiveNodeModified = true;
274
+ latestActiveNode.anchorName = nodeDecAtActivePos.spec.anchorName;
275
+ latestActiveNode.nodeType = nodeDecAtActivePos.spec.nodeType;
276
+ }
277
+ } else {
278
+ var _nodeDecAtActivePos = getDecorationAtPos(decorations, latestActiveNode.pos, to);
279
+ var rootNodeDecAtActivePos = getDecorationAtPos(decorations, latestActiveNode.rootPos, to);
280
+ if (_nodeDecAtActivePos || rootNodeDecAtActivePos) {
281
+ isActiveNodeModified = true;
282
+ }
283
+
284
+ // Update the active node anchor-name and type for accurate positioning
285
+ if (_nodeDecAtActivePos) {
286
+ latestActiveNode.anchorName = _nodeDecAtActivePos.spec.anchorName;
287
+ latestActiveNode.nodeType = _nodeDecAtActivePos.spec.nodeType;
288
+ }
289
+ if (rootNodeDecAtActivePos) {
290
+ latestActiveNode.rootAnchorName = rootNodeDecAtActivePos.spec.anchorName;
291
+ latestActiveNode.rootNodeType = rootNodeDecAtActivePos.spec.nodeType;
292
+ }
248
293
  }
249
294
  }
250
295
  }
@@ -155,18 +155,6 @@ var topLevelNodeMarginStyles = (0, _react.css)({
155
155
  }
156
156
  }
157
157
  });
158
-
159
- // when quick insert is rendered there are 2 widgets before the first block node
160
- var topLevelNodeMarginWithQuickInsertStyles = (0, _react.css)({
161
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
162
- '.ProseMirror': {
163
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
164
- '> .ProseMirror-widget:nth-child(-n + 2) + .ProseMirror-gapcursor + *:not([data-layout-section="true"]), > .ProseMirror-widget:nth-child(-n + 2) + *:not([data-layout-section="true"])': {
165
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles -- Ignored via go/DSP-18766
166
- marginTop: '0 !important'
167
- }
168
- }
169
- });
170
158
  var withDividerInPanelStyleFix = (0, _react.css)((0, _defineProperty2.default)({}, "".concat(dividerBodiedInCustomPanelWithNoIconSelector), {
171
159
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles
172
160
  marginTop: '0 !important'
@@ -228,6 +216,6 @@ var blockCardWithoutLayout = (0, _react.css)({
228
216
  });
229
217
  var GlobalStylesWrapper = exports.GlobalStylesWrapper = function GlobalStylesWrapper() {
230
218
  return (0, _react.jsx)(_react.Global, {
231
- styles: [globalStyles(), (0, _platformFeatureFlags.fg)('platform_editor_advanced_layouts_post_fix_patch_1') && globalDnDStyle, (0, _experiments.editorExperiment)('nested-dnd', true) ? extendedHoverZoneNested() : extendedHoverZone(), withInlineNodeStyle, withDeleteLinesStyleFix, withMediaSingleStyleFix, legacyBreakoutWideLayoutStyle, headingWithIndentationInLayoutStyleFix, (0, _experiments.editorExperiment)('advanced_layouts', true) ? blockCardWithoutLayout : undefined, withDividerInPanelStyleFix, withFormatInLayoutStyleFix, withRelativePosStyle, (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') ? topLevelNodeMarginWithQuickInsertStyles : topLevelNodeMarginStyles, (0, _experiments.editorExperiment)('nested-dnd', true) ? withAnchorNameZindexNestedStyle : withAnchorNameZindexStyle,,]
219
+ styles: [globalStyles(), (0, _platformFeatureFlags.fg)('platform_editor_advanced_layouts_post_fix_patch_1') && globalDnDStyle, (0, _experiments.editorExperiment)('nested-dnd', true) ? extendedHoverZoneNested() : extendedHoverZone(), withInlineNodeStyle, withDeleteLinesStyleFix, withMediaSingleStyleFix, legacyBreakoutWideLayoutStyle, headingWithIndentationInLayoutStyleFix, (0, _experiments.editorExperiment)('advanced_layouts', true) ? blockCardWithoutLayout : undefined, withDividerInPanelStyleFix, withFormatInLayoutStyleFix, withRelativePosStyle, topLevelNodeMarginStyles, (0, _experiments.editorExperiment)('nested-dnd', true) ? withAnchorNameZindexNestedStyle : withAnchorNameZindexStyle,,]
232
220
  });
233
221
  };
@@ -13,7 +13,7 @@ var _keymaps = require("@atlaskit/editor-common/keymaps");
13
13
  var _messages = require("@atlaskit/editor-common/messages");
14
14
  var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
15
15
  var _state = require("@atlaskit/editor-prosemirror/state");
16
- var _add = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/add"));
16
+ var _add = _interopRequireDefault(require("@atlaskit/icon/utility/add"));
17
17
  var _primitives = require("@atlaskit/primitives");
18
18
  var _tooltip = _interopRequireDefault(require("@atlaskit/tooltip"));
19
19
  var _dragHandlePositions = require("../pm-plugins/utils/drag-handle-positions");
@@ -151,8 +151,7 @@ var TypeAheadControl = exports.TypeAheadControl = function TypeAheadControl(_ref
151
151
  xcss: [containerStaticStyles]
152
152
  }, /*#__PURE__*/_react.default.createElement(_tooltip.default, {
153
153
  content: /*#__PURE__*/_react.default.createElement(_keymaps.ToolTipContent, {
154
- description: formatMessage(_messages.blockControlsMessages.insert),
155
- shortcutOverride: "/"
154
+ description: formatMessage(_messages.blockControlsMessages.insert)
156
155
  })
157
156
  }, /*#__PURE__*/_react.default.createElement(_primitives.Pressable, {
158
157
  type: "button",
@@ -179,8 +178,7 @@ var TypeAheadControl = exports.TypeAheadControl = function TypeAheadControl(_ref
179
178
  api === null || api === void 0 || (_api$quickInsert = api.quickInsert) === null || _api$quickInsert === void 0 || _api$quickInsert.actions.openTypeAhead('blockControl');
180
179
  }
181
180
  }, /*#__PURE__*/_react.default.createElement(_add.default, {
182
- label: "add",
183
- size: "medium"
181
+ label: "add"
184
182
  }))))
185
183
  );
186
184
  };
@@ -88,7 +88,10 @@ export const nodeDecorations = (newState, from, to) => {
88
88
  return shouldDescend; //skip over, don't consider it a valid depth
89
89
  }
90
90
  }
91
- const anchorStyles = `anchor-name: ${anchorName};`;
91
+ const anchorStyles = pos === 0 && editorExperiment('platform_editor_controls', 'variant1') ?
92
+ // why margin-top:0? well it's not possible using CSS to select the first node in the document while excluding n number of nodes, in this case
93
+ // we're rendering quick insert button and drag handle. For now override margin-top to 0
94
+ `anchor-name: ${anchorName};margin-top:0px;` : `anchor-name: ${anchorName};`;
92
95
  decs.push(Decoration.node(pos, pos + node.nodeSize, {
93
96
  style: anchorStyles,
94
97
  ['data-drag-handler-anchor-name']: anchorName,
@@ -66,7 +66,7 @@ export const dragHandleDecoration = (api, formatMessage, pos, anchorName, nodeTy
66
66
  // temporarily re-instating ReactDOM.render to fix drag handle focus issue, fix to
67
67
  // follow via ED-26546
68
68
 
69
- // if (fg('platform_editor_react18_plugin_portalprovider')) {
69
+ // previous under platform_editor_react18_plugin_portalprovider
70
70
  // nodeViewPortalProviderAPI.render(
71
71
  // () =>
72
72
  // createElement(DragHandle, {
@@ -82,7 +82,7 @@ export const dragHandleDecoration = (api, formatMessage, pos, anchorName, nodeTy
82
82
  // element,
83
83
  // key,
84
84
  // );
85
- // } else {
85
+
86
86
  ReactDOM.render( /*#__PURE__*/createElement(DragHandle, {
87
87
  view,
88
88
  api,
@@ -11,6 +11,7 @@ export const quickInsertButtonDecoration = (api, formatMessage, rootPos, anchorN
11
11
  return Decoration.widget(rootPos, (view, getPos) => {
12
12
  const element = document.createElement('span');
13
13
  element.contentEditable = 'false';
14
+ element.setAttribute('data-blocks-quick-insert-container', 'true');
14
15
  nodeViewPortalProviderAPI.render(() => /*#__PURE__*/createElement(TypeAheadControl, {
15
16
  api,
16
17
  getPos,
@@ -162,6 +162,17 @@ export const getDecorations = state => {
162
162
  var _key$getState;
163
163
  return (_key$getState = key.getState(state)) === null || _key$getState === void 0 ? void 0 : _key$getState.decorations;
164
164
  };
165
+ const getDecorationAtPos = (decorations, pos, to) => {
166
+ // Find the newly minted node decs that touch the active node
167
+ const findNewNodeDecs = findNodeDecs(decorations, pos - 1, to);
168
+
169
+ // Find the specific dec that the active node corresponds to
170
+ const nodeDecsAtActivePos = findNewNodeDecs.filter(dec => (dec === null || dec === void 0 ? void 0 : dec.from) === pos);
171
+
172
+ // If multiple decorations at the active node pos, we want the last one
173
+ const nodeDecAtActivePos = nodeDecsAtActivePos.pop();
174
+ return nodeDecAtActivePos;
175
+ };
165
176
  export const newApply = (api, formatMessage, tr, currentState, newState, flags, nodeViewPortalProviderAPI, anchorRectCache) => {
166
177
  var _meta$multiSelectDnD, _meta$activeNode, _activeNode, _activeNode2, _meta$activeNode$hand, _meta$isDragging, _meta$isDragging2, _meta$toggleMenu, _meta$editorHeight, _meta$editorWidthLeft, _meta$editorWidthRigh, _meta$isPMDragging, _meta$isShiftDown, _meta$lastDragCancell;
167
178
  let {
@@ -189,14 +200,28 @@ export const newApply = (api, formatMessage, tr, currentState, newState, flags,
189
200
  if (activeNode) {
190
201
  const mappedPos = tr.mapping.mapResult(activeNode.pos);
191
202
  isActiveNodeDeleted = mappedPos.deleted;
192
- activeNode = {
193
- pos: mappedPos.pos,
194
- anchorName: activeNode.anchorName,
195
- nodeType: activeNode.nodeType,
196
- rootPos: activeNode.rootPos,
197
- rootAnchorName: activeNode.rootAnchorName,
198
- rootNodeType: activeNode.rootNodeType
199
- };
203
+ if (editorExperiment('platform_editor_controls', 'control')) {
204
+ activeNode = {
205
+ pos: mappedPos.pos,
206
+ anchorName: activeNode.anchorName,
207
+ nodeType: activeNode.nodeType
208
+ };
209
+ } else {
210
+ var _mappedRootPos$pos, _mappedRootPos;
211
+ // for editor controls, remap the rootPos as well
212
+ let mappedRootPos;
213
+ if (activeNode.rootPos !== undefined) {
214
+ mappedRootPos = tr.mapping.mapResult(activeNode.rootPos);
215
+ }
216
+ activeNode = {
217
+ pos: mappedPos.pos,
218
+ anchorName: activeNode.anchorName,
219
+ nodeType: activeNode.nodeType,
220
+ rootPos: (_mappedRootPos$pos = (_mappedRootPos = mappedRootPos) === null || _mappedRootPos === void 0 ? void 0 : _mappedRootPos.pos) !== null && _mappedRootPos$pos !== void 0 ? _mappedRootPos$pos : activeNode.rootPos,
221
+ rootAnchorName: activeNode.rootAnchorName,
222
+ rootNodeType: activeNode.rootNodeType
223
+ };
224
+ }
200
225
  }
201
226
  if (multiSelectDnD && flags.isMultiSelectEnabled) {
202
227
  multiSelectDnD.anchor = tr.mapping.map(multiSelectDnD.anchor);
@@ -230,20 +255,38 @@ export const newApply = (api, formatMessage, tr, currentState, newState, flags,
230
255
  const newNodeDecs = nodeDecorations(newState, isDecSetEmpty ? undefined : from, isDecSetEmpty ? undefined : to);
231
256
  decorations = decorations.add(newState.doc, newNodeDecs);
232
257
  if (latestActiveNode && !isActiveNodeDeleted) {
233
- // Find the newly minted node decs that touch the active node
234
- const findNewNodeDecs = findNodeDecs(decorations, latestActiveNode.pos - 1, to);
258
+ if (editorExperiment('platform_editor_controls', 'control')) {
259
+ // Find the newly minted node decs that touch the active node
260
+ const findNewNodeDecs = findNodeDecs(decorations, latestActiveNode.pos - 1, to);
235
261
 
236
- // Find the specific dec that the active node corresponds to
237
- const nodeDecsAtActivePos = findNewNodeDecs.filter(dec => (dec === null || dec === void 0 ? void 0 : dec.from) === latestActiveNode.pos);
262
+ // Find the specific dec that the active node corresponds to
263
+ const nodeDecsAtActivePos = findNewNodeDecs.filter(dec => (dec === null || dec === void 0 ? void 0 : dec.from) === latestActiveNode.pos);
238
264
 
239
- // If multiple decorations at the active node pos, we want the last one
240
- const nodeDecAtActivePos = nodeDecsAtActivePos.pop();
265
+ // If multiple decorations at the active node pos, we want the last one
266
+ const nodeDecAtActivePos = nodeDecsAtActivePos.pop();
241
267
 
242
- // Update the active node anchor-name and type for accurate positioning
243
- if (nodeDecAtActivePos) {
244
- isActiveNodeModified = true;
245
- latestActiveNode.anchorName = nodeDecAtActivePos.spec.anchorName;
246
- latestActiveNode.nodeType = nodeDecAtActivePos.spec.nodeType;
268
+ // Update the active node anchor-name and type for accurate positioning
269
+ if (nodeDecAtActivePos) {
270
+ isActiveNodeModified = true;
271
+ latestActiveNode.anchorName = nodeDecAtActivePos.spec.anchorName;
272
+ latestActiveNode.nodeType = nodeDecAtActivePos.spec.nodeType;
273
+ }
274
+ } else {
275
+ const nodeDecAtActivePos = getDecorationAtPos(decorations, latestActiveNode.pos, to);
276
+ const rootNodeDecAtActivePos = getDecorationAtPos(decorations, latestActiveNode.rootPos, to);
277
+ if (nodeDecAtActivePos || rootNodeDecAtActivePos) {
278
+ isActiveNodeModified = true;
279
+ }
280
+
281
+ // Update the active node anchor-name and type for accurate positioning
282
+ if (nodeDecAtActivePos) {
283
+ latestActiveNode.anchorName = nodeDecAtActivePos.spec.anchorName;
284
+ latestActiveNode.nodeType = nodeDecAtActivePos.spec.nodeType;
285
+ }
286
+ if (rootNodeDecAtActivePos) {
287
+ latestActiveNode.rootAnchorName = rootNodeDecAtActivePos.spec.anchorName;
288
+ latestActiveNode.rootNodeType = rootNodeDecAtActivePos.spec.nodeType;
289
+ }
247
290
  }
248
291
  }
249
292
  }
@@ -178,18 +178,6 @@ const topLevelNodeMarginStyles = css({
178
178
  }
179
179
  }
180
180
  });
181
-
182
- // when quick insert is rendered there are 2 widgets before the first block node
183
- const topLevelNodeMarginWithQuickInsertStyles = css({
184
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
185
- '.ProseMirror': {
186
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
187
- '> .ProseMirror-widget:nth-child(-n + 2) + .ProseMirror-gapcursor + *:not([data-layout-section="true"]), > .ProseMirror-widget:nth-child(-n + 2) + *:not([data-layout-section="true"])': {
188
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles -- Ignored via go/DSP-18766
189
- marginTop: '0 !important'
190
- }
191
- }
192
- });
193
181
  const withDividerInPanelStyleFix = css({
194
182
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-values
195
183
  [`${dividerBodiedInCustomPanelWithNoIconSelector}`]: {
@@ -272,6 +260,6 @@ const blockCardWithoutLayout = css({
272
260
  });
273
261
  export const GlobalStylesWrapper = () => {
274
262
  return jsx(Global, {
275
- styles: [globalStyles(), fg('platform_editor_advanced_layouts_post_fix_patch_1') && globalDnDStyle, editorExperiment('nested-dnd', true) ? extendedHoverZoneNested() : extendedHoverZone(), withInlineNodeStyle, withDeleteLinesStyleFix, withMediaSingleStyleFix, legacyBreakoutWideLayoutStyle, headingWithIndentationInLayoutStyleFix, editorExperiment('advanced_layouts', true) ? blockCardWithoutLayout : undefined, withDividerInPanelStyleFix, withFormatInLayoutStyleFix, withRelativePosStyle, editorExperiment('platform_editor_controls', 'variant1') ? topLevelNodeMarginWithQuickInsertStyles : topLevelNodeMarginStyles, editorExperiment('nested-dnd', true) ? withAnchorNameZindexNestedStyle : withAnchorNameZindexStyle,,]
263
+ styles: [globalStyles(), fg('platform_editor_advanced_layouts_post_fix_patch_1') && globalDnDStyle, editorExperiment('nested-dnd', true) ? extendedHoverZoneNested() : extendedHoverZone(), withInlineNodeStyle, withDeleteLinesStyleFix, withMediaSingleStyleFix, legacyBreakoutWideLayoutStyle, headingWithIndentationInLayoutStyleFix, editorExperiment('advanced_layouts', true) ? blockCardWithoutLayout : undefined, withDividerInPanelStyleFix, withFormatInLayoutStyleFix, withRelativePosStyle, topLevelNodeMarginStyles, editorExperiment('nested-dnd', true) ? withAnchorNameZindexNestedStyle : withAnchorNameZindexStyle,,]
276
264
  });
277
265
  };
@@ -4,7 +4,7 @@ import { ToolTipContent } from '@atlaskit/editor-common/keymaps';
4
4
  import { blockControlsMessages as messages } from '@atlaskit/editor-common/messages';
5
5
  import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
6
6
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
7
- import EditorAddIcon from '@atlaskit/icon/glyph/editor/add';
7
+ import AddIcon from '@atlaskit/icon/utility/add';
8
8
  import { Box, Pressable, xcss } from '@atlaskit/primitives';
9
9
  import Tooltip from '@atlaskit/tooltip';
10
10
  import { getTopPosition } from '../pm-plugins/utils/drag-handle-positions';
@@ -139,8 +139,7 @@ export const TypeAheadControl = ({
139
139
  xcss: [containerStaticStyles]
140
140
  }, /*#__PURE__*/React.createElement(Tooltip, {
141
141
  content: /*#__PURE__*/React.createElement(ToolTipContent, {
142
- description: formatMessage(messages.insert),
143
- shortcutOverride: "/"
142
+ description: formatMessage(messages.insert)
144
143
  })
145
144
  }, /*#__PURE__*/React.createElement(Pressable, {
146
145
  type: "button",
@@ -167,9 +166,8 @@ export const TypeAheadControl = ({
167
166
  }
168
167
  api === null || api === void 0 ? void 0 : (_api$quickInsert = api.quickInsert) === null || _api$quickInsert === void 0 ? void 0 : _api$quickInsert.actions.openTypeAhead('blockControl');
169
168
  }
170
- }, /*#__PURE__*/React.createElement(EditorAddIcon, {
171
- label: "add",
172
- size: "medium"
169
+ }, /*#__PURE__*/React.createElement(AddIcon, {
170
+ label: "add"
173
171
  }))))
174
172
  );
175
173
  };
@@ -91,7 +91,9 @@ export var nodeDecorations = function nodeDecorations(newState, from, to) {
91
91
  return shouldDescend; //skip over, don't consider it a valid depth
92
92
  }
93
93
  }
94
- var anchorStyles = "anchor-name: ".concat(anchorName, ";");
94
+ var anchorStyles = pos === 0 && editorExperiment('platform_editor_controls', 'variant1') ? // why margin-top:0? well it's not possible using CSS to select the first node in the document while excluding n number of nodes, in this case
95
+ // we're rendering quick insert button and drag handle. For now override margin-top to 0
96
+ "anchor-name: ".concat(anchorName, ";margin-top:0px;") : "anchor-name: ".concat(anchorName, ";");
95
97
  decs.push(Decoration.node(pos, pos + node.nodeSize, _defineProperty(_defineProperty(_defineProperty({
96
98
  style: anchorStyles
97
99
  }, 'data-drag-handler-anchor-name', anchorName), 'data-drag-handler-node-type', nodeTypeWithLevel), 'data-drag-handler-anchor-depth', "".concat(depth)), {
@@ -68,7 +68,7 @@ export var dragHandleDecoration = function dragHandleDecoration(api, formatMessa
68
68
  // temporarily re-instating ReactDOM.render to fix drag handle focus issue, fix to
69
69
  // follow via ED-26546
70
70
 
71
- // if (fg('platform_editor_react18_plugin_portalprovider')) {
71
+ // previous under platform_editor_react18_plugin_portalprovider
72
72
  // nodeViewPortalProviderAPI.render(
73
73
  // () =>
74
74
  // createElement(DragHandle, {
@@ -84,7 +84,7 @@ export var dragHandleDecoration = function dragHandleDecoration(api, formatMessa
84
84
  // element,
85
85
  // key,
86
86
  // );
87
- // } else {
87
+
88
88
  ReactDOM.render( /*#__PURE__*/createElement(DragHandle, {
89
89
  view: view,
90
90
  api: api,
@@ -13,6 +13,7 @@ export var quickInsertButtonDecoration = function quickInsertButtonDecoration(ap
13
13
  return Decoration.widget(rootPos, function (view, getPos) {
14
14
  var element = document.createElement('span');
15
15
  element.contentEditable = 'false';
16
+ element.setAttribute('data-blocks-quick-insert-container', 'true');
16
17
  nodeViewPortalProviderAPI.render(function () {
17
18
  return /*#__PURE__*/createElement(TypeAheadControl, {
18
19
  api: api,
@@ -159,6 +159,19 @@ export var getDecorations = function getDecorations(state) {
159
159
  var _key$getState;
160
160
  return (_key$getState = key.getState(state)) === null || _key$getState === void 0 ? void 0 : _key$getState.decorations;
161
161
  };
162
+ var getDecorationAtPos = function getDecorationAtPos(decorations, pos, to) {
163
+ // Find the newly minted node decs that touch the active node
164
+ var findNewNodeDecs = findNodeDecs(decorations, pos - 1, to);
165
+
166
+ // Find the specific dec that the active node corresponds to
167
+ var nodeDecsAtActivePos = findNewNodeDecs.filter(function (dec) {
168
+ return (dec === null || dec === void 0 ? void 0 : dec.from) === pos;
169
+ });
170
+
171
+ // If multiple decorations at the active node pos, we want the last one
172
+ var nodeDecAtActivePos = nodeDecsAtActivePos.pop();
173
+ return nodeDecAtActivePos;
174
+ };
162
175
  export var newApply = function newApply(api, formatMessage, tr, currentState, newState, flags, nodeViewPortalProviderAPI, anchorRectCache) {
163
176
  var _meta$multiSelectDnD, _meta$activeNode, _activeNode, _activeNode2, _meta$activeNode$hand, _meta$isDragging, _meta$isDragging2, _meta$toggleMenu, _meta$editorHeight, _meta$editorWidthLeft, _meta$editorWidthRigh, _meta$isPMDragging, _meta$isShiftDown, _meta$lastDragCancell;
164
177
  var activeNode = currentState.activeNode,
@@ -182,14 +195,28 @@ export var newApply = function newApply(api, formatMessage, tr, currentState, ne
182
195
  if (activeNode) {
183
196
  var mappedPos = tr.mapping.mapResult(activeNode.pos);
184
197
  isActiveNodeDeleted = mappedPos.deleted;
185
- activeNode = {
186
- pos: mappedPos.pos,
187
- anchorName: activeNode.anchorName,
188
- nodeType: activeNode.nodeType,
189
- rootPos: activeNode.rootPos,
190
- rootAnchorName: activeNode.rootAnchorName,
191
- rootNodeType: activeNode.rootNodeType
192
- };
198
+ if (editorExperiment('platform_editor_controls', 'control')) {
199
+ activeNode = {
200
+ pos: mappedPos.pos,
201
+ anchorName: activeNode.anchorName,
202
+ nodeType: activeNode.nodeType
203
+ };
204
+ } else {
205
+ var _mappedRootPos$pos, _mappedRootPos;
206
+ // for editor controls, remap the rootPos as well
207
+ var mappedRootPos;
208
+ if (activeNode.rootPos !== undefined) {
209
+ mappedRootPos = tr.mapping.mapResult(activeNode.rootPos);
210
+ }
211
+ activeNode = {
212
+ pos: mappedPos.pos,
213
+ anchorName: activeNode.anchorName,
214
+ nodeType: activeNode.nodeType,
215
+ rootPos: (_mappedRootPos$pos = (_mappedRootPos = mappedRootPos) === null || _mappedRootPos === void 0 ? void 0 : _mappedRootPos.pos) !== null && _mappedRootPos$pos !== void 0 ? _mappedRootPos$pos : activeNode.rootPos,
216
+ rootAnchorName: activeNode.rootAnchorName,
217
+ rootNodeType: activeNode.rootNodeType
218
+ };
219
+ }
193
220
  }
194
221
  if (multiSelectDnD && flags.isMultiSelectEnabled) {
195
222
  multiSelectDnD.anchor = tr.mapping.map(multiSelectDnD.anchor);
@@ -222,22 +249,40 @@ export var newApply = function newApply(api, formatMessage, tr, currentState, ne
222
249
  var newNodeDecs = nodeDecorations(newState, isDecSetEmpty ? undefined : from, isDecSetEmpty ? undefined : to);
223
250
  decorations = decorations.add(newState.doc, newNodeDecs);
224
251
  if (latestActiveNode && !isActiveNodeDeleted) {
225
- // Find the newly minted node decs that touch the active node
226
- var findNewNodeDecs = findNodeDecs(decorations, latestActiveNode.pos - 1, to);
252
+ if (editorExperiment('platform_editor_controls', 'control')) {
253
+ // Find the newly minted node decs that touch the active node
254
+ var findNewNodeDecs = findNodeDecs(decorations, latestActiveNode.pos - 1, to);
227
255
 
228
- // Find the specific dec that the active node corresponds to
229
- var nodeDecsAtActivePos = findNewNodeDecs.filter(function (dec) {
230
- return (dec === null || dec === void 0 ? void 0 : dec.from) === latestActiveNode.pos;
231
- });
256
+ // Find the specific dec that the active node corresponds to
257
+ var nodeDecsAtActivePos = findNewNodeDecs.filter(function (dec) {
258
+ return (dec === null || dec === void 0 ? void 0 : dec.from) === latestActiveNode.pos;
259
+ });
232
260
 
233
- // If multiple decorations at the active node pos, we want the last one
234
- var nodeDecAtActivePos = nodeDecsAtActivePos.pop();
261
+ // If multiple decorations at the active node pos, we want the last one
262
+ var nodeDecAtActivePos = nodeDecsAtActivePos.pop();
235
263
 
236
- // Update the active node anchor-name and type for accurate positioning
237
- if (nodeDecAtActivePos) {
238
- isActiveNodeModified = true;
239
- latestActiveNode.anchorName = nodeDecAtActivePos.spec.anchorName;
240
- latestActiveNode.nodeType = nodeDecAtActivePos.spec.nodeType;
264
+ // Update the active node anchor-name and type for accurate positioning
265
+ if (nodeDecAtActivePos) {
266
+ isActiveNodeModified = true;
267
+ latestActiveNode.anchorName = nodeDecAtActivePos.spec.anchorName;
268
+ latestActiveNode.nodeType = nodeDecAtActivePos.spec.nodeType;
269
+ }
270
+ } else {
271
+ var _nodeDecAtActivePos = getDecorationAtPos(decorations, latestActiveNode.pos, to);
272
+ var rootNodeDecAtActivePos = getDecorationAtPos(decorations, latestActiveNode.rootPos, to);
273
+ if (_nodeDecAtActivePos || rootNodeDecAtActivePos) {
274
+ isActiveNodeModified = true;
275
+ }
276
+
277
+ // Update the active node anchor-name and type for accurate positioning
278
+ if (_nodeDecAtActivePos) {
279
+ latestActiveNode.anchorName = _nodeDecAtActivePos.spec.anchorName;
280
+ latestActiveNode.nodeType = _nodeDecAtActivePos.spec.nodeType;
281
+ }
282
+ if (rootNodeDecAtActivePos) {
283
+ latestActiveNode.rootAnchorName = rootNodeDecAtActivePos.spec.anchorName;
284
+ latestActiveNode.rootNodeType = rootNodeDecAtActivePos.spec.nodeType;
285
+ }
241
286
  }
242
287
  }
243
288
  }
@@ -148,18 +148,6 @@ var topLevelNodeMarginStyles = css({
148
148
  }
149
149
  }
150
150
  });
151
-
152
- // when quick insert is rendered there are 2 widgets before the first block node
153
- var topLevelNodeMarginWithQuickInsertStyles = css({
154
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
155
- '.ProseMirror': {
156
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
157
- '> .ProseMirror-widget:nth-child(-n + 2) + .ProseMirror-gapcursor + *:not([data-layout-section="true"]), > .ProseMirror-widget:nth-child(-n + 2) + *:not([data-layout-section="true"])': {
158
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles -- Ignored via go/DSP-18766
159
- marginTop: '0 !important'
160
- }
161
- }
162
- });
163
151
  var withDividerInPanelStyleFix = css(_defineProperty({}, "".concat(dividerBodiedInCustomPanelWithNoIconSelector), {
164
152
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles
165
153
  marginTop: '0 !important'
@@ -221,6 +209,6 @@ var blockCardWithoutLayout = css({
221
209
  });
222
210
  export var GlobalStylesWrapper = function GlobalStylesWrapper() {
223
211
  return jsx(Global, {
224
- styles: [globalStyles(), fg('platform_editor_advanced_layouts_post_fix_patch_1') && globalDnDStyle, editorExperiment('nested-dnd', true) ? extendedHoverZoneNested() : extendedHoverZone(), withInlineNodeStyle, withDeleteLinesStyleFix, withMediaSingleStyleFix, legacyBreakoutWideLayoutStyle, headingWithIndentationInLayoutStyleFix, editorExperiment('advanced_layouts', true) ? blockCardWithoutLayout : undefined, withDividerInPanelStyleFix, withFormatInLayoutStyleFix, withRelativePosStyle, editorExperiment('platform_editor_controls', 'variant1') ? topLevelNodeMarginWithQuickInsertStyles : topLevelNodeMarginStyles, editorExperiment('nested-dnd', true) ? withAnchorNameZindexNestedStyle : withAnchorNameZindexStyle,,]
212
+ styles: [globalStyles(), fg('platform_editor_advanced_layouts_post_fix_patch_1') && globalDnDStyle, editorExperiment('nested-dnd', true) ? extendedHoverZoneNested() : extendedHoverZone(), withInlineNodeStyle, withDeleteLinesStyleFix, withMediaSingleStyleFix, legacyBreakoutWideLayoutStyle, headingWithIndentationInLayoutStyleFix, editorExperiment('advanced_layouts', true) ? blockCardWithoutLayout : undefined, withDividerInPanelStyleFix, withFormatInLayoutStyleFix, withRelativePosStyle, topLevelNodeMarginStyles, editorExperiment('nested-dnd', true) ? withAnchorNameZindexNestedStyle : withAnchorNameZindexStyle,,]
225
213
  });
226
214
  };
@@ -5,7 +5,7 @@ import { ToolTipContent } from '@atlaskit/editor-common/keymaps';
5
5
  import { blockControlsMessages as messages } from '@atlaskit/editor-common/messages';
6
6
  import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
7
7
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
8
- import EditorAddIcon from '@atlaskit/icon/glyph/editor/add';
8
+ import AddIcon from '@atlaskit/icon/utility/add';
9
9
  import { Box, Pressable, xcss } from '@atlaskit/primitives';
10
10
  import Tooltip from '@atlaskit/tooltip';
11
11
  import { getTopPosition } from '../pm-plugins/utils/drag-handle-positions';
@@ -141,8 +141,7 @@ export var TypeAheadControl = function TypeAheadControl(_ref) {
141
141
  xcss: [containerStaticStyles]
142
142
  }, /*#__PURE__*/React.createElement(Tooltip, {
143
143
  content: /*#__PURE__*/React.createElement(ToolTipContent, {
144
- description: formatMessage(messages.insert),
145
- shortcutOverride: "/"
144
+ description: formatMessage(messages.insert)
146
145
  })
147
146
  }, /*#__PURE__*/React.createElement(Pressable, {
148
147
  type: "button",
@@ -168,9 +167,8 @@ export var TypeAheadControl = function TypeAheadControl(_ref) {
168
167
  }
169
168
  api === null || api === void 0 || (_api$quickInsert = api.quickInsert) === null || _api$quickInsert === void 0 || _api$quickInsert.actions.openTypeAhead('blockControl');
170
169
  }
171
- }, /*#__PURE__*/React.createElement(EditorAddIcon, {
172
- label: "add",
173
- size: "medium"
170
+ }, /*#__PURE__*/React.createElement(AddIcon, {
171
+ label: "add"
174
172
  }))))
175
173
  );
176
174
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-controls",
3
- "version": "3.1.9",
3
+ "version": "3.2.1",
4
4
  "description": "Block controls plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -32,10 +32,10 @@
32
32
  ".": "./src/index.ts"
33
33
  },
34
34
  "dependencies": {
35
- "@atlaskit/adf-schema": "^47.2.1",
36
- "@atlaskit/editor-common": "^100.4.0",
35
+ "@atlaskit/adf-schema": "^47.6.0",
36
+ "@atlaskit/editor-common": "^101.0.0",
37
37
  "@atlaskit/editor-plugin-accessibility-utils": "^2.0.0",
38
- "@atlaskit/editor-plugin-analytics": "^2.0.0",
38
+ "@atlaskit/editor-plugin-analytics": "^2.1.0",
39
39
  "@atlaskit/editor-plugin-editor-disabled": "^2.0.0",
40
40
  "@atlaskit/editor-plugin-feature-flags": "^1.3.0",
41
41
  "@atlaskit/editor-plugin-quick-insert": "^2.0.0",
@@ -51,7 +51,7 @@
51
51
  "@atlaskit/pragmatic-drag-and-drop-react-drop-indicator": "^2.1.0",
52
52
  "@atlaskit/primitives": "^14.1.0",
53
53
  "@atlaskit/theme": "^17.0.0",
54
- "@atlaskit/tmp-editor-statsig": "^3.3.0",
54
+ "@atlaskit/tmp-editor-statsig": "^3.4.0",
55
55
  "@atlaskit/tokens": "^4.3.0",
56
56
  "@atlaskit/tooltip": "^20.0.0",
57
57
  "@babel/runtime": "^7.0.0",