@atlaskit/editor-plugin-block-controls 2.7.0 → 2.7.1
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 +9 -0
- package/dist/cjs/ui/inline-drop-target.js +27 -12
- package/dist/cjs/utils/advanced-layouts-flags.js +7 -2
- package/dist/es2019/ui/inline-drop-target.js +20 -2
- package/dist/es2019/utils/advanced-layouts-flags.js +7 -1
- package/dist/esm/ui/inline-drop-target.js +27 -12
- package/dist/esm/utils/advanced-layouts-flags.js +7 -1
- package/dist/types/ui/inline-drop-target.d.ts +1 -1
- package/dist/types/utils/advanced-layouts-flags.d.ts +1 -0
- package/dist/types-ts4.5/ui/inline-drop-target.d.ts +1 -1
- package/dist/types-ts4.5/utils/advanced-layouts-flags.d.ts +1 -0
- package/package.json +5 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-controls
|
|
2
2
|
|
|
3
|
+
## 2.7.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#153381](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/153381)
|
|
8
|
+
[`47cf4f0676e5a`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/47cf4f0676e5a) -
|
|
9
|
+
ED-25040 setup feature flags and hooked up pre release-1
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
3
12
|
## 2.7.0
|
|
4
13
|
|
|
5
14
|
### Minor Changes
|
|
@@ -44,7 +44,8 @@ var InlineDropTarget = exports.InlineDropTarget = function InlineDropTarget(_ref
|
|
|
44
44
|
var api = _ref.api,
|
|
45
45
|
nextNode = _ref.nextNode,
|
|
46
46
|
position = _ref.position,
|
|
47
|
-
anchorRectCache = _ref.anchorRectCache
|
|
47
|
+
anchorRectCache = _ref.anchorRectCache,
|
|
48
|
+
getPos = _ref.getPos;
|
|
48
49
|
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['width']),
|
|
49
50
|
widthState = _useSharedPluginState.widthState;
|
|
50
51
|
var _useState = (0, _react.useState)(false),
|
|
@@ -74,6 +75,20 @@ var InlineDropTarget = exports.InlineDropTarget = function InlineDropTarget(_ref
|
|
|
74
75
|
top: "".concat((nodeRect === null || nodeRect === void 0 ? void 0 : nodeRect.top) || 0, "px")
|
|
75
76
|
});
|
|
76
77
|
}, [anchorName, anchorRectCache, position]);
|
|
78
|
+
var onDrop = (0, _react.useCallback)(function () {
|
|
79
|
+
var _api$blockControls;
|
|
80
|
+
var _ref2 = (api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.sharedState.currentState()) || {},
|
|
81
|
+
activeNode = _ref2.activeNode;
|
|
82
|
+
if (!activeNode) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
var toPos = getPos();
|
|
86
|
+
if (activeNode && toPos !== undefined) {
|
|
87
|
+
var _api$core, _api$blockControls2;
|
|
88
|
+
var start = activeNode.pos;
|
|
89
|
+
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 || (_api$blockControls2 = _api$blockControls2.commands) === null || _api$blockControls2 === void 0 ? void 0 : _api$blockControls2.moveToLayout(start, toPos, position));
|
|
90
|
+
}
|
|
91
|
+
}, [api, getPos, position]);
|
|
77
92
|
return (0, _react2.jsx)(_react.Fragment, null, (0, _react2.jsx)("div", {
|
|
78
93
|
"data-test-id": "block-ctrl-drop-target-".concat(position),
|
|
79
94
|
css: [dropTargetCommonStyle, dropTargetRectStyle, !isDraggedOver && hideDropTargetStyle]
|
|
@@ -86,20 +101,20 @@ var InlineDropTarget = exports.InlineDropTarget = function InlineDropTarget(_ref
|
|
|
86
101
|
anchorRectCache: anchorRectCache,
|
|
87
102
|
onDragEnter: handleDragEnter,
|
|
88
103
|
onDragLeave: handleDragLeave,
|
|
89
|
-
onDrop:
|
|
104
|
+
onDrop: onDrop
|
|
90
105
|
}));
|
|
91
106
|
};
|
|
92
|
-
var InlineHoverZone = exports.InlineHoverZone = function InlineHoverZone(
|
|
93
|
-
var node =
|
|
94
|
-
editorWidthState =
|
|
95
|
-
anchorRectCache =
|
|
96
|
-
position =
|
|
97
|
-
onDragEnter =
|
|
98
|
-
onDragLeave =
|
|
99
|
-
onDrop =
|
|
107
|
+
var InlineHoverZone = exports.InlineHoverZone = function InlineHoverZone(_ref3) {
|
|
108
|
+
var node = _ref3.node,
|
|
109
|
+
editorWidthState = _ref3.editorWidthState,
|
|
110
|
+
anchorRectCache = _ref3.anchorRectCache,
|
|
111
|
+
position = _ref3.position,
|
|
112
|
+
onDragEnter = _ref3.onDragEnter,
|
|
113
|
+
onDragLeave = _ref3.onDragLeave,
|
|
114
|
+
onDrop = _ref3.onDrop;
|
|
100
115
|
var ref = (0, _react.useRef)(null);
|
|
101
|
-
var
|
|
102
|
-
editorWith =
|
|
116
|
+
var _ref4 = editorWidthState || {},
|
|
117
|
+
editorWith = _ref4.width;
|
|
103
118
|
var anchorName = node ? (0, _decorations.getNodeAnchor)(node) : '';
|
|
104
119
|
(0, _react.useEffect)(function () {
|
|
105
120
|
if (ref.current) {
|
|
@@ -3,9 +3,14 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.isPreRelease1 = void 0;
|
|
6
|
+
exports.isPreRelease2 = exports.isPreRelease1 = void 0;
|
|
7
7
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
8
8
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
9
|
+
// When we turn on re-release 2, will also turn on pre-release 1
|
|
10
|
+
// but not vice-versa
|
|
9
11
|
var isPreRelease1 = exports.isPreRelease1 = function isPreRelease1() {
|
|
10
|
-
return (0, _experiments.editorExperiment)('advanced_layouts', true) || (0, _platformFeatureFlags.fg)('platform_editor_advanced_layouts_pre_release_1');
|
|
12
|
+
return (0, _experiments.editorExperiment)('advanced_layouts', true) || (0, _platformFeatureFlags.fg)('platform_editor_advanced_layouts_pre_release_1') || (0, _platformFeatureFlags.fg)('platform_editor_advanced_layouts_pre_release_2');
|
|
13
|
+
};
|
|
14
|
+
var isPreRelease2 = exports.isPreRelease2 = function isPreRelease2() {
|
|
15
|
+
return (0, _experiments.editorExperiment)('advanced_layouts', true) || (0, _platformFeatureFlags.fg)('platform_editor_advanced_layouts_pre_release_2');
|
|
11
16
|
};
|
|
@@ -35,7 +35,8 @@ export const InlineDropTarget = ({
|
|
|
35
35
|
api,
|
|
36
36
|
nextNode,
|
|
37
37
|
position,
|
|
38
|
-
anchorRectCache
|
|
38
|
+
anchorRectCache,
|
|
39
|
+
getPos
|
|
39
40
|
}) => {
|
|
40
41
|
const {
|
|
41
42
|
widthState
|
|
@@ -64,6 +65,23 @@ export const InlineDropTarget = ({
|
|
|
64
65
|
top: `${(nodeRect === null || nodeRect === void 0 ? void 0 : nodeRect.top) || 0}px`
|
|
65
66
|
});
|
|
66
67
|
}, [anchorName, anchorRectCache, position]);
|
|
68
|
+
const onDrop = useCallback(() => {
|
|
69
|
+
var _api$blockControls;
|
|
70
|
+
const {
|
|
71
|
+
activeNode
|
|
72
|
+
} = (api === null || api === void 0 ? void 0 : (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.sharedState.currentState()) || {};
|
|
73
|
+
if (!activeNode) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const toPos = getPos();
|
|
77
|
+
if (activeNode && toPos !== undefined) {
|
|
78
|
+
var _api$core, _api$blockControls2, _api$blockControls2$c;
|
|
79
|
+
const {
|
|
80
|
+
pos: start
|
|
81
|
+
} = activeNode;
|
|
82
|
+
api === null || api === void 0 ? void 0 : (_api$core = api.core) === null || _api$core === void 0 ? void 0 : _api$core.actions.execute(api === null || api === void 0 ? void 0 : (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 ? void 0 : (_api$blockControls2$c = _api$blockControls2.commands) === null || _api$blockControls2$c === void 0 ? void 0 : _api$blockControls2$c.moveToLayout(start, toPos, position));
|
|
83
|
+
}
|
|
84
|
+
}, [api, getPos, position]);
|
|
67
85
|
return jsx(Fragment, null, jsx("div", {
|
|
68
86
|
"data-test-id": `block-ctrl-drop-target-${position}`,
|
|
69
87
|
css: [dropTargetCommonStyle, dropTargetRectStyle, !isDraggedOver && hideDropTargetStyle]
|
|
@@ -76,7 +94,7 @@ export const InlineDropTarget = ({
|
|
|
76
94
|
anchorRectCache: anchorRectCache,
|
|
77
95
|
onDragEnter: handleDragEnter,
|
|
78
96
|
onDragLeave: handleDragLeave,
|
|
79
|
-
onDrop:
|
|
97
|
+
onDrop: onDrop
|
|
80
98
|
}));
|
|
81
99
|
};
|
|
82
100
|
export const InlineHoverZone = ({
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
2
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
3
|
+
|
|
4
|
+
// When we turn on re-release 2, will also turn on pre-release 1
|
|
5
|
+
// but not vice-versa
|
|
3
6
|
export const isPreRelease1 = () => {
|
|
4
|
-
return editorExperiment('advanced_layouts', true) || fg('platform_editor_advanced_layouts_pre_release_1');
|
|
7
|
+
return editorExperiment('advanced_layouts', true) || fg('platform_editor_advanced_layouts_pre_release_1') || fg('platform_editor_advanced_layouts_pre_release_2');
|
|
8
|
+
};
|
|
9
|
+
export const isPreRelease2 = () => {
|
|
10
|
+
return editorExperiment('advanced_layouts', true) || fg('platform_editor_advanced_layouts_pre_release_2');
|
|
5
11
|
};
|
|
@@ -36,7 +36,8 @@ export var InlineDropTarget = function InlineDropTarget(_ref) {
|
|
|
36
36
|
var api = _ref.api,
|
|
37
37
|
nextNode = _ref.nextNode,
|
|
38
38
|
position = _ref.position,
|
|
39
|
-
anchorRectCache = _ref.anchorRectCache
|
|
39
|
+
anchorRectCache = _ref.anchorRectCache,
|
|
40
|
+
getPos = _ref.getPos;
|
|
40
41
|
var _useSharedPluginState = useSharedPluginState(api, ['width']),
|
|
41
42
|
widthState = _useSharedPluginState.widthState;
|
|
42
43
|
var _useState = useState(false),
|
|
@@ -66,6 +67,20 @@ export var InlineDropTarget = function InlineDropTarget(_ref) {
|
|
|
66
67
|
top: "".concat((nodeRect === null || nodeRect === void 0 ? void 0 : nodeRect.top) || 0, "px")
|
|
67
68
|
});
|
|
68
69
|
}, [anchorName, anchorRectCache, position]);
|
|
70
|
+
var onDrop = useCallback(function () {
|
|
71
|
+
var _api$blockControls;
|
|
72
|
+
var _ref2 = (api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.sharedState.currentState()) || {},
|
|
73
|
+
activeNode = _ref2.activeNode;
|
|
74
|
+
if (!activeNode) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
var toPos = getPos();
|
|
78
|
+
if (activeNode && toPos !== undefined) {
|
|
79
|
+
var _api$core, _api$blockControls2;
|
|
80
|
+
var start = activeNode.pos;
|
|
81
|
+
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 || (_api$blockControls2 = _api$blockControls2.commands) === null || _api$blockControls2 === void 0 ? void 0 : _api$blockControls2.moveToLayout(start, toPos, position));
|
|
82
|
+
}
|
|
83
|
+
}, [api, getPos, position]);
|
|
69
84
|
return jsx(Fragment, null, jsx("div", {
|
|
70
85
|
"data-test-id": "block-ctrl-drop-target-".concat(position),
|
|
71
86
|
css: [dropTargetCommonStyle, dropTargetRectStyle, !isDraggedOver && hideDropTargetStyle]
|
|
@@ -78,20 +93,20 @@ export var InlineDropTarget = function InlineDropTarget(_ref) {
|
|
|
78
93
|
anchorRectCache: anchorRectCache,
|
|
79
94
|
onDragEnter: handleDragEnter,
|
|
80
95
|
onDragLeave: handleDragLeave,
|
|
81
|
-
onDrop:
|
|
96
|
+
onDrop: onDrop
|
|
82
97
|
}));
|
|
83
98
|
};
|
|
84
|
-
export var InlineHoverZone = function InlineHoverZone(
|
|
85
|
-
var node =
|
|
86
|
-
editorWidthState =
|
|
87
|
-
anchorRectCache =
|
|
88
|
-
position =
|
|
89
|
-
onDragEnter =
|
|
90
|
-
onDragLeave =
|
|
91
|
-
onDrop =
|
|
99
|
+
export var InlineHoverZone = function InlineHoverZone(_ref3) {
|
|
100
|
+
var node = _ref3.node,
|
|
101
|
+
editorWidthState = _ref3.editorWidthState,
|
|
102
|
+
anchorRectCache = _ref3.anchorRectCache,
|
|
103
|
+
position = _ref3.position,
|
|
104
|
+
onDragEnter = _ref3.onDragEnter,
|
|
105
|
+
onDragLeave = _ref3.onDragLeave,
|
|
106
|
+
onDrop = _ref3.onDrop;
|
|
92
107
|
var ref = useRef(null);
|
|
93
|
-
var
|
|
94
|
-
editorWith =
|
|
108
|
+
var _ref4 = editorWidthState || {},
|
|
109
|
+
editorWith = _ref4.width;
|
|
95
110
|
var anchorName = node ? getNodeAnchor(node) : '';
|
|
96
111
|
useEffect(function () {
|
|
97
112
|
if (ref.current) {
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
2
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
3
|
+
|
|
4
|
+
// When we turn on re-release 2, will also turn on pre-release 1
|
|
5
|
+
// but not vice-versa
|
|
3
6
|
export var isPreRelease1 = function isPreRelease1() {
|
|
4
|
-
return editorExperiment('advanced_layouts', true) || fg('platform_editor_advanced_layouts_pre_release_1');
|
|
7
|
+
return editorExperiment('advanced_layouts', true) || fg('platform_editor_advanced_layouts_pre_release_1') || fg('platform_editor_advanced_layouts_pre_release_2');
|
|
8
|
+
};
|
|
9
|
+
export var isPreRelease2 = function isPreRelease2() {
|
|
10
|
+
return editorExperiment('advanced_layouts', true) || fg('platform_editor_advanced_layouts_pre_release_2');
|
|
5
11
|
};
|
|
@@ -3,7 +3,7 @@ import { type EditorContainerWidth } from '@atlaskit/editor-common/src/types';
|
|
|
3
3
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
4
4
|
import { type AnchorRectCache } from '../utils/anchor-utils';
|
|
5
5
|
import { type DropTargetProps } from './drop-target';
|
|
6
|
-
export declare const InlineDropTarget: ({ api, nextNode, position, anchorRectCache, }: DropTargetProps & {
|
|
6
|
+
export declare const InlineDropTarget: ({ api, nextNode, position, anchorRectCache, getPos, }: DropTargetProps & {
|
|
7
7
|
anchorRectCache?: AnchorRectCache | undefined;
|
|
8
8
|
position: 'left' | 'right';
|
|
9
9
|
}) => jsx.JSX.Element;
|
|
@@ -3,7 +3,7 @@ import { type EditorContainerWidth } from '@atlaskit/editor-common/src/types';
|
|
|
3
3
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
4
4
|
import { type AnchorRectCache } from '../utils/anchor-utils';
|
|
5
5
|
import { type DropTargetProps } from './drop-target';
|
|
6
|
-
export declare const InlineDropTarget: ({ api, nextNode, position, anchorRectCache, }: DropTargetProps & {
|
|
6
|
+
export declare const InlineDropTarget: ({ api, nextNode, position, anchorRectCache, getPos, }: DropTargetProps & {
|
|
7
7
|
anchorRectCache?: AnchorRectCache | undefined;
|
|
8
8
|
position: 'left' | 'right';
|
|
9
9
|
}) => jsx.JSX.Element;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-block-controls",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.1",
|
|
4
4
|
"description": "Block controls plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^1.4.0",
|
|
48
48
|
"@atlaskit/pragmatic-drag-and-drop-react-drop-indicator": "^1.1.0",
|
|
49
49
|
"@atlaskit/primitives": "^12.2.0",
|
|
50
|
-
"@atlaskit/theme": "^
|
|
50
|
+
"@atlaskit/theme": "^14.0.0",
|
|
51
51
|
"@atlaskit/tmp-editor-statsig": "^2.6.0",
|
|
52
52
|
"@atlaskit/tokens": "^2.0.0",
|
|
53
53
|
"@atlaskit/tooltip": "^18.8.0",
|
|
@@ -153,6 +153,9 @@
|
|
|
153
153
|
},
|
|
154
154
|
"platform_editor_advanced_layouts_pre_release_1": {
|
|
155
155
|
"type": "boolean"
|
|
156
|
+
},
|
|
157
|
+
"platform_editor_advanced_layouts_pre_release_2": {
|
|
158
|
+
"type": "boolean"
|
|
156
159
|
}
|
|
157
160
|
}
|
|
158
161
|
}
|