@atlaskit/editor-plugin-block-controls 1.4.24 → 1.4.26
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 +17 -0
- package/dist/cjs/pm-plugins/main.js +21 -0
- package/dist/cjs/utils/getSelection.js +10 -10
- package/dist/es2019/pm-plugins/main.js +23 -0
- package/dist/es2019/utils/getSelection.js +10 -10
- package/dist/esm/pm-plugins/main.js +21 -0
- package/dist/esm/utils/getSelection.js +10 -10
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-controls
|
|
2
2
|
|
|
3
|
+
## 1.4.26
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#113192](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/113192)
|
|
8
|
+
[`e30355e61e571`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/e30355e61e571) -
|
|
9
|
+
[ED-23770] Fix the bug where clicking drag handle does not select inline nodes
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
12
|
+
## 1.4.25
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- [#112850](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/112850)
|
|
17
|
+
[`b5b96fe430ecb`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/b5b96fe430ecb) -
|
|
18
|
+
ED-23767 Add drop listener to prevent default behaviour of duplicating dropped node
|
|
19
|
+
|
|
3
20
|
## 1.4.24
|
|
4
21
|
|
|
5
22
|
### 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) {
|
|
@@ -14,23 +14,23 @@ var getSelection = exports.getSelection = function getSelection(tr, start) {
|
|
|
14
14
|
if (isNodeSelection) {
|
|
15
15
|
return new _state.NodeSelection($startPos);
|
|
16
16
|
} else {
|
|
17
|
-
// To trigger the annotation floating toolbar for non-selectable node, we need to select
|
|
18
|
-
// Find the first
|
|
19
|
-
var
|
|
20
|
-
var
|
|
17
|
+
// To trigger the annotation floating toolbar for non-selectable node, we need to select inline nodes
|
|
18
|
+
// Find the first inline node in the node
|
|
19
|
+
var inlineNodePos = start;
|
|
20
|
+
var foundInlineNode = false;
|
|
21
21
|
tr.doc.nodesBetween($startPos.pos, $startPos.pos + nodeSize, function (n, pos) {
|
|
22
|
-
if (
|
|
22
|
+
if (foundInlineNode) {
|
|
23
23
|
return false;
|
|
24
24
|
}
|
|
25
|
-
if (n.
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
if (n.isInline) {
|
|
26
|
+
inlineNodePos = pos;
|
|
27
|
+
foundInlineNode = true;
|
|
28
28
|
return false;
|
|
29
29
|
}
|
|
30
30
|
return true;
|
|
31
31
|
});
|
|
32
|
-
var
|
|
33
|
-
return new _state.TextSelection(tr.doc.resolve(
|
|
32
|
+
var inlineNodeDepth = inlineNodePos - start;
|
|
33
|
+
return new _state.TextSelection(tr.doc.resolve(inlineNodePos), tr.doc.resolve(start + nodeSize - inlineNodeDepth));
|
|
34
34
|
}
|
|
35
35
|
};
|
|
36
36
|
var selectNode = exports.selectNode = function selectNode(tr, start, nodeType) {
|
|
@@ -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 => {
|
|
@@ -8,23 +8,23 @@ export const getSelection = (tr, start) => {
|
|
|
8
8
|
if (isNodeSelection) {
|
|
9
9
|
return new NodeSelection($startPos);
|
|
10
10
|
} else {
|
|
11
|
-
// To trigger the annotation floating toolbar for non-selectable node, we need to select
|
|
12
|
-
// Find the first
|
|
13
|
-
let
|
|
14
|
-
let
|
|
11
|
+
// To trigger the annotation floating toolbar for non-selectable node, we need to select inline nodes
|
|
12
|
+
// Find the first inline node in the node
|
|
13
|
+
let inlineNodePos = start;
|
|
14
|
+
let foundInlineNode = false;
|
|
15
15
|
tr.doc.nodesBetween($startPos.pos, $startPos.pos + nodeSize, (n, pos) => {
|
|
16
|
-
if (
|
|
16
|
+
if (foundInlineNode) {
|
|
17
17
|
return false;
|
|
18
18
|
}
|
|
19
|
-
if (n.
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
if (n.isInline) {
|
|
20
|
+
inlineNodePos = pos;
|
|
21
|
+
foundInlineNode = true;
|
|
22
22
|
return false;
|
|
23
23
|
}
|
|
24
24
|
return true;
|
|
25
25
|
});
|
|
26
|
-
const
|
|
27
|
-
return new TextSelection(tr.doc.resolve(
|
|
26
|
+
const inlineNodeDepth = inlineNodePos - start;
|
|
27
|
+
return new TextSelection(tr.doc.resolve(inlineNodePos), tr.doc.resolve(start + nodeSize - inlineNodeDepth));
|
|
28
28
|
}
|
|
29
29
|
};
|
|
30
30
|
export const selectNode = (tr, start, nodeType) => {
|
|
@@ -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) {
|
|
@@ -8,23 +8,23 @@ export var getSelection = function getSelection(tr, start) {
|
|
|
8
8
|
if (isNodeSelection) {
|
|
9
9
|
return new NodeSelection($startPos);
|
|
10
10
|
} else {
|
|
11
|
-
// To trigger the annotation floating toolbar for non-selectable node, we need to select
|
|
12
|
-
// Find the first
|
|
13
|
-
var
|
|
14
|
-
var
|
|
11
|
+
// To trigger the annotation floating toolbar for non-selectable node, we need to select inline nodes
|
|
12
|
+
// Find the first inline node in the node
|
|
13
|
+
var inlineNodePos = start;
|
|
14
|
+
var foundInlineNode = false;
|
|
15
15
|
tr.doc.nodesBetween($startPos.pos, $startPos.pos + nodeSize, function (n, pos) {
|
|
16
|
-
if (
|
|
16
|
+
if (foundInlineNode) {
|
|
17
17
|
return false;
|
|
18
18
|
}
|
|
19
|
-
if (n.
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
if (n.isInline) {
|
|
20
|
+
inlineNodePos = pos;
|
|
21
|
+
foundInlineNode = true;
|
|
22
22
|
return false;
|
|
23
23
|
}
|
|
24
24
|
return true;
|
|
25
25
|
});
|
|
26
|
-
var
|
|
27
|
-
return new TextSelection(tr.doc.resolve(
|
|
26
|
+
var inlineNodeDepth = inlineNodePos - start;
|
|
27
|
+
return new TextSelection(tr.doc.resolve(inlineNodePos), tr.doc.resolve(start + nodeSize - inlineNodeDepth));
|
|
28
28
|
}
|
|
29
29
|
};
|
|
30
30
|
export var selectNode = function selectNode(tr, start, nodeType) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-block-controls",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.26",
|
|
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.
|
|
35
|
+
"@atlaskit/editor-common": "^82.10.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",
|