@atlaskit/editor-plugin-block-controls 17.2.4 → 17.3.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 +20 -0
- package/dist/cjs/blockControlsPlugin.js +28 -8
- package/dist/cjs/editor-commands/move-node-with-block-menu.js +2 -2
- package/dist/cjs/editor-commands/move-node.js +6 -6
- package/dist/cjs/editor-commands/utils/move-node-utils.js +4 -4
- package/dist/cjs/pm-plugins/decorations-anchor.js +4 -4
- package/dist/cjs/pm-plugins/decorations-drag-handle.js +3 -3
- package/dist/cjs/pm-plugins/decorations-drop-target-active.js +2 -2
- package/dist/cjs/pm-plugins/decorations-drop-target.js +2 -2
- package/dist/cjs/pm-plugins/decorations-quick-insert-button.js +2 -2
- package/dist/cjs/pm-plugins/handle-mouse-down.js +3 -3
- package/dist/cjs/pm-plugins/handle-mouse-over.js +7 -7
- package/dist/cjs/pm-plugins/interaction-tracking/pm-plugin.js +3 -3
- package/dist/cjs/pm-plugins/main.js +23 -21
- package/dist/cjs/pm-plugins/react-root-registry.js +7 -7
- package/dist/cjs/pm-plugins/utils/active-anchor-tracker.js +2 -2
- package/dist/cjs/pm-plugins/utils/consts.js +2 -2
- package/dist/cjs/pm-plugins/utils/drag-handle-positions.js +6 -6
- package/dist/cjs/pm-plugins/utils/expand-and-update-selection.js +2 -2
- package/dist/cjs/pm-plugins/utils/getSelection.js +5 -5
- package/dist/cjs/pm-plugins/utils/inline-drop-target.js +2 -2
- package/dist/cjs/pm-plugins/utils/remove-from-source.js +2 -2
- package/dist/cjs/pm-plugins/utils/surface-node-positions.js +45 -19
- package/dist/cjs/pm-plugins/utils/validation.js +2 -2
- package/dist/cjs/ui/block-controls-left-surfaces.js +5 -4
- package/dist/cjs/ui/block-controls-right-surface.compiled.css +4 -0
- package/dist/cjs/ui/block-controls-right-surface.js +45 -0
- package/dist/cjs/ui/block-controls-right-surfaces.js +222 -0
- package/dist/{esm/ui/block-controls-left-surface-targets.js → cjs/ui/block-controls-surface-targets.js} +14 -2
- package/dist/cjs/ui/consts.js +4 -4
- package/dist/cjs/ui/drag-handle.js +20 -19
- package/dist/cjs/ui/drop-target.js +2 -2
- package/dist/cjs/ui/global-styles.js +5 -5
- package/dist/cjs/ui/utils/get-surface-placement.js +20 -6
- package/dist/cjs/ui/visibility-container.js +2 -2
- package/dist/es2019/blockControlsPlugin.js +28 -4
- package/dist/es2019/editor-commands/move-node-with-block-menu.js +1 -1
- package/dist/es2019/editor-commands/move-node.js +1 -1
- package/dist/es2019/editor-commands/utils/move-node-utils.js +1 -1
- package/dist/es2019/pm-plugins/decorations-anchor.js +1 -1
- package/dist/es2019/pm-plugins/decorations-drag-handle.js +1 -1
- package/dist/es2019/pm-plugins/decorations-drop-target-active.js +1 -1
- package/dist/es2019/pm-plugins/decorations-drop-target.js +1 -1
- package/dist/es2019/pm-plugins/decorations-quick-insert-button.js +1 -1
- package/dist/es2019/pm-plugins/handle-mouse-down.js +1 -1
- package/dist/es2019/pm-plugins/handle-mouse-over.js +1 -1
- package/dist/es2019/pm-plugins/interaction-tracking/pm-plugin.js +1 -1
- package/dist/es2019/pm-plugins/main.js +10 -10
- package/dist/es2019/pm-plugins/react-root-registry.js +7 -7
- package/dist/es2019/pm-plugins/utils/active-anchor-tracker.js +1 -1
- package/dist/es2019/pm-plugins/utils/consts.js +1 -1
- package/dist/es2019/pm-plugins/utils/drag-handle-positions.js +1 -1
- package/dist/es2019/pm-plugins/utils/expand-and-update-selection.js +1 -1
- package/dist/es2019/pm-plugins/utils/getSelection.js +1 -1
- package/dist/es2019/pm-plugins/utils/inline-drop-target.js +1 -1
- package/dist/es2019/pm-plugins/utils/remove-from-source.js +1 -1
- package/dist/es2019/pm-plugins/utils/surface-node-positions.js +34 -15
- package/dist/es2019/pm-plugins/utils/validation.js +1 -1
- package/dist/es2019/ui/block-controls-left-surfaces.js +5 -4
- package/dist/es2019/ui/block-controls-right-surface.compiled.css +4 -0
- package/dist/es2019/ui/block-controls-right-surface.js +39 -0
- package/dist/es2019/ui/block-controls-right-surfaces.js +187 -0
- package/dist/es2019/ui/{block-controls-left-surface-targets.js → block-controls-surface-targets.js} +8 -2
- package/dist/es2019/ui/consts.js +1 -1
- package/dist/es2019/ui/drag-handle.js +4 -3
- package/dist/es2019/ui/drop-target.js +1 -1
- package/dist/es2019/ui/global-styles.js +1 -1
- package/dist/es2019/ui/utils/get-surface-placement.js +20 -6
- package/dist/es2019/ui/visibility-container.js +1 -1
- package/dist/esm/blockControlsPlugin.js +24 -4
- package/dist/esm/editor-commands/move-node-with-block-menu.js +1 -1
- package/dist/esm/editor-commands/move-node.js +1 -1
- package/dist/esm/editor-commands/utils/move-node-utils.js +1 -1
- package/dist/esm/pm-plugins/decorations-anchor.js +1 -1
- package/dist/esm/pm-plugins/decorations-drag-handle.js +1 -1
- package/dist/esm/pm-plugins/decorations-drop-target-active.js +1 -1
- package/dist/esm/pm-plugins/decorations-drop-target.js +1 -1
- package/dist/esm/pm-plugins/decorations-quick-insert-button.js +1 -1
- package/dist/esm/pm-plugins/handle-mouse-down.js +1 -1
- package/dist/esm/pm-plugins/handle-mouse-over.js +1 -1
- package/dist/esm/pm-plugins/interaction-tracking/pm-plugin.js +1 -1
- package/dist/esm/pm-plugins/main.js +11 -9
- package/dist/esm/pm-plugins/react-root-registry.js +7 -7
- package/dist/esm/pm-plugins/utils/active-anchor-tracker.js +1 -1
- package/dist/esm/pm-plugins/utils/consts.js +1 -1
- package/dist/esm/pm-plugins/utils/drag-handle-positions.js +1 -1
- package/dist/esm/pm-plugins/utils/expand-and-update-selection.js +1 -1
- package/dist/esm/pm-plugins/utils/getSelection.js +1 -1
- package/dist/esm/pm-plugins/utils/inline-drop-target.js +1 -1
- package/dist/esm/pm-plugins/utils/remove-from-source.js +1 -1
- package/dist/esm/pm-plugins/utils/surface-node-positions.js +45 -19
- package/dist/esm/pm-plugins/utils/validation.js +1 -1
- package/dist/esm/ui/block-controls-left-surfaces.js +5 -4
- package/dist/esm/ui/block-controls-right-surface.compiled.css +4 -0
- package/dist/esm/ui/block-controls-right-surface.js +38 -0
- package/dist/esm/ui/block-controls-right-surfaces.js +213 -0
- package/dist/{cjs/ui/block-controls-left-surface-targets.js → esm/ui/block-controls-surface-targets.js} +8 -8
- package/dist/esm/ui/consts.js +1 -1
- package/dist/esm/ui/drag-handle.js +4 -3
- package/dist/esm/ui/drop-target.js +1 -1
- package/dist/esm/ui/global-styles.js +1 -1
- package/dist/esm/ui/utils/get-surface-placement.js +20 -6
- package/dist/esm/ui/visibility-container.js +1 -1
- package/dist/types/pm-plugins/main.d.ts +2 -2
- package/dist/types/pm-plugins/react-root-registry.d.ts +4 -4
- package/dist/types/pm-plugins/utils/surface-node-positions.d.ts +3 -3
- package/dist/types/ui/block-controls-left-surface.d.ts +2 -2
- package/dist/types/ui/block-controls-right-surface.d.ts +23 -0
- package/dist/types/ui/block-controls-right-surfaces.d.ts +20 -0
- package/dist/types/ui/block-controls-surface-targets.d.ts +13 -0
- package/dist/types/ui/utils/get-surface-placement.d.ts +12 -4
- package/package.json +23 -26
- package/dist/types/ui/block-controls-left-surface-targets.d.ts +0 -7
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
/* block-controls-right-surfaces.tsx generated by @compiled/babel-plugin v2.0.0 */
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
Object.defineProperty(exports, "__esModule", {
|
|
7
|
+
value: true
|
|
8
|
+
});
|
|
9
|
+
exports.BlockControlsRightSurfaces = void 0;
|
|
10
|
+
var _runtime = require("@compiled/react/runtime");
|
|
11
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
12
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
14
|
+
var _bindEventListener = require("bind-event-listener");
|
|
15
|
+
var _browserApis = require("@atlaskit/browser-apis");
|
|
16
|
+
var _blockControlUiContext = require("@atlaskit/editor-common/block-controls/block-control-ui-context");
|
|
17
|
+
var _surfaceKeys = require("@atlaskit/editor-common/block-controls/surface-keys");
|
|
18
|
+
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
19
|
+
var _types = require("@atlaskit/editor-ui-control-model/types");
|
|
20
|
+
var _decorationsCommon = require("../pm-plugins/decorations-common");
|
|
21
|
+
var _blockControlsRightSurface = require("./block-controls-right-surface");
|
|
22
|
+
var _blockControlsSurfaceContext = require("./block-controls-surface-context");
|
|
23
|
+
var _blockControlsSurfaceTargets = require("./block-controls-surface-targets");
|
|
24
|
+
var _getNodeContentElement = require("./utils/get-node-content-element");
|
|
25
|
+
var _getSurfacePlacement = require("./utils/get-surface-placement");
|
|
26
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
27
|
+
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
28
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
29
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
30
|
+
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; }
|
|
31
|
+
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; }
|
|
32
|
+
var EMPTY_SURFACE_POSITIONS = [];
|
|
33
|
+
var EMPTY_SURFACE_COMPONENTS = [];
|
|
34
|
+
/**
|
|
35
|
+
* Registry-backed right surface tree. Mirrors the left surface's single-tree, measured-placement
|
|
36
|
+
* approach, but keeps its own components lookup, targets, placements and measurement lifecycle so
|
|
37
|
+
* the right surface never depends on the left surface's render pass.
|
|
38
|
+
*/
|
|
39
|
+
var BlockControlsRightSurfaces = exports.BlockControlsRightSurfaces = function BlockControlsRightSurfaces(_ref) {
|
|
40
|
+
var _api$uiControlRegistr, _api$uiControlRegistr2;
|
|
41
|
+
var api = _ref.api,
|
|
42
|
+
editorView = _ref.editorView;
|
|
43
|
+
var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(api, ['blockControls'], function (states) {
|
|
44
|
+
var _states$blockControls, _states$blockControls2, _states$blockControls3;
|
|
45
|
+
return {
|
|
46
|
+
activeNode: (_states$blockControls = states.blockControlsState) === null || _states$blockControls === void 0 ? void 0 : _states$blockControls.activeNode,
|
|
47
|
+
surfaceNodePositions: (_states$blockControls2 = (_states$blockControls3 = states.blockControlsState) === null || _states$blockControls3 === void 0 ? void 0 : _states$blockControls3.surfaceNodePositions) !== null && _states$blockControls2 !== void 0 ? _states$blockControls2 : EMPTY_SURFACE_POSITIONS
|
|
48
|
+
};
|
|
49
|
+
}),
|
|
50
|
+
activeNode = _useSharedPluginState.activeNode,
|
|
51
|
+
surfaceNodePositions = _useSharedPluginState.surfaceNodePositions;
|
|
52
|
+
var components = (_api$uiControlRegistr = (_api$uiControlRegistr2 = api.uiControlRegistry) === null || _api$uiControlRegistr2 === void 0 ? void 0 : _api$uiControlRegistr2.actions.getComponents(_surfaceKeys.BLOCK_CONTROLS_RIGHT_SURFACE)) !== null && _api$uiControlRegistr !== void 0 ? _api$uiControlRegistr : EMPTY_SURFACE_COMPONENTS;
|
|
53
|
+
var targets = (0, _react.useMemo)(function () {
|
|
54
|
+
return (0, _blockControlsSurfaceTargets.getBlockControlsSurfaceTargets)(activeNode, surfaceNodePositions);
|
|
55
|
+
}, [activeNode, surfaceNodePositions]);
|
|
56
|
+
var surfaces = (0, _react.useMemo)(function () {
|
|
57
|
+
return targets.flatMap(function (target) {
|
|
58
|
+
var context = target.source === 'stored' ? (0, _blockControlsSurfaceContext.createBlockControlsSurfaceContextForPosition)(editorView.state, target.position, activeNode) : (0, _blockControlsSurfaceContext.createBlockControlsSurfaceContext)(editorView, activeNode, target.source);
|
|
59
|
+
if (!context) {
|
|
60
|
+
return [];
|
|
61
|
+
}
|
|
62
|
+
var surfaceContext = (0, _types.createSurfaceContext)(_blockControlUiContext.BLOCK_CONTROL_UI_CONTEXT, context);
|
|
63
|
+
return [_objectSpread(_objectSpread({}, target), {}, {
|
|
64
|
+
blockControlsContext: context,
|
|
65
|
+
surfaceContext: surfaceContext
|
|
66
|
+
})];
|
|
67
|
+
});
|
|
68
|
+
}, [activeNode, editorView, targets]);
|
|
69
|
+
var _useState = (0, _react.useState)(new Map()),
|
|
70
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
71
|
+
placements = _useState2[0],
|
|
72
|
+
setPlacements = _useState2[1];
|
|
73
|
+
var animationFrameRef = (0, _react.useRef)(undefined);
|
|
74
|
+
(0, _react.useLayoutEffect)(function () {
|
|
75
|
+
var _getDocument;
|
|
76
|
+
if (surfaces.length === 0) {
|
|
77
|
+
setPlacements(new Map());
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
var measurementTargets = surfaces.flatMap(function (_ref2) {
|
|
81
|
+
var blockControlsContext = _ref2.blockControlsContext,
|
|
82
|
+
position = _ref2.position;
|
|
83
|
+
var targetNodeElement = editorView.nodeDOM(blockControlsContext.targetNode.pos);
|
|
84
|
+
var targetElementRoot = targetNodeElement instanceof HTMLElement ? targetNodeElement : targetNodeElement === null || targetNodeElement === void 0 ? void 0 : targetNodeElement.parentElement;
|
|
85
|
+
if (!targetElementRoot) {
|
|
86
|
+
return [];
|
|
87
|
+
}
|
|
88
|
+
return [{
|
|
89
|
+
blockControlsContext: blockControlsContext,
|
|
90
|
+
position: position,
|
|
91
|
+
targetElement: (0, _getNodeContentElement.getNodeContentElement)(targetElementRoot, blockControlsContext.targetNode.type.name),
|
|
92
|
+
targetElementRoot: targetElementRoot
|
|
93
|
+
}];
|
|
94
|
+
});
|
|
95
|
+
var offsetParent = editorView.dom.offsetParent;
|
|
96
|
+
var isDocumentOffsetParent = !offsetParent || offsetParent === ((_getDocument = (0, _browserApis.getDocument)()) === null || _getDocument === void 0 ? void 0 : _getDocument.body);
|
|
97
|
+
var scrollingOffsetParent = offsetParent instanceof HTMLElement && !isDocumentOffsetParent ? offsetParent : undefined;
|
|
98
|
+
var updatePositions = function updatePositions() {
|
|
99
|
+
var _scrollingOffsetParen, _scrollingOffsetParen2;
|
|
100
|
+
animationFrameRef.current = undefined;
|
|
101
|
+
var offsetParentRect = offsetParent === null || offsetParent === void 0 ? void 0 : offsetParent.getBoundingClientRect();
|
|
102
|
+
var offsetParentScrollTop = (_scrollingOffsetParen = scrollingOffsetParent === null || scrollingOffsetParent === void 0 ? void 0 : scrollingOffsetParent.scrollTop) !== null && _scrollingOffsetParen !== void 0 ? _scrollingOffsetParen : window.scrollY;
|
|
103
|
+
var offsetParentScrollLeft = (_scrollingOffsetParen2 = scrollingOffsetParent === null || scrollingOffsetParent === void 0 ? void 0 : scrollingOffsetParent.scrollLeft) !== null && _scrollingOffsetParen2 !== void 0 ? _scrollingOffsetParen2 : window.scrollX;
|
|
104
|
+
var nextPlacements = new Map();
|
|
105
|
+
var _iterator = _createForOfIteratorHelper(measurementTargets),
|
|
106
|
+
_step;
|
|
107
|
+
try {
|
|
108
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
109
|
+
var _targetElementRoot$ge;
|
|
110
|
+
var _step$value = _step.value,
|
|
111
|
+
blockControlsContext = _step$value.blockControlsContext,
|
|
112
|
+
position = _step$value.position,
|
|
113
|
+
targetElement = _step$value.targetElement,
|
|
114
|
+
targetElementRoot = _step$value.targetElementRoot;
|
|
115
|
+
if (!targetElementRoot.isConnected || !targetElement.isConnected) {
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
var placement = (0, _getSurfacePlacement.getSurfacePlacement)({
|
|
119
|
+
layout: (_targetElementRoot$ge = targetElementRoot.getAttribute('layout')) !== null && _targetElementRoot$ge !== void 0 ? _targetElementRoot$ge : '',
|
|
120
|
+
nodeRect: targetElement.getBoundingClientRect(),
|
|
121
|
+
nodeType: blockControlsContext.targetNode.type.name,
|
|
122
|
+
nodeTypeWithLevel: (0, _decorationsCommon.getNodeTypeWithLevel)(blockControlsContext.targetNode.node),
|
|
123
|
+
parentNodeType: blockControlsContext.targetNode.parentType === 'doc' ? undefined : blockControlsContext.targetNode.parentType,
|
|
124
|
+
side: 'right'
|
|
125
|
+
});
|
|
126
|
+
nextPlacements.set(position, (0, _getSurfacePlacement.getAbsoluteSurfacePlacement)({
|
|
127
|
+
offsetParentRect: offsetParentRect,
|
|
128
|
+
offsetParentScrollLeft: offsetParentScrollLeft,
|
|
129
|
+
offsetParentScrollTop: offsetParentScrollTop,
|
|
130
|
+
placement: placement
|
|
131
|
+
}));
|
|
132
|
+
}
|
|
133
|
+
} catch (err) {
|
|
134
|
+
_iterator.e(err);
|
|
135
|
+
} finally {
|
|
136
|
+
_iterator.f();
|
|
137
|
+
}
|
|
138
|
+
setPlacements(nextPlacements);
|
|
139
|
+
};
|
|
140
|
+
var schedulePositionUpdate = function schedulePositionUpdate() {
|
|
141
|
+
if (animationFrameRef.current === undefined) {
|
|
142
|
+
animationFrameRef.current = requestAnimationFrame(updatePositions);
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
updatePositions();
|
|
146
|
+
var resizeObserver = new ResizeObserver(schedulePositionUpdate);
|
|
147
|
+
var observedElements = new Set([editorView.dom]);
|
|
148
|
+
var _iterator2 = _createForOfIteratorHelper(measurementTargets),
|
|
149
|
+
_step2;
|
|
150
|
+
try {
|
|
151
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
152
|
+
var targetElement = _step2.value.targetElement;
|
|
153
|
+
observedElements.add(targetElement);
|
|
154
|
+
}
|
|
155
|
+
} catch (err) {
|
|
156
|
+
_iterator2.e(err);
|
|
157
|
+
} finally {
|
|
158
|
+
_iterator2.f();
|
|
159
|
+
}
|
|
160
|
+
if (offsetParent instanceof HTMLElement) {
|
|
161
|
+
observedElements.add(offsetParent);
|
|
162
|
+
}
|
|
163
|
+
observedElements.forEach(function (element) {
|
|
164
|
+
return resizeObserver.observe(element);
|
|
165
|
+
});
|
|
166
|
+
var unbindWindowResize = (0, _bindEventListener.bind)(window, {
|
|
167
|
+
type: 'resize',
|
|
168
|
+
listener: schedulePositionUpdate
|
|
169
|
+
});
|
|
170
|
+
var unbindWindowScroll = (0, _bindEventListener.bind)(window, {
|
|
171
|
+
type: 'scroll',
|
|
172
|
+
listener: schedulePositionUpdate,
|
|
173
|
+
options: {
|
|
174
|
+
capture: true,
|
|
175
|
+
passive: true
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
var visualViewport = window.visualViewport;
|
|
179
|
+
var unbindVisualViewportResize = visualViewport ? (0, _bindEventListener.bind)(visualViewport, {
|
|
180
|
+
type: 'resize',
|
|
181
|
+
listener: schedulePositionUpdate
|
|
182
|
+
}) : undefined;
|
|
183
|
+
var unbindVisualViewportScroll = visualViewport ? (0, _bindEventListener.bind)(visualViewport, {
|
|
184
|
+
type: 'scroll',
|
|
185
|
+
listener: schedulePositionUpdate
|
|
186
|
+
}) : undefined;
|
|
187
|
+
var unbindTransitionEnd = (0, _bindEventListener.bind)(editorView.dom, {
|
|
188
|
+
type: 'transitionend',
|
|
189
|
+
listener: schedulePositionUpdate,
|
|
190
|
+
options: {
|
|
191
|
+
capture: true
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
return function () {
|
|
195
|
+
if (animationFrameRef.current !== undefined) {
|
|
196
|
+
cancelAnimationFrame(animationFrameRef.current);
|
|
197
|
+
animationFrameRef.current = undefined;
|
|
198
|
+
}
|
|
199
|
+
resizeObserver.disconnect();
|
|
200
|
+
unbindWindowResize();
|
|
201
|
+
unbindWindowScroll();
|
|
202
|
+
unbindVisualViewportResize === null || unbindVisualViewportResize === void 0 || unbindVisualViewportResize();
|
|
203
|
+
unbindVisualViewportScroll === null || unbindVisualViewportScroll === void 0 || unbindVisualViewportScroll();
|
|
204
|
+
unbindTransitionEnd();
|
|
205
|
+
};
|
|
206
|
+
}, [editorView, surfaces]);
|
|
207
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, surfaces.map(function (_ref3) {
|
|
208
|
+
var _activeNode$handleOpt;
|
|
209
|
+
var position = _ref3.position,
|
|
210
|
+
source = _ref3.source,
|
|
211
|
+
surfaceContext = _ref3.surfaceContext;
|
|
212
|
+
return /*#__PURE__*/_react.default.createElement(_blockControlsRightSurface.BlockControlsRightSurface, {
|
|
213
|
+
api: api,
|
|
214
|
+
components: components,
|
|
215
|
+
forceVisibleOnMouseOut: Boolean(activeNode === null || activeNode === void 0 || (_activeNode$handleOpt = activeNode.handleOptions) === null || _activeNode$handleOpt === void 0 ? void 0 : _activeNode$handleOpt.isFocused),
|
|
216
|
+
key: position,
|
|
217
|
+
placement: placements.get(position),
|
|
218
|
+
source: source,
|
|
219
|
+
surfaceContext: surfaceContext
|
|
220
|
+
});
|
|
221
|
+
}));
|
|
222
|
+
};
|
|
@@ -1,8 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getBlockControlsSurfaceTargets = void 0;
|
|
1
7
|
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
2
8
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
3
9
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
4
|
-
/**
|
|
5
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Combines hover-driven and stored surface positions into one deduplicated list.
|
|
12
|
+
* Shared by both the left and right surfaces: this is pure position bookkeeping with no
|
|
13
|
+
* surface-specific behavior, so there's nothing to keep independent between them. What *is*
|
|
14
|
+
* kept independent is each surface's own React tree (component lookup, measurement effects,
|
|
15
|
+
* observers) — see block-controls-left-surfaces.tsx / block-controls-right-surfaces.tsx.
|
|
16
|
+
*/
|
|
17
|
+
var getBlockControlsSurfaceTargets = exports.getBlockControlsSurfaceTargets = function getBlockControlsSurfaceTargets(activeNode, storedPositions) {
|
|
6
18
|
var targetsByPosition = new Map();
|
|
7
19
|
var _iterator = _createForOfIteratorHelper(storedPositions),
|
|
8
20
|
_step;
|
package/dist/cjs/ui/consts.js
CHANGED
|
@@ -13,7 +13,7 @@ var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
|
13
13
|
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
14
14
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
15
15
|
var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
|
|
16
|
-
var
|
|
16
|
+
var _editorExperiment = require("@atlaskit/tmp-editor-statsig/editor-experiment");
|
|
17
17
|
var _dropTargetMarginMap;
|
|
18
18
|
var ACTIVE_DRAG_HANDLE_ATTR = exports.ACTIVE_DRAG_HANDLE_ATTR = 'data-active-drag-handle';
|
|
19
19
|
var ACTIVE_QUICK_INSERT_ATTR = exports.ACTIVE_QUICK_INSERT_ATTR = 'data-active-quick-insert';
|
|
@@ -70,7 +70,7 @@ var dragHandleGap = exports.dragHandleGap = function dragHandleGap(nodeType, par
|
|
|
70
70
|
} else {
|
|
71
71
|
breakoutResizableNodesList = (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_lovability_resize_dividers_panels', 'isEnabled', true) ? [].concat((0, _toConsumableArray2.default)(_utils.breakoutResizableNodes), ['rule', 'panel']) : _utils.breakoutResizableNodes;
|
|
72
72
|
}
|
|
73
|
-
if ((0,
|
|
73
|
+
if ((0, _editorExperiment.editorExperiment)('platform_editor_breakout_resizing', true) && breakoutResizableNodesList.includes(nodeType)) {
|
|
74
74
|
if (nodeType === 'layoutSection') {
|
|
75
75
|
return DRAG_HANDLE_MAX_GAP + 20;
|
|
76
76
|
} else {
|
|
@@ -94,7 +94,7 @@ var rootElementGap = exports.rootElementGap = function rootElementGap(nodeType)
|
|
|
94
94
|
} else {
|
|
95
95
|
breakoutResizableNodesList = (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_lovability_resize_dividers_panels', 'isEnabled', true) ? [].concat((0, _toConsumableArray2.default)(_utils.breakoutResizableNodes), ['rule', 'panel']) : _utils.breakoutResizableNodes;
|
|
96
96
|
}
|
|
97
|
-
if (nodeTypeExcludeList.includes(nodeType) || (0,
|
|
97
|
+
if (nodeTypeExcludeList.includes(nodeType) || (0, _editorExperiment.editorExperiment)('platform_editor_breakout_resizing', true) && breakoutResizableNodesList.includes(nodeType)) {
|
|
98
98
|
if (nodeType === 'layoutSection') {
|
|
99
99
|
return DRAG_HANDLE_MAX_GAP + 20;
|
|
100
100
|
} else {
|
|
@@ -131,7 +131,7 @@ var getNestedNodeLeftPaddingMargin = exports.getNestedNodeLeftPaddingMargin = fu
|
|
|
131
131
|
}
|
|
132
132
|
};
|
|
133
133
|
var topPositionAdjustment = exports.topPositionAdjustment = function topPositionAdjustment(nodeType, layout) {
|
|
134
|
-
if ((0,
|
|
134
|
+
if ((0, _editorExperiment.editorExperiment)('advanced_layouts', true)) {
|
|
135
135
|
switch (nodeType) {
|
|
136
136
|
case 'layoutSection':
|
|
137
137
|
return DRAG_HANDLE_LAYOUT_SECTION_TOP_ADJUSTMENT;
|
|
@@ -22,13 +22,14 @@ var _state = require("@atlaskit/editor-prosemirror/state");
|
|
|
22
22
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
23
23
|
var _consts = require("@atlaskit/editor-shared-styles/consts");
|
|
24
24
|
var _dragHandleVertical = _interopRequireDefault(require("@atlaskit/icon/core/drag-handle-vertical"));
|
|
25
|
+
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
25
26
|
var _fg = require("@atlaskit/platform-feature-flags/fg");
|
|
26
27
|
var _elementAdapter = require("@atlaskit/pragmatic-drag-and-drop/adapter/element-adapter");
|
|
27
28
|
var _setCustomNativeDragPreview = require("@atlaskit/pragmatic-drag-and-drop/utils/set-custom-native-drag-preview");
|
|
28
29
|
var _primitives = require("@atlaskit/primitives");
|
|
29
30
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
30
31
|
var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
|
|
31
|
-
var
|
|
32
|
+
var _editorExperiment = require("@atlaskit/tmp-editor-statsig/editor-experiment");
|
|
32
33
|
var _Tooltip = _interopRequireDefault(require("@atlaskit/tooltip/Tooltip"));
|
|
33
34
|
var _decorationsCommon = require("../pm-plugins/decorations-common");
|
|
34
35
|
var _main = require("../pm-plugins/main");
|
|
@@ -831,7 +832,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref2) {
|
|
|
831
832
|
var node = parentPos !== undefined ? view.state.doc.nodeAt(parentPos) : undefined;
|
|
832
833
|
var parentNodeType = node === null || node === void 0 ? void 0 : node.type.name;
|
|
833
834
|
var supportsAnchor = CSS.supports('top', "anchor(".concat(anchorName, " start)")) && CSS.supports('left', "anchor(".concat(anchorName, " start)"));
|
|
834
|
-
var safeAnchorName = (0,
|
|
835
|
+
var safeAnchorName = (0, _editorExperiment.editorExperiment)('platform_editor_controls', 'variant1') ? (0, _anchorName.refreshAnchorName)({
|
|
835
836
|
getPos: getPos,
|
|
836
837
|
view: view,
|
|
837
838
|
anchorName: anchorName
|
|
@@ -883,13 +884,13 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref2) {
|
|
|
883
884
|
edge: 'right',
|
|
884
885
|
safeAnchorName: safeAnchorName
|
|
885
886
|
});
|
|
886
|
-
var bottom = (0,
|
|
887
|
+
var bottom = (0, _editorExperiment.editorExperiment)('platform_editor_controls', 'variant1') ? (0, _dragHandlePositions.getControlBottomCSSValue)(safeAnchorName, isSticky, isTopLevelNodeValue, isLayoutColumn, _consts2.ACTIVE_DRAG_HANDLE_FALLBACK_ANCHOR_NAME) : {};
|
|
887
888
|
return _objectSpread({
|
|
888
|
-
left: isEdgeCase ? "calc(".concat(anchorStart, " + ").concat((0, _dragHandlePositions.getLeftPosition)(dom, nodeType, innerContainer, isMacroInteractionUpdates, parentNodeType), ")") : (0,
|
|
889
|
-
top: (0,
|
|
889
|
+
left: isEdgeCase ? "calc(".concat(anchorStart, " + ").concat((0, _dragHandlePositions.getLeftPosition)(dom, nodeType, innerContainer, isMacroInteractionUpdates, parentNodeType), ")") : (0, _editorExperiment.editorExperiment)('advanced_layouts', true) && isLayoutColumn ? "calc((".concat(anchorRight, " + ").concat(anchorLeft, ")/2 - ").concat(_consts2.DRAG_HANDLE_HEIGHT / 2, "px)") : "calc(".concat(anchorStart, " - ").concat(_styles.DRAG_HANDLE_WIDTH, "px - ").concat((0, _consts2.dragHandleGap)(nodeType, parentNodeType), "px)"),
|
|
890
|
+
top: (0, _editorExperiment.editorExperiment)('advanced_layouts', true) && isLayoutColumn ? "calc(".concat(anchorTop, " - ").concat(_styles.DRAG_HANDLE_WIDTH, "px)") : "calc(".concat(anchorStart, " + ").concat((0, _consts2.topPositionAdjustment)((0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? $pos && $pos.nodeAfter && (0, _decorationsCommon.getNodeTypeWithLevel)($pos.nodeAfter) || nodeType : nodeType, (dom === null || dom === void 0 ? void 0 : dom.getAttribute('layout')) || ''), "px)")
|
|
890
891
|
}, bottom);
|
|
891
892
|
}
|
|
892
|
-
var height = (0,
|
|
893
|
+
var height = (0, _editorExperiment.editorExperiment)('platform_editor_controls', 'variant1') ? (0, _dragHandlePositions.getControlHeightCSSValue)((0, _dragHandlePositions.getNodeHeight)(dom, safeAnchorName, anchorRectCache) || 0, isSticky, isTopLevelNodeValue, "".concat(_consts2.DRAG_HANDLE_HEIGHT), isLayoutColumn) : {};
|
|
893
894
|
return _objectSpread({
|
|
894
895
|
left: isEdgeCase ? "calc(".concat((dom === null || dom === void 0 ? void 0 : dom.offsetLeft) || 0, "px + ").concat((0, _dragHandlePositions.getLeftPosition)(dom, nodeType, innerContainer, isMacroInteractionUpdates, parentNodeType), ")") : (0, _dragHandlePositions.getLeftPosition)(dom, nodeType, innerContainer, isMacroInteractionUpdates, parentNodeType),
|
|
895
896
|
top: (0, _dragHandlePositions.getTopPosition)(dom, nodeType)
|
|
@@ -979,7 +980,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref2) {
|
|
|
979
980
|
}, [isReliableAnchorEnabled, calculatePositionOld, view.dom, anchorName, nodeType, docDepForReliableAnchor]);
|
|
980
981
|
var isHandleShown = positionStylesOld.display !== 'none';
|
|
981
982
|
(0, _react.useEffect)(function () {
|
|
982
|
-
if ((0,
|
|
983
|
+
if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_react19_migration')) {
|
|
983
984
|
return;
|
|
984
985
|
}
|
|
985
986
|
if (handleOptions !== null && handleOptions !== void 0 && handleOptions.isFocused && buttonRef.current) {
|
|
@@ -994,7 +995,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref2) {
|
|
|
994
995
|
}
|
|
995
996
|
}, [buttonRef, handleOptions === null || handleOptions === void 0 ? void 0 : handleOptions.isFocused, view]);
|
|
996
997
|
(0, _react.useEffect)(function () {
|
|
997
|
-
if (!(0,
|
|
998
|
+
if (!(0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_react19_migration')) {
|
|
998
999
|
return;
|
|
999
1000
|
}
|
|
1000
1001
|
if (!(handleOptions !== null && handleOptions !== void 0 && handleOptions.isFocused && isHandleShown && buttonRef.current)) {
|
|
@@ -1050,7 +1051,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref2) {
|
|
|
1050
1051
|
setDragHandleDisabled(false);
|
|
1051
1052
|
}
|
|
1052
1053
|
}, [api === null || api === void 0 || (_api$blockControls8 = api.blockControls) === null || _api$blockControls8 === void 0 ? void 0 : _api$blockControls8.sharedState, isLayoutColumn, isShiftDown, isTopLevelNodeValue, view]);
|
|
1053
|
-
var dragHandleMessage = (0,
|
|
1054
|
+
var dragHandleMessage = (0, _editorExperiment.editorExperiment)('platform_editor_block_menu', true) ? formatMessage(_messages.blockControlsMessages.dragToMoveClickToOpen, {
|
|
1054
1055
|
br: (0, _react2.jsx)("br", null)
|
|
1055
1056
|
}) : formatMessage(_messages.blockControlsMessages.dragToMove);
|
|
1056
1057
|
|
|
@@ -1101,7 +1102,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref2) {
|
|
|
1101
1102
|
}
|
|
1102
1103
|
|
|
1103
1104
|
// When advanced layout is on, layout column drag handle show only show 'Drag to move', no shortcuts
|
|
1104
|
-
if ((0,
|
|
1105
|
+
if ((0, _editorExperiment.editorExperiment)('advanced_layouts', true) && nodeType === 'layoutColumn') {
|
|
1105
1106
|
helpDescriptors = [{
|
|
1106
1107
|
description: formatMessage(_messages.blockControlsMessages.dragToRearrange)
|
|
1107
1108
|
}, {
|
|
@@ -1118,7 +1119,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref2) {
|
|
|
1118
1119
|
keymap: _keymaps.dragToMoveRight
|
|
1119
1120
|
}];
|
|
1120
1121
|
}
|
|
1121
|
-
if ((0,
|
|
1122
|
+
if ((0, _editorExperiment.editorExperiment)('platform_editor_controls', 'variant1')) {
|
|
1122
1123
|
helpDescriptors = [{
|
|
1123
1124
|
description: dragHandleMessage
|
|
1124
1125
|
}];
|
|
@@ -1136,18 +1137,18 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref2) {
|
|
|
1136
1137
|
// eslint-disable-next-line @atlaskit/design-system/no-html-button
|
|
1137
1138
|
(0, _react2.jsx)("button", {
|
|
1138
1139
|
type: "button",
|
|
1139
|
-
css: [(0,
|
|
1140
|
+
css: [(0, _editorExperiment.editorExperiment)('platform_editor_controls', 'variant1') ? dragHandleButtonStyles : dragHandleButtonStylesOld, (0, _editorExperiment.editorExperiment)('platform_editor_controls', 'variant1') && dragHandleColor,
|
|
1140
1141
|
// ED-26266: Fixed the drag handle highlight when selecting multiple line in Firefox
|
|
1141
1142
|
// See https://product-fabric.atlassian.net/browse/ED-26266
|
|
1142
|
-
browser.gecko && dragHandleMultiLineSelectionFixFirefox, (0,
|
|
1143
|
+
browser.gecko && dragHandleMultiLineSelectionFixFirefox, (0, _editorExperiment.editorExperiment)('advanced_layouts', true) && isLayoutColumn && layoutColumnDragHandleStyles, dragHandleSelected && hasHadInteraction && selectedStyles, (0, _editorExperiment.editorExperiment)('platform_editor_preview_panel_responsiveness', true) && (0, _editorExperiment.editorExperiment)('platform_editor_controls', 'control') && dragHandleButtonSmallScreenStyles, (0, _editorExperiment.editorExperiment)('platform_editor_block_menu', true) && isFocused && keyboardFocusedDragHandleStyles, (0, _editorExperiment.editorExperiment)('platform_editor_block_menu', true) ? focusedStyles : focusedStylesOld, dragHandleButtonScaledStyles],
|
|
1143
1144
|
ref: buttonRef
|
|
1144
1145
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
1145
1146
|
,
|
|
1146
|
-
style: !(0,
|
|
1147
|
+
style: !(0, _editorExperiment.editorExperiment)('platform_editor_controls', 'variant1') ? positionStylesOld : {},
|
|
1147
1148
|
onMouseDown: (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_selection_toolbar_block_handle', 'isEnabled', true) ? handleMouseDown : undefined,
|
|
1148
|
-
onMouseUp: (0,
|
|
1149
|
-
onClick: (0,
|
|
1150
|
-
onKeyDown: (0,
|
|
1149
|
+
onMouseUp: (0, _editorExperiment.editorExperiment)('platform_editor_block_menu', true) ? handleMouseUp : undefined,
|
|
1150
|
+
onClick: (0, _editorExperiment.editorExperiment)('platform_editor_block_menu', true) ? handleOnClickNew : handleOnClick,
|
|
1151
|
+
onKeyDown: (0, _editorExperiment.editorExperiment)('platform_editor_block_menu', true) ? handleKeyDownNew : handleKeyDown
|
|
1151
1152
|
// eslint-disable-next-line @atlaskit/design-system/no-direct-use-of-web-platform-drag-and-drop
|
|
1152
1153
|
,
|
|
1153
1154
|
onDrop: handleOnDrop,
|
|
@@ -1157,7 +1158,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref2) {
|
|
|
1157
1158
|
"data-testid": "block-ctrl-drag-handle",
|
|
1158
1159
|
"aria-label": dragHandleAriaLabel,
|
|
1159
1160
|
onBlur: function onBlur() {
|
|
1160
|
-
if ((0,
|
|
1161
|
+
if ((0, _editorExperiment.editorExperiment)('platform_editor_block_menu', true)) {
|
|
1161
1162
|
setIsFocused(false);
|
|
1162
1163
|
}
|
|
1163
1164
|
var pos = getPos();
|
|
@@ -1256,7 +1257,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref2) {
|
|
|
1256
1257
|
var isTooltip = !dragHandleDisabled;
|
|
1257
1258
|
var stickyRender = isTooltip ? stickyWithTooltip() : stickyWithoutTooltip();
|
|
1258
1259
|
var render = isTooltip ? buttonWithTooltip() : renderButton();
|
|
1259
|
-
return (0,
|
|
1260
|
+
return (0, _editorExperiment.editorExperiment)('platform_editor_controls', 'variant1') ? stickyRender : render;
|
|
1260
1261
|
};
|
|
1261
1262
|
var DragHandleWithVisibility = exports.DragHandleWithVisibility = function DragHandleWithVisibility(_ref10) {
|
|
1262
1263
|
var view = _ref10.view,
|
|
@@ -16,7 +16,7 @@ var _box = require("@atlaskit/pragmatic-drag-and-drop-react-drop-indicator/box")
|
|
|
16
16
|
var _elementAdapter = require("@atlaskit/pragmatic-drag-and-drop/adapter/element-adapter");
|
|
17
17
|
var _constants = require("@atlaskit/theme/constants");
|
|
18
18
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
19
|
-
var
|
|
19
|
+
var _editorExperiment = require("@atlaskit/tmp-editor-statsig/editor-experiment");
|
|
20
20
|
var _decorationsCommon = require("../pm-plugins/decorations-common");
|
|
21
21
|
var _activeAnchorTracker = require("../pm-plugins/utils/active-anchor-tracker");
|
|
22
22
|
var _anchorUtils = require("../pm-plugins/utils/anchor-utils");
|
|
@@ -114,7 +114,7 @@ var HoverZone = function HoverZone(_ref) {
|
|
|
114
114
|
return (0, _elementAdapter.dropTargetForElements)({
|
|
115
115
|
element: ref.current,
|
|
116
116
|
onDragEnter: function onDragEnter() {
|
|
117
|
-
if ((!isNestedDropTarget || isInsideBodiedSyncBlock) && (0,
|
|
117
|
+
if ((!isNestedDropTarget || isInsideBodiedSyncBlock) && (0, _editorExperiment.editorExperiment)('advanced_layouts', true)) {
|
|
118
118
|
setActiveAnchor();
|
|
119
119
|
}
|
|
120
120
|
_onDragEnter();
|
|
@@ -13,7 +13,7 @@ var _toolbarFlagCheck = require("@atlaskit/editor-common/toolbar-flag-check");
|
|
|
13
13
|
var _whitespace = require("@atlaskit/editor-common/whitespace");
|
|
14
14
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
15
15
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
16
|
-
var
|
|
16
|
+
var _editorExperiment = require("@atlaskit/tmp-editor-statsig/editor-experiment");
|
|
17
17
|
var _consts = require("./consts");
|
|
18
18
|
var _domAttrName = require("./utils/dom-attr-name");
|
|
19
19
|
/**
|
|
@@ -38,10 +38,10 @@ var dragHandlerAnchorSelectorNext = "[".concat(_domAttrName.NODE_ANCHOR_ATTR_NAM
|
|
|
38
38
|
*/
|
|
39
39
|
var dragHandlerAnchorSelectorWithTaskExclusion = "[".concat(_domAttrName.NODE_ANCHOR_ATTR_NAME, "]:not([data-prosemirror-node-name=\"tableRow\"], [data-prosemirror-node-name=\"tableCell\"], [data-prosemirror-node-name=\"tableHeader\"], [data-prosemirror-node-name=\"media\"], [data-prosemirror-node-inline=\"true\"], [data-prosemirror-node-name=\"taskList\"] [").concat(_domAttrName.NODE_ANCHOR_ATTR_NAME, "])");
|
|
40
40
|
var gutterPaddingWidth = function gutterPaddingWidth() {
|
|
41
|
-
return (0,
|
|
41
|
+
return (0, _editorExperiment.editorExperiment)('platform_editor_controls', 'variant1') ? "".concat((0, _editorSharedStyles.akEditorGutterPaddingDynamic)(), "px") : '100%';
|
|
42
42
|
};
|
|
43
43
|
var gutterPaddingLeft = function gutterPaddingLeft() {
|
|
44
|
-
return (0,
|
|
44
|
+
return (0, _editorExperiment.editorExperiment)('platform_editor_controls', 'variant1') ? "-".concat((0, _editorSharedStyles.akEditorGutterPaddingDynamic)(), "px") : '-100px';
|
|
45
45
|
};
|
|
46
46
|
var extendedHoverZone = function extendedHoverZone() {
|
|
47
47
|
return (0, _react.css)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, ".block-ctrl-drag-preview ".concat(dragHandlerAnchorSelector, "::after"), {
|
|
@@ -419,11 +419,11 @@ var GlobalStylesWrapper = exports.GlobalStylesWrapper = function GlobalStylesWra
|
|
|
419
419
|
return (0, _react.jsx)(_react.Global
|
|
420
420
|
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
421
421
|
, {
|
|
422
|
-
styles: [globalStyles(), globalDnDStyle, (0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? extendedHoverZoneNext() : extendedHoverZone(), isDragging && ((0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? extendedDragZoneNext : extendedDragZone), (0,
|
|
422
|
+
styles: [globalStyles(), globalDnDStyle, (0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? extendedHoverZoneNext() : extendedHoverZone(), isDragging && ((0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? extendedDragZoneNext : extendedDragZone), (0, _editorExperiment.editorExperiment)('platform_editor_preview_panel_responsiveness', true, {
|
|
423
423
|
exposure: true
|
|
424
424
|
}) ? (0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? extendHoverZoneReducedNext : extendHoverZoneReduced : undefined,
|
|
425
425
|
// platform_editor_controls note: this allows drag handles to render on empty lines
|
|
426
|
-
toolbarFlagsEnabled ? undefined : withInlineNodeStyle, withDeleteLinesStyleFix, withMediaSingleStyleFix, legacyBreakoutWideLayoutStyle, headingWithIndentationInLayoutStyleFix, (0,
|
|
426
|
+
toolbarFlagsEnabled ? undefined : withInlineNodeStyle, withDeleteLinesStyleFix, withMediaSingleStyleFix, legacyBreakoutWideLayoutStyle, headingWithIndentationInLayoutStyleFix, (0, _editorExperiment.editorExperiment)('advanced_layouts', true) ? blockCardWithoutLayout : undefined, withDividerInPanelStyleFix, withFormatInLayoutStyleFix, (0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? withRelativePosStyleNext : withRelativePosStyle, (0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? withAnchorNameZindexStyleNext : withAnchorNameZindexStyle, (0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) && (0, _expValEquals.expValEquals)('advanced_layouts', 'isEnabled', true) ? layoutColumnExtendedHoverZone : layoutColumnWithoutHoverZone, (0, _expValEquals.expValEquals)('platform_editor_controls_reliable_anchor', 'isEnabled', true) ?
|
|
427
427
|
// dragAnchorStyles sets anchor-name on ALL nodes during drag (needed for drop target positioning).
|
|
428
428
|
// staticControlsAnchorStyles handles anchor-name via node decorations for non-drag state.
|
|
429
429
|
// shouldRenderAnchors guards both: only apply anchor styles on browsers that support CSS anchor positioning.
|
|
@@ -22,25 +22,39 @@ var getAbsoluteSurfacePlacement = exports.getAbsoluteSurfacePlacement = function
|
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
|
-
* Positions the
|
|
26
|
-
*
|
|
25
|
+
* Positions the surface beside the legacy drag-handle slot, on either the left or right edge
|
|
26
|
+
* of the target node. Node-type-specific gap/top-adjustment maths (layouts, tables, media, cards,
|
|
27
|
+
* extensions, etc.) live in one place so left/right edge cases can't drift out of sync.
|
|
28
|
+
*
|
|
29
|
+
* The left side grows away from the node without knowing its own width, so it needs
|
|
30
|
+
* `translateX(-100%)` to anchor its right edge at `nodeRect.left` and extend backward. The right
|
|
31
|
+
* side grows in the normal box-flow direction (away from the node, into the margin), so the gap
|
|
32
|
+
* can be folded straight into `left` with no transform needed.
|
|
27
33
|
*/
|
|
28
34
|
var getSurfacePlacement = exports.getSurfacePlacement = function getSurfacePlacement(_ref2) {
|
|
29
35
|
var layout = _ref2.layout,
|
|
30
36
|
nodeRect = _ref2.nodeRect,
|
|
31
37
|
nodeType = _ref2.nodeType,
|
|
32
38
|
nodeTypeWithLevel = _ref2.nodeTypeWithLevel,
|
|
33
|
-
parentNodeType = _ref2.parentNodeType
|
|
39
|
+
parentNodeType = _ref2.parentNodeType,
|
|
40
|
+
side = _ref2.side;
|
|
34
41
|
if (nodeType === 'layoutColumn') {
|
|
42
|
+
// nodeRect.left + width/2 === nodeRect.right - width/2 — side-independent.
|
|
35
43
|
return {
|
|
36
44
|
left: nodeRect.left + nodeRect.width / 2,
|
|
37
45
|
top: nodeRect.top,
|
|
38
46
|
transform: 'translate(-50%, -50%)'
|
|
39
47
|
};
|
|
40
48
|
}
|
|
41
|
-
|
|
49
|
+
var gap = (0, _consts.dragHandleGap)(nodeType, parentNodeType);
|
|
50
|
+
var top = nodeRect.top + (0, _consts.topPositionAdjustment)(nodeTypeWithLevel, layout);
|
|
51
|
+
return side === 'right' ? {
|
|
52
|
+
left: nodeRect.right + gap,
|
|
53
|
+
top: top,
|
|
54
|
+
transform: ''
|
|
55
|
+
} : {
|
|
42
56
|
left: nodeRect.left,
|
|
43
|
-
top:
|
|
44
|
-
transform: "translateX(calc(-100% - ".concat(
|
|
57
|
+
top: top,
|
|
58
|
+
transform: "translateX(calc(-100% - ".concat(gap, "px))")
|
|
45
59
|
};
|
|
46
60
|
};
|
|
@@ -14,7 +14,7 @@ var _hooks = require("@atlaskit/editor-common/hooks");
|
|
|
14
14
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
15
15
|
var _primitives = require("@atlaskit/primitives");
|
|
16
16
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
17
|
-
var
|
|
17
|
+
var _editorExperiment = require("@atlaskit/tmp-editor-statsig/editor-experiment");
|
|
18
18
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
19
19
|
/**
|
|
20
20
|
* @jsxRuntime classic
|
|
@@ -135,7 +135,7 @@ var VisibilityContainer = exports.VisibilityContainer = function VisibilityConta
|
|
|
135
135
|
};
|
|
136
136
|
}, [shouldHideImmediate, isRightControlViewMode]);
|
|
137
137
|
var shouldHide = isRightControlViewMode ? delayedShouldHide : shouldHideImmediate;
|
|
138
|
-
if ((0,
|
|
138
|
+
if ((0, _editorExperiment.editorExperiment)('platform_editor_preview_panel_responsiveness', true, {
|
|
139
139
|
exposure: true
|
|
140
140
|
})) {
|
|
141
141
|
return (0, _react2.jsx)("div", {
|