@atlaskit/editor-plugin-block-controls 1.4.23 → 1.4.25

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,21 @@
1
1
  # @atlaskit/editor-plugin-block-controls
2
2
 
3
+ ## 1.4.25
4
+
5
+ ### Patch Changes
6
+
7
+ - [#112850](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/112850)
8
+ [`b5b96fe430ecb`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/b5b96fe430ecb) -
9
+ ED-23767 Add drop listener to prevent default behaviour of duplicating dropped node
10
+
11
+ ## 1.4.24
12
+
13
+ ### Patch Changes
14
+
15
+ - [#112937](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/112937)
16
+ [`77f74659f0ac3`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/77f74659f0ac3) -
17
+ [ED-23676] Fix drag and drop issue with table charts
18
+
3
19
  ## 1.4.23
4
20
 
5
21
  ### Patch Changes
@@ -32,7 +32,8 @@ var dropTargetDecorations = exports.dropTargetDecorations = function dropTargetD
32
32
  }), element);
33
33
  return element;
34
34
  }, {
35
- type: 'drop-target-decoration'
35
+ type: 'drop-target-decoration',
36
+ side: -1
36
37
  }));
37
38
  return false;
38
39
  });
@@ -221,6 +221,27 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
221
221
  return;
222
222
  }
223
223
  return (_key$getState = key.getState(state)) === null || _key$getState === void 0 ? void 0 : _key$getState.decorations;
224
+ },
225
+ handleDOMEvents: {
226
+ drop: function drop(view, event) {
227
+ var _pluginState$activeNo;
228
+ // prosemirror has sends a default transaction on drop (meta where uiEvent is 'drop'),
229
+ // this duplicates the an empty version of the node it was dropping,
230
+ // Adding some check here to prevent that if drop position is within activeNode
231
+ var state = view.state;
232
+ var pluginState = key.getState(state);
233
+ if (!(event.target instanceof HTMLElement) || !(pluginState !== null && pluginState !== void 0 && pluginState.activeNode)) {
234
+ return false;
235
+ }
236
+ var node = view.nodeDOM(pluginState === null || pluginState === void 0 || (_pluginState$activeNo = pluginState.activeNode) === null || _pluginState$activeNo === void 0 ? void 0 : _pluginState$activeNo.pos);
237
+ var isActiveNode = (node === null || node === void 0 ? void 0 : node.contains(event.target)) || event.target === node;
238
+ if (isActiveNode) {
239
+ // Prevent the default drop behavior if the position is within the activeNode
240
+ event.preventDefault();
241
+ return true;
242
+ }
243
+ return false;
244
+ }
224
245
  }
225
246
  },
226
247
  view: function view(editorView) {
@@ -24,7 +24,8 @@ export const dropTargetDecorations = (oldState, newState, api) => {
24
24
  }), element);
25
25
  return element;
26
26
  }, {
27
- type: 'drop-target-decoration'
27
+ type: 'drop-target-decoration',
28
+ side: -1
28
29
  }));
29
30
  return false;
30
31
  });
@@ -214,6 +214,29 @@ export const createPlugin = api => {
214
214
  return;
215
215
  }
216
216
  return (_key$getState = key.getState(state)) === null || _key$getState === void 0 ? void 0 : _key$getState.decorations;
217
+ },
218
+ handleDOMEvents: {
219
+ drop(view, event) {
220
+ var _pluginState$activeNo;
221
+ // prosemirror has sends a default transaction on drop (meta where uiEvent is 'drop'),
222
+ // this duplicates the an empty version of the node it was dropping,
223
+ // Adding some check here to prevent that if drop position is within activeNode
224
+ const {
225
+ state
226
+ } = view;
227
+ const pluginState = key.getState(state);
228
+ if (!(event.target instanceof HTMLElement) || !(pluginState !== null && pluginState !== void 0 && pluginState.activeNode)) {
229
+ return false;
230
+ }
231
+ const node = view.nodeDOM(pluginState === null || pluginState === void 0 ? void 0 : (_pluginState$activeNo = pluginState.activeNode) === null || _pluginState$activeNo === void 0 ? void 0 : _pluginState$activeNo.pos);
232
+ const isActiveNode = (node === null || node === void 0 ? void 0 : node.contains(event.target)) || event.target === node;
233
+ if (isActiveNode) {
234
+ // Prevent the default drop behavior if the position is within the activeNode
235
+ event.preventDefault();
236
+ return true;
237
+ }
238
+ return false;
239
+ }
217
240
  }
218
241
  },
219
242
  view: editorView => {
@@ -25,7 +25,8 @@ export var dropTargetDecorations = function dropTargetDecorations(oldState, newS
25
25
  }), element);
26
26
  return element;
27
27
  }, {
28
- type: 'drop-target-decoration'
28
+ type: 'drop-target-decoration',
29
+ side: -1
29
30
  }));
30
31
  return false;
31
32
  });
@@ -214,6 +214,27 @@ export var createPlugin = function createPlugin(api) {
214
214
  return;
215
215
  }
216
216
  return (_key$getState = key.getState(state)) === null || _key$getState === void 0 ? void 0 : _key$getState.decorations;
217
+ },
218
+ handleDOMEvents: {
219
+ drop: function drop(view, event) {
220
+ var _pluginState$activeNo;
221
+ // prosemirror has sends a default transaction on drop (meta where uiEvent is 'drop'),
222
+ // this duplicates the an empty version of the node it was dropping,
223
+ // Adding some check here to prevent that if drop position is within activeNode
224
+ var state = view.state;
225
+ var pluginState = key.getState(state);
226
+ if (!(event.target instanceof HTMLElement) || !(pluginState !== null && pluginState !== void 0 && pluginState.activeNode)) {
227
+ return false;
228
+ }
229
+ var node = view.nodeDOM(pluginState === null || pluginState === void 0 || (_pluginState$activeNo = pluginState.activeNode) === null || _pluginState$activeNo === void 0 ? void 0 : _pluginState$activeNo.pos);
230
+ var isActiveNode = (node === null || node === void 0 ? void 0 : node.contains(event.target)) || event.target === node;
231
+ if (isActiveNode) {
232
+ // Prevent the default drop behavior if the position is within the activeNode
233
+ event.preventDefault();
234
+ return true;
235
+ }
236
+ return false;
237
+ }
217
238
  }
218
239
  },
219
240
  view: function view(editorView) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-controls",
3
- "version": "1.4.23",
3
+ "version": "1.4.25",
4
4
  "description": "Block controls plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -32,7 +32,7 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "@atlaskit/adf-schema": "^36.10.7",
35
- "@atlaskit/editor-common": "^82.8.0",
35
+ "@atlaskit/editor-common": "^82.9.0",
36
36
  "@atlaskit/editor-plugin-analytics": "^1.2.3",
37
37
  "@atlaskit/editor-plugin-editor-disabled": "^1.1.5",
38
38
  "@atlaskit/editor-plugin-feature-flags": "^1.1.0",