@atlaskit/editor-plugin-block-controls 1.4.24 → 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 +8 -0
- package/dist/cjs/pm-plugins/main.js +21 -0
- package/dist/es2019/pm-plugins/main.js +23 -0
- package/dist/esm/pm-plugins/main.js +21 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
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
|
+
|
|
3
11
|
## 1.4.24
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
@@ -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) {
|
|
@@ -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 => {
|
|
@@ -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) {
|