@atlaskit/editor-plugin-layout 11.1.0 → 11.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/cjs/ui/LayoutColumnMenu/index.js +21 -2
- package/dist/cjs/ui/LayoutColumnMenu/utils.js +48 -0
- package/dist/es2019/ui/LayoutColumnMenu/index.js +20 -1
- package/dist/es2019/ui/LayoutColumnMenu/utils.js +44 -0
- package/dist/esm/ui/LayoutColumnMenu/index.js +20 -1
- package/dist/esm/ui/LayoutColumnMenu/utils.js +41 -0
- package/dist/types/ui/LayoutColumnMenu/utils.d.ts +10 -0
- package/dist/types-ts4.5/ui/LayoutColumnMenu/utils.d.ts +13 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-layout
|
|
2
2
|
|
|
3
|
+
## 11.1.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`7f12a2679677d`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/7f12a2679677d) -
|
|
8
|
+
Open the layout column menu above the drag handle when space allows
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
11
|
+
## 11.1.1
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies
|
|
16
|
+
|
|
3
17
|
## 11.1.0
|
|
4
18
|
|
|
5
19
|
### Minor Changes
|
|
@@ -19,9 +19,9 @@ var _editorUiControlModel = require("@atlaskit/editor-ui-control-model");
|
|
|
19
19
|
var _layoutColumnSelection = require("../../pm-plugins/utils/layout-column-selection");
|
|
20
20
|
var _components = require("./components");
|
|
21
21
|
var _keys = require("./keys");
|
|
22
|
+
var _utils = require("./utils");
|
|
22
23
|
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); }
|
|
23
24
|
var PopupWithListeners = (0, _uiReact.withReactEditorViewOuterListeners)(_ui.Popup);
|
|
24
|
-
var LAYOUT_COLUMN_MENU_POPUP_OFFSET = [0, 4];
|
|
25
25
|
var TOOLBAR_MENU_SELECTOR = '[data-toolbar-component="menu"]';
|
|
26
26
|
var NESTED_DROPDOWN_MENU_SELECTOR = '[data-toolbar-nested-dropdown-menu]';
|
|
27
27
|
|
|
@@ -125,6 +125,22 @@ var LayoutColumnMenu = exports.LayoutColumnMenu = /*#__PURE__*/_react.default.me
|
|
|
125
125
|
return isLayoutColumnMenuOpen ? getLayoutColumnMenuTarget(editorView, selection, layoutColumnMenuAnchorPos) : null;
|
|
126
126
|
}, [editorView, isLayoutColumnMenuOpen, layoutColumnMenuAnchorPos, selection]);
|
|
127
127
|
var hasValidTarget = target instanceof HTMLElement;
|
|
128
|
+
var positionLayoutColumnMenu = (0, _react.useCallback)(function (position) {
|
|
129
|
+
var _menuWrapperRef$curre;
|
|
130
|
+
var popup = (_menuWrapperRef$curre = menuWrapperRef.current) === null || _menuWrapperRef$curre === void 0 ? void 0 : _menuWrapperRef$curre.parentElement;
|
|
131
|
+
if (!(target instanceof HTMLElement) || !(popup instanceof HTMLElement)) {
|
|
132
|
+
return position;
|
|
133
|
+
}
|
|
134
|
+
if ((0, _utils.shouldOpenLayoutColumnMenuBelow)({
|
|
135
|
+
editorView: editorView,
|
|
136
|
+
popup: popup,
|
|
137
|
+
scrollableElement: scrollableElement,
|
|
138
|
+
target: target
|
|
139
|
+
})) {
|
|
140
|
+
return (0, _utils.calculateFallbackBottomPosition)(position, target, popup);
|
|
141
|
+
}
|
|
142
|
+
return position;
|
|
143
|
+
}, [editorView, scrollableElement, target]);
|
|
128
144
|
(0, _react.useEffect)(function () {
|
|
129
145
|
if (isLayoutColumnMenuOpen && (!hasValidTarget || components.length === 0)) {
|
|
130
146
|
closeLayoutColumnMenu();
|
|
@@ -140,9 +156,12 @@ var LayoutColumnMenu = exports.LayoutColumnMenu = /*#__PURE__*/_react.default.me
|
|
|
140
156
|
scrollableElement: scrollableElement,
|
|
141
157
|
zIndex: _editorSharedStyles.akEditorFloatingOverlapPanelZIndex,
|
|
142
158
|
alignX: "center",
|
|
159
|
+
alignY: "top",
|
|
160
|
+
forcePlacement: true,
|
|
143
161
|
preventOverflow: true,
|
|
144
162
|
stick: true,
|
|
145
|
-
offset: LAYOUT_COLUMN_MENU_POPUP_OFFSET,
|
|
163
|
+
offset: _utils.LAYOUT_COLUMN_MENU_POPUP_OFFSET,
|
|
164
|
+
onPositionCalculated: positionLayoutColumnMenu,
|
|
146
165
|
handleClickOutside: handleClickOutside,
|
|
147
166
|
handleEscapeKeydown: closeLayoutColumnMenu,
|
|
148
167
|
focusTrap: openedViaKeyboard ? focusTrap : undefined
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.shouldOpenLayoutColumnMenuBelow = exports.calculateFallbackBottomPosition = exports.LAYOUT_COLUMN_MENU_POPUP_OFFSET = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _ui = require("@atlaskit/editor-common/ui");
|
|
10
|
+
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; }
|
|
11
|
+
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; }
|
|
12
|
+
var LAYOUT_COLUMN_MENU_POPUP_OFFSET = exports.LAYOUT_COLUMN_MENU_POPUP_OFFSET = [0, 4];
|
|
13
|
+
var getVisibleEditorAreaTop = function getVisibleEditorAreaTop(editorView, scrollableElement) {
|
|
14
|
+
var visibleEditorArea = scrollableElement || (0, _ui.findOverflowScrollParent)(editorView.dom);
|
|
15
|
+
return Math.max(visibleEditorArea ? visibleEditorArea.getBoundingClientRect().top : 0, 0);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
// Prefer opening above the column drag handle, but fall back below when the visible editor
|
|
19
|
+
// area does not have enough space above (for example near the top toolbar).
|
|
20
|
+
var shouldOpenLayoutColumnMenuBelow = exports.shouldOpenLayoutColumnMenuBelow = function shouldOpenLayoutColumnMenuBelow(_ref) {
|
|
21
|
+
var editorView = _ref.editorView,
|
|
22
|
+
popup = _ref.popup,
|
|
23
|
+
scrollableElement = _ref.scrollableElement,
|
|
24
|
+
target = _ref.target;
|
|
25
|
+
var offsetY = LAYOUT_COLUMN_MENU_POPUP_OFFSET[1];
|
|
26
|
+
var spaceAbove = target.getBoundingClientRect().top - getVisibleEditorAreaTop(editorView, scrollableElement);
|
|
27
|
+
var popupHeight = popup.getBoundingClientRect().height || popup.clientHeight;
|
|
28
|
+
return spaceAbove <= popupHeight + offsetY;
|
|
29
|
+
};
|
|
30
|
+
var calculateFallbackBottomPosition = exports.calculateFallbackBottomPosition = function calculateFallbackBottomPosition(position, target, popup) {
|
|
31
|
+
if (!(popup.offsetParent instanceof HTMLElement)) {
|
|
32
|
+
return position;
|
|
33
|
+
}
|
|
34
|
+
var offsetParent = popup.offsetParent;
|
|
35
|
+
var borderBottomWidth = parseInt(window.getComputedStyle(offsetParent).borderBottomWidth, 10) || 0;
|
|
36
|
+
var _offsetParent$getBoun = offsetParent.getBoundingClientRect(),
|
|
37
|
+
offsetParentTop = _offsetParent$getBoun.top;
|
|
38
|
+
var _target$getBoundingCl = target.getBoundingClientRect(),
|
|
39
|
+
targetTop = _target$getBoundingCl.top,
|
|
40
|
+
targetHeight = _target$getBoundingCl.height;
|
|
41
|
+
var offsetY = LAYOUT_COLUMN_MENU_POPUP_OFFSET[1];
|
|
42
|
+
var top = Math.ceil(targetTop - offsetParentTop + targetHeight + (offsetParent === offsetParent.ownerDocument.body ? 0 : offsetParent.scrollTop) - borderBottomWidth + offsetY);
|
|
43
|
+
var positionWithoutBottom = _objectSpread({}, position);
|
|
44
|
+
delete positionWithoutBottom.bottom;
|
|
45
|
+
return _objectSpread(_objectSpread({}, positionWithoutBottom), {}, {
|
|
46
|
+
top: top
|
|
47
|
+
});
|
|
48
|
+
};
|
|
@@ -12,8 +12,8 @@ import { SurfaceRenderer } from '@atlaskit/editor-ui-control-model';
|
|
|
12
12
|
import { getLayoutColumnMenuAnchorPos } from '../../pm-plugins/utils/layout-column-selection';
|
|
13
13
|
import { LAYOUT_COLUMN_MENU_FALLBACKS } from './components';
|
|
14
14
|
import { LAYOUT_COLUMN_MENU } from './keys';
|
|
15
|
+
import { calculateFallbackBottomPosition, LAYOUT_COLUMN_MENU_POPUP_OFFSET, shouldOpenLayoutColumnMenuBelow } from './utils';
|
|
15
16
|
const PopupWithListeners = withReactEditorViewOuterListeners(Popup);
|
|
16
|
-
const LAYOUT_COLUMN_MENU_POPUP_OFFSET = [0, 4];
|
|
17
17
|
const TOOLBAR_MENU_SELECTOR = '[data-toolbar-component="menu"]';
|
|
18
18
|
const NESTED_DROPDOWN_MENU_SELECTOR = '[data-toolbar-nested-dropdown-menu]';
|
|
19
19
|
|
|
@@ -117,6 +117,22 @@ export const LayoutColumnMenu = /*#__PURE__*/React.memo(function LayoutColumnMen
|
|
|
117
117
|
const components = (_api$uiControlRegistr = api === null || api === void 0 ? void 0 : (_api$uiControlRegistr2 = api.uiControlRegistry) === null || _api$uiControlRegistr2 === void 0 ? void 0 : _api$uiControlRegistr2.actions.getComponents(LAYOUT_COLUMN_MENU.key)) !== null && _api$uiControlRegistr !== void 0 ? _api$uiControlRegistr : [];
|
|
118
118
|
const target = useMemo(() => isLayoutColumnMenuOpen ? getLayoutColumnMenuTarget(editorView, selection, layoutColumnMenuAnchorPos) : null, [editorView, isLayoutColumnMenuOpen, layoutColumnMenuAnchorPos, selection]);
|
|
119
119
|
const hasValidTarget = target instanceof HTMLElement;
|
|
120
|
+
const positionLayoutColumnMenu = useCallback(position => {
|
|
121
|
+
var _menuWrapperRef$curre;
|
|
122
|
+
const popup = (_menuWrapperRef$curre = menuWrapperRef.current) === null || _menuWrapperRef$curre === void 0 ? void 0 : _menuWrapperRef$curre.parentElement;
|
|
123
|
+
if (!(target instanceof HTMLElement) || !(popup instanceof HTMLElement)) {
|
|
124
|
+
return position;
|
|
125
|
+
}
|
|
126
|
+
if (shouldOpenLayoutColumnMenuBelow({
|
|
127
|
+
editorView,
|
|
128
|
+
popup,
|
|
129
|
+
scrollableElement,
|
|
130
|
+
target
|
|
131
|
+
})) {
|
|
132
|
+
return calculateFallbackBottomPosition(position, target, popup);
|
|
133
|
+
}
|
|
134
|
+
return position;
|
|
135
|
+
}, [editorView, scrollableElement, target]);
|
|
120
136
|
useEffect(() => {
|
|
121
137
|
if (isLayoutColumnMenuOpen && (!hasValidTarget || components.length === 0)) {
|
|
122
138
|
closeLayoutColumnMenu();
|
|
@@ -132,9 +148,12 @@ export const LayoutColumnMenu = /*#__PURE__*/React.memo(function LayoutColumnMen
|
|
|
132
148
|
scrollableElement: scrollableElement,
|
|
133
149
|
zIndex: akEditorFloatingOverlapPanelZIndex,
|
|
134
150
|
alignX: "center",
|
|
151
|
+
alignY: "top",
|
|
152
|
+
forcePlacement: true,
|
|
135
153
|
preventOverflow: true,
|
|
136
154
|
stick: true,
|
|
137
155
|
offset: LAYOUT_COLUMN_MENU_POPUP_OFFSET,
|
|
156
|
+
onPositionCalculated: positionLayoutColumnMenu,
|
|
138
157
|
handleClickOutside: handleClickOutside,
|
|
139
158
|
handleEscapeKeydown: closeLayoutColumnMenu,
|
|
140
159
|
focusTrap: openedViaKeyboard ? focusTrap : undefined
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { findOverflowScrollParent } from '@atlaskit/editor-common/ui';
|
|
2
|
+
export const LAYOUT_COLUMN_MENU_POPUP_OFFSET = [0, 4];
|
|
3
|
+
const getVisibleEditorAreaTop = (editorView, scrollableElement) => {
|
|
4
|
+
const visibleEditorArea = scrollableElement || findOverflowScrollParent(editorView.dom);
|
|
5
|
+
return Math.max(visibleEditorArea ? visibleEditorArea.getBoundingClientRect().top : 0, 0);
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
// Prefer opening above the column drag handle, but fall back below when the visible editor
|
|
9
|
+
// area does not have enough space above (for example near the top toolbar).
|
|
10
|
+
export const shouldOpenLayoutColumnMenuBelow = ({
|
|
11
|
+
editorView,
|
|
12
|
+
popup,
|
|
13
|
+
scrollableElement,
|
|
14
|
+
target
|
|
15
|
+
}) => {
|
|
16
|
+
const [, offsetY] = LAYOUT_COLUMN_MENU_POPUP_OFFSET;
|
|
17
|
+
const spaceAbove = target.getBoundingClientRect().top - getVisibleEditorAreaTop(editorView, scrollableElement);
|
|
18
|
+
const popupHeight = popup.getBoundingClientRect().height || popup.clientHeight;
|
|
19
|
+
return spaceAbove <= popupHeight + offsetY;
|
|
20
|
+
};
|
|
21
|
+
export const calculateFallbackBottomPosition = (position, target, popup) => {
|
|
22
|
+
if (!(popup.offsetParent instanceof HTMLElement)) {
|
|
23
|
+
return position;
|
|
24
|
+
}
|
|
25
|
+
const offsetParent = popup.offsetParent;
|
|
26
|
+
const borderBottomWidth = parseInt(window.getComputedStyle(offsetParent).borderBottomWidth, 10) || 0;
|
|
27
|
+
const {
|
|
28
|
+
top: offsetParentTop
|
|
29
|
+
} = offsetParent.getBoundingClientRect();
|
|
30
|
+
const {
|
|
31
|
+
top: targetTop,
|
|
32
|
+
height: targetHeight
|
|
33
|
+
} = target.getBoundingClientRect();
|
|
34
|
+
const [, offsetY] = LAYOUT_COLUMN_MENU_POPUP_OFFSET;
|
|
35
|
+
const top = Math.ceil(targetTop - offsetParentTop + targetHeight + (offsetParent === offsetParent.ownerDocument.body ? 0 : offsetParent.scrollTop) - borderBottomWidth + offsetY);
|
|
36
|
+
const positionWithoutBottom = {
|
|
37
|
+
...position
|
|
38
|
+
};
|
|
39
|
+
delete positionWithoutBottom.bottom;
|
|
40
|
+
return {
|
|
41
|
+
...positionWithoutBottom,
|
|
42
|
+
top
|
|
43
|
+
};
|
|
44
|
+
};
|
|
@@ -12,8 +12,8 @@ import { SurfaceRenderer } from '@atlaskit/editor-ui-control-model';
|
|
|
12
12
|
import { getLayoutColumnMenuAnchorPos } from '../../pm-plugins/utils/layout-column-selection';
|
|
13
13
|
import { LAYOUT_COLUMN_MENU_FALLBACKS } from './components';
|
|
14
14
|
import { LAYOUT_COLUMN_MENU } from './keys';
|
|
15
|
+
import { calculateFallbackBottomPosition, LAYOUT_COLUMN_MENU_POPUP_OFFSET, shouldOpenLayoutColumnMenuBelow } from './utils';
|
|
15
16
|
var PopupWithListeners = withReactEditorViewOuterListeners(Popup);
|
|
16
|
-
var LAYOUT_COLUMN_MENU_POPUP_OFFSET = [0, 4];
|
|
17
17
|
var TOOLBAR_MENU_SELECTOR = '[data-toolbar-component="menu"]';
|
|
18
18
|
var NESTED_DROPDOWN_MENU_SELECTOR = '[data-toolbar-nested-dropdown-menu]';
|
|
19
19
|
|
|
@@ -117,6 +117,22 @@ export var LayoutColumnMenu = /*#__PURE__*/React.memo(function LayoutColumnMenu(
|
|
|
117
117
|
return isLayoutColumnMenuOpen ? getLayoutColumnMenuTarget(editorView, selection, layoutColumnMenuAnchorPos) : null;
|
|
118
118
|
}, [editorView, isLayoutColumnMenuOpen, layoutColumnMenuAnchorPos, selection]);
|
|
119
119
|
var hasValidTarget = target instanceof HTMLElement;
|
|
120
|
+
var positionLayoutColumnMenu = useCallback(function (position) {
|
|
121
|
+
var _menuWrapperRef$curre;
|
|
122
|
+
var popup = (_menuWrapperRef$curre = menuWrapperRef.current) === null || _menuWrapperRef$curre === void 0 ? void 0 : _menuWrapperRef$curre.parentElement;
|
|
123
|
+
if (!(target instanceof HTMLElement) || !(popup instanceof HTMLElement)) {
|
|
124
|
+
return position;
|
|
125
|
+
}
|
|
126
|
+
if (shouldOpenLayoutColumnMenuBelow({
|
|
127
|
+
editorView: editorView,
|
|
128
|
+
popup: popup,
|
|
129
|
+
scrollableElement: scrollableElement,
|
|
130
|
+
target: target
|
|
131
|
+
})) {
|
|
132
|
+
return calculateFallbackBottomPosition(position, target, popup);
|
|
133
|
+
}
|
|
134
|
+
return position;
|
|
135
|
+
}, [editorView, scrollableElement, target]);
|
|
120
136
|
useEffect(function () {
|
|
121
137
|
if (isLayoutColumnMenuOpen && (!hasValidTarget || components.length === 0)) {
|
|
122
138
|
closeLayoutColumnMenu();
|
|
@@ -132,9 +148,12 @@ export var LayoutColumnMenu = /*#__PURE__*/React.memo(function LayoutColumnMenu(
|
|
|
132
148
|
scrollableElement: scrollableElement,
|
|
133
149
|
zIndex: akEditorFloatingOverlapPanelZIndex,
|
|
134
150
|
alignX: "center",
|
|
151
|
+
alignY: "top",
|
|
152
|
+
forcePlacement: true,
|
|
135
153
|
preventOverflow: true,
|
|
136
154
|
stick: true,
|
|
137
155
|
offset: LAYOUT_COLUMN_MENU_POPUP_OFFSET,
|
|
156
|
+
onPositionCalculated: positionLayoutColumnMenu,
|
|
138
157
|
handleClickOutside: handleClickOutside,
|
|
139
158
|
handleEscapeKeydown: closeLayoutColumnMenu,
|
|
140
159
|
focusTrap: openedViaKeyboard ? focusTrap : undefined
|
|
@@ -0,0 +1,41 @@
|
|
|
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 { findOverflowScrollParent } from '@atlaskit/editor-common/ui';
|
|
5
|
+
export var LAYOUT_COLUMN_MENU_POPUP_OFFSET = [0, 4];
|
|
6
|
+
var getVisibleEditorAreaTop = function getVisibleEditorAreaTop(editorView, scrollableElement) {
|
|
7
|
+
var visibleEditorArea = scrollableElement || findOverflowScrollParent(editorView.dom);
|
|
8
|
+
return Math.max(visibleEditorArea ? visibleEditorArea.getBoundingClientRect().top : 0, 0);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
// Prefer opening above the column drag handle, but fall back below when the visible editor
|
|
12
|
+
// area does not have enough space above (for example near the top toolbar).
|
|
13
|
+
export var shouldOpenLayoutColumnMenuBelow = function shouldOpenLayoutColumnMenuBelow(_ref) {
|
|
14
|
+
var editorView = _ref.editorView,
|
|
15
|
+
popup = _ref.popup,
|
|
16
|
+
scrollableElement = _ref.scrollableElement,
|
|
17
|
+
target = _ref.target;
|
|
18
|
+
var offsetY = LAYOUT_COLUMN_MENU_POPUP_OFFSET[1];
|
|
19
|
+
var spaceAbove = target.getBoundingClientRect().top - getVisibleEditorAreaTop(editorView, scrollableElement);
|
|
20
|
+
var popupHeight = popup.getBoundingClientRect().height || popup.clientHeight;
|
|
21
|
+
return spaceAbove <= popupHeight + offsetY;
|
|
22
|
+
};
|
|
23
|
+
export var calculateFallbackBottomPosition = function calculateFallbackBottomPosition(position, target, popup) {
|
|
24
|
+
if (!(popup.offsetParent instanceof HTMLElement)) {
|
|
25
|
+
return position;
|
|
26
|
+
}
|
|
27
|
+
var offsetParent = popup.offsetParent;
|
|
28
|
+
var borderBottomWidth = parseInt(window.getComputedStyle(offsetParent).borderBottomWidth, 10) || 0;
|
|
29
|
+
var _offsetParent$getBoun = offsetParent.getBoundingClientRect(),
|
|
30
|
+
offsetParentTop = _offsetParent$getBoun.top;
|
|
31
|
+
var _target$getBoundingCl = target.getBoundingClientRect(),
|
|
32
|
+
targetTop = _target$getBoundingCl.top,
|
|
33
|
+
targetHeight = _target$getBoundingCl.height;
|
|
34
|
+
var offsetY = LAYOUT_COLUMN_MENU_POPUP_OFFSET[1];
|
|
35
|
+
var top = Math.ceil(targetTop - offsetParentTop + targetHeight + (offsetParent === offsetParent.ownerDocument.body ? 0 : offsetParent.scrollTop) - borderBottomWidth + offsetY);
|
|
36
|
+
var positionWithoutBottom = _objectSpread({}, position);
|
|
37
|
+
delete positionWithoutBottom.bottom;
|
|
38
|
+
return _objectSpread(_objectSpread({}, positionWithoutBottom), {}, {
|
|
39
|
+
top: top
|
|
40
|
+
});
|
|
41
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type PopupPosition } from '@atlaskit/editor-common/ui';
|
|
2
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
3
|
+
export declare const LAYOUT_COLUMN_MENU_POPUP_OFFSET: [number, number];
|
|
4
|
+
export declare const shouldOpenLayoutColumnMenuBelow: ({ editorView, popup, scrollableElement, target, }: {
|
|
5
|
+
editorView: EditorView;
|
|
6
|
+
popup: HTMLElement;
|
|
7
|
+
scrollableElement?: HTMLElement;
|
|
8
|
+
target: HTMLElement;
|
|
9
|
+
}) => boolean;
|
|
10
|
+
export declare const calculateFallbackBottomPosition: (position: PopupPosition, target: HTMLElement, popup: HTMLElement) => PopupPosition;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type PopupPosition } from '@atlaskit/editor-common/ui';
|
|
2
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
3
|
+
export declare const LAYOUT_COLUMN_MENU_POPUP_OFFSET: [
|
|
4
|
+
number,
|
|
5
|
+
number
|
|
6
|
+
];
|
|
7
|
+
export declare const shouldOpenLayoutColumnMenuBelow: ({ editorView, popup, scrollableElement, target, }: {
|
|
8
|
+
editorView: EditorView;
|
|
9
|
+
popup: HTMLElement;
|
|
10
|
+
scrollableElement?: HTMLElement;
|
|
11
|
+
target: HTMLElement;
|
|
12
|
+
}) => boolean;
|
|
13
|
+
export declare const calculateFallbackBottomPosition: (position: PopupPosition, target: HTMLElement, popup: HTMLElement) => PopupPosition;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-layout",
|
|
3
|
-
"version": "11.1.
|
|
3
|
+
"version": "11.1.2",
|
|
4
4
|
"description": "Layout plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"@atlaskit/adf-schema": "^52.16.0",
|
|
33
33
|
"@atlaskit/css": "^0.19.0",
|
|
34
34
|
"@atlaskit/editor-plugin-analytics": "^11.0.0",
|
|
35
|
-
"@atlaskit/editor-plugin-block-controls": "^12.
|
|
35
|
+
"@atlaskit/editor-plugin-block-controls": "^12.2.0",
|
|
36
36
|
"@atlaskit/editor-plugin-block-menu": "^10.1.0",
|
|
37
37
|
"@atlaskit/editor-plugin-decorations": "^11.0.0",
|
|
38
38
|
"@atlaskit/editor-plugin-editor-disabled": "^11.0.0",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"@atlaskit/icon": "^35.4.0",
|
|
51
51
|
"@atlaskit/icon-lab": "^6.13.0",
|
|
52
52
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
53
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
53
|
+
"@atlaskit/tmp-editor-statsig": "^91.0.0",
|
|
54
54
|
"@atlaskit/tokens": "^13.3.0",
|
|
55
55
|
"@babel/runtime": "^7.0.0",
|
|
56
56
|
"@emotion/react": "^11.7.1",
|