@atlaskit/editor-plugin-block-controls 3.17.1 → 3.19.0
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/blockControlsPlugin.js +6 -1
- package/dist/cjs/pm-plugins/decorations-drop-target-active.js +29 -3
- package/dist/cjs/pm-plugins/interaction-tracking/commands.js +11 -1
- package/dist/cjs/pm-plugins/interaction-tracking/handle-mouse-move.js +9 -1
- package/dist/cjs/pm-plugins/interaction-tracking/pm-plugin.js +64 -9
- package/dist/cjs/ui/global-styles.js +10 -2
- package/dist/cjs/ui/visibility-container.js +2 -1
- package/dist/es2019/blockControlsPlugin.js +6 -1
- package/dist/es2019/pm-plugins/decorations-drop-target-active.js +30 -4
- package/dist/es2019/pm-plugins/interaction-tracking/commands.js +10 -0
- package/dist/es2019/pm-plugins/interaction-tracking/handle-mouse-move.js +9 -1
- package/dist/es2019/pm-plugins/interaction-tracking/pm-plugin.js +64 -10
- package/dist/es2019/ui/global-styles.js +7 -3
- package/dist/es2019/ui/visibility-container.js +2 -1
- package/dist/esm/blockControlsPlugin.js +6 -1
- package/dist/esm/pm-plugins/decorations-drop-target-active.js +30 -4
- package/dist/esm/pm-plugins/interaction-tracking/commands.js +10 -0
- package/dist/esm/pm-plugins/interaction-tracking/handle-mouse-move.js +9 -1
- package/dist/esm/pm-plugins/interaction-tracking/pm-plugin.js +64 -10
- package/dist/esm/ui/global-styles.js +11 -3
- package/dist/esm/ui/visibility-container.js +2 -1
- package/dist/types/blockControlsPluginType.d.ts +2 -0
- package/dist/types/pm-plugins/interaction-tracking/commands.d.ts +2 -0
- package/dist/types/pm-plugins/interaction-tracking/handle-mouse-move.d.ts +2 -0
- package/dist/types/pm-plugins/interaction-tracking/pm-plugin.d.ts +4 -0
- package/dist/types-ts4.5/blockControlsPluginType.d.ts +2 -0
- package/dist/types-ts4.5/pm-plugins/interaction-tracking/commands.d.ts +2 -0
- package/dist/types-ts4.5/pm-plugins/interaction-tracking/handle-mouse-move.d.ts +2 -0
- package/dist/types-ts4.5/pm-plugins/interaction-tracking/pm-plugin.d.ts +4 -0
- package/package.json +4 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-controls
|
|
2
2
|
|
|
3
|
+
## 3.19.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#170348](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/170348)
|
|
8
|
+
[`8f9510a71c843`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/8f9510a71c843) -
|
|
9
|
+
ED-28158 implement active advanced layout drop targets
|
|
10
|
+
|
|
11
|
+
## 3.18.0
|
|
12
|
+
|
|
13
|
+
### Minor Changes
|
|
14
|
+
|
|
15
|
+
- [#169535](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/169535)
|
|
16
|
+
[`275f3d6725a4e`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/275f3d6725a4e) -
|
|
17
|
+
[ux] Hide plus and block control buttons when hovering over gutter space on the left and right
|
|
18
|
+
|
|
3
19
|
## 3.17.1
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
@@ -186,7 +186,7 @@ var blockControlsPlugin = exports.blockControlsPlugin = function blockControlsPl
|
|
|
186
186
|
if (!editorState) {
|
|
187
187
|
return undefined;
|
|
188
188
|
}
|
|
189
|
-
|
|
189
|
+
var sharedState = {
|
|
190
190
|
isMenuOpen: (_key$getState$isMenuO = (_key$getState = _main.key.getState(editorState)) === null || _key$getState === void 0 ? void 0 : _key$getState.isMenuOpen) !== null && _key$getState$isMenuO !== void 0 ? _key$getState$isMenuO : false,
|
|
191
191
|
menuTriggerBy: (_key$getState$menuTri = (_key$getState2 = _main.key.getState(editorState)) === null || _key$getState2 === void 0 ? void 0 : _key$getState2.menuTriggerBy) !== null && _key$getState$menuTri !== void 0 ? _key$getState$menuTri : undefined,
|
|
192
192
|
activeNode: (_key$getState$activeN = (_key$getState3 = _main.key.getState(editorState)) === null || _key$getState3 === void 0 ? void 0 : _key$getState3.activeNode) !== null && _key$getState$activeN !== void 0 ? _key$getState$activeN : undefined,
|
|
@@ -199,6 +199,11 @@ var blockControlsPlugin = exports.blockControlsPlugin = function blockControlsPl
|
|
|
199
199
|
isEditing: (_interactionTrackingP = _pmPlugin.interactionTrackingPluginKey.getState(editorState)) === null || _interactionTrackingP === void 0 ? void 0 : _interactionTrackingP.isEditing,
|
|
200
200
|
isSelectedViaDragHandle: (_key$getState$isSelec = (_key$getState0 = _main.key.getState(editorState)) === null || _key$getState0 === void 0 ? void 0 : _key$getState0.isSelectedViaDragHandle) !== null && _key$getState$isSelec !== void 0 ? _key$getState$isSelec : false
|
|
201
201
|
};
|
|
202
|
+
if ((0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_13')) {
|
|
203
|
+
var _interactionTrackingP2, _interactionTrackingP3;
|
|
204
|
+
sharedState.isMouseOut = (_interactionTrackingP2 = (_interactionTrackingP3 = _pmPlugin.interactionTrackingPluginKey.getState(editorState)) === null || _interactionTrackingP3 === void 0 ? void 0 : _interactionTrackingP3.isMouseOut) !== null && _interactionTrackingP2 !== void 0 ? _interactionTrackingP2 : false;
|
|
205
|
+
}
|
|
206
|
+
return sharedState;
|
|
202
207
|
},
|
|
203
208
|
contentComponent: function contentComponent(_ref8) {
|
|
204
209
|
var editorView = _ref8.editorView,
|
|
@@ -11,6 +11,7 @@ var _decorationsCommon = require("./decorations-common");
|
|
|
11
11
|
var _decorationsDropTarget = require("./decorations-drop-target");
|
|
12
12
|
var _decorationsFindSurroundingNodes = require("./decorations-find-surrounding-nodes");
|
|
13
13
|
var _activeAnchorTracker = require("./utils/active-anchor-tracker");
|
|
14
|
+
var _consts = require("./utils/consts");
|
|
14
15
|
var _validation = require("./utils/validation");
|
|
15
16
|
/**
|
|
16
17
|
* List of parent node types that can have child nodes
|
|
@@ -134,6 +135,10 @@ var getActiveDropTargetDecorations = exports.getActiveDropTargetDecorations = fu
|
|
|
134
135
|
}, nodeViewPortalProviderAPI, -1, undefined, isSameLayout));
|
|
135
136
|
}
|
|
136
137
|
}
|
|
138
|
+
var rootNodeWithPos = {
|
|
139
|
+
node: node,
|
|
140
|
+
pos: pos
|
|
141
|
+
};
|
|
137
142
|
|
|
138
143
|
// if the current node is not a top level node, we create one for advanced layout drop targets
|
|
139
144
|
if (depth > 1) {
|
|
@@ -146,9 +151,30 @@ var getActiveDropTargetDecorations = exports.getActiveDropTargetDecorations = fu
|
|
|
146
151
|
formatMessage: formatMessage,
|
|
147
152
|
dropTargetStyle: 'default'
|
|
148
153
|
}, nodeViewPortalProviderAPI, 0, undefined, false));
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
154
|
+
rootNodeWithPos = {
|
|
155
|
+
node: root.node,
|
|
156
|
+
pos: root.pos
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
if ((0, _experiments.editorExperiment)('advanced_layouts', true)) {
|
|
160
|
+
var _isSameLayout = $activeNodePos && (0, _validation.isInSameLayout)($activeNodePos, state.doc.resolve(rootNodeWithPos.pos));
|
|
161
|
+
if (rootNodeWithPos.node.type.name === 'layoutSection') {
|
|
162
|
+
var layoutSectionNode = rootNodeWithPos.node;
|
|
163
|
+
if (layoutSectionNode.childCount < (0, _consts.maxLayoutColumnSupported)() || _isSameLayout) {
|
|
164
|
+
layoutSectionNode.descendants(function (childNode, childPos, parent, index) {
|
|
165
|
+
if (childNode.type.name === 'layoutColumn' && (parent === null || parent === void 0 ? void 0 : parent.type.name) === 'layoutSection' && index !== 0 // Not the first node
|
|
166
|
+
) {
|
|
167
|
+
decs.push((0, _decorationsDropTarget.createLayoutDropTargetDecoration)(rootNodeWithPos.pos + childPos + 1, {
|
|
168
|
+
api: api,
|
|
169
|
+
parent: parent,
|
|
170
|
+
formatMessage: formatMessage
|
|
171
|
+
}, nodeViewPortalProviderAPI, undefined));
|
|
172
|
+
}
|
|
173
|
+
return false;
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
}
|
|
152
177
|
}
|
|
178
|
+
_activeAnchorTracker.defaultActiveAnchorTracker.emit((0, _decorationsCommon.getNodeAnchor)(rootNodeWithPos.node));
|
|
153
179
|
return decs;
|
|
154
180
|
};
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.stopEditing = exports.startEditing = void 0;
|
|
6
|
+
exports.stopEditing = exports.startEditing = exports.mouseLeave = exports.mouseEnter = void 0;
|
|
7
7
|
var _pmPlugin = require("./pm-plugin");
|
|
8
8
|
var stopEditing = exports.stopEditing = function stopEditing(view) {
|
|
9
9
|
view.dispatch(view.state.tr.setMeta(_pmPlugin.interactionTrackingPluginKey, {
|
|
@@ -14,4 +14,14 @@ var startEditing = exports.startEditing = function startEditing(view) {
|
|
|
14
14
|
view.dispatch(view.state.tr.setMeta(_pmPlugin.interactionTrackingPluginKey, {
|
|
15
15
|
type: 'startEditing'
|
|
16
16
|
}));
|
|
17
|
+
};
|
|
18
|
+
var mouseLeave = exports.mouseLeave = function mouseLeave(view) {
|
|
19
|
+
view.dispatch(view.state.tr.setMeta(_pmPlugin.interactionTrackingPluginKey, {
|
|
20
|
+
type: 'mouseLeave'
|
|
21
|
+
}));
|
|
22
|
+
};
|
|
23
|
+
var mouseEnter = exports.mouseEnter = function mouseEnter(view) {
|
|
24
|
+
view.dispatch(view.state.tr.setMeta(_pmPlugin.interactionTrackingPluginKey, {
|
|
25
|
+
type: 'mouseEnter'
|
|
26
|
+
}));
|
|
17
27
|
};
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.handleMouseMove = void 0;
|
|
6
|
+
exports.handleMouseMove = exports.handleMouseLeave = exports.handleMouseEnter = void 0;
|
|
7
7
|
var _commands = require("./commands");
|
|
8
8
|
var _pmPlugin = require("./pm-plugin");
|
|
9
9
|
var handleMouseMove = exports.handleMouseMove = function handleMouseMove(view) {
|
|
@@ -13,4 +13,12 @@ var handleMouseMove = exports.handleMouseMove = function handleMouseMove(view) {
|
|
|
13
13
|
(0, _commands.stopEditing)(view);
|
|
14
14
|
}
|
|
15
15
|
return false;
|
|
16
|
+
};
|
|
17
|
+
var handleMouseLeave = exports.handleMouseLeave = function handleMouseLeave(view) {
|
|
18
|
+
(0, _commands.mouseLeave)(view);
|
|
19
|
+
return false;
|
|
20
|
+
};
|
|
21
|
+
var handleMouseEnter = exports.handleMouseEnter = function handleMouseEnter(view) {
|
|
22
|
+
(0, _commands.mouseEnter)(view);
|
|
23
|
+
return false;
|
|
16
24
|
};
|
|
@@ -1,36 +1,65 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports.interactionTrackingPluginKey = exports.getInteractionTrackingState = exports.createInteractionTrackingPlugin = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _bindEventListener = require("bind-event-listener");
|
|
7
10
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
8
11
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
12
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
13
|
+
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
9
14
|
var _handleKeyDown = require("./handle-key-down");
|
|
10
15
|
var _handleMouseMove = require("./handle-mouse-move");
|
|
16
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
17
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
11
18
|
var interactionTrackingPluginKey = exports.interactionTrackingPluginKey = new _state.PluginKey('interactionTrackingPlugin');
|
|
12
19
|
var createInteractionTrackingPlugin = exports.createInteractionTrackingPlugin = function createInteractionTrackingPlugin() {
|
|
13
20
|
return new _safePlugin.SafePlugin({
|
|
14
21
|
key: interactionTrackingPluginKey,
|
|
15
22
|
state: {
|
|
16
23
|
init: function init() {
|
|
17
|
-
|
|
24
|
+
var state = {
|
|
18
25
|
isEditing: false
|
|
19
26
|
};
|
|
27
|
+
if ((0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_13')) {
|
|
28
|
+
state.isMouseOut = false;
|
|
29
|
+
}
|
|
30
|
+
return state;
|
|
20
31
|
},
|
|
21
32
|
apply: function apply(tr, pluginState) {
|
|
22
33
|
var meta = tr.getMeta(interactionTrackingPluginKey);
|
|
34
|
+
if (!(0, _platformFeatureFlags.fg)('platform_editor_controls_patch_13')) {
|
|
35
|
+
switch (meta === null || meta === void 0 ? void 0 : meta.type) {
|
|
36
|
+
case 'startEditing':
|
|
37
|
+
return {
|
|
38
|
+
isEditing: true
|
|
39
|
+
};
|
|
40
|
+
case 'stopEditing':
|
|
41
|
+
return {
|
|
42
|
+
isEditing: false
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
return pluginState;
|
|
46
|
+
}
|
|
47
|
+
var newState = {};
|
|
23
48
|
switch (meta === null || meta === void 0 ? void 0 : meta.type) {
|
|
24
49
|
case 'startEditing':
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
};
|
|
50
|
+
newState.isEditing = true;
|
|
51
|
+
break;
|
|
28
52
|
case 'stopEditing':
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
53
|
+
newState.isEditing = false;
|
|
54
|
+
break;
|
|
55
|
+
case 'mouseLeave':
|
|
56
|
+
newState.isMouseOut = true;
|
|
57
|
+
break;
|
|
58
|
+
case 'mouseEnter':
|
|
59
|
+
newState.isMouseOut = false;
|
|
60
|
+
break;
|
|
32
61
|
}
|
|
33
|
-
return pluginState;
|
|
62
|
+
return _objectSpread(_objectSpread({}, pluginState), newState);
|
|
34
63
|
}
|
|
35
64
|
},
|
|
36
65
|
props: {
|
|
@@ -38,7 +67,33 @@ var createInteractionTrackingPlugin = exports.createInteractionTrackingPlugin =
|
|
|
38
67
|
handleDOMEvents: {
|
|
39
68
|
mousemove: _handleMouseMove.handleMouseMove
|
|
40
69
|
}
|
|
41
|
-
}
|
|
70
|
+
},
|
|
71
|
+
view: (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_13') ? function (view) {
|
|
72
|
+
var editorContentArea = view.dom.closest('.ak-editor-content-area');
|
|
73
|
+
var unbindMouseEnter;
|
|
74
|
+
var unbindMouseLeave;
|
|
75
|
+
if (editorContentArea) {
|
|
76
|
+
unbindMouseEnter = (0, _bindEventListener.bind)(editorContentArea, {
|
|
77
|
+
type: 'mouseenter',
|
|
78
|
+
listener: function listener() {
|
|
79
|
+
(0, _handleMouseMove.handleMouseEnter)(view);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
unbindMouseLeave = (0, _bindEventListener.bind)(editorContentArea, {
|
|
83
|
+
type: 'mouseleave',
|
|
84
|
+
listener: function listener() {
|
|
85
|
+
(0, _handleMouseMove.handleMouseLeave)(view);
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
return {
|
|
90
|
+
destroy: function destroy() {
|
|
91
|
+
var _unbindMouseEnter, _unbindMouseLeave;
|
|
92
|
+
(_unbindMouseEnter = unbindMouseEnter) === null || _unbindMouseEnter === void 0 || _unbindMouseEnter();
|
|
93
|
+
(_unbindMouseLeave = unbindMouseLeave) === null || _unbindMouseLeave === void 0 || _unbindMouseLeave();
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
} : undefined
|
|
42
97
|
});
|
|
43
98
|
};
|
|
44
99
|
var getInteractionTrackingState = exports.getInteractionTrackingState = function getInteractionTrackingState(state) {
|
|
@@ -25,6 +25,12 @@ var _consts = require("./consts");
|
|
|
25
25
|
* including those within table rows and media.
|
|
26
26
|
*/
|
|
27
27
|
var dragHandlerAnchorSelector = '[data-drag-handler-anchor-name]:not([data-drag-handler-node-type="tableRow"], [data-drag-handler-node-type="media"])';
|
|
28
|
+
var gutterPaddingWidth = function gutterPaddingWidth() {
|
|
29
|
+
return (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_13') ? "".concat((0, _editorSharedStyles.akEditorGutterPaddingDynamic)(), "px") : '100%';
|
|
30
|
+
};
|
|
31
|
+
var gutterPaddingLeft = function gutterPaddingLeft() {
|
|
32
|
+
return (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_13') ? "-".concat((0, _editorSharedStyles.akEditorGutterPaddingDynamic)(), "px") : '-100px';
|
|
33
|
+
};
|
|
28
34
|
var extendedHoverZone = function extendedHoverZone() {
|
|
29
35
|
return (0, _react.css)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, ".block-ctrl-drag-preview ".concat(dragHandlerAnchorSelector, "::after"), {
|
|
30
36
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles
|
|
@@ -44,8 +50,10 @@ var extendedHoverZone = function extendedHoverZone() {
|
|
|
44
50
|
content: '""',
|
|
45
51
|
position: 'absolute',
|
|
46
52
|
top: 0,
|
|
47
|
-
|
|
48
|
-
|
|
53
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
54
|
+
left: gutterPaddingLeft(),
|
|
55
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
56
|
+
width: gutterPaddingWidth(),
|
|
49
57
|
height: '100%',
|
|
50
58
|
cursor: 'default',
|
|
51
59
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
|
|
@@ -24,7 +24,8 @@ var VisibilityContainer = exports.VisibilityContainer = function VisibilityConta
|
|
|
24
24
|
children = _ref.children;
|
|
25
25
|
var isTypeAheadOpen = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'typeAhead.isOpen');
|
|
26
26
|
var isEditing = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'blockControls.isEditing');
|
|
27
|
-
var
|
|
27
|
+
var isMouseOut = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'blockControls.isMouseOut');
|
|
28
|
+
var shouldHide = isTypeAheadOpen || isEditing || isMouseOut;
|
|
28
29
|
return /*#__PURE__*/_react.default.createElement(_primitives.Box, {
|
|
29
30
|
xcss: [baseStyles, shouldHide ? hiddenStyles : visibleStyles]
|
|
30
31
|
}, children);
|
|
@@ -177,7 +177,7 @@ export const blockControlsPlugin = ({
|
|
|
177
177
|
if (!editorState) {
|
|
178
178
|
return undefined;
|
|
179
179
|
}
|
|
180
|
-
|
|
180
|
+
const sharedState = {
|
|
181
181
|
isMenuOpen: (_key$getState$isMenuO = (_key$getState = key.getState(editorState)) === null || _key$getState === void 0 ? void 0 : _key$getState.isMenuOpen) !== null && _key$getState$isMenuO !== void 0 ? _key$getState$isMenuO : false,
|
|
182
182
|
menuTriggerBy: (_key$getState$menuTri = (_key$getState2 = key.getState(editorState)) === null || _key$getState2 === void 0 ? void 0 : _key$getState2.menuTriggerBy) !== null && _key$getState$menuTri !== void 0 ? _key$getState$menuTri : undefined,
|
|
183
183
|
activeNode: (_key$getState$activeN = (_key$getState3 = key.getState(editorState)) === null || _key$getState3 === void 0 ? void 0 : _key$getState3.activeNode) !== null && _key$getState$activeN !== void 0 ? _key$getState$activeN : undefined,
|
|
@@ -190,6 +190,11 @@ export const blockControlsPlugin = ({
|
|
|
190
190
|
isEditing: (_interactionTrackingP = interactionTrackingPluginKey.getState(editorState)) === null || _interactionTrackingP === void 0 ? void 0 : _interactionTrackingP.isEditing,
|
|
191
191
|
isSelectedViaDragHandle: (_key$getState$isSelec = (_key$getState0 = key.getState(editorState)) === null || _key$getState0 === void 0 ? void 0 : _key$getState0.isSelectedViaDragHandle) !== null && _key$getState$isSelec !== void 0 ? _key$getState$isSelec : false
|
|
192
192
|
};
|
|
193
|
+
if (editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_13')) {
|
|
194
|
+
var _interactionTrackingP2, _interactionTrackingP3;
|
|
195
|
+
sharedState.isMouseOut = (_interactionTrackingP2 = (_interactionTrackingP3 = interactionTrackingPluginKey.getState(editorState)) === null || _interactionTrackingP3 === void 0 ? void 0 : _interactionTrackingP3.isMouseOut) !== null && _interactionTrackingP2 !== void 0 ? _interactionTrackingP2 : false;
|
|
196
|
+
}
|
|
197
|
+
return sharedState;
|
|
193
198
|
},
|
|
194
199
|
contentComponent({
|
|
195
200
|
editorView,
|
|
@@ -2,9 +2,10 @@ import { expandSelectionBounds } from '@atlaskit/editor-common/selection';
|
|
|
2
2
|
import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
|
|
3
3
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
4
4
|
import { getNodeAnchor, unmountDecorations } from './decorations-common';
|
|
5
|
-
import { createDropTargetDecoration } from './decorations-drop-target';
|
|
5
|
+
import { createDropTargetDecoration, createLayoutDropTargetDecoration } from './decorations-drop-target';
|
|
6
6
|
import { findSurroundingNodes } from './decorations-find-surrounding-nodes';
|
|
7
7
|
import { defaultActiveAnchorTracker } from './utils/active-anchor-tracker';
|
|
8
|
+
import { maxLayoutColumnSupported } from './utils/consts';
|
|
8
9
|
import { canMoveNodeToIndex, canMoveSliceToIndex, isInSameLayout } from './utils/validation';
|
|
9
10
|
|
|
10
11
|
/**
|
|
@@ -131,6 +132,10 @@ export const getActiveDropTargetDecorations = (activeDropTargetNode, state, api,
|
|
|
131
132
|
}, nodeViewPortalProviderAPI, -1, undefined, isSameLayout));
|
|
132
133
|
}
|
|
133
134
|
}
|
|
135
|
+
let rootNodeWithPos = {
|
|
136
|
+
node,
|
|
137
|
+
pos
|
|
138
|
+
};
|
|
134
139
|
|
|
135
140
|
// if the current node is not a top level node, we create one for advanced layout drop targets
|
|
136
141
|
if (depth > 1) {
|
|
@@ -143,9 +148,30 @@ export const getActiveDropTargetDecorations = (activeDropTargetNode, state, api,
|
|
|
143
148
|
formatMessage,
|
|
144
149
|
dropTargetStyle: 'default'
|
|
145
150
|
}, nodeViewPortalProviderAPI, 0, undefined, false));
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
151
|
+
rootNodeWithPos = {
|
|
152
|
+
node: root.node,
|
|
153
|
+
pos: root.pos
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
if (editorExperiment('advanced_layouts', true)) {
|
|
157
|
+
const isSameLayout = $activeNodePos && isInSameLayout($activeNodePos, state.doc.resolve(rootNodeWithPos.pos));
|
|
158
|
+
if (rootNodeWithPos.node.type.name === 'layoutSection') {
|
|
159
|
+
const layoutSectionNode = rootNodeWithPos.node;
|
|
160
|
+
if (layoutSectionNode.childCount < maxLayoutColumnSupported() || isSameLayout) {
|
|
161
|
+
layoutSectionNode.descendants((childNode, childPos, parent, index) => {
|
|
162
|
+
if (childNode.type.name === 'layoutColumn' && (parent === null || parent === void 0 ? void 0 : parent.type.name) === 'layoutSection' && index !== 0 // Not the first node
|
|
163
|
+
) {
|
|
164
|
+
decs.push(createLayoutDropTargetDecoration(rootNodeWithPos.pos + childPos + 1, {
|
|
165
|
+
api,
|
|
166
|
+
parent,
|
|
167
|
+
formatMessage
|
|
168
|
+
}, nodeViewPortalProviderAPI, undefined));
|
|
169
|
+
}
|
|
170
|
+
return false;
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
}
|
|
149
174
|
}
|
|
175
|
+
defaultActiveAnchorTracker.emit(getNodeAnchor(rootNodeWithPos.node));
|
|
150
176
|
return decs;
|
|
151
177
|
};
|
|
@@ -8,4 +8,14 @@ export const startEditing = view => {
|
|
|
8
8
|
view.dispatch(view.state.tr.setMeta(interactionTrackingPluginKey, {
|
|
9
9
|
type: 'startEditing'
|
|
10
10
|
}));
|
|
11
|
+
};
|
|
12
|
+
export const mouseLeave = view => {
|
|
13
|
+
view.dispatch(view.state.tr.setMeta(interactionTrackingPluginKey, {
|
|
14
|
+
type: 'mouseLeave'
|
|
15
|
+
}));
|
|
16
|
+
};
|
|
17
|
+
export const mouseEnter = view => {
|
|
18
|
+
view.dispatch(view.state.tr.setMeta(interactionTrackingPluginKey, {
|
|
19
|
+
type: 'mouseEnter'
|
|
20
|
+
}));
|
|
11
21
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { stopEditing } from './commands';
|
|
1
|
+
import { mouseEnter, mouseLeave, stopEditing } from './commands';
|
|
2
2
|
import { getInteractionTrackingState } from './pm-plugin';
|
|
3
3
|
export const handleMouseMove = view => {
|
|
4
4
|
const state = getInteractionTrackingState(view.state);
|
|
@@ -7,4 +7,12 @@ export const handleMouseMove = view => {
|
|
|
7
7
|
stopEditing(view);
|
|
8
8
|
}
|
|
9
9
|
return false;
|
|
10
|
+
};
|
|
11
|
+
export const handleMouseLeave = view => {
|
|
12
|
+
mouseLeave(view);
|
|
13
|
+
return false;
|
|
14
|
+
};
|
|
15
|
+
export const handleMouseEnter = view => {
|
|
16
|
+
mouseEnter(view);
|
|
17
|
+
return false;
|
|
10
18
|
};
|
|
@@ -1,30 +1,58 @@
|
|
|
1
|
+
import { bind } from 'bind-event-listener';
|
|
1
2
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
3
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
3
6
|
import { handleKeyDown } from './handle-key-down';
|
|
4
|
-
import { handleMouseMove } from './handle-mouse-move';
|
|
7
|
+
import { handleMouseEnter, handleMouseLeave, handleMouseMove } from './handle-mouse-move';
|
|
5
8
|
export const interactionTrackingPluginKey = new PluginKey('interactionTrackingPlugin');
|
|
6
9
|
export const createInteractionTrackingPlugin = () => {
|
|
7
10
|
return new SafePlugin({
|
|
8
11
|
key: interactionTrackingPluginKey,
|
|
9
12
|
state: {
|
|
10
13
|
init() {
|
|
11
|
-
|
|
14
|
+
const state = {
|
|
12
15
|
isEditing: false
|
|
13
16
|
};
|
|
17
|
+
if (editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_13')) {
|
|
18
|
+
state.isMouseOut = false;
|
|
19
|
+
}
|
|
20
|
+
return state;
|
|
14
21
|
},
|
|
15
22
|
apply(tr, pluginState) {
|
|
16
23
|
const meta = tr.getMeta(interactionTrackingPluginKey);
|
|
24
|
+
if (!fg('platform_editor_controls_patch_13')) {
|
|
25
|
+
switch (meta === null || meta === void 0 ? void 0 : meta.type) {
|
|
26
|
+
case 'startEditing':
|
|
27
|
+
return {
|
|
28
|
+
isEditing: true
|
|
29
|
+
};
|
|
30
|
+
case 'stopEditing':
|
|
31
|
+
return {
|
|
32
|
+
isEditing: false
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
return pluginState;
|
|
36
|
+
}
|
|
37
|
+
const newState = {};
|
|
17
38
|
switch (meta === null || meta === void 0 ? void 0 : meta.type) {
|
|
18
39
|
case 'startEditing':
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
};
|
|
40
|
+
newState.isEditing = true;
|
|
41
|
+
break;
|
|
22
42
|
case 'stopEditing':
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
43
|
+
newState.isEditing = false;
|
|
44
|
+
break;
|
|
45
|
+
case 'mouseLeave':
|
|
46
|
+
newState.isMouseOut = true;
|
|
47
|
+
break;
|
|
48
|
+
case 'mouseEnter':
|
|
49
|
+
newState.isMouseOut = false;
|
|
50
|
+
break;
|
|
26
51
|
}
|
|
27
|
-
return
|
|
52
|
+
return {
|
|
53
|
+
...pluginState,
|
|
54
|
+
...newState
|
|
55
|
+
};
|
|
28
56
|
}
|
|
29
57
|
},
|
|
30
58
|
props: {
|
|
@@ -32,7 +60,33 @@ export const createInteractionTrackingPlugin = () => {
|
|
|
32
60
|
handleDOMEvents: {
|
|
33
61
|
mousemove: handleMouseMove
|
|
34
62
|
}
|
|
35
|
-
}
|
|
63
|
+
},
|
|
64
|
+
view: editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_13') ? view => {
|
|
65
|
+
const editorContentArea = view.dom.closest('.ak-editor-content-area');
|
|
66
|
+
let unbindMouseEnter;
|
|
67
|
+
let unbindMouseLeave;
|
|
68
|
+
if (editorContentArea) {
|
|
69
|
+
unbindMouseEnter = bind(editorContentArea, {
|
|
70
|
+
type: 'mouseenter',
|
|
71
|
+
listener: () => {
|
|
72
|
+
handleMouseEnter(view);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
unbindMouseLeave = bind(editorContentArea, {
|
|
76
|
+
type: 'mouseleave',
|
|
77
|
+
listener: () => {
|
|
78
|
+
handleMouseLeave(view);
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
return {
|
|
83
|
+
destroy: () => {
|
|
84
|
+
var _unbindMouseEnter, _unbindMouseLeave;
|
|
85
|
+
(_unbindMouseEnter = unbindMouseEnter) === null || _unbindMouseEnter === void 0 ? void 0 : _unbindMouseEnter();
|
|
86
|
+
(_unbindMouseLeave = unbindMouseLeave) === null || _unbindMouseLeave === void 0 ? void 0 : _unbindMouseLeave();
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
} : undefined
|
|
36
90
|
});
|
|
37
91
|
};
|
|
38
92
|
export const getInteractionTrackingState = state => {
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import { css, Global, jsx } from '@emotion/react';
|
|
7
7
|
import { tableControlsSpacing } from '@atlaskit/editor-common/styles';
|
|
8
8
|
import { ZERO_WIDTH_SPACE } from '@atlaskit/editor-common/whitespace';
|
|
9
|
-
import { akEditorBreakoutPadding, akEditorCalculatedWideLayoutWidth, akEditorCalculatedWideLayoutWidthSmallViewport } from '@atlaskit/editor-shared-styles';
|
|
9
|
+
import { akEditorBreakoutPadding, akEditorCalculatedWideLayoutWidth, akEditorCalculatedWideLayoutWidthSmallViewport, akEditorGutterPaddingDynamic } from '@atlaskit/editor-shared-styles';
|
|
10
10
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
11
11
|
import { layers } from '@atlaskit/theme/constants';
|
|
12
12
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
@@ -17,6 +17,8 @@ import { DRAG_HANDLE_MAX_WIDTH_PLUS_GAP, DRAG_HANDLE_WIDTH } from './consts';
|
|
|
17
17
|
* including those within table rows and media.
|
|
18
18
|
*/
|
|
19
19
|
const dragHandlerAnchorSelector = '[data-drag-handler-anchor-name]:not([data-drag-handler-node-type="tableRow"], [data-drag-handler-node-type="media"])';
|
|
20
|
+
const gutterPaddingWidth = () => editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_13') ? `${akEditorGutterPaddingDynamic()}px` : '100%';
|
|
21
|
+
const gutterPaddingLeft = () => editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_13') ? `-${akEditorGutterPaddingDynamic()}px` : '-100px';
|
|
20
22
|
const extendedHoverZone = () => css({
|
|
21
23
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-values
|
|
22
24
|
[`.block-ctrl-drag-preview ${dragHandlerAnchorSelector}::after`]: {
|
|
@@ -43,8 +45,10 @@ const extendedHoverZone = () => css({
|
|
|
43
45
|
content: '""',
|
|
44
46
|
position: 'absolute',
|
|
45
47
|
top: 0,
|
|
46
|
-
|
|
47
|
-
|
|
48
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
49
|
+
left: gutterPaddingLeft(),
|
|
50
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
51
|
+
width: gutterPaddingWidth(),
|
|
48
52
|
height: '100%',
|
|
49
53
|
cursor: 'default',
|
|
50
54
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
|
|
@@ -18,7 +18,8 @@ export const VisibilityContainer = ({
|
|
|
18
18
|
}) => {
|
|
19
19
|
const isTypeAheadOpen = useSharedPluginStateSelector(api, 'typeAhead.isOpen');
|
|
20
20
|
const isEditing = useSharedPluginStateSelector(api, 'blockControls.isEditing');
|
|
21
|
-
const
|
|
21
|
+
const isMouseOut = useSharedPluginStateSelector(api, 'blockControls.isMouseOut');
|
|
22
|
+
const shouldHide = isTypeAheadOpen || isEditing || isMouseOut;
|
|
22
23
|
return /*#__PURE__*/React.createElement(Box, {
|
|
23
24
|
xcss: [baseStyles, shouldHide ? hiddenStyles : visibleStyles]
|
|
24
25
|
}, children);
|
|
@@ -179,7 +179,7 @@ export var blockControlsPlugin = function blockControlsPlugin(_ref) {
|
|
|
179
179
|
if (!editorState) {
|
|
180
180
|
return undefined;
|
|
181
181
|
}
|
|
182
|
-
|
|
182
|
+
var sharedState = {
|
|
183
183
|
isMenuOpen: (_key$getState$isMenuO = (_key$getState = key.getState(editorState)) === null || _key$getState === void 0 ? void 0 : _key$getState.isMenuOpen) !== null && _key$getState$isMenuO !== void 0 ? _key$getState$isMenuO : false,
|
|
184
184
|
menuTriggerBy: (_key$getState$menuTri = (_key$getState2 = key.getState(editorState)) === null || _key$getState2 === void 0 ? void 0 : _key$getState2.menuTriggerBy) !== null && _key$getState$menuTri !== void 0 ? _key$getState$menuTri : undefined,
|
|
185
185
|
activeNode: (_key$getState$activeN = (_key$getState3 = key.getState(editorState)) === null || _key$getState3 === void 0 ? void 0 : _key$getState3.activeNode) !== null && _key$getState$activeN !== void 0 ? _key$getState$activeN : undefined,
|
|
@@ -192,6 +192,11 @@ export var blockControlsPlugin = function blockControlsPlugin(_ref) {
|
|
|
192
192
|
isEditing: (_interactionTrackingP = interactionTrackingPluginKey.getState(editorState)) === null || _interactionTrackingP === void 0 ? void 0 : _interactionTrackingP.isEditing,
|
|
193
193
|
isSelectedViaDragHandle: (_key$getState$isSelec = (_key$getState0 = key.getState(editorState)) === null || _key$getState0 === void 0 ? void 0 : _key$getState0.isSelectedViaDragHandle) !== null && _key$getState$isSelec !== void 0 ? _key$getState$isSelec : false
|
|
194
194
|
};
|
|
195
|
+
if (editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_13')) {
|
|
196
|
+
var _interactionTrackingP2, _interactionTrackingP3;
|
|
197
|
+
sharedState.isMouseOut = (_interactionTrackingP2 = (_interactionTrackingP3 = interactionTrackingPluginKey.getState(editorState)) === null || _interactionTrackingP3 === void 0 ? void 0 : _interactionTrackingP3.isMouseOut) !== null && _interactionTrackingP2 !== void 0 ? _interactionTrackingP2 : false;
|
|
198
|
+
}
|
|
199
|
+
return sharedState;
|
|
195
200
|
},
|
|
196
201
|
contentComponent: function contentComponent(_ref8) {
|
|
197
202
|
var editorView = _ref8.editorView,
|
|
@@ -2,9 +2,10 @@ import { expandSelectionBounds } from '@atlaskit/editor-common/selection';
|
|
|
2
2
|
import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
|
|
3
3
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
4
4
|
import { getNodeAnchor, unmountDecorations } from './decorations-common';
|
|
5
|
-
import { createDropTargetDecoration } from './decorations-drop-target';
|
|
5
|
+
import { createDropTargetDecoration, createLayoutDropTargetDecoration } from './decorations-drop-target';
|
|
6
6
|
import { findSurroundingNodes } from './decorations-find-surrounding-nodes';
|
|
7
7
|
import { defaultActiveAnchorTracker } from './utils/active-anchor-tracker';
|
|
8
|
+
import { maxLayoutColumnSupported } from './utils/consts';
|
|
8
9
|
import { canMoveNodeToIndex, canMoveSliceToIndex, isInSameLayout } from './utils/validation';
|
|
9
10
|
|
|
10
11
|
/**
|
|
@@ -129,6 +130,10 @@ export var getActiveDropTargetDecorations = function getActiveDropTargetDecorati
|
|
|
129
130
|
}, nodeViewPortalProviderAPI, -1, undefined, isSameLayout));
|
|
130
131
|
}
|
|
131
132
|
}
|
|
133
|
+
var rootNodeWithPos = {
|
|
134
|
+
node: node,
|
|
135
|
+
pos: pos
|
|
136
|
+
};
|
|
132
137
|
|
|
133
138
|
// if the current node is not a top level node, we create one for advanced layout drop targets
|
|
134
139
|
if (depth > 1) {
|
|
@@ -141,9 +146,30 @@ export var getActiveDropTargetDecorations = function getActiveDropTargetDecorati
|
|
|
141
146
|
formatMessage: formatMessage,
|
|
142
147
|
dropTargetStyle: 'default'
|
|
143
148
|
}, nodeViewPortalProviderAPI, 0, undefined, false));
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
149
|
+
rootNodeWithPos = {
|
|
150
|
+
node: root.node,
|
|
151
|
+
pos: root.pos
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
if (editorExperiment('advanced_layouts', true)) {
|
|
155
|
+
var _isSameLayout = $activeNodePos && isInSameLayout($activeNodePos, state.doc.resolve(rootNodeWithPos.pos));
|
|
156
|
+
if (rootNodeWithPos.node.type.name === 'layoutSection') {
|
|
157
|
+
var layoutSectionNode = rootNodeWithPos.node;
|
|
158
|
+
if (layoutSectionNode.childCount < maxLayoutColumnSupported() || _isSameLayout) {
|
|
159
|
+
layoutSectionNode.descendants(function (childNode, childPos, parent, index) {
|
|
160
|
+
if (childNode.type.name === 'layoutColumn' && (parent === null || parent === void 0 ? void 0 : parent.type.name) === 'layoutSection' && index !== 0 // Not the first node
|
|
161
|
+
) {
|
|
162
|
+
decs.push(createLayoutDropTargetDecoration(rootNodeWithPos.pos + childPos + 1, {
|
|
163
|
+
api: api,
|
|
164
|
+
parent: parent,
|
|
165
|
+
formatMessage: formatMessage
|
|
166
|
+
}, nodeViewPortalProviderAPI, undefined));
|
|
167
|
+
}
|
|
168
|
+
return false;
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
}
|
|
147
172
|
}
|
|
173
|
+
defaultActiveAnchorTracker.emit(getNodeAnchor(rootNodeWithPos.node));
|
|
148
174
|
return decs;
|
|
149
175
|
};
|
|
@@ -8,4 +8,14 @@ export var startEditing = function startEditing(view) {
|
|
|
8
8
|
view.dispatch(view.state.tr.setMeta(interactionTrackingPluginKey, {
|
|
9
9
|
type: 'startEditing'
|
|
10
10
|
}));
|
|
11
|
+
};
|
|
12
|
+
export var mouseLeave = function mouseLeave(view) {
|
|
13
|
+
view.dispatch(view.state.tr.setMeta(interactionTrackingPluginKey, {
|
|
14
|
+
type: 'mouseLeave'
|
|
15
|
+
}));
|
|
16
|
+
};
|
|
17
|
+
export var mouseEnter = function mouseEnter(view) {
|
|
18
|
+
view.dispatch(view.state.tr.setMeta(interactionTrackingPluginKey, {
|
|
19
|
+
type: 'mouseEnter'
|
|
20
|
+
}));
|
|
11
21
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { stopEditing } from './commands';
|
|
1
|
+
import { mouseEnter, mouseLeave, stopEditing } from './commands';
|
|
2
2
|
import { getInteractionTrackingState } from './pm-plugin';
|
|
3
3
|
export var handleMouseMove = function handleMouseMove(view) {
|
|
4
4
|
var state = getInteractionTrackingState(view.state);
|
|
@@ -7,4 +7,12 @@ export var handleMouseMove = function handleMouseMove(view) {
|
|
|
7
7
|
stopEditing(view);
|
|
8
8
|
}
|
|
9
9
|
return false;
|
|
10
|
+
};
|
|
11
|
+
export var handleMouseLeave = function handleMouseLeave(view) {
|
|
12
|
+
mouseLeave(view);
|
|
13
|
+
return false;
|
|
14
|
+
};
|
|
15
|
+
export var handleMouseEnter = function handleMouseEnter(view) {
|
|
16
|
+
mouseEnter(view);
|
|
17
|
+
return false;
|
|
10
18
|
};
|
|
@@ -1,30 +1,58 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
import { bind } from 'bind-event-listener';
|
|
1
5
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
6
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
7
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
8
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
3
9
|
import { handleKeyDown } from './handle-key-down';
|
|
4
|
-
import { handleMouseMove } from './handle-mouse-move';
|
|
10
|
+
import { handleMouseEnter, handleMouseLeave, handleMouseMove } from './handle-mouse-move';
|
|
5
11
|
export var interactionTrackingPluginKey = new PluginKey('interactionTrackingPlugin');
|
|
6
12
|
export var createInteractionTrackingPlugin = function createInteractionTrackingPlugin() {
|
|
7
13
|
return new SafePlugin({
|
|
8
14
|
key: interactionTrackingPluginKey,
|
|
9
15
|
state: {
|
|
10
16
|
init: function init() {
|
|
11
|
-
|
|
17
|
+
var state = {
|
|
12
18
|
isEditing: false
|
|
13
19
|
};
|
|
20
|
+
if (editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_13')) {
|
|
21
|
+
state.isMouseOut = false;
|
|
22
|
+
}
|
|
23
|
+
return state;
|
|
14
24
|
},
|
|
15
25
|
apply: function apply(tr, pluginState) {
|
|
16
26
|
var meta = tr.getMeta(interactionTrackingPluginKey);
|
|
27
|
+
if (!fg('platform_editor_controls_patch_13')) {
|
|
28
|
+
switch (meta === null || meta === void 0 ? void 0 : meta.type) {
|
|
29
|
+
case 'startEditing':
|
|
30
|
+
return {
|
|
31
|
+
isEditing: true
|
|
32
|
+
};
|
|
33
|
+
case 'stopEditing':
|
|
34
|
+
return {
|
|
35
|
+
isEditing: false
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
return pluginState;
|
|
39
|
+
}
|
|
40
|
+
var newState = {};
|
|
17
41
|
switch (meta === null || meta === void 0 ? void 0 : meta.type) {
|
|
18
42
|
case 'startEditing':
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
};
|
|
43
|
+
newState.isEditing = true;
|
|
44
|
+
break;
|
|
22
45
|
case 'stopEditing':
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
46
|
+
newState.isEditing = false;
|
|
47
|
+
break;
|
|
48
|
+
case 'mouseLeave':
|
|
49
|
+
newState.isMouseOut = true;
|
|
50
|
+
break;
|
|
51
|
+
case 'mouseEnter':
|
|
52
|
+
newState.isMouseOut = false;
|
|
53
|
+
break;
|
|
26
54
|
}
|
|
27
|
-
return pluginState;
|
|
55
|
+
return _objectSpread(_objectSpread({}, pluginState), newState);
|
|
28
56
|
}
|
|
29
57
|
},
|
|
30
58
|
props: {
|
|
@@ -32,7 +60,33 @@ export var createInteractionTrackingPlugin = function createInteractionTrackingP
|
|
|
32
60
|
handleDOMEvents: {
|
|
33
61
|
mousemove: handleMouseMove
|
|
34
62
|
}
|
|
35
|
-
}
|
|
63
|
+
},
|
|
64
|
+
view: editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_13') ? function (view) {
|
|
65
|
+
var editorContentArea = view.dom.closest('.ak-editor-content-area');
|
|
66
|
+
var unbindMouseEnter;
|
|
67
|
+
var unbindMouseLeave;
|
|
68
|
+
if (editorContentArea) {
|
|
69
|
+
unbindMouseEnter = bind(editorContentArea, {
|
|
70
|
+
type: 'mouseenter',
|
|
71
|
+
listener: function listener() {
|
|
72
|
+
handleMouseEnter(view);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
unbindMouseLeave = bind(editorContentArea, {
|
|
76
|
+
type: 'mouseleave',
|
|
77
|
+
listener: function listener() {
|
|
78
|
+
handleMouseLeave(view);
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
return {
|
|
83
|
+
destroy: function destroy() {
|
|
84
|
+
var _unbindMouseEnter, _unbindMouseLeave;
|
|
85
|
+
(_unbindMouseEnter = unbindMouseEnter) === null || _unbindMouseEnter === void 0 || _unbindMouseEnter();
|
|
86
|
+
(_unbindMouseLeave = unbindMouseLeave) === null || _unbindMouseLeave === void 0 || _unbindMouseLeave();
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
} : undefined
|
|
36
90
|
});
|
|
37
91
|
};
|
|
38
92
|
export var getInteractionTrackingState = function getInteractionTrackingState(state) {
|
|
@@ -7,7 +7,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
7
7
|
import { css, Global, jsx } from '@emotion/react';
|
|
8
8
|
import { tableControlsSpacing } from '@atlaskit/editor-common/styles';
|
|
9
9
|
import { ZERO_WIDTH_SPACE } from '@atlaskit/editor-common/whitespace';
|
|
10
|
-
import { akEditorBreakoutPadding, akEditorCalculatedWideLayoutWidth, akEditorCalculatedWideLayoutWidthSmallViewport } from '@atlaskit/editor-shared-styles';
|
|
10
|
+
import { akEditorBreakoutPadding, akEditorCalculatedWideLayoutWidth, akEditorCalculatedWideLayoutWidthSmallViewport, akEditorGutterPaddingDynamic } from '@atlaskit/editor-shared-styles';
|
|
11
11
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
12
12
|
import { layers } from '@atlaskit/theme/constants';
|
|
13
13
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
@@ -18,6 +18,12 @@ import { DRAG_HANDLE_MAX_WIDTH_PLUS_GAP, DRAG_HANDLE_WIDTH } from './consts';
|
|
|
18
18
|
* including those within table rows and media.
|
|
19
19
|
*/
|
|
20
20
|
var dragHandlerAnchorSelector = '[data-drag-handler-anchor-name]:not([data-drag-handler-node-type="tableRow"], [data-drag-handler-node-type="media"])';
|
|
21
|
+
var gutterPaddingWidth = function gutterPaddingWidth() {
|
|
22
|
+
return editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_13') ? "".concat(akEditorGutterPaddingDynamic(), "px") : '100%';
|
|
23
|
+
};
|
|
24
|
+
var gutterPaddingLeft = function gutterPaddingLeft() {
|
|
25
|
+
return editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_13') ? "-".concat(akEditorGutterPaddingDynamic(), "px") : '-100px';
|
|
26
|
+
};
|
|
21
27
|
var extendedHoverZone = function extendedHoverZone() {
|
|
22
28
|
return css(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, ".block-ctrl-drag-preview ".concat(dragHandlerAnchorSelector, "::after"), {
|
|
23
29
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles
|
|
@@ -37,8 +43,10 @@ var extendedHoverZone = function extendedHoverZone() {
|
|
|
37
43
|
content: '""',
|
|
38
44
|
position: 'absolute',
|
|
39
45
|
top: 0,
|
|
40
|
-
|
|
41
|
-
|
|
46
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
47
|
+
left: gutterPaddingLeft(),
|
|
48
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
49
|
+
width: gutterPaddingWidth(),
|
|
42
50
|
height: '100%',
|
|
43
51
|
cursor: 'default',
|
|
44
52
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
|
|
@@ -17,7 +17,8 @@ export var VisibilityContainer = function VisibilityContainer(_ref) {
|
|
|
17
17
|
children = _ref.children;
|
|
18
18
|
var isTypeAheadOpen = useSharedPluginStateSelector(api, 'typeAhead.isOpen');
|
|
19
19
|
var isEditing = useSharedPluginStateSelector(api, 'blockControls.isEditing');
|
|
20
|
-
var
|
|
20
|
+
var isMouseOut = useSharedPluginStateSelector(api, 'blockControls.isMouseOut');
|
|
21
|
+
var shouldHide = isTypeAheadOpen || isEditing || isMouseOut;
|
|
21
22
|
return /*#__PURE__*/React.createElement(Box, {
|
|
22
23
|
xcss: [baseStyles, shouldHide ? hiddenStyles : visibleStyles]
|
|
23
24
|
}, children);
|
|
@@ -69,7 +69,9 @@ export type BlockControlsSharedState = {
|
|
|
69
69
|
isPMDragging: boolean;
|
|
70
70
|
multiSelectDnD?: MultiSelectDnD;
|
|
71
71
|
isShiftDown?: boolean;
|
|
72
|
+
lastDragCancelled: boolean;
|
|
72
73
|
isEditing?: boolean;
|
|
74
|
+
isMouseOut?: boolean;
|
|
73
75
|
isSelectedViaDragHandle?: boolean;
|
|
74
76
|
} | undefined;
|
|
75
77
|
export type HandleOptions = {
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
2
2
|
export declare const stopEditing: (view: EditorView) => void;
|
|
3
3
|
export declare const startEditing: (view: EditorView) => void;
|
|
4
|
+
export declare const mouseLeave: (view: EditorView) => void;
|
|
5
|
+
export declare const mouseEnter: (view: EditorView) => void;
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
2
2
|
export declare const handleMouseMove: (view: EditorView) => boolean;
|
|
3
|
+
export declare const handleMouseLeave: (view: EditorView) => boolean;
|
|
4
|
+
export declare const handleMouseEnter: (view: EditorView) => boolean;
|
|
@@ -6,6 +6,10 @@ export type InteractionTrackingPluginState = {
|
|
|
6
6
|
* Tracks if a users intention is to edit the document (e.g. typing, deleting, etc.)
|
|
7
7
|
*/
|
|
8
8
|
isEditing: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Tracks if the mouse is outside of the editor
|
|
11
|
+
*/
|
|
12
|
+
isMouseOut?: boolean;
|
|
9
13
|
};
|
|
10
14
|
export declare const interactionTrackingPluginKey: PluginKey<InteractionTrackingPluginState>;
|
|
11
15
|
export declare const createInteractionTrackingPlugin: () => SafePlugin<InteractionTrackingPluginState>;
|
|
@@ -69,7 +69,9 @@ export type BlockControlsSharedState = {
|
|
|
69
69
|
isPMDragging: boolean;
|
|
70
70
|
multiSelectDnD?: MultiSelectDnD;
|
|
71
71
|
isShiftDown?: boolean;
|
|
72
|
+
lastDragCancelled: boolean;
|
|
72
73
|
isEditing?: boolean;
|
|
74
|
+
isMouseOut?: boolean;
|
|
73
75
|
isSelectedViaDragHandle?: boolean;
|
|
74
76
|
} | undefined;
|
|
75
77
|
export type HandleOptions = {
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
2
2
|
export declare const stopEditing: (view: EditorView) => void;
|
|
3
3
|
export declare const startEditing: (view: EditorView) => void;
|
|
4
|
+
export declare const mouseLeave: (view: EditorView) => void;
|
|
5
|
+
export declare const mouseEnter: (view: EditorView) => void;
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
2
2
|
export declare const handleMouseMove: (view: EditorView) => boolean;
|
|
3
|
+
export declare const handleMouseLeave: (view: EditorView) => boolean;
|
|
4
|
+
export declare const handleMouseEnter: (view: EditorView) => boolean;
|
|
@@ -6,6 +6,10 @@ export type InteractionTrackingPluginState = {
|
|
|
6
6
|
* Tracks if a users intention is to edit the document (e.g. typing, deleting, etc.)
|
|
7
7
|
*/
|
|
8
8
|
isEditing: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Tracks if the mouse is outside of the editor
|
|
11
|
+
*/
|
|
12
|
+
isMouseOut?: boolean;
|
|
9
13
|
};
|
|
10
14
|
export declare const interactionTrackingPluginKey: PluginKey<InteractionTrackingPluginState>;
|
|
11
15
|
export declare const createInteractionTrackingPlugin: () => SafePlugin<InteractionTrackingPluginState>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-block-controls",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.19.0",
|
|
4
4
|
"description": "Block controls plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -201,6 +201,9 @@
|
|
|
201
201
|
"platform_editor_controls_patch_11": {
|
|
202
202
|
"type": "boolean"
|
|
203
203
|
},
|
|
204
|
+
"platform_editor_controls_patch_13": {
|
|
205
|
+
"type": "boolean"
|
|
206
|
+
},
|
|
204
207
|
"platform_editor_breakout_resizing_hello_release": {
|
|
205
208
|
"type": "boolean"
|
|
206
209
|
}
|