@atlaskit/editor-plugin-layout 23.0.3 → 23.0.5
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 +22 -0
- package/dist/cjs/layoutPlugin.js +13 -19
- package/dist/cjs/pm-plugins/actions.js +9 -28
- package/dist/cjs/pm-plugins/column-resize-divider.js +1 -3
- package/dist/cjs/pm-plugins/main.js +1 -2
- package/dist/cjs/pm-plugins/utils/index.js +3 -10
- package/dist/cjs/ui/LayoutColumnMenu/index.js +2 -28
- package/dist/cjs/ui/toolbar.js +2 -45
- package/dist/es2019/layoutPlugin.js +11 -17
- package/dist/es2019/pm-plugins/actions.js +9 -28
- package/dist/es2019/pm-plugins/column-resize-divider.js +1 -3
- package/dist/es2019/pm-plugins/main.js +1 -2
- package/dist/es2019/pm-plugins/utils/index.js +3 -10
- package/dist/es2019/ui/LayoutColumnMenu/index.js +2 -27
- package/dist/es2019/ui/toolbar.js +2 -45
- package/dist/esm/layoutPlugin.js +13 -19
- package/dist/esm/pm-plugins/actions.js +9 -28
- package/dist/esm/pm-plugins/column-resize-divider.js +1 -3
- package/dist/esm/pm-plugins/main.js +1 -2
- package/dist/esm/pm-plugins/utils/index.js +3 -10
- package/dist/esm/ui/LayoutColumnMenu/index.js +2 -28
- package/dist/esm/ui/toolbar.js +2 -45
- package/dist/types/pm-plugins/utils/index.d.ts +3 -5
- package/package.json +4 -7
- package/dist/cjs/ui/LayoutColumnMenu/utils.js +0 -69
- package/dist/es2019/ui/LayoutColumnMenu/utils.js +0 -65
- package/dist/esm/ui/LayoutColumnMenu/utils.js +0 -62
- package/dist/types/ui/LayoutColumnMenu/utils.d.ts +0 -19
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { findOverflowScrollParent } from '@atlaskit/editor-common/ui';
|
|
2
|
-
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
3
|
-
export const LAYOUT_COLUMN_MENU_POPUP_OFFSET = [0, 4];
|
|
4
|
-
|
|
5
|
-
// Gate OFF: small gap below the handle; Popup handles invert/nudge fallbacks.
|
|
6
|
-
export const LAYOUT_COLUMN_MENU_POPUP_OFFSET_BELOW = [0, 2];
|
|
7
|
-
// Gate OFF: left-aligned, below the handle. Gate ON (legacy): centred, prefer above with manual flip.
|
|
8
|
-
export const getLayoutColumnMenuPositioningProps = () => {
|
|
9
|
-
if (!fg('platform_editor_layout_column_menu_kill_switch_1')) {
|
|
10
|
-
return {
|
|
11
|
-
alignX: undefined,
|
|
12
|
-
alignY: undefined,
|
|
13
|
-
offset: LAYOUT_COLUMN_MENU_POPUP_OFFSET_BELOW,
|
|
14
|
-
useManualBelowFlip: false
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
return {
|
|
18
|
-
alignX: 'center',
|
|
19
|
-
alignY: 'top',
|
|
20
|
-
offset: LAYOUT_COLUMN_MENU_POPUP_OFFSET,
|
|
21
|
-
useManualBelowFlip: true
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
const getVisibleEditorAreaTop = (editorView, scrollableElement) => {
|
|
25
|
-
const visibleEditorArea = scrollableElement || findOverflowScrollParent(editorView.dom);
|
|
26
|
-
return Math.max(visibleEditorArea ? visibleEditorArea.getBoundingClientRect().top : 0, 0);
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
// Prefer opening above the column drag handle, but fall back below when the visible editor
|
|
30
|
-
// area does not have enough space above (for example near the top toolbar).
|
|
31
|
-
export const shouldOpenLayoutColumnMenuBelow = ({
|
|
32
|
-
editorView,
|
|
33
|
-
popup,
|
|
34
|
-
scrollableElement,
|
|
35
|
-
target
|
|
36
|
-
}) => {
|
|
37
|
-
const [, offsetY] = LAYOUT_COLUMN_MENU_POPUP_OFFSET;
|
|
38
|
-
const spaceAbove = target.getBoundingClientRect().top - getVisibleEditorAreaTop(editorView, scrollableElement);
|
|
39
|
-
const popupHeight = popup.getBoundingClientRect().height || popup.clientHeight;
|
|
40
|
-
return spaceAbove <= popupHeight + offsetY;
|
|
41
|
-
};
|
|
42
|
-
export const calculateFallbackBottomPosition = (position, target, popup) => {
|
|
43
|
-
if (!(popup.offsetParent instanceof HTMLElement)) {
|
|
44
|
-
return position;
|
|
45
|
-
}
|
|
46
|
-
const offsetParent = popup.offsetParent;
|
|
47
|
-
const borderBottomWidth = parseInt(window.getComputedStyle(offsetParent).borderBottomWidth, 10) || 0;
|
|
48
|
-
const {
|
|
49
|
-
top: offsetParentTop
|
|
50
|
-
} = offsetParent.getBoundingClientRect();
|
|
51
|
-
const {
|
|
52
|
-
top: targetTop,
|
|
53
|
-
height: targetHeight
|
|
54
|
-
} = target.getBoundingClientRect();
|
|
55
|
-
const [, offsetY] = LAYOUT_COLUMN_MENU_POPUP_OFFSET;
|
|
56
|
-
const top = Math.ceil(targetTop - offsetParentTop + targetHeight + (offsetParent === offsetParent.ownerDocument.body ? 0 : offsetParent.scrollTop) - borderBottomWidth + offsetY);
|
|
57
|
-
const positionWithoutBottom = {
|
|
58
|
-
...position
|
|
59
|
-
};
|
|
60
|
-
delete positionWithoutBottom.bottom;
|
|
61
|
-
return {
|
|
62
|
-
...positionWithoutBottom,
|
|
63
|
-
top
|
|
64
|
-
};
|
|
65
|
-
};
|
|
@@ -1,62 +0,0 @@
|
|
|
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
|
-
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
6
|
-
export var LAYOUT_COLUMN_MENU_POPUP_OFFSET = [0, 4];
|
|
7
|
-
|
|
8
|
-
// Gate OFF: small gap below the handle; Popup handles invert/nudge fallbacks.
|
|
9
|
-
export var LAYOUT_COLUMN_MENU_POPUP_OFFSET_BELOW = [0, 2];
|
|
10
|
-
// Gate OFF: left-aligned, below the handle. Gate ON (legacy): centred, prefer above with manual flip.
|
|
11
|
-
export var getLayoutColumnMenuPositioningProps = function getLayoutColumnMenuPositioningProps() {
|
|
12
|
-
if (!fg('platform_editor_layout_column_menu_kill_switch_1')) {
|
|
13
|
-
return {
|
|
14
|
-
alignX: undefined,
|
|
15
|
-
alignY: undefined,
|
|
16
|
-
offset: LAYOUT_COLUMN_MENU_POPUP_OFFSET_BELOW,
|
|
17
|
-
useManualBelowFlip: false
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
return {
|
|
21
|
-
alignX: 'center',
|
|
22
|
-
alignY: 'top',
|
|
23
|
-
offset: LAYOUT_COLUMN_MENU_POPUP_OFFSET,
|
|
24
|
-
useManualBelowFlip: true
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
var getVisibleEditorAreaTop = function getVisibleEditorAreaTop(editorView, scrollableElement) {
|
|
28
|
-
var visibleEditorArea = scrollableElement || findOverflowScrollParent(editorView.dom);
|
|
29
|
-
return Math.max(visibleEditorArea ? visibleEditorArea.getBoundingClientRect().top : 0, 0);
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
// Prefer opening above the column drag handle, but fall back below when the visible editor
|
|
33
|
-
// area does not have enough space above (for example near the top toolbar).
|
|
34
|
-
export var shouldOpenLayoutColumnMenuBelow = function shouldOpenLayoutColumnMenuBelow(_ref) {
|
|
35
|
-
var editorView = _ref.editorView,
|
|
36
|
-
popup = _ref.popup,
|
|
37
|
-
scrollableElement = _ref.scrollableElement,
|
|
38
|
-
target = _ref.target;
|
|
39
|
-
var offsetY = LAYOUT_COLUMN_MENU_POPUP_OFFSET[1];
|
|
40
|
-
var spaceAbove = target.getBoundingClientRect().top - getVisibleEditorAreaTop(editorView, scrollableElement);
|
|
41
|
-
var popupHeight = popup.getBoundingClientRect().height || popup.clientHeight;
|
|
42
|
-
return spaceAbove <= popupHeight + offsetY;
|
|
43
|
-
};
|
|
44
|
-
export var calculateFallbackBottomPosition = function calculateFallbackBottomPosition(position, target, popup) {
|
|
45
|
-
if (!(popup.offsetParent instanceof HTMLElement)) {
|
|
46
|
-
return position;
|
|
47
|
-
}
|
|
48
|
-
var offsetParent = popup.offsetParent;
|
|
49
|
-
var borderBottomWidth = parseInt(window.getComputedStyle(offsetParent).borderBottomWidth, 10) || 0;
|
|
50
|
-
var _offsetParent$getBoun = offsetParent.getBoundingClientRect(),
|
|
51
|
-
offsetParentTop = _offsetParent$getBoun.top;
|
|
52
|
-
var _target$getBoundingCl = target.getBoundingClientRect(),
|
|
53
|
-
targetTop = _target$getBoundingCl.top,
|
|
54
|
-
targetHeight = _target$getBoundingCl.height;
|
|
55
|
-
var offsetY = LAYOUT_COLUMN_MENU_POPUP_OFFSET[1];
|
|
56
|
-
var top = Math.ceil(targetTop - offsetParentTop + targetHeight + (offsetParent === offsetParent.ownerDocument.body ? 0 : offsetParent.scrollTop) - borderBottomWidth + offsetY);
|
|
57
|
-
var positionWithoutBottom = _objectSpread({}, position);
|
|
58
|
-
delete positionWithoutBottom.bottom;
|
|
59
|
-
return _objectSpread(_objectSpread({}, positionWithoutBottom), {}, {
|
|
60
|
-
top: top
|
|
61
|
-
});
|
|
62
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
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 LAYOUT_COLUMN_MENU_POPUP_OFFSET_BELOW: [number, number];
|
|
5
|
-
type LayoutColumnMenuPositioningProps = {
|
|
6
|
-
alignX: 'center' | undefined;
|
|
7
|
-
alignY: 'top' | undefined;
|
|
8
|
-
offset: [number, number];
|
|
9
|
-
useManualBelowFlip: boolean;
|
|
10
|
-
};
|
|
11
|
-
export declare const getLayoutColumnMenuPositioningProps: () => LayoutColumnMenuPositioningProps;
|
|
12
|
-
export declare const shouldOpenLayoutColumnMenuBelow: ({ editorView, popup, scrollableElement, target, }: {
|
|
13
|
-
editorView: EditorView;
|
|
14
|
-
popup: HTMLElement;
|
|
15
|
-
scrollableElement?: HTMLElement;
|
|
16
|
-
target: HTMLElement;
|
|
17
|
-
}) => boolean;
|
|
18
|
-
export declare const calculateFallbackBottomPosition: (position: PopupPosition, target: HTMLElement, popup: HTMLElement) => PopupPosition;
|
|
19
|
-
export {};
|