@atlaskit/editor-plugin-layout 10.3.4 → 10.4.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/layoutPlugin.js +8 -0
- package/dist/cjs/pm-plugins/actions.js +158 -8
- package/dist/cjs/pm-plugins/column-resize-divider.js +7 -9
- package/dist/cjs/pm-plugins/consts.js +4 -1
- package/dist/cjs/pm-plugins/utils/redistribute-proportionally.js +141 -0
- package/dist/cjs/ui/LayoutColumnMenu/DeleteColumnDropdownItem.js +42 -0
- package/dist/cjs/ui/LayoutColumnMenu/InsertColumnDropdownItem.js +69 -0
- package/dist/cjs/ui/LayoutColumnMenu/VerticalAlignDropdownItem.js +7 -9
- package/dist/cjs/ui/LayoutColumnMenu/VerticalAlignNestedMenu.js +11 -10
- package/dist/cjs/ui/LayoutColumnMenu/components.js +31 -0
- package/dist/cjs/ui/LayoutColumnMenu/index.js +39 -11
- package/dist/cjs/ui/LayoutColumnMenu/keys.js +14 -2
- package/dist/cjs/ui/LayoutColumnMenu/layoutColumnSelection.js +21 -0
- package/dist/cjs/ui/LayoutColumnMenu/useCurrentLayoutColumn.js +20 -0
- package/dist/es2019/layoutPlugin.js +9 -1
- package/dist/es2019/pm-plugins/actions.js +152 -1
- package/dist/es2019/pm-plugins/column-resize-divider.js +8 -9
- package/dist/es2019/pm-plugins/consts.js +3 -0
- package/dist/es2019/pm-plugins/utils/redistribute-proportionally.js +113 -0
- package/dist/es2019/ui/LayoutColumnMenu/DeleteColumnDropdownItem.js +37 -0
- package/dist/es2019/ui/LayoutColumnMenu/InsertColumnDropdownItem.js +64 -0
- package/dist/es2019/ui/LayoutColumnMenu/VerticalAlignDropdownItem.js +6 -11
- package/dist/es2019/ui/LayoutColumnMenu/VerticalAlignNestedMenu.js +7 -10
- package/dist/es2019/ui/LayoutColumnMenu/components.js +32 -1
- package/dist/es2019/ui/LayoutColumnMenu/index.js +34 -13
- package/dist/es2019/ui/LayoutColumnMenu/keys.js +17 -2
- package/dist/es2019/ui/LayoutColumnMenu/layoutColumnSelection.js +9 -0
- package/dist/es2019/ui/LayoutColumnMenu/useCurrentLayoutColumn.js +10 -0
- package/dist/esm/layoutPlugin.js +9 -1
- package/dist/esm/pm-plugins/actions.js +156 -7
- package/dist/esm/pm-plugins/column-resize-divider.js +8 -9
- package/dist/esm/pm-plugins/consts.js +3 -0
- package/dist/esm/pm-plugins/utils/redistribute-proportionally.js +134 -0
- package/dist/esm/ui/LayoutColumnMenu/DeleteColumnDropdownItem.js +35 -0
- package/dist/esm/ui/LayoutColumnMenu/InsertColumnDropdownItem.js +61 -0
- package/dist/esm/ui/LayoutColumnMenu/VerticalAlignDropdownItem.js +8 -10
- package/dist/esm/ui/LayoutColumnMenu/VerticalAlignNestedMenu.js +9 -9
- package/dist/esm/ui/LayoutColumnMenu/components.js +32 -1
- package/dist/esm/ui/LayoutColumnMenu/index.js +40 -13
- package/dist/esm/ui/LayoutColumnMenu/keys.js +13 -1
- package/dist/esm/ui/LayoutColumnMenu/layoutColumnSelection.js +15 -0
- package/dist/esm/ui/LayoutColumnMenu/useCurrentLayoutColumn.js +14 -0
- package/dist/types/layoutPluginType.d.ts +4 -2
- package/dist/types/pm-plugins/actions.d.ts +7 -0
- package/dist/types/pm-plugins/consts.d.ts +3 -0
- package/dist/types/pm-plugins/utils/redistribute-proportionally.d.ts +2 -0
- package/dist/types/ui/LayoutColumnMenu/DeleteColumnDropdownItem.d.ts +8 -0
- package/dist/types/ui/LayoutColumnMenu/InsertColumnDropdownItem.d.ts +10 -0
- package/dist/types/ui/LayoutColumnMenu/keys.d.ts +3 -0
- package/dist/types/ui/LayoutColumnMenu/layoutColumnSelection.d.ts +7 -0
- package/dist/types/ui/LayoutColumnMenu/useCurrentLayoutColumn.d.ts +5 -0
- package/dist/types-ts4.5/layoutPluginType.d.ts +4 -2
- package/dist/types-ts4.5/pm-plugins/actions.d.ts +7 -0
- package/dist/types-ts4.5/pm-plugins/consts.d.ts +3 -0
- package/dist/types-ts4.5/pm-plugins/utils/redistribute-proportionally.d.ts +2 -0
- package/dist/types-ts4.5/ui/LayoutColumnMenu/DeleteColumnDropdownItem.d.ts +8 -0
- package/dist/types-ts4.5/ui/LayoutColumnMenu/InsertColumnDropdownItem.d.ts +10 -0
- package/dist/types-ts4.5/ui/LayoutColumnMenu/keys.d.ts +3 -0
- package/dist/types-ts4.5/ui/LayoutColumnMenu/layoutColumnSelection.d.ts +7 -0
- package/dist/types-ts4.5/ui/LayoutColumnMenu/useCurrentLayoutColumn.d.ts +5 -0
- package/package.json +4 -4
- package/dist/cjs/ui/LayoutColumnMenu/useCurrentLayoutColumnValign.js +0 -22
- package/dist/es2019/ui/LayoutColumnMenu/useCurrentLayoutColumnValign.js +0 -14
- package/dist/esm/ui/LayoutColumnMenu/useCurrentLayoutColumnValign.js +0 -16
- package/dist/types/ui/LayoutColumnMenu/useCurrentLayoutColumnValign.d.ts +0 -11
- package/dist/types-ts4.5/ui/LayoutColumnMenu/useCurrentLayoutColumnValign.d.ts +0 -11
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
+
var roundLayoutColumnWidth = function roundLayoutColumnWidth(width) {
|
|
3
|
+
return Number(width.toFixed(2));
|
|
4
|
+
};
|
|
5
|
+
var sumWidths = function sumWidths(widths) {
|
|
6
|
+
return widths.reduce(function (sum, width) {
|
|
7
|
+
return sum + width;
|
|
8
|
+
}, 0);
|
|
9
|
+
};
|
|
10
|
+
var isValidWidth = function isValidWidth(width) {
|
|
11
|
+
return Number.isFinite(width) && width > 0;
|
|
12
|
+
};
|
|
13
|
+
var normaliseWidthsTotal = function normaliseWidthsTotal(widths, totalWidth, minWidth) {
|
|
14
|
+
var roundedWidths = widths.map(roundLayoutColumnWidth);
|
|
15
|
+
var remainder = roundLayoutColumnWidth(totalWidth - sumWidths(roundedWidths));
|
|
16
|
+
if (remainder === 0 || roundedWidths.length === 0) {
|
|
17
|
+
return roundedWidths;
|
|
18
|
+
}
|
|
19
|
+
var adjustmentIndex = 0;
|
|
20
|
+
roundedWidths.forEach(function (width, index) {
|
|
21
|
+
if (width > roundedWidths[adjustmentIndex]) {
|
|
22
|
+
adjustmentIndex = index;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
var adjustedWidth = roundLayoutColumnWidth(roundedWidths[adjustmentIndex] + remainder);
|
|
26
|
+
if (adjustedWidth < minWidth) {
|
|
27
|
+
return roundedWidths;
|
|
28
|
+
}
|
|
29
|
+
return roundedWidths.map(function (width, index) {
|
|
30
|
+
return index === adjustmentIndex ? adjustedWidth : width;
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
var redistributeWithMinimumWidth = function redistributeWithMinimumWidth(_ref) {
|
|
34
|
+
var minWidth = _ref.minWidth,
|
|
35
|
+
totalWidth = _ref.totalWidth,
|
|
36
|
+
weights = _ref.weights;
|
|
37
|
+
if (weights.length * minWidth > totalWidth) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
var widths = Array(weights.length).fill(0);
|
|
41
|
+
var clampedIndexes = new Set();
|
|
42
|
+
var remainingWidth = totalWidth;
|
|
43
|
+
var remainingWeight = sumWidths(weights);
|
|
44
|
+
var _loop = function _loop() {
|
|
45
|
+
var remainingWidthForPass = remainingWidth;
|
|
46
|
+
var remainingWeightForPass = remainingWeight;
|
|
47
|
+
var indexesToClamp = [];
|
|
48
|
+
weights.forEach(function (weight, index) {
|
|
49
|
+
if (clampedIndexes.has(index)) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
var proportionalWidth = remainingWeightForPass > 0 ? weight / remainingWeightForPass * remainingWidthForPass : 0;
|
|
53
|
+
if (proportionalWidth < minWidth) {
|
|
54
|
+
indexesToClamp.push(index);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
if (indexesToClamp.length === 0) {
|
|
58
|
+
return 1; // break
|
|
59
|
+
}
|
|
60
|
+
indexesToClamp.forEach(function (index) {
|
|
61
|
+
widths[index] = minWidth;
|
|
62
|
+
clampedIndexes.add(index);
|
|
63
|
+
remainingWidth -= minWidth;
|
|
64
|
+
remainingWeight -= weights[index];
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
while (clampedIndexes.size < weights.length) {
|
|
68
|
+
if (_loop()) break;
|
|
69
|
+
}
|
|
70
|
+
weights.forEach(function (weight, index) {
|
|
71
|
+
if (!clampedIndexes.has(index)) {
|
|
72
|
+
widths[index] = remainingWeight > 0 ? weight / remainingWeight * remainingWidth : minWidth;
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
return widths;
|
|
76
|
+
};
|
|
77
|
+
export var redistributeAfterDeletion = function redistributeAfterDeletion(currentWidths, removeIndex, minWidth) {
|
|
78
|
+
if (currentWidths.length === 0 || removeIndex < 0 || removeIndex >= currentWidths.length || !isValidWidth(minWidth)) {
|
|
79
|
+
return currentWidths;
|
|
80
|
+
}
|
|
81
|
+
if (currentWidths.some(function (width) {
|
|
82
|
+
return !isValidWidth(width);
|
|
83
|
+
})) {
|
|
84
|
+
return currentWidths.filter(function (_, i) {
|
|
85
|
+
return i !== removeIndex;
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
var remainingWidths = currentWidths.filter(function (_, i) {
|
|
89
|
+
return i !== removeIndex;
|
|
90
|
+
});
|
|
91
|
+
if (remainingWidths.length === 0) {
|
|
92
|
+
return remainingWidths;
|
|
93
|
+
}
|
|
94
|
+
var currentTotalWidth = sumWidths(currentWidths);
|
|
95
|
+
var targetTotalWidth = Math.round(currentTotalWidth) === 100 ? 100 : currentTotalWidth;
|
|
96
|
+
var redistributed = redistributeWithMinimumWidth({
|
|
97
|
+
weights: remainingWidths,
|
|
98
|
+
totalWidth: targetTotalWidth,
|
|
99
|
+
minWidth: minWidth
|
|
100
|
+
});
|
|
101
|
+
if (!redistributed) {
|
|
102
|
+
var equalWidth = roundLayoutColumnWidth(targetTotalWidth / remainingWidths.length);
|
|
103
|
+
return normaliseWidthsTotal(Array(remainingWidths.length).fill(equalWidth), targetTotalWidth, minWidth);
|
|
104
|
+
}
|
|
105
|
+
return normaliseWidthsTotal(redistributed, targetTotalWidth, minWidth);
|
|
106
|
+
};
|
|
107
|
+
export var redistributeProportionally = function redistributeProportionally(currentWidths, insertIndex, maxColumns, minWidth) {
|
|
108
|
+
if (currentWidths.length === 0 || !Number.isInteger(maxColumns) || maxColumns <= 0 || currentWidths.length >= maxColumns || insertIndex < 0 || insertIndex > currentWidths.length || !isValidWidth(minWidth) || currentWidths.some(function (width) {
|
|
109
|
+
return !isValidWidth(width);
|
|
110
|
+
})) {
|
|
111
|
+
return currentWidths;
|
|
112
|
+
}
|
|
113
|
+
var currentTotalWidth = sumWidths(currentWidths);
|
|
114
|
+
if (!isValidWidth(currentTotalWidth)) {
|
|
115
|
+
return currentWidths;
|
|
116
|
+
}
|
|
117
|
+
var targetTotalWidth = Math.round(currentTotalWidth) === 100 ? 100 : currentTotalWidth;
|
|
118
|
+
var newColumnWidth = Math.max(minWidth, roundLayoutColumnWidth(targetTotalWidth / (currentWidths.length + 1)));
|
|
119
|
+
var existingColumnsTotalWidth = targetTotalWidth - newColumnWidth;
|
|
120
|
+
if (existingColumnsTotalWidth < currentWidths.length * minWidth) {
|
|
121
|
+
return currentWidths;
|
|
122
|
+
}
|
|
123
|
+
var redistributedExistingWidths = redistributeWithMinimumWidth({
|
|
124
|
+
weights: currentWidths,
|
|
125
|
+
totalWidth: existingColumnsTotalWidth,
|
|
126
|
+
minWidth: minWidth
|
|
127
|
+
});
|
|
128
|
+
if (!redistributedExistingWidths) {
|
|
129
|
+
return currentWidths;
|
|
130
|
+
}
|
|
131
|
+
var nextWidths = _toConsumableArray(redistributedExistingWidths);
|
|
132
|
+
nextWidths.splice(insertIndex, 0, newColumnWidth);
|
|
133
|
+
return normaliseWidthsTotal(nextWidths, targetTotalWidth, minWidth);
|
|
134
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
|
+
import { useIntl } from 'react-intl';
|
|
3
|
+
import { layoutMessages } from '@atlaskit/editor-common/messages';
|
|
4
|
+
import { ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
|
|
5
|
+
import { useCurrentLayoutColumn } from './useCurrentLayoutColumn';
|
|
6
|
+
var DeleteColumnDropdownItem = function DeleteColumnDropdownItem(_ref) {
|
|
7
|
+
var api = _ref.api;
|
|
8
|
+
var _useIntl = useIntl(),
|
|
9
|
+
formatMessage = _useIntl.formatMessage;
|
|
10
|
+
var currentColumn = useCurrentLayoutColumn(api);
|
|
11
|
+
var onClick = useCallback(function () {
|
|
12
|
+
var _api$layout, _api$core;
|
|
13
|
+
var deleteCommand = api === null || api === void 0 || (_api$layout = api.layout) === null || _api$layout === void 0 ? void 0 : _api$layout.commands.deleteLayoutColumn;
|
|
14
|
+
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(function (props) {
|
|
15
|
+
var _api$layout2;
|
|
16
|
+
var tr = deleteCommand === null || deleteCommand === void 0 ? void 0 : deleteCommand(props);
|
|
17
|
+
if (!tr) {
|
|
18
|
+
return tr !== null && tr !== void 0 ? tr : null;
|
|
19
|
+
}
|
|
20
|
+
api === null || api === void 0 || (_api$layout2 = api.layout) === null || _api$layout2 === void 0 || _api$layout2.commands.toggleLayoutColumnMenu({
|
|
21
|
+
isOpen: false
|
|
22
|
+
})({
|
|
23
|
+
tr: tr
|
|
24
|
+
});
|
|
25
|
+
return tr;
|
|
26
|
+
});
|
|
27
|
+
}, [api]);
|
|
28
|
+
if (currentColumn === undefined) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
|
|
32
|
+
onClick: onClick
|
|
33
|
+
}, formatMessage(layoutMessages.deleteColumn));
|
|
34
|
+
};
|
|
35
|
+
export { DeleteColumnDropdownItem };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
|
+
import { useIntl } from 'react-intl';
|
|
3
|
+
import { layoutMessages } from '@atlaskit/editor-common/messages';
|
|
4
|
+
import { TableColumnAddLeftIcon, TableColumnAddRightIcon, ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
|
|
5
|
+
import { getEffectiveMaxLayoutColumns } from '../../pm-plugins/actions';
|
|
6
|
+
import { getLayoutSectionColumnCount } from './layoutColumnSelection';
|
|
7
|
+
import { useCurrentLayoutColumn, useCurrentLayoutSection } from './useCurrentLayoutColumn';
|
|
8
|
+
var INSERT_COLUMN_OPTIONS = {
|
|
9
|
+
left: {
|
|
10
|
+
Icon: TableColumnAddLeftIcon,
|
|
11
|
+
label: layoutMessages.insertColumnLeft,
|
|
12
|
+
side: 'left'
|
|
13
|
+
},
|
|
14
|
+
right: {
|
|
15
|
+
Icon: TableColumnAddRightIcon,
|
|
16
|
+
label: layoutMessages.insertColumnRight,
|
|
17
|
+
side: 'right'
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
export var InsertColumnDropdownItem = function InsertColumnDropdownItem(_ref) {
|
|
21
|
+
var api = _ref.api,
|
|
22
|
+
side = _ref.side;
|
|
23
|
+
var _useIntl = useIntl(),
|
|
24
|
+
formatMessage = _useIntl.formatMessage;
|
|
25
|
+
var _INSERT_COLUMN_OPTION = INSERT_COLUMN_OPTIONS[side],
|
|
26
|
+
Icon = _INSERT_COLUMN_OPTION.Icon,
|
|
27
|
+
label = _INSERT_COLUMN_OPTION.label;
|
|
28
|
+
var currentColumn = useCurrentLayoutColumn(api);
|
|
29
|
+
var currentLayoutSection = useCurrentLayoutSection(api);
|
|
30
|
+
var columnCount = getLayoutSectionColumnCount(currentLayoutSection);
|
|
31
|
+
var maxColumnCount = getEffectiveMaxLayoutColumns();
|
|
32
|
+
var canInsertColumn = currentColumn !== undefined && columnCount < maxColumnCount;
|
|
33
|
+
var onClick = useCallback(function () {
|
|
34
|
+
var _api$layout, _api$core;
|
|
35
|
+
var insertCommand = api === null || api === void 0 || (_api$layout = api.layout) === null || _api$layout === void 0 ? void 0 : _api$layout.commands.insertLayoutColumn(side);
|
|
36
|
+
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(function (props) {
|
|
37
|
+
var _api$layout2;
|
|
38
|
+
var tr = insertCommand === null || insertCommand === void 0 ? void 0 : insertCommand(props);
|
|
39
|
+
if (!tr) {
|
|
40
|
+
return tr !== null && tr !== void 0 ? tr : null;
|
|
41
|
+
}
|
|
42
|
+
api === null || api === void 0 || (_api$layout2 = api.layout) === null || _api$layout2 === void 0 || _api$layout2.commands.toggleLayoutColumnMenu({
|
|
43
|
+
isOpen: false
|
|
44
|
+
})({
|
|
45
|
+
tr: tr
|
|
46
|
+
});
|
|
47
|
+
return tr;
|
|
48
|
+
});
|
|
49
|
+
}, [api, side]);
|
|
50
|
+
if (!canInsertColumn) {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
|
|
54
|
+
elemBefore: /*#__PURE__*/React.createElement(Icon, {
|
|
55
|
+
color: "currentColor",
|
|
56
|
+
label: "",
|
|
57
|
+
size: "small"
|
|
58
|
+
}),
|
|
59
|
+
onClick: onClick
|
|
60
|
+
}, formatMessage(label));
|
|
61
|
+
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import React, { useCallback } from 'react';
|
|
1
|
+
import React, { useCallback, useMemo } from 'react';
|
|
2
2
|
import { useIntl } from 'react-intl';
|
|
3
3
|
import { ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
|
|
4
|
-
import {
|
|
4
|
+
import { getLayoutColumnValign } from './layoutColumnSelection';
|
|
5
|
+
import { useCurrentLayoutColumn } from './useCurrentLayoutColumn';
|
|
5
6
|
import { VERTICAL_ALIGN_ICONS } from './verticalAlignIcons';
|
|
6
7
|
export var VerticalAlignDropdownItem = function VerticalAlignDropdownItem(_ref) {
|
|
7
8
|
var api = _ref.api,
|
|
@@ -9,24 +10,21 @@ export var VerticalAlignDropdownItem = function VerticalAlignDropdownItem(_ref)
|
|
|
9
10
|
value = _ref.value;
|
|
10
11
|
var _useIntl = useIntl(),
|
|
11
12
|
formatMessage = _useIntl.formatMessage;
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
var currentColumn = useCurrentLayoutColumn(api);
|
|
14
|
+
var currentValign = useMemo(function () {
|
|
15
|
+
return getLayoutColumnValign(currentColumn);
|
|
16
|
+
}, [currentColumn]);
|
|
15
17
|
var Icon = VERTICAL_ALIGN_ICONS[value];
|
|
16
18
|
var onClick = useCallback(function () {
|
|
17
19
|
var _api$core, _api$layout;
|
|
18
20
|
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(api === null || api === void 0 || (_api$layout = api.layout) === null || _api$layout === void 0 ? void 0 : _api$layout.commands.setLayoutColumnValign(value));
|
|
19
21
|
}, [api, value]);
|
|
20
|
-
if (!selectedColumn) {
|
|
21
|
-
return null;
|
|
22
|
-
}
|
|
23
22
|
return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
|
|
24
23
|
elemBefore: /*#__PURE__*/React.createElement(Icon, {
|
|
25
24
|
label: "",
|
|
26
25
|
size: "small"
|
|
27
26
|
}),
|
|
28
27
|
isSelected: currentValign === value,
|
|
29
|
-
onClick: onClick
|
|
30
|
-
testId: "layout-column-align-".concat(value)
|
|
28
|
+
onClick: onClick
|
|
31
29
|
}, formatMessage(label));
|
|
32
30
|
};
|
|
@@ -1,19 +1,21 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
2
|
import { useIntl } from 'react-intl';
|
|
3
3
|
import { layoutMessages } from '@atlaskit/editor-common/messages';
|
|
4
4
|
import { LayoutIcon, NestedDropdownRightIcon, ToolbarNestedDropdownMenu } from '@atlaskit/editor-toolbar';
|
|
5
|
-
import {
|
|
5
|
+
import { getLayoutColumnValign } from './layoutColumnSelection';
|
|
6
|
+
import { useCurrentLayoutColumn } from './useCurrentLayoutColumn';
|
|
6
7
|
import { VERTICAL_ALIGN_ICONS } from './verticalAlignIcons';
|
|
7
8
|
export var VerticalAlignNestedMenu = function VerticalAlignNestedMenu(_ref) {
|
|
8
9
|
var api = _ref.api,
|
|
9
10
|
children = _ref.children;
|
|
10
11
|
var _useIntl = useIntl(),
|
|
11
12
|
formatMessage = _useIntl.formatMessage;
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
var currentColumn = useCurrentLayoutColumn(api);
|
|
14
|
+
var currentValign = useMemo(function () {
|
|
15
|
+
return getLayoutColumnValign(currentColumn);
|
|
16
|
+
}, [currentColumn]);
|
|
15
17
|
var TriggerIcon = currentValign ? VERTICAL_ALIGN_ICONS[currentValign] : LayoutIcon;
|
|
16
|
-
if (!
|
|
18
|
+
if (!currentColumn) {
|
|
17
19
|
return null;
|
|
18
20
|
}
|
|
19
21
|
return /*#__PURE__*/React.createElement(ToolbarNestedDropdownMenu, {
|
|
@@ -25,8 +27,6 @@ export var VerticalAlignNestedMenu = function VerticalAlignNestedMenu(_ref) {
|
|
|
25
27
|
label: "",
|
|
26
28
|
size: "small"
|
|
27
29
|
}),
|
|
28
|
-
text: formatMessage(layoutMessages.alignColumn)
|
|
29
|
-
testId: "layout-column-align-menu",
|
|
30
|
-
dropdownTestId: "layout-column-align-dropdown"
|
|
30
|
+
text: formatMessage(layoutMessages.alignColumn)
|
|
31
31
|
}, children);
|
|
32
32
|
};
|
|
@@ -5,8 +5,10 @@ import React from 'react';
|
|
|
5
5
|
import { layoutMessages } from '@atlaskit/editor-common/messages';
|
|
6
6
|
import { ToolbarDropdownItemSection } from '@atlaskit/editor-toolbar';
|
|
7
7
|
import { ToolbarMenuContainer } from '@atlaskit/editor-toolbar/toolbar-menu-container';
|
|
8
|
+
import { DeleteColumnDropdownItem } from './DeleteColumnDropdownItem';
|
|
8
9
|
import { createDistributeColumnsDropdownItem } from './DistributeColumnsDropdownItem';
|
|
9
|
-
import {
|
|
10
|
+
import { InsertColumnDropdownItem } from './InsertColumnDropdownItem';
|
|
11
|
+
import { DELETE_COLUMN_MENU_ITEM, DISTRIBUTE_COLUMNS_MENU_ITEM, INSERT_COLUMN_LEFT_MENU_ITEM, INSERT_COLUMN_RIGHT_MENU_ITEM, LAYOUT_COLUMN_MENU, LAYOUT_COLUMN_MENU_RANK, LAYOUT_COLUMN_MENU_SECTION, LAYOUT_COLUMN_MENU_SECTION_RANK, LAYOUT_COLUMN_VERTICAL_ALIGN_MENU_SECTION, VERTICAL_ALIGN_BOTTOM_MENU_ITEM, VERTICAL_ALIGN_MENU, VERTICAL_ALIGN_MENU_RANK, VERTICAL_ALIGN_MENU_SECTION_RANK, VERTICAL_ALIGN_MIDDLE_MENU_ITEM, VERTICAL_ALIGN_TOP_MENU_ITEM } from './keys';
|
|
10
12
|
import { VerticalAlignDropdownItem } from './VerticalAlignDropdownItem';
|
|
11
13
|
import { VerticalAlignNestedMenu } from './VerticalAlignNestedMenu';
|
|
12
14
|
export var LAYOUT_COLUMN_MENU_FALLBACKS = {
|
|
@@ -23,11 +25,40 @@ export var getLayoutColumnMenuComponents = function getLayoutColumnMenuComponent
|
|
|
23
25
|
parents: [_objectSpread(_objectSpread({}, LAYOUT_COLUMN_MENU), {}, {
|
|
24
26
|
rank: LAYOUT_COLUMN_MENU_RANK[LAYOUT_COLUMN_MENU_SECTION.key]
|
|
25
27
|
})]
|
|
28
|
+
}), _objectSpread(_objectSpread({}, INSERT_COLUMN_LEFT_MENU_ITEM), {}, {
|
|
29
|
+
component: function component() {
|
|
30
|
+
return /*#__PURE__*/React.createElement(InsertColumnDropdownItem, {
|
|
31
|
+
api: api,
|
|
32
|
+
side: "left"
|
|
33
|
+
});
|
|
34
|
+
},
|
|
35
|
+
parents: [_objectSpread(_objectSpread({}, LAYOUT_COLUMN_MENU_SECTION), {}, {
|
|
36
|
+
rank: LAYOUT_COLUMN_MENU_SECTION_RANK[INSERT_COLUMN_LEFT_MENU_ITEM.key]
|
|
37
|
+
})]
|
|
38
|
+
}), _objectSpread(_objectSpread({}, INSERT_COLUMN_RIGHT_MENU_ITEM), {}, {
|
|
39
|
+
component: function component() {
|
|
40
|
+
return /*#__PURE__*/React.createElement(InsertColumnDropdownItem, {
|
|
41
|
+
api: api,
|
|
42
|
+
side: "right"
|
|
43
|
+
});
|
|
44
|
+
},
|
|
45
|
+
parents: [_objectSpread(_objectSpread({}, LAYOUT_COLUMN_MENU_SECTION), {}, {
|
|
46
|
+
rank: LAYOUT_COLUMN_MENU_SECTION_RANK[INSERT_COLUMN_RIGHT_MENU_ITEM.key]
|
|
47
|
+
})]
|
|
26
48
|
}), _objectSpread(_objectSpread({}, DISTRIBUTE_COLUMNS_MENU_ITEM), {}, {
|
|
27
49
|
component: createDistributeColumnsDropdownItem(api),
|
|
28
50
|
parents: [_objectSpread(_objectSpread({}, LAYOUT_COLUMN_MENU_SECTION), {}, {
|
|
29
51
|
rank: LAYOUT_COLUMN_MENU_SECTION_RANK[DISTRIBUTE_COLUMNS_MENU_ITEM.key]
|
|
30
52
|
})]
|
|
53
|
+
}), _objectSpread(_objectSpread({}, DELETE_COLUMN_MENU_ITEM), {}, {
|
|
54
|
+
component: function component() {
|
|
55
|
+
return /*#__PURE__*/React.createElement(DeleteColumnDropdownItem, {
|
|
56
|
+
api: api
|
|
57
|
+
});
|
|
58
|
+
},
|
|
59
|
+
parents: [_objectSpread(_objectSpread({}, LAYOUT_COLUMN_MENU_SECTION), {}, {
|
|
60
|
+
rank: LAYOUT_COLUMN_MENU_SECTION_RANK[DELETE_COLUMN_MENU_ITEM.key]
|
|
61
|
+
})]
|
|
31
62
|
}), _objectSpread(_objectSpread({}, VERTICAL_ALIGN_MENU), {}, {
|
|
32
63
|
component: function component(_ref3) {
|
|
33
64
|
var children = _ref3.children;
|
|
@@ -1,25 +1,34 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
import React, { useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef } from 'react';
|
|
2
3
|
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
4
|
+
import { DRAG_HANDLE_SELECTOR } from '@atlaskit/editor-common/styles';
|
|
3
5
|
import { EditorToolbarProvider } from '@atlaskit/editor-common/toolbar';
|
|
4
6
|
import { Popup } from '@atlaskit/editor-common/ui';
|
|
5
7
|
import { OutsideClickTargetRefContext, withReactEditorViewOuterListeners } from '@atlaskit/editor-common/ui-react';
|
|
6
|
-
import {
|
|
7
|
-
import { akEditorFloatingPanelZIndex } from '@atlaskit/editor-shared-styles';
|
|
8
|
+
import { akEditorFloatingOverlapPanelZIndex } from '@atlaskit/editor-shared-styles';
|
|
8
9
|
import { ToolbarDropdownMenuProvider } from '@atlaskit/editor-toolbar';
|
|
9
10
|
import { SurfaceRenderer } from '@atlaskit/editor-ui-control-model';
|
|
10
11
|
import { LAYOUT_COLUMN_MENU_FALLBACKS } from './components';
|
|
11
12
|
import { LAYOUT_COLUMN_MENU } from './keys';
|
|
13
|
+
import { getLayoutColumnAtSelection } from './layoutColumnSelection';
|
|
12
14
|
var PopupWithListeners = withReactEditorViewOuterListeners(Popup);
|
|
13
|
-
var
|
|
14
|
-
var
|
|
15
|
-
|
|
15
|
+
var FALLBACK_MENU_HEIGHT = 300;
|
|
16
|
+
var LAYOUT_COLUMN_MENU_POPUP_OFFSET = [0, 4];
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Returns the drag handle button for the selected layout column.
|
|
20
|
+
*/
|
|
21
|
+
var getLayoutColumnMenuTarget = function getLayoutColumnMenuTarget(editorView, selection) {
|
|
22
|
+
var _columnDomRef$parentE;
|
|
23
|
+
if (!getLayoutColumnAtSelection(selection) || (selection === null || selection === void 0 ? void 0 : selection.from) === undefined) {
|
|
16
24
|
return null;
|
|
17
25
|
}
|
|
18
|
-
var
|
|
19
|
-
if ((
|
|
26
|
+
var columnDomRef = editorView.nodeDOM(selection.from);
|
|
27
|
+
if (!(columnDomRef instanceof HTMLElement)) {
|
|
20
28
|
return null;
|
|
21
29
|
}
|
|
22
|
-
|
|
30
|
+
var dragHandleContainer = (_columnDomRef$parentE = columnDomRef.parentElement) === null || _columnDomRef$parentE === void 0 ? void 0 : _columnDomRef$parentE.querySelector(':scope > [data-blocks-drag-handle-container]');
|
|
31
|
+
return dragHandleContainer === null || dragHandleContainer === void 0 ? void 0 : dragHandleContainer.querySelector(DRAG_HANDLE_SELECTOR);
|
|
23
32
|
};
|
|
24
33
|
export var LayoutColumnMenu = /*#__PURE__*/React.memo(function LayoutColumnMenu(_ref) {
|
|
25
34
|
var _api$uiControlRegistr, _api$uiControlRegistr2;
|
|
@@ -39,6 +48,18 @@ export var LayoutColumnMenu = /*#__PURE__*/React.memo(function LayoutColumnMenu(
|
|
|
39
48
|
selection = _useSharedPluginState.selection;
|
|
40
49
|
var setOutsideClickTargetRef = useContext(OutsideClickTargetRefContext);
|
|
41
50
|
var menuRef = useRef(null);
|
|
51
|
+
var popupRef = useRef(undefined);
|
|
52
|
+
var _React$useState = React.useState(FALLBACK_MENU_HEIGHT),
|
|
53
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
54
|
+
menuHeight = _React$useState2[0],
|
|
55
|
+
setMenuHeight = _React$useState2[1];
|
|
56
|
+
useLayoutEffect(function () {
|
|
57
|
+
var _popupRef$current;
|
|
58
|
+
if (!isLayoutColumnMenuOpen) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
setMenuHeight(((_popupRef$current = popupRef.current) === null || _popupRef$current === void 0 ? void 0 : _popupRef$current.clientHeight) || FALLBACK_MENU_HEIGHT);
|
|
62
|
+
}, [isLayoutColumnMenuOpen]);
|
|
42
63
|
var closeLayoutColumnMenu = useCallback(function () {
|
|
43
64
|
var _api$core, _api$layout;
|
|
44
65
|
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(api === null || api === void 0 || (_api$layout = api.layout) === null || _api$layout === void 0 ? void 0 : _api$layout.commands.toggleLayoutColumnMenu({
|
|
@@ -63,9 +84,14 @@ export var LayoutColumnMenu = /*#__PURE__*/React.memo(function LayoutColumnMenu(
|
|
|
63
84
|
var handleMenuRef = useCallback(function (el) {
|
|
64
85
|
setOutsideClickTargetRef === null || setOutsideClickTargetRef === void 0 || setOutsideClickTargetRef(el);
|
|
65
86
|
menuRef.current = el;
|
|
87
|
+
if (el) {
|
|
88
|
+
popupRef.current = el;
|
|
89
|
+
}
|
|
66
90
|
}, [setOutsideClickTargetRef]);
|
|
67
91
|
var components = (_api$uiControlRegistr = api === null || api === 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 : [];
|
|
68
|
-
var target =
|
|
92
|
+
var target = useMemo(function () {
|
|
93
|
+
return isLayoutColumnMenuOpen ? getLayoutColumnMenuTarget(editorView, selection) : null;
|
|
94
|
+
}, [editorView, isLayoutColumnMenuOpen, selection]);
|
|
69
95
|
var hasValidTarget = target instanceof HTMLElement;
|
|
70
96
|
useEffect(function () {
|
|
71
97
|
if (isLayoutColumnMenuOpen && (!hasValidTarget || components.length === 0)) {
|
|
@@ -80,10 +106,11 @@ export var LayoutColumnMenu = /*#__PURE__*/React.memo(function LayoutColumnMenu(
|
|
|
80
106
|
mountTo: mountTo,
|
|
81
107
|
boundariesElement: boundariesElement,
|
|
82
108
|
scrollableElement: scrollableElement,
|
|
83
|
-
zIndex:
|
|
109
|
+
zIndex: akEditorFloatingOverlapPanelZIndex,
|
|
84
110
|
alignX: "center",
|
|
85
|
-
|
|
86
|
-
|
|
111
|
+
fitHeight: menuHeight,
|
|
112
|
+
preventOverflow: true,
|
|
113
|
+
stick: true,
|
|
87
114
|
offset: LAYOUT_COLUMN_MENU_POPUP_OFFSET,
|
|
88
115
|
handleClickOutside: handleClickOutside,
|
|
89
116
|
handleEscapeKeydown: closeLayoutColumnMenu
|
|
@@ -27,6 +27,14 @@ export var VERTICAL_ALIGN_MENU = {
|
|
|
27
27
|
|
|
28
28
|
// --- Items ---
|
|
29
29
|
|
|
30
|
+
export var INSERT_COLUMN_LEFT_MENU_ITEM = {
|
|
31
|
+
type: 'menu-item',
|
|
32
|
+
key: 'layout-column-menu-insert-left-item'
|
|
33
|
+
};
|
|
34
|
+
export var INSERT_COLUMN_RIGHT_MENU_ITEM = {
|
|
35
|
+
type: 'menu-item',
|
|
36
|
+
key: 'layout-column-menu-insert-right-item'
|
|
37
|
+
};
|
|
30
38
|
export var DISTRIBUTE_COLUMNS_MENU_ITEM = {
|
|
31
39
|
type: 'menu-item',
|
|
32
40
|
key: 'layout-column-menu-distribute-columns-item'
|
|
@@ -43,9 +51,13 @@ export var VERTICAL_ALIGN_BOTTOM_MENU_ITEM = {
|
|
|
43
51
|
type: 'menu-item',
|
|
44
52
|
key: 'layout-column-menu-vertical-align-bottom-item'
|
|
45
53
|
};
|
|
54
|
+
export var DELETE_COLUMN_MENU_ITEM = {
|
|
55
|
+
type: 'menu-item',
|
|
56
|
+
key: 'layout-column-menu-delete-item'
|
|
57
|
+
};
|
|
46
58
|
|
|
47
59
|
// --- Item ranks within sections ---
|
|
48
60
|
|
|
49
|
-
export var LAYOUT_COLUMN_MENU_SECTION_RANK = _defineProperty(_defineProperty({},
|
|
61
|
+
export var LAYOUT_COLUMN_MENU_SECTION_RANK = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, VERTICAL_ALIGN_MENU.key, 100), INSERT_COLUMN_LEFT_MENU_ITEM.key, 200), INSERT_COLUMN_RIGHT_MENU_ITEM.key, 300), DISTRIBUTE_COLUMNS_MENU_ITEM.key, 400), DELETE_COLUMN_MENU_ITEM.key, 500);
|
|
50
62
|
export var VERTICAL_ALIGN_MENU_RANK = _defineProperty({}, LAYOUT_COLUMN_VERTICAL_ALIGN_MENU_SECTION.key, 100);
|
|
51
63
|
export var VERTICAL_ALIGN_MENU_SECTION_RANK = _defineProperty(_defineProperty(_defineProperty({}, VERTICAL_ALIGN_TOP_MENU_ITEM.key, 100), VERTICAL_ALIGN_MIDDLE_MENU_ITEM.key, 200), VERTICAL_ALIGN_BOTTOM_MENU_ITEM.key, 300);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
+
export var getLayoutColumnAtSelection = function getLayoutColumnAtSelection(selection) {
|
|
3
|
+
return selection instanceof NodeSelection && selection.node.type.name === 'layoutColumn' ? selection.node : undefined;
|
|
4
|
+
};
|
|
5
|
+
export var getLayoutSectionAtSelection = function getLayoutSectionAtSelection(selection) {
|
|
6
|
+
var selectedColumn = getLayoutColumnAtSelection(selection);
|
|
7
|
+
var parent = selectedColumn ? selection === null || selection === void 0 ? void 0 : selection.$from.parent : undefined;
|
|
8
|
+
return (parent === null || parent === void 0 ? void 0 : parent.type.name) === 'layoutSection' ? parent : undefined;
|
|
9
|
+
};
|
|
10
|
+
export var getLayoutSectionColumnCount = function getLayoutSectionColumnCount(layoutSection) {
|
|
11
|
+
return (layoutSection === null || layoutSection === void 0 ? void 0 : layoutSection.type.name) === 'layoutSection' ? layoutSection.childCount : 0;
|
|
12
|
+
};
|
|
13
|
+
export var getLayoutColumnValign = function getLayoutColumnValign(layoutColumn) {
|
|
14
|
+
return layoutColumn === null || layoutColumn === void 0 ? void 0 : layoutColumn.attrs.valign;
|
|
15
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
2
|
+
import { getLayoutColumnAtSelection, getLayoutSectionAtSelection } from './layoutColumnSelection';
|
|
3
|
+
export var useCurrentLayoutColumn = function useCurrentLayoutColumn(api) {
|
|
4
|
+
return useSharedPluginStateWithSelector(api, ['selection'], function (states) {
|
|
5
|
+
var _states$selectionStat;
|
|
6
|
+
return getLayoutColumnAtSelection((_states$selectionStat = states.selectionState) === null || _states$selectionStat === void 0 ? void 0 : _states$selectionStat.selection);
|
|
7
|
+
});
|
|
8
|
+
};
|
|
9
|
+
export var useCurrentLayoutSection = function useCurrentLayoutSection(api) {
|
|
10
|
+
return useSharedPluginStateWithSelector(api, ['selection'], function (states) {
|
|
11
|
+
var _states$selectionStat2;
|
|
12
|
+
return getLayoutSectionAtSelection((_states$selectionStat2 = states.selectionState) === null || _states$selectionStat2 === void 0 ? void 0 : _states$selectionStat2.selection);
|
|
13
|
+
});
|
|
14
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
1
|
+
import type { EditorCommand, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
2
2
|
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
3
3
|
import type { BlockMenuPlugin } from '@atlaskit/editor-plugin-block-menu';
|
|
4
4
|
import type { DecorationsPlugin } from '@atlaskit/editor-plugin-decorations';
|
|
@@ -9,7 +9,7 @@ import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
|
|
|
9
9
|
import type { ToolbarPlugin } from '@atlaskit/editor-plugin-toolbar';
|
|
10
10
|
import type { UiControlRegistryPlugin } from '@atlaskit/editor-plugin-ui-control-registry';
|
|
11
11
|
import type { WidthPlugin } from '@atlaskit/editor-plugin-width';
|
|
12
|
-
import type { insertLayoutColumnsWithAnalytics, setLayoutColumnValign, toggleLayoutColumnMenu } from './pm-plugins/actions';
|
|
12
|
+
import type { deleteLayoutColumn, InsertLayoutColumnSide, insertLayoutColumnsWithAnalytics, setLayoutColumnValign, toggleLayoutColumnMenu } from './pm-plugins/actions';
|
|
13
13
|
import type { LayoutState } from './pm-plugins/types';
|
|
14
14
|
import type { LayoutPluginOptions } from './types';
|
|
15
15
|
export type LayoutPluginDependencies = [
|
|
@@ -29,6 +29,8 @@ export type LayoutPlugin = NextEditorPlugin<'layout', {
|
|
|
29
29
|
insertLayoutColumns: ReturnType<typeof insertLayoutColumnsWithAnalytics>;
|
|
30
30
|
};
|
|
31
31
|
commands: {
|
|
32
|
+
deleteLayoutColumn: ReturnType<typeof deleteLayoutColumn>;
|
|
33
|
+
insertLayoutColumn: (side: InsertLayoutColumnSide) => EditorCommand;
|
|
32
34
|
setLayoutColumnValign: typeof setLayoutColumnValign;
|
|
33
35
|
toggleLayoutColumnMenu: typeof toggleLayoutColumnMenu;
|
|
34
36
|
};
|
|
@@ -27,7 +27,14 @@ export declare const setPresetLayout: (editorAnalyticsAPI: EditorAnalyticsAPI |
|
|
|
27
27
|
export declare const fixColumnSizes: (changedTr: Transaction, state: EditorState) => Change | undefined;
|
|
28
28
|
export declare const fixColumnStructure: (state: EditorState) => Transaction | undefined;
|
|
29
29
|
export declare const deleteActiveLayoutNode: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, inputMethod?: INPUT_METHOD.FLOATING_TB) => Command;
|
|
30
|
+
export type InsertLayoutColumnSide = 'left' | 'right';
|
|
31
|
+
/**
|
|
32
|
+
* Returns the active maximum layout column count for the current advanced layouts experiment state.
|
|
33
|
+
*/
|
|
34
|
+
export declare function getEffectiveMaxLayoutColumns(): number;
|
|
35
|
+
export declare const insertLayoutColumn: (side: InsertLayoutColumnSide, editorAnalyticsAPI?: EditorAnalyticsAPI) => EditorCommand;
|
|
30
36
|
export declare const setLayoutColumnValign: (valign: Valign) => EditorCommand;
|
|
31
37
|
export declare const toggleLayoutColumnMenu: ({ isOpen }: {
|
|
32
38
|
isOpen?: boolean;
|
|
33
39
|
}) => EditorCommand;
|
|
40
|
+
export declare const deleteLayoutColumn: (editorAnalyticsAPI?: EditorAnalyticsAPI) => EditorCommand;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
|
+
import type { LayoutPlugin } from '../../layoutPluginType';
|
|
4
|
+
type DeleteColumnDropdownItemProps = {
|
|
5
|
+
api: ExtractInjectionAPI<LayoutPlugin> | undefined;
|
|
6
|
+
};
|
|
7
|
+
declare const DeleteColumnDropdownItem: ({ api, }: DeleteColumnDropdownItemProps) => React.JSX.Element | null;
|
|
8
|
+
export { DeleteColumnDropdownItem };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
|
+
import type { LayoutPlugin } from '../../layoutPluginType';
|
|
4
|
+
import { type InsertLayoutColumnSide } from '../../pm-plugins/actions';
|
|
5
|
+
type InsertColumnDropdownItemProps = {
|
|
6
|
+
api: ExtractInjectionAPI<LayoutPlugin> | undefined;
|
|
7
|
+
side: InsertLayoutColumnSide;
|
|
8
|
+
};
|
|
9
|
+
export declare const InsertColumnDropdownItem: ({ api, side, }: InsertColumnDropdownItemProps) => React.JSX.Element | null;
|
|
10
|
+
export {};
|
|
@@ -4,10 +4,13 @@ export declare const LAYOUT_COLUMN_MENU_SECTION: MenuSectionType;
|
|
|
4
4
|
export declare const LAYOUT_COLUMN_VERTICAL_ALIGN_MENU_SECTION: MenuSectionType;
|
|
5
5
|
export declare const LAYOUT_COLUMN_MENU_RANK: Record<string, number>;
|
|
6
6
|
export declare const VERTICAL_ALIGN_MENU: NestedMenuType;
|
|
7
|
+
export declare const INSERT_COLUMN_LEFT_MENU_ITEM: MenuItemType;
|
|
8
|
+
export declare const INSERT_COLUMN_RIGHT_MENU_ITEM: MenuItemType;
|
|
7
9
|
export declare const DISTRIBUTE_COLUMNS_MENU_ITEM: MenuItemType;
|
|
8
10
|
export declare const VERTICAL_ALIGN_TOP_MENU_ITEM: MenuItemType;
|
|
9
11
|
export declare const VERTICAL_ALIGN_MIDDLE_MENU_ITEM: MenuItemType;
|
|
10
12
|
export declare const VERTICAL_ALIGN_BOTTOM_MENU_ITEM: MenuItemType;
|
|
13
|
+
export declare const DELETE_COLUMN_MENU_ITEM: MenuItemType;
|
|
11
14
|
export declare const LAYOUT_COLUMN_MENU_SECTION_RANK: Record<string, number>;
|
|
12
15
|
export declare const VERTICAL_ALIGN_MENU_RANK: Record<string, number>;
|
|
13
16
|
export declare const VERTICAL_ALIGN_MENU_SECTION_RANK: Record<string, number>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Valign } from '@atlaskit/editor-common/types/valign';
|
|
2
|
+
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
3
|
+
import type { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
+
export declare const getLayoutColumnAtSelection: (selection: Selection | undefined) => PMNode | undefined;
|
|
5
|
+
export declare const getLayoutSectionAtSelection: (selection: Selection | undefined) => PMNode | undefined;
|
|
6
|
+
export declare const getLayoutSectionColumnCount: (layoutSection: PMNode | undefined) => number;
|
|
7
|
+
export declare const getLayoutColumnValign: (layoutColumn: PMNode | undefined) => Valign | undefined;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
2
|
+
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
3
|
+
import type { LayoutPlugin } from '../../layoutPluginType';
|
|
4
|
+
export declare const useCurrentLayoutColumn: (api: ExtractInjectionAPI<LayoutPlugin> | undefined) => PMNode | undefined;
|
|
5
|
+
export declare const useCurrentLayoutSection: (api: ExtractInjectionAPI<LayoutPlugin> | undefined) => PMNode | undefined;
|