@atlaskit/editor-plugin-block-controls 1.5.5 → 1.5.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,24 @@
1
1
  # @atlaskit/editor-plugin-block-controls
2
2
 
3
+ ## 1.5.7
4
+
5
+ ### Patch Changes
6
+
7
+ - [`2f20977ad803d`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/2f20977ad803d) -
8
+ Fix paragraph to blockquotes with refactor
9
+ platform.editor.elements.drag-and-drop-remove-wrapper_fyqr2 FF off
10
+ - [#114548](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/114548)
11
+ [`8b2d47bffb50e`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/8b2d47bffb50e) -
12
+ bump adf-schema version
13
+ - Updated dependencies
14
+
15
+ ## 1.5.6
16
+
17
+ ### Patch Changes
18
+
19
+ - [`e7c8b06889c5a`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/e7c8b06889c5a) -
20
+ [ux] Fix scroll issue for layout node when drap and drop
21
+
3
22
  ## 1.5.5
4
23
 
5
24
  ### Patch Changes
@@ -109,6 +109,7 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
109
109
  isResizerResizing = currentState.isResizerResizing,
110
110
  isDragging = currentState.isDragging,
111
111
  isPMDragging = currentState.isPMDragging;
112
+ var activeNodeWithNewNodeType = null;
112
113
  var meta = tr.getMeta(key);
113
114
  // when creating analytics during drag/drop events, PM thinks the doc has changed
114
115
  // so tr.docChange is true and causes some decorations to not render
@@ -184,6 +185,11 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
184
185
  if (newActiveNode && (newActiveNode === null || newActiveNode === void 0 ? void 0 : newActiveNode.type.name) !== activeNode.nodeType) {
185
186
  nodeType = newActiveNode.type.name;
186
187
  anchorName = activeNode.anchorName.replace(activeNode.nodeType, nodeType);
188
+ activeNodeWithNewNodeType = {
189
+ pos: prevMappedPos,
190
+ nodeType: nodeType,
191
+ anchorName: anchorName
192
+ };
187
193
  }
188
194
  var draghandleDec = (0, _decorations.dragHandleDecoration)(activeNode.pos, anchorName, nodeType, api);
189
195
  decorations = decorations.add(newState.doc, [draghandleDec]);
@@ -200,21 +206,33 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
200
206
  var decs = (0, _decorations.dragHandleDecoration)(meta.activeNode.pos, meta.activeNode.anchorName, meta.activeNode.nodeType, api);
201
207
  decorations = decorations.add(newState.doc, [decs]);
202
208
  }
203
-
209
+ if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.elements.drag-and-drop-ed-23816')) {
210
+ var _activeNodeWithNewNod;
211
+ // Remove previous drag handle widget and draw new drag handle widget when node type changes
212
+ if (activeNodeWithNewNodeType && ((_activeNodeWithNewNod = activeNodeWithNewNodeType) === null || _activeNodeWithNewNod === void 0 ? void 0 : _activeNodeWithNewNod.nodeType) !== (activeNode === null || activeNode === void 0 ? void 0 : activeNode.nodeType) && api) {
213
+ var _oldHandle2 = decorations.find().filter(function (_ref9) {
214
+ var spec = _ref9.spec;
215
+ return spec.id === 'drag-handle';
216
+ });
217
+ decorations = decorations.remove(_oldHandle2);
218
+ var _decs = (0, _decorations.dragHandleDecoration)(activeNodeWithNewNodeType.pos, activeNodeWithNewNodeType.anchorName, activeNodeWithNewNodeType.nodeType, api);
219
+ decorations = decorations.add(newState.doc, [_decs]);
220
+ }
221
+ }
204
222
  // Add drop targets when node is being dragged
205
223
  // if the transaction is only for analytics and user is dragging, continue to draw drop targets
206
224
  if (meta !== null && meta !== void 0 && meta.isDragging && (!tr.docChanged || tr.docChanged && isAnalyticTr) && api) {
207
225
  var _dropTargetDecoration = (0, _decorations.dropTargetDecorations)(oldState, newState, api),
208
- _decs = _dropTargetDecoration.decs,
226
+ _decs2 = _dropTargetDecoration.decs,
209
227
  updatedDecorationState = _dropTargetDecoration.decorationState;
210
228
  decorationState = updatedDecorationState;
211
- decorations = decorations.add(newState.doc, _decs);
229
+ decorations = decorations.add(newState.doc, _decs2);
212
230
  }
213
231
 
214
232
  // Remove drop target decoration when dragging stops
215
233
  if ((meta === null || meta === void 0 ? void 0 : meta.isDragging) === false && !tr.docChanged) {
216
- var dropTargetDecs = decorations.find().filter(function (_ref9) {
217
- var spec = _ref9.spec;
234
+ var dropTargetDecs = decorations.find().filter(function (_ref10) {
235
+ var spec = _ref10.spec;
218
236
  return spec.type === 'drop-target-decoration';
219
237
  });
220
238
  decorations = decorations.remove(dropTargetDecs);
@@ -222,9 +240,9 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
222
240
 
223
241
  // Map drop target decoration positions when the document changes
224
242
  if (tr.docChanged && isDragging) {
225
- decorationState = decorationState.map(function (_ref10) {
226
- var index = _ref10.index,
227
- pos = _ref10.pos;
243
+ decorationState = decorationState.map(function (_ref11) {
244
+ var index = _ref11.index,
245
+ pos = _ref11.pos;
228
246
  return {
229
247
  index: index,
230
248
  pos: tr.mapping.map(pos)
@@ -237,8 +255,8 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
237
255
  decorations = decorations.map(tr.mapping, tr.doc);
238
256
  }
239
257
  var isEmptyDoc = newState.doc.childCount === 1 && newState.doc.nodeSize <= 4;
240
- var hasNodeDecoration = decorations.find().some(function (_ref11) {
241
- var spec = _ref11.spec;
258
+ var hasNodeDecoration = decorations.find().some(function (_ref12) {
259
+ var spec = _ref12.spec;
242
260
  return spec.type === 'node-decoration';
243
261
  });
244
262
  if (!hasNodeDecoration && isEmptyDoc) {
@@ -246,11 +264,20 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
246
264
  }
247
265
 
248
266
  // Map active node position when the document changes
249
- var mappedActiveNodePos = tr.docChanged && activeNode ? {
250
- pos: tr.mapping.map(activeNode.pos),
251
- anchorName: activeNode.anchorName,
252
- nodeType: activeNode.nodeType
253
- } : activeNode;
267
+ var mappedActiveNodePos;
268
+ if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.elements.drag-and-drop-ed-23816')) {
269
+ mappedActiveNodePos = tr.docChanged && activeNode ? activeNodeWithNewNodeType || {
270
+ pos: tr.mapping.map(activeNode.pos),
271
+ anchorName: activeNode.anchorName,
272
+ nodeType: activeNode.nodeType
273
+ } : activeNode;
274
+ } else {
275
+ mappedActiveNodePos = tr.docChanged && activeNode ? {
276
+ pos: tr.mapping.map(activeNode.pos),
277
+ anchorName: activeNode.anchorName,
278
+ nodeType: activeNode.nodeType
279
+ } : activeNode;
280
+ }
254
281
  return {
255
282
  decorations: decorations,
256
283
  decorationState: decorationState,
@@ -105,6 +105,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
105
105
  });
106
106
  var resolvedMovingNode = tr.doc.resolve(start);
107
107
  var maybeNode = resolvedMovingNode.nodeAfter;
108
+ (0, _platformFeatureFlags.getBooleanFF)('platform.editor.elements.drag-and-drop-long-node-scroll') && tr.setMeta('scrollIntoView', false);
108
109
  api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.attachAnalyticsEvent({
109
110
  eventType: _analytics.EVENT_TYPE.UI,
110
111
  action: _analytics.ACTION.CLICKED,
@@ -105,6 +105,7 @@ export const createPlugin = api => {
105
105
  isDragging,
106
106
  isPMDragging
107
107
  } = currentState;
108
+ let activeNodeWithNewNodeType = null;
108
109
  const meta = tr.getMeta(key);
109
110
  // when creating analytics during drag/drop events, PM thinks the doc has changed
110
111
  // so tr.docChange is true and causes some decorations to not render
@@ -175,6 +176,11 @@ export const createPlugin = api => {
175
176
  if (newActiveNode && (newActiveNode === null || newActiveNode === void 0 ? void 0 : newActiveNode.type.name) !== activeNode.nodeType) {
176
177
  nodeType = newActiveNode.type.name;
177
178
  anchorName = activeNode.anchorName.replace(activeNode.nodeType, nodeType);
179
+ activeNodeWithNewNodeType = {
180
+ pos: prevMappedPos,
181
+ nodeType,
182
+ anchorName
183
+ };
178
184
  }
179
185
  const draghandleDec = dragHandleDecoration(activeNode.pos, anchorName, nodeType, api);
180
186
  decorations = decorations.add(newState.doc, [draghandleDec]);
@@ -190,7 +196,18 @@ export const createPlugin = api => {
190
196
  const decs = dragHandleDecoration(meta.activeNode.pos, meta.activeNode.anchorName, meta.activeNode.nodeType, api);
191
197
  decorations = decorations.add(newState.doc, [decs]);
192
198
  }
193
-
199
+ if (getBooleanFF('platform.editor.elements.drag-and-drop-ed-23816')) {
200
+ var _activeNodeWithNewNod;
201
+ // Remove previous drag handle widget and draw new drag handle widget when node type changes
202
+ if (activeNodeWithNewNodeType && ((_activeNodeWithNewNod = activeNodeWithNewNodeType) === null || _activeNodeWithNewNod === void 0 ? void 0 : _activeNodeWithNewNod.nodeType) !== (activeNode === null || activeNode === void 0 ? void 0 : activeNode.nodeType) && api) {
203
+ const oldHandle = decorations.find().filter(({
204
+ spec
205
+ }) => spec.id === 'drag-handle');
206
+ decorations = decorations.remove(oldHandle);
207
+ const decs = dragHandleDecoration(activeNodeWithNewNodeType.pos, activeNodeWithNewNodeType.anchorName, activeNodeWithNewNodeType.nodeType, api);
208
+ decorations = decorations.add(newState.doc, [decs]);
209
+ }
210
+ }
194
211
  // Add drop targets when node is being dragged
195
212
  // if the transaction is only for analytics and user is dragging, continue to draw drop targets
196
213
  if (meta !== null && meta !== void 0 && meta.isDragging && (!tr.docChanged || tr.docChanged && isAnalyticTr) && api) {
@@ -236,11 +253,20 @@ export const createPlugin = api => {
236
253
  }
237
254
 
238
255
  // Map active node position when the document changes
239
- const mappedActiveNodePos = tr.docChanged && activeNode ? {
240
- pos: tr.mapping.map(activeNode.pos),
241
- anchorName: activeNode.anchorName,
242
- nodeType: activeNode.nodeType
243
- } : activeNode;
256
+ let mappedActiveNodePos;
257
+ if (getBooleanFF('platform.editor.elements.drag-and-drop-ed-23816')) {
258
+ mappedActiveNodePos = tr.docChanged && activeNode ? activeNodeWithNewNodeType || {
259
+ pos: tr.mapping.map(activeNode.pos),
260
+ anchorName: activeNode.anchorName,
261
+ nodeType: activeNode.nodeType
262
+ } : activeNode;
263
+ } else {
264
+ mappedActiveNodePos = tr.docChanged && activeNode ? {
265
+ pos: tr.mapping.map(activeNode.pos),
266
+ anchorName: activeNode.anchorName,
267
+ nodeType: activeNode.nodeType
268
+ } : activeNode;
269
+ }
244
270
  return {
245
271
  decorations,
246
272
  decorationState,
@@ -91,6 +91,7 @@ export const DragHandle = ({
91
91
  });
92
92
  const resolvedMovingNode = tr.doc.resolve(start);
93
93
  const maybeNode = resolvedMovingNode.nodeAfter;
94
+ getBooleanFF('platform.editor.elements.drag-and-drop-long-node-scroll') && tr.setMeta('scrollIntoView', false);
94
95
  api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions.attachAnalyticsEvent({
95
96
  eventType: EVENT_TYPE.UI,
96
97
  action: ACTION.CLICKED,
@@ -102,6 +102,7 @@ export var createPlugin = function createPlugin(api) {
102
102
  isResizerResizing = currentState.isResizerResizing,
103
103
  isDragging = currentState.isDragging,
104
104
  isPMDragging = currentState.isPMDragging;
105
+ var activeNodeWithNewNodeType = null;
105
106
  var meta = tr.getMeta(key);
106
107
  // when creating analytics during drag/drop events, PM thinks the doc has changed
107
108
  // so tr.docChange is true and causes some decorations to not render
@@ -177,6 +178,11 @@ export var createPlugin = function createPlugin(api) {
177
178
  if (newActiveNode && (newActiveNode === null || newActiveNode === void 0 ? void 0 : newActiveNode.type.name) !== activeNode.nodeType) {
178
179
  nodeType = newActiveNode.type.name;
179
180
  anchorName = activeNode.anchorName.replace(activeNode.nodeType, nodeType);
181
+ activeNodeWithNewNodeType = {
182
+ pos: prevMappedPos,
183
+ nodeType: nodeType,
184
+ anchorName: anchorName
185
+ };
180
186
  }
181
187
  var draghandleDec = dragHandleDecoration(activeNode.pos, anchorName, nodeType, api);
182
188
  decorations = decorations.add(newState.doc, [draghandleDec]);
@@ -193,21 +199,33 @@ export var createPlugin = function createPlugin(api) {
193
199
  var decs = dragHandleDecoration(meta.activeNode.pos, meta.activeNode.anchorName, meta.activeNode.nodeType, api);
194
200
  decorations = decorations.add(newState.doc, [decs]);
195
201
  }
196
-
202
+ if (getBooleanFF('platform.editor.elements.drag-and-drop-ed-23816')) {
203
+ var _activeNodeWithNewNod;
204
+ // Remove previous drag handle widget and draw new drag handle widget when node type changes
205
+ if (activeNodeWithNewNodeType && ((_activeNodeWithNewNod = activeNodeWithNewNodeType) === null || _activeNodeWithNewNod === void 0 ? void 0 : _activeNodeWithNewNod.nodeType) !== (activeNode === null || activeNode === void 0 ? void 0 : activeNode.nodeType) && api) {
206
+ var _oldHandle2 = decorations.find().filter(function (_ref9) {
207
+ var spec = _ref9.spec;
208
+ return spec.id === 'drag-handle';
209
+ });
210
+ decorations = decorations.remove(_oldHandle2);
211
+ var _decs = dragHandleDecoration(activeNodeWithNewNodeType.pos, activeNodeWithNewNodeType.anchorName, activeNodeWithNewNodeType.nodeType, api);
212
+ decorations = decorations.add(newState.doc, [_decs]);
213
+ }
214
+ }
197
215
  // Add drop targets when node is being dragged
198
216
  // if the transaction is only for analytics and user is dragging, continue to draw drop targets
199
217
  if (meta !== null && meta !== void 0 && meta.isDragging && (!tr.docChanged || tr.docChanged && isAnalyticTr) && api) {
200
218
  var _dropTargetDecoration = dropTargetDecorations(oldState, newState, api),
201
- _decs = _dropTargetDecoration.decs,
219
+ _decs2 = _dropTargetDecoration.decs,
202
220
  updatedDecorationState = _dropTargetDecoration.decorationState;
203
221
  decorationState = updatedDecorationState;
204
- decorations = decorations.add(newState.doc, _decs);
222
+ decorations = decorations.add(newState.doc, _decs2);
205
223
  }
206
224
 
207
225
  // Remove drop target decoration when dragging stops
208
226
  if ((meta === null || meta === void 0 ? void 0 : meta.isDragging) === false && !tr.docChanged) {
209
- var dropTargetDecs = decorations.find().filter(function (_ref9) {
210
- var spec = _ref9.spec;
227
+ var dropTargetDecs = decorations.find().filter(function (_ref10) {
228
+ var spec = _ref10.spec;
211
229
  return spec.type === 'drop-target-decoration';
212
230
  });
213
231
  decorations = decorations.remove(dropTargetDecs);
@@ -215,9 +233,9 @@ export var createPlugin = function createPlugin(api) {
215
233
 
216
234
  // Map drop target decoration positions when the document changes
217
235
  if (tr.docChanged && isDragging) {
218
- decorationState = decorationState.map(function (_ref10) {
219
- var index = _ref10.index,
220
- pos = _ref10.pos;
236
+ decorationState = decorationState.map(function (_ref11) {
237
+ var index = _ref11.index,
238
+ pos = _ref11.pos;
221
239
  return {
222
240
  index: index,
223
241
  pos: tr.mapping.map(pos)
@@ -230,8 +248,8 @@ export var createPlugin = function createPlugin(api) {
230
248
  decorations = decorations.map(tr.mapping, tr.doc);
231
249
  }
232
250
  var isEmptyDoc = newState.doc.childCount === 1 && newState.doc.nodeSize <= 4;
233
- var hasNodeDecoration = decorations.find().some(function (_ref11) {
234
- var spec = _ref11.spec;
251
+ var hasNodeDecoration = decorations.find().some(function (_ref12) {
252
+ var spec = _ref12.spec;
235
253
  return spec.type === 'node-decoration';
236
254
  });
237
255
  if (!hasNodeDecoration && isEmptyDoc) {
@@ -239,11 +257,20 @@ export var createPlugin = function createPlugin(api) {
239
257
  }
240
258
 
241
259
  // Map active node position when the document changes
242
- var mappedActiveNodePos = tr.docChanged && activeNode ? {
243
- pos: tr.mapping.map(activeNode.pos),
244
- anchorName: activeNode.anchorName,
245
- nodeType: activeNode.nodeType
246
- } : activeNode;
260
+ var mappedActiveNodePos;
261
+ if (getBooleanFF('platform.editor.elements.drag-and-drop-ed-23816')) {
262
+ mappedActiveNodePos = tr.docChanged && activeNode ? activeNodeWithNewNodeType || {
263
+ pos: tr.mapping.map(activeNode.pos),
264
+ anchorName: activeNode.anchorName,
265
+ nodeType: activeNode.nodeType
266
+ } : activeNode;
267
+ } else {
268
+ mappedActiveNodePos = tr.docChanged && activeNode ? {
269
+ pos: tr.mapping.map(activeNode.pos),
270
+ anchorName: activeNode.anchorName,
271
+ nodeType: activeNode.nodeType
272
+ } : activeNode;
273
+ }
247
274
  return {
248
275
  decorations: decorations,
249
276
  decorationState: decorationState,
@@ -97,6 +97,7 @@ export var DragHandle = function DragHandle(_ref) {
97
97
  });
98
98
  var resolvedMovingNode = tr.doc.resolve(start);
99
99
  var maybeNode = resolvedMovingNode.nodeAfter;
100
+ getBooleanFF('platform.editor.elements.drag-and-drop-long-node-scroll') && tr.setMeta('scrollIntoView', false);
100
101
  api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.attachAnalyticsEvent({
101
102
  eventType: EVENT_TYPE.UI,
102
103
  action: ACTION.CLICKED,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-controls",
3
- "version": "1.5.5",
3
+ "version": "1.5.7",
4
4
  "description": "Block controls plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -31,8 +31,8 @@
31
31
  ".": "./src/index.ts"
32
32
  },
33
33
  "dependencies": {
34
- "@atlaskit/adf-schema": "^38.0.0",
35
- "@atlaskit/editor-common": "^83.4.0",
34
+ "@atlaskit/adf-schema": "^39.0.3",
35
+ "@atlaskit/editor-common": "^83.5.0",
36
36
  "@atlaskit/editor-plugin-analytics": "^1.4.0",
37
37
  "@atlaskit/editor-plugin-editor-disabled": "^1.1.5",
38
38
  "@atlaskit/editor-plugin-feature-flags": "^1.1.0",
@@ -101,12 +101,18 @@
101
101
  "platform.editor.elements.drag-and-drop-remove-wrapper_fyqr2": {
102
102
  "type": "boolean"
103
103
  },
104
+ "platform.editor.elements.drag-and-drop-long-node-scroll": {
105
+ "type": "boolean"
106
+ },
104
107
  "platform.editor.media.extended-resize-experience": {
105
108
  "type": "boolean",
106
109
  "referenceOnly": true
107
110
  },
108
111
  "platform.editor.elements.drag-and-drop-ed-23892": {
109
112
  "type": "boolean"
113
+ },
114
+ "platform.editor.elements.drag-and-drop-ed-23816": {
115
+ "type": "boolean"
110
116
  }
111
117
  }
112
118
  }