@atlaskit/editor-plugin-block-controls 2.1.9 → 2.1.11
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 +14 -0
- package/dist/cjs/plugin.js +12 -1
- package/dist/cjs/pm-plugins/handle-mouse-over.js +12 -2
- package/dist/cjs/pm-plugins/main.js +1 -1
- package/dist/es2019/plugin.js +10 -0
- package/dist/es2019/pm-plugins/handle-mouse-over.js +12 -2
- package/dist/es2019/pm-plugins/main.js +1 -1
- package/dist/esm/plugin.js +12 -1
- package/dist/esm/pm-plugins/handle-mouse-over.js +12 -2
- package/dist/esm/pm-plugins/main.js +1 -1
- package/dist/types/types.d.ts +1 -0
- package/dist/types-ts4.5/types.d.ts +1 -0
- package/package.json +6 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-controls
|
|
2
2
|
|
|
3
|
+
## 2.1.11
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 2.1.10
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#147228](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/147228)
|
|
14
|
+
[`ff45a3671e9a6`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/ff45a3671e9a6) -
|
|
15
|
+
Remove the handle from decorations when hovering on empty paragraphs.
|
|
16
|
+
|
|
3
17
|
## 2.1.9
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/dist/cjs/plugin.js
CHANGED
|
@@ -52,9 +52,20 @@ var blockControlsPlugin = exports.blockControlsPlugin = function blockControlsPl
|
|
|
52
52
|
return tr;
|
|
53
53
|
};
|
|
54
54
|
},
|
|
55
|
-
|
|
55
|
+
hideDragHandle: function hideDragHandle() {
|
|
56
56
|
return function (_ref5) {
|
|
57
57
|
var tr = _ref5.tr;
|
|
58
|
+
if ((0, _platformFeatureFlags.fg)('confluence_frontend_page_title_enter_improvements')) {
|
|
59
|
+
tr.setMeta(_main.key, {
|
|
60
|
+
hideDragHandle: true
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
return tr;
|
|
64
|
+
};
|
|
65
|
+
},
|
|
66
|
+
setNodeDragged: function setNodeDragged(getPos, anchorName, nodeType) {
|
|
67
|
+
return function (_ref6) {
|
|
68
|
+
var tr = _ref6.tr;
|
|
58
69
|
var pos = getPos();
|
|
59
70
|
if (pos === undefined) {
|
|
60
71
|
return tr;
|
|
@@ -13,6 +13,11 @@ var isEmptyNestedParagraphOrHeading = function isEmptyNestedParagraphOrHeading(t
|
|
|
13
13
|
}
|
|
14
14
|
return false;
|
|
15
15
|
};
|
|
16
|
+
var isDocFirstChildEmptyLine = function isDocFirstChildEmptyLine(elem) {
|
|
17
|
+
var _elem$firstElementChi;
|
|
18
|
+
var parentElement = elem.parentElement;
|
|
19
|
+
return (parentElement === null || parentElement === void 0 ? void 0 : parentElement.firstElementChild) === elem && ['P', 'H1', 'H2', 'H3', 'H4', 'H5', 'H6'].includes(elem.nodeName) && elem.childNodes.length === 1 && ((_elem$firstElementChi = elem.firstElementChild) === null || _elem$firstElementChi === void 0 ? void 0 : _elem$firstElementChi.classList.contains('ProseMirror-trailingBreak'));
|
|
20
|
+
};
|
|
16
21
|
var handleMouseOver = exports.handleMouseOver = function handleMouseOver(view, event, api) {
|
|
17
22
|
var _api$blockControls;
|
|
18
23
|
var _ref = (api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.sharedState.currentState()) || {},
|
|
@@ -31,6 +36,11 @@ var handleMouseOver = exports.handleMouseOver = function handleMouseOver(view, e
|
|
|
31
36
|
var rootElement = target === null || target === void 0 ? void 0 : target.closest('[data-drag-handler-anchor-name]');
|
|
32
37
|
if (rootElement) {
|
|
33
38
|
var _rootElement$parentEl;
|
|
39
|
+
if (isDocFirstChildEmptyLine(rootElement) && (0, _platformFeatureFlags.fg)('confluence_frontend_page_title_enter_improvements')) {
|
|
40
|
+
var _api$core, _api$blockControls2;
|
|
41
|
+
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 ? void 0 : _api$blockControls2.commands.hideDragHandle());
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
34
44
|
// We want to exlude handles from showing for empty paragraph and heading nodes
|
|
35
45
|
if ((0, _experiments.editorExperiment)('nested-dnd', true) && isEmptyNestedParagraphOrHeading(rootElement)) {
|
|
36
46
|
return false;
|
|
@@ -79,8 +89,8 @@ var handleMouseOver = exports.handleMouseOver = function handleMouseOver(view, e
|
|
|
79
89
|
}
|
|
80
90
|
var nodeType = rootElement.getAttribute('data-drag-handler-node-type');
|
|
81
91
|
if (nodeType) {
|
|
82
|
-
var _api$
|
|
83
|
-
api === null || api === void 0 || (_api$
|
|
92
|
+
var _api$core2, _api$blockControls3;
|
|
93
|
+
api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 || _api$core2.actions.execute(api === null || api === void 0 || (_api$blockControls3 = api.blockControls) === null || _api$blockControls3 === void 0 ? void 0 : _api$blockControls3.commands.showDragHandleAt(rootPos, anchorName, nodeType));
|
|
84
94
|
}
|
|
85
95
|
}
|
|
86
96
|
};
|
|
@@ -144,7 +144,7 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl) {
|
|
|
144
144
|
// During resize, remove the drag handle widget so its dom positioning doesn't need to be maintained
|
|
145
145
|
// Also remove the handle when the node is moved or the node count changes. This helps prevent incorrect positioning
|
|
146
146
|
// Don't remove the handle if remote changes are changing the node count, its prosemirror position can be mapped instead
|
|
147
|
-
if (isResizerResizing || maybeNodeCountChanged && shouldRemoveHandle || meta !== null && meta !== void 0 && meta.nodeMoved) {
|
|
147
|
+
if (meta !== null && meta !== void 0 && meta.hideDragHandle && (0, _platformFeatureFlags.fg)('confluence_frontend_page_title_enter_improvements') || isResizerResizing || maybeNodeCountChanged && shouldRemoveHandle || meta !== null && meta !== void 0 && meta.nodeMoved) {
|
|
148
148
|
var oldHandle = decorations.find(undefined, undefined, function (spec) {
|
|
149
149
|
return spec.id === 'drag-handle';
|
|
150
150
|
});
|
package/dist/es2019/plugin.js
CHANGED
|
@@ -41,6 +41,16 @@ export const blockControlsPlugin = ({
|
|
|
41
41
|
});
|
|
42
42
|
return tr;
|
|
43
43
|
},
|
|
44
|
+
hideDragHandle: () => ({
|
|
45
|
+
tr
|
|
46
|
+
}) => {
|
|
47
|
+
if (fg('confluence_frontend_page_title_enter_improvements')) {
|
|
48
|
+
tr.setMeta(key, {
|
|
49
|
+
hideDragHandle: true
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
return tr;
|
|
53
|
+
},
|
|
44
54
|
setNodeDragged: (getPos, anchorName, nodeType) => ({
|
|
45
55
|
tr
|
|
46
56
|
}) => {
|
|
@@ -7,6 +7,11 @@ const isEmptyNestedParagraphOrHeading = target => {
|
|
|
7
7
|
}
|
|
8
8
|
return false;
|
|
9
9
|
};
|
|
10
|
+
const isDocFirstChildEmptyLine = elem => {
|
|
11
|
+
var _elem$firstElementChi;
|
|
12
|
+
const parentElement = elem.parentElement;
|
|
13
|
+
return (parentElement === null || parentElement === void 0 ? void 0 : parentElement.firstElementChild) === elem && ['P', 'H1', 'H2', 'H3', 'H4', 'H5', 'H6'].includes(elem.nodeName) && elem.childNodes.length === 1 && ((_elem$firstElementChi = elem.firstElementChild) === null || _elem$firstElementChi === void 0 ? void 0 : _elem$firstElementChi.classList.contains('ProseMirror-trailingBreak'));
|
|
14
|
+
};
|
|
10
15
|
export const handleMouseOver = (view, event, api) => {
|
|
11
16
|
var _api$blockControls;
|
|
12
17
|
const {
|
|
@@ -26,6 +31,11 @@ export const handleMouseOver = (view, event, api) => {
|
|
|
26
31
|
let rootElement = target === null || target === void 0 ? void 0 : target.closest('[data-drag-handler-anchor-name]');
|
|
27
32
|
if (rootElement) {
|
|
28
33
|
var _rootElement$parentEl;
|
|
34
|
+
if (isDocFirstChildEmptyLine(rootElement) && fg('confluence_frontend_page_title_enter_improvements')) {
|
|
35
|
+
var _api$core, _api$blockControls2;
|
|
36
|
+
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.commands.hideDragHandle());
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
29
39
|
// We want to exlude handles from showing for empty paragraph and heading nodes
|
|
30
40
|
if (editorExperiment('nested-dnd', true) && isEmptyNestedParagraphOrHeading(rootElement)) {
|
|
31
41
|
return false;
|
|
@@ -74,8 +84,8 @@ export const handleMouseOver = (view, event, api) => {
|
|
|
74
84
|
}
|
|
75
85
|
const nodeType = rootElement.getAttribute('data-drag-handler-node-type');
|
|
76
86
|
if (nodeType) {
|
|
77
|
-
var _api$
|
|
78
|
-
api === null || api === void 0 ? void 0 : (_api$
|
|
87
|
+
var _api$core2, _api$blockControls3;
|
|
88
|
+
api === null || api === void 0 ? void 0 : (_api$core2 = api.core) === null || _api$core2 === void 0 ? void 0 : _api$core2.actions.execute(api === null || api === void 0 ? void 0 : (_api$blockControls3 = api.blockControls) === null || _api$blockControls3 === void 0 ? void 0 : _api$blockControls3.commands.showDragHandleAt(rootPos, anchorName, nodeType));
|
|
79
89
|
}
|
|
80
90
|
}
|
|
81
91
|
};
|
|
@@ -137,7 +137,7 @@ export const createPlugin = (api, getIntl) => {
|
|
|
137
137
|
// During resize, remove the drag handle widget so its dom positioning doesn't need to be maintained
|
|
138
138
|
// Also remove the handle when the node is moved or the node count changes. This helps prevent incorrect positioning
|
|
139
139
|
// Don't remove the handle if remote changes are changing the node count, its prosemirror position can be mapped instead
|
|
140
|
-
if (isResizerResizing || maybeNodeCountChanged && shouldRemoveHandle || meta !== null && meta !== void 0 && meta.nodeMoved) {
|
|
140
|
+
if (meta !== null && meta !== void 0 && meta.hideDragHandle && fg('confluence_frontend_page_title_enter_improvements') || isResizerResizing || maybeNodeCountChanged && shouldRemoveHandle || meta !== null && meta !== void 0 && meta.nodeMoved) {
|
|
141
141
|
const oldHandle = decorations.find(undefined, undefined, spec => spec.id === 'drag-handle');
|
|
142
142
|
decorations = decorations.remove(oldHandle);
|
|
143
143
|
}
|
package/dist/esm/plugin.js
CHANGED
|
@@ -45,9 +45,20 @@ export var blockControlsPlugin = function blockControlsPlugin(_ref) {
|
|
|
45
45
|
return tr;
|
|
46
46
|
};
|
|
47
47
|
},
|
|
48
|
-
|
|
48
|
+
hideDragHandle: function hideDragHandle() {
|
|
49
49
|
return function (_ref5) {
|
|
50
50
|
var tr = _ref5.tr;
|
|
51
|
+
if (fg('confluence_frontend_page_title_enter_improvements')) {
|
|
52
|
+
tr.setMeta(key, {
|
|
53
|
+
hideDragHandle: true
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
return tr;
|
|
57
|
+
};
|
|
58
|
+
},
|
|
59
|
+
setNodeDragged: function setNodeDragged(getPos, anchorName, nodeType) {
|
|
60
|
+
return function (_ref6) {
|
|
61
|
+
var tr = _ref6.tr;
|
|
51
62
|
var pos = getPos();
|
|
52
63
|
if (pos === undefined) {
|
|
53
64
|
return tr;
|
|
@@ -7,6 +7,11 @@ var isEmptyNestedParagraphOrHeading = function isEmptyNestedParagraphOrHeading(t
|
|
|
7
7
|
}
|
|
8
8
|
return false;
|
|
9
9
|
};
|
|
10
|
+
var isDocFirstChildEmptyLine = function isDocFirstChildEmptyLine(elem) {
|
|
11
|
+
var _elem$firstElementChi;
|
|
12
|
+
var parentElement = elem.parentElement;
|
|
13
|
+
return (parentElement === null || parentElement === void 0 ? void 0 : parentElement.firstElementChild) === elem && ['P', 'H1', 'H2', 'H3', 'H4', 'H5', 'H6'].includes(elem.nodeName) && elem.childNodes.length === 1 && ((_elem$firstElementChi = elem.firstElementChild) === null || _elem$firstElementChi === void 0 ? void 0 : _elem$firstElementChi.classList.contains('ProseMirror-trailingBreak'));
|
|
14
|
+
};
|
|
10
15
|
export var handleMouseOver = function handleMouseOver(view, event, api) {
|
|
11
16
|
var _api$blockControls;
|
|
12
17
|
var _ref = (api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.sharedState.currentState()) || {},
|
|
@@ -25,6 +30,11 @@ export var handleMouseOver = function handleMouseOver(view, event, api) {
|
|
|
25
30
|
var rootElement = target === null || target === void 0 ? void 0 : target.closest('[data-drag-handler-anchor-name]');
|
|
26
31
|
if (rootElement) {
|
|
27
32
|
var _rootElement$parentEl;
|
|
33
|
+
if (isDocFirstChildEmptyLine(rootElement) && fg('confluence_frontend_page_title_enter_improvements')) {
|
|
34
|
+
var _api$core, _api$blockControls2;
|
|
35
|
+
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 ? void 0 : _api$blockControls2.commands.hideDragHandle());
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
28
38
|
// We want to exlude handles from showing for empty paragraph and heading nodes
|
|
29
39
|
if (editorExperiment('nested-dnd', true) && isEmptyNestedParagraphOrHeading(rootElement)) {
|
|
30
40
|
return false;
|
|
@@ -73,8 +83,8 @@ export var handleMouseOver = function handleMouseOver(view, event, api) {
|
|
|
73
83
|
}
|
|
74
84
|
var nodeType = rootElement.getAttribute('data-drag-handler-node-type');
|
|
75
85
|
if (nodeType) {
|
|
76
|
-
var _api$
|
|
77
|
-
api === null || api === void 0 || (_api$
|
|
86
|
+
var _api$core2, _api$blockControls3;
|
|
87
|
+
api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 || _api$core2.actions.execute(api === null || api === void 0 || (_api$blockControls3 = api.blockControls) === null || _api$blockControls3 === void 0 ? void 0 : _api$blockControls3.commands.showDragHandleAt(rootPos, anchorName, nodeType));
|
|
78
88
|
}
|
|
79
89
|
}
|
|
80
90
|
};
|
|
@@ -137,7 +137,7 @@ export var createPlugin = function createPlugin(api, getIntl) {
|
|
|
137
137
|
// During resize, remove the drag handle widget so its dom positioning doesn't need to be maintained
|
|
138
138
|
// Also remove the handle when the node is moved or the node count changes. This helps prevent incorrect positioning
|
|
139
139
|
// Don't remove the handle if remote changes are changing the node count, its prosemirror position can be mapped instead
|
|
140
|
-
if (isResizerResizing || maybeNodeCountChanged && shouldRemoveHandle || meta !== null && meta !== void 0 && meta.nodeMoved) {
|
|
140
|
+
if (meta !== null && meta !== void 0 && meta.hideDragHandle && fg('confluence_frontend_page_title_enter_improvements') || isResizerResizing || maybeNodeCountChanged && shouldRemoveHandle || meta !== null && meta !== void 0 && meta.nodeMoved) {
|
|
141
141
|
var oldHandle = decorations.find(undefined, undefined, function (spec) {
|
|
142
142
|
return spec.id === 'drag-handle';
|
|
143
143
|
});
|
package/dist/types/types.d.ts
CHANGED
|
@@ -60,6 +60,7 @@ export type BlockControlsPlugin = NextEditorPlugin<'blockControls', {
|
|
|
60
60
|
commands: {
|
|
61
61
|
moveNode: (start: number, to: number, inputMethod?: MoveNodeMethod, formatMessage?: IntlShape['formatMessage']) => EditorCommand;
|
|
62
62
|
showDragHandleAt: (pos: number, anchorName: string, nodeType: string, handleOptions?: HandleOptions) => EditorCommand;
|
|
63
|
+
hideDragHandle: () => EditorCommand;
|
|
63
64
|
setNodeDragged: (getPos: () => number | undefined, anchorName: string, nodeType: string) => EditorCommand;
|
|
64
65
|
};
|
|
65
66
|
}>;
|
|
@@ -60,6 +60,7 @@ export type BlockControlsPlugin = NextEditorPlugin<'blockControls', {
|
|
|
60
60
|
commands: {
|
|
61
61
|
moveNode: (start: number, to: number, inputMethod?: MoveNodeMethod, formatMessage?: IntlShape['formatMessage']) => EditorCommand;
|
|
62
62
|
showDragHandleAt: (pos: number, anchorName: string, nodeType: string, handleOptions?: HandleOptions) => EditorCommand;
|
|
63
|
+
hideDragHandle: () => EditorCommand;
|
|
63
64
|
setNodeDragged: (getPos: () => number | undefined, anchorName: string, nodeType: string) => EditorCommand;
|
|
64
65
|
};
|
|
65
66
|
}>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-block-controls",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.11",
|
|
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
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@atlaskit/adf-schema": "^40.9.0",
|
|
34
|
-
"@atlaskit/editor-common": "^
|
|
34
|
+
"@atlaskit/editor-common": "^93.0.0",
|
|
35
35
|
"@atlaskit/editor-plugin-accessibility-utils": "^1.2.0",
|
|
36
36
|
"@atlaskit/editor-plugin-analytics": "^1.8.0",
|
|
37
37
|
"@atlaskit/editor-plugin-editor-disabled": "^1.3.0",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"@atlaskit/theme": "^13.0.0",
|
|
51
51
|
"@atlaskit/tmp-editor-statsig": "^2.2.0",
|
|
52
52
|
"@atlaskit/tokens": "^2.0.0",
|
|
53
|
-
"@atlaskit/tooltip": "^18.
|
|
53
|
+
"@atlaskit/tooltip": "^18.8.0",
|
|
54
54
|
"@babel/runtime": "^7.0.0",
|
|
55
55
|
"@emotion/react": "^11.7.1",
|
|
56
56
|
"bind-event-listener": "^3.0.0",
|
|
@@ -144,6 +144,9 @@
|
|
|
144
144
|
},
|
|
145
145
|
"platform_editor_element_dnd_nested_type_error_fix": {
|
|
146
146
|
"type": "boolean"
|
|
147
|
+
},
|
|
148
|
+
"confluence_frontend_page_title_enter_improvements": {
|
|
149
|
+
"type": "boolean"
|
|
147
150
|
}
|
|
148
151
|
}
|
|
149
152
|
}
|