@atlaskit/editor-plugin-block-controls 1.4.3 → 1.4.5
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 +16 -0
- package/dist/cjs/pm-plugins/decorations.js +1 -0
- package/dist/cjs/ui/drag-handle.js +2 -1
- package/dist/cjs/ui/global-styles.js +1 -1
- package/dist/cjs/utils/getSelection.js +11 -5
- package/dist/cjs/utils/index.js +12 -0
- package/dist/es2019/pm-plugins/decorations.js +1 -0
- package/dist/es2019/ui/drag-handle.js +2 -1
- package/dist/es2019/ui/global-styles.js +1 -1
- package/dist/es2019/utils/getSelection.js +11 -5
- package/dist/es2019/utils/index.js +1 -0
- package/dist/esm/pm-plugins/decorations.js +1 -0
- package/dist/esm/ui/drag-handle.js +2 -1
- package/dist/esm/ui/global-styles.js +1 -1
- package/dist/esm/utils/getSelection.js +11 -5
- package/dist/esm/utils/index.js +1 -0
- package/dist/types/utils/index.d.ts +1 -0
- package/dist/types-ts4.5/utils/index.d.ts +1 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-controls
|
|
2
2
|
|
|
3
|
+
## 1.4.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#103935](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/103935)
|
|
8
|
+
[`e9aa08ecec9b`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/e9aa08ecec9b) -
|
|
9
|
+
Add block control plugin libra models and tests
|
|
10
|
+
|
|
11
|
+
## 1.4.4
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [#104094](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/104094)
|
|
16
|
+
[`ae80ae898d90`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/ae80ae898d90) -
|
|
17
|
+
Refactor getSelection and add tests
|
|
18
|
+
|
|
3
19
|
## 1.4.3
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
@@ -78,6 +78,7 @@ var dragHandleDecoration = exports.dragHandleDecoration = function dragHandleDec
|
|
|
78
78
|
} else {
|
|
79
79
|
element.style.top = "".concat(meta.dom.offsetTop, "px");
|
|
80
80
|
}
|
|
81
|
+
element.setAttribute('data-testid', 'block-ctrl-decorator-widget');
|
|
81
82
|
return element;
|
|
82
83
|
}, {
|
|
83
84
|
side: -1
|
|
@@ -122,7 +122,8 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
122
122
|
type: "button",
|
|
123
123
|
css: [dragHandleButtonStyles, dragHandleSelected && selectedStyles],
|
|
124
124
|
ref: buttonRef,
|
|
125
|
-
onClick: handleClick
|
|
125
|
+
onClick: handleClick,
|
|
126
|
+
"data-testid": "block-ctrl-drag-handle"
|
|
126
127
|
}, (0, _react2.jsx)(_dragHandler.default, {
|
|
127
128
|
label: "",
|
|
128
129
|
size: "medium"
|
|
@@ -9,7 +9,7 @@ var _react = require("@emotion/react");
|
|
|
9
9
|
|
|
10
10
|
var globalStyles = (0, _react.css)({
|
|
11
11
|
'.ProseMirror-widget:first-child + *': {
|
|
12
|
-
|
|
12
|
+
marginTop: '0 !important'
|
|
13
13
|
}
|
|
14
14
|
});
|
|
15
15
|
var GlobalStylesWrapper = exports.GlobalStylesWrapper = function GlobalStylesWrapper() {
|
|
@@ -13,16 +13,22 @@ var getSelection = exports.getSelection = function getSelection(tr, start) {
|
|
|
13
13
|
if (isNodeSelection) {
|
|
14
14
|
return new _state.NodeSelection($startPos);
|
|
15
15
|
} else {
|
|
16
|
-
|
|
16
|
+
// To trigger the annotation floating toolbar for non-selectable node, we need to select on the text node
|
|
17
|
+
// Find the first text node in the node
|
|
18
|
+
var textNodesPos = start;
|
|
19
|
+
var foundTextNodes = false;
|
|
17
20
|
tr.doc.nodesBetween($startPos.pos, $startPos.pos + nodeSize, function (n, pos) {
|
|
21
|
+
if (foundTextNodes) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
18
24
|
if (n.isText) {
|
|
19
|
-
textNodesPos
|
|
25
|
+
textNodesPos = pos;
|
|
26
|
+
foundTextNodes = true;
|
|
20
27
|
return false;
|
|
21
28
|
}
|
|
22
29
|
return true;
|
|
23
30
|
});
|
|
24
|
-
var
|
|
25
|
-
|
|
26
|
-
return new _state.TextSelection(tr.doc.resolve(textNodeStart), tr.doc.resolve(start + nodeSize - textNodeDepth));
|
|
31
|
+
var textNodeDepth = textNodesPos - start;
|
|
32
|
+
return new _state.TextSelection(tr.doc.resolve(textNodesPos), tr.doc.resolve(start + nodeSize - textNodeDepth));
|
|
27
33
|
}
|
|
28
34
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "getSelection", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _getSelection.getSelection;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _getSelection = require("./getSelection");
|
|
@@ -114,7 +114,8 @@ export const DragHandle = ({
|
|
|
114
114
|
type: "button",
|
|
115
115
|
css: [dragHandleButtonStyles, dragHandleSelected && selectedStyles],
|
|
116
116
|
ref: buttonRef,
|
|
117
|
-
onClick: handleClick
|
|
117
|
+
onClick: handleClick,
|
|
118
|
+
"data-testid": "block-ctrl-drag-handle"
|
|
118
119
|
}, jsx(DragHandlerIcon, {
|
|
119
120
|
label: "",
|
|
120
121
|
size: "medium"
|
|
@@ -7,16 +7,22 @@ export const getSelection = (tr, start) => {
|
|
|
7
7
|
if (isNodeSelection) {
|
|
8
8
|
return new NodeSelection($startPos);
|
|
9
9
|
} else {
|
|
10
|
-
|
|
10
|
+
// To trigger the annotation floating toolbar for non-selectable node, we need to select on the text node
|
|
11
|
+
// Find the first text node in the node
|
|
12
|
+
let textNodesPos = start;
|
|
13
|
+
let foundTextNodes = false;
|
|
11
14
|
tr.doc.nodesBetween($startPos.pos, $startPos.pos + nodeSize, (n, pos) => {
|
|
15
|
+
if (foundTextNodes) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
12
18
|
if (n.isText) {
|
|
13
|
-
textNodesPos
|
|
19
|
+
textNodesPos = pos;
|
|
20
|
+
foundTextNodes = true;
|
|
14
21
|
return false;
|
|
15
22
|
}
|
|
16
23
|
return true;
|
|
17
24
|
});
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
return new TextSelection(tr.doc.resolve(textNodeStart), tr.doc.resolve(start + nodeSize - textNodeDepth));
|
|
25
|
+
const textNodeDepth = textNodesPos - start;
|
|
26
|
+
return new TextSelection(tr.doc.resolve(textNodesPos), tr.doc.resolve(start + nodeSize - textNodeDepth));
|
|
21
27
|
}
|
|
22
28
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getSelection } from './getSelection';
|
|
@@ -71,6 +71,7 @@ export var dragHandleDecoration = function dragHandleDecoration(oldState, meta,
|
|
|
71
71
|
} else {
|
|
72
72
|
element.style.top = "".concat(meta.dom.offsetTop, "px");
|
|
73
73
|
}
|
|
74
|
+
element.setAttribute('data-testid', 'block-ctrl-decorator-widget');
|
|
74
75
|
return element;
|
|
75
76
|
}, {
|
|
76
77
|
side: -1
|
|
@@ -114,7 +114,8 @@ export var DragHandle = function DragHandle(_ref) {
|
|
|
114
114
|
type: "button",
|
|
115
115
|
css: [dragHandleButtonStyles, dragHandleSelected && selectedStyles],
|
|
116
116
|
ref: buttonRef,
|
|
117
|
-
onClick: handleClick
|
|
117
|
+
onClick: handleClick,
|
|
118
|
+
"data-testid": "block-ctrl-drag-handle"
|
|
118
119
|
}, jsx(DragHandlerIcon, {
|
|
119
120
|
label: "",
|
|
120
121
|
size: "medium"
|
|
@@ -7,16 +7,22 @@ export var getSelection = function getSelection(tr, start) {
|
|
|
7
7
|
if (isNodeSelection) {
|
|
8
8
|
return new NodeSelection($startPos);
|
|
9
9
|
} else {
|
|
10
|
-
|
|
10
|
+
// To trigger the annotation floating toolbar for non-selectable node, we need to select on the text node
|
|
11
|
+
// Find the first text node in the node
|
|
12
|
+
var textNodesPos = start;
|
|
13
|
+
var foundTextNodes = false;
|
|
11
14
|
tr.doc.nodesBetween($startPos.pos, $startPos.pos + nodeSize, function (n, pos) {
|
|
15
|
+
if (foundTextNodes) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
12
18
|
if (n.isText) {
|
|
13
|
-
textNodesPos
|
|
19
|
+
textNodesPos = pos;
|
|
20
|
+
foundTextNodes = true;
|
|
14
21
|
return false;
|
|
15
22
|
}
|
|
16
23
|
return true;
|
|
17
24
|
});
|
|
18
|
-
var
|
|
19
|
-
|
|
20
|
-
return new TextSelection(tr.doc.resolve(textNodeStart), tr.doc.resolve(start + nodeSize - textNodeDepth));
|
|
25
|
+
var textNodeDepth = textNodesPos - start;
|
|
26
|
+
return new TextSelection(tr.doc.resolve(textNodesPos), tr.doc.resolve(start + nodeSize - textNodeDepth));
|
|
21
27
|
}
|
|
22
28
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getSelection } from './getSelection';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getSelection } from './getSelection';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getSelection } from './getSelection';
|
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.5",
|
|
4
4
|
"description": "Block controls plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
".": "./src/index.ts"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@atlaskit/editor-common": "^81.
|
|
34
|
+
"@atlaskit/editor-common": "^81.1.0",
|
|
35
35
|
"@atlaskit/editor-prosemirror": "4.0.1",
|
|
36
36
|
"@atlaskit/icon": "^22.3.0",
|
|
37
37
|
"@atlaskit/pragmatic-drag-and-drop": "^1.1.0",
|