@atlaskit/editor-plugin-layout 10.6.1 → 10.7.1
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 +18 -0
- package/dist/cjs/layoutPlugin.js +8 -4
- package/dist/cjs/pm-plugins/actions.js +82 -8
- package/dist/cjs/ui/LayoutColumnMenu/DistributeColumnsDropdownItem.js +47 -17
- package/dist/cjs/ui/LayoutColumnMenu/components.js +5 -1
- package/dist/es2019/layoutPlugin.js +9 -5
- package/dist/es2019/pm-plugins/actions.js +68 -0
- package/dist/es2019/ui/LayoutColumnMenu/DistributeColumnsDropdownItem.js +38 -13
- package/dist/es2019/ui/LayoutColumnMenu/components.js +4 -2
- package/dist/esm/layoutPlugin.js +9 -5
- package/dist/esm/pm-plugins/actions.js +81 -7
- package/dist/esm/ui/LayoutColumnMenu/DistributeColumnsDropdownItem.js +44 -15
- package/dist/esm/ui/LayoutColumnMenu/components.js +6 -2
- package/dist/types/layoutPluginType.d.ts +2 -1
- package/dist/types/pm-plugins/actions.d.ts +1 -0
- package/dist/types/ui/LayoutColumnMenu/DistributeColumnsDropdownItem.d.ts +5 -1
- package/dist/types-ts4.5/layoutPluginType.d.ts +2 -1
- package/dist/types-ts4.5/pm-plugins/actions.d.ts +1 -0
- package/dist/types-ts4.5/ui/LayoutColumnMenu/DistributeColumnsDropdownItem.d.ts +5 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-layout
|
|
2
2
|
|
|
3
|
+
## 10.7.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 10.7.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [`6767563047c0e`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/6767563047c0e) -
|
|
14
|
+
Add distributeLayoutColumns command that equalises widths of selected layout columns; wire into
|
|
15
|
+
drag-handle column menu and floating toolbar
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Updated dependencies
|
|
20
|
+
|
|
3
21
|
## 10.6.1
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/dist/cjs/layoutPlugin.js
CHANGED
|
@@ -381,13 +381,17 @@ var layoutPlugin = exports.layoutPlugin = function layoutPlugin(_ref) {
|
|
|
381
381
|
var _api$analytics4;
|
|
382
382
|
return (0, _actions.deleteLayoutColumn)(api === null || api === void 0 || (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions)(props);
|
|
383
383
|
},
|
|
384
|
-
|
|
384
|
+
distributeLayoutColumns: function distributeLayoutColumns(props) {
|
|
385
385
|
var _api$analytics5;
|
|
386
|
-
return (0, _actions.
|
|
386
|
+
return (0, _actions.distributeLayoutColumns)(api === null || api === void 0 || (_api$analytics5 = api.analytics) === null || _api$analytics5 === void 0 ? void 0 : _api$analytics5.actions)(props);
|
|
387
387
|
},
|
|
388
|
-
|
|
388
|
+
insertLayoutColumn: function insertLayoutColumn(side) {
|
|
389
389
|
var _api$analytics6;
|
|
390
|
-
return (0, _actions.
|
|
390
|
+
return (0, _actions.insertLayoutColumn)(side, api === null || api === void 0 || (_api$analytics6 = api.analytics) === null || _api$analytics6 === void 0 ? void 0 : _api$analytics6.actions);
|
|
391
|
+
},
|
|
392
|
+
setLayoutColumnValign: function setLayoutColumnValign(valign) {
|
|
393
|
+
var _api$analytics7;
|
|
394
|
+
return (0, _actions.setLayoutColumnValign)(valign, api === null || api === void 0 || (_api$analytics7 = api.analytics) === null || _api$analytics7 === void 0 ? void 0 : _api$analytics7.actions);
|
|
391
395
|
},
|
|
392
396
|
toggleLayoutColumnMenu: _actions.toggleLayoutColumnMenu
|
|
393
397
|
}
|
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.fixColumnStructure = exports.fixColumnSizes = exports.deleteLayoutColumn = exports.deleteActiveLayoutNode = exports.createMultiColumnLayoutSection = exports.createDefaultLayoutSection = exports.TWO_COL_LAYOUTS = exports.THREE_COL_LAYOUTS = exports.ONE_COL_LAYOUTS = void 0;
|
|
7
|
+
exports.fixColumnStructure = exports.fixColumnSizes = exports.distributeLayoutColumns = exports.deleteLayoutColumn = exports.deleteActiveLayoutNode = exports.createMultiColumnLayoutSection = exports.createDefaultLayoutSection = exports.TWO_COL_LAYOUTS = exports.THREE_COL_LAYOUTS = exports.ONE_COL_LAYOUTS = void 0;
|
|
8
8
|
exports.forceSectionToPresetLayout = forceSectionToPresetLayout;
|
|
9
9
|
exports.getEffectiveMaxLayoutColumns = getEffectiveMaxLayoutColumns;
|
|
10
10
|
exports.toggleLayoutColumnMenu = exports.setPresetLayout = exports.setLayoutColumnValign = exports.insertLayoutColumnsWithAnalytics = exports.insertLayoutColumns = exports.insertLayoutColumn = exports.getSelectedLayout = exports.getPresetLayout = void 0;
|
|
@@ -675,11 +675,85 @@ var setLayoutColumnValign = exports.setLayoutColumnValign = function setLayoutCo
|
|
|
675
675
|
return tr;
|
|
676
676
|
};
|
|
677
677
|
};
|
|
678
|
-
var
|
|
679
|
-
var
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
678
|
+
var distributeLayoutColumns = exports.distributeLayoutColumns = function distributeLayoutColumns(editorAnalyticsAPI) {
|
|
679
|
+
var inputMethod = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _analytics.INPUT_METHOD.LAYOUT_COLUMN_MENU;
|
|
680
|
+
return function (_ref8) {
|
|
681
|
+
var tr = _ref8.tr;
|
|
682
|
+
if (!(0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_layout_column_menu', 'isEnabled', true)) {
|
|
683
|
+
return null;
|
|
684
|
+
}
|
|
685
|
+
var selectedLayoutColumns = (0, _layoutColumnSelection.getSelectedLayoutColumns)(tr.selection);
|
|
686
|
+
if (!selectedLayoutColumns || selectedLayoutColumns.selectedColumns.length < 2) {
|
|
687
|
+
return null;
|
|
688
|
+
}
|
|
689
|
+
var layoutSectionNode = selectedLayoutColumns.layoutSectionNode,
|
|
690
|
+
layoutSectionPos = selectedLayoutColumns.layoutSectionPos,
|
|
691
|
+
selectedColumnIndices = selectedLayoutColumns.selectedColumnIndices,
|
|
692
|
+
selectedColumns = selectedLayoutColumns.selectedColumns;
|
|
693
|
+
var endIndex = selectedColumnIndices[selectedColumnIndices.length - 1];
|
|
694
|
+
var selectedColumnCount = selectedColumns.length;
|
|
695
|
+
var totalColumnCount = layoutSectionNode.childCount;
|
|
696
|
+
|
|
697
|
+
// Compute equal width for selected columns
|
|
698
|
+
var existingWidths = (0, _utils.mapChildren)(layoutSectionNode, function (column) {
|
|
699
|
+
return column.attrs.width;
|
|
700
|
+
});
|
|
701
|
+
var selectedTotal = selectedColumnIndices.reduce(function (sum, idx) {
|
|
702
|
+
return sum + existingWidths[idx];
|
|
703
|
+
}, 0);
|
|
704
|
+
var equalWidth = selectedTotal / selectedColumnCount;
|
|
705
|
+
|
|
706
|
+
// Early return if selected columns are already uniformly distributed — avoids spurious undo entry.
|
|
707
|
+
if (selectedColumnIndices.every(function (idx) {
|
|
708
|
+
return existingWidths[idx] === Number(equalWidth.toFixed(2));
|
|
709
|
+
})) {
|
|
710
|
+
return null;
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
// Build new widths array: selected columns get equal share, unselected unchanged.
|
|
714
|
+
// Assign truncated (2dp) equal widths to all selected cols except the last, which absorbs
|
|
715
|
+
// the rounding remainder so the sum of selected widths equals selectedTotal exactly.
|
|
716
|
+
var selectedIndexSet = new Set(selectedColumnIndices);
|
|
717
|
+
var assignedToSelected = 0;
|
|
718
|
+
var selectedAssignedCount = 0;
|
|
719
|
+
var newWidths = existingWidths.map(function (w, idx) {
|
|
720
|
+
if (!selectedIndexSet.has(idx)) {
|
|
721
|
+
return w;
|
|
722
|
+
}
|
|
723
|
+
selectedAssignedCount += 1;
|
|
724
|
+
if (selectedAssignedCount < selectedColumnCount) {
|
|
725
|
+
var truncated = Number(equalWidth.toFixed(2));
|
|
726
|
+
assignedToSelected += truncated;
|
|
727
|
+
return truncated;
|
|
728
|
+
}
|
|
729
|
+
// Last selected column: absorb the remainder to avoid drift
|
|
730
|
+
return Number((selectedTotal - assignedToSelected).toFixed(2));
|
|
731
|
+
});
|
|
732
|
+
|
|
733
|
+
// Apply widths via replaceWith (mirroring forceColumnWidths approach)
|
|
734
|
+
tr.replaceWith(layoutSectionPos + 1, layoutSectionPos + layoutSectionNode.nodeSize - 1, columnWidth(layoutSectionNode, tr.doc.type.schema, newWidths));
|
|
735
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent({
|
|
736
|
+
action: _analytics.ACTION.UPDATED,
|
|
737
|
+
actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
|
|
738
|
+
actionSubjectId: _analytics.ACTION_SUBJECT_ID.LAYOUT_COLUMN,
|
|
739
|
+
attributes: {
|
|
740
|
+
columnCount: totalColumnCount,
|
|
741
|
+
endIndex: endIndex,
|
|
742
|
+
inputMethod: inputMethod,
|
|
743
|
+
selectedCount: selectedColumnCount,
|
|
744
|
+
startIndex: selectedColumnIndices[0]
|
|
745
|
+
},
|
|
746
|
+
eventType: _analytics.EVENT_TYPE.TRACK
|
|
747
|
+
})(tr);
|
|
748
|
+
tr.setMeta('scrollIntoView', false);
|
|
749
|
+
return tr;
|
|
750
|
+
};
|
|
751
|
+
};
|
|
752
|
+
var toggleLayoutColumnMenu = exports.toggleLayoutColumnMenu = function toggleLayoutColumnMenu(_ref9) {
|
|
753
|
+
var anchorPos = _ref9.anchorPos,
|
|
754
|
+
isOpen = _ref9.isOpen;
|
|
755
|
+
return function (_ref0) {
|
|
756
|
+
var tr = _ref0.tr;
|
|
683
757
|
tr.setMeta('toggleLayoutColumnMenu', {
|
|
684
758
|
anchorPos: anchorPos,
|
|
685
759
|
isOpen: isOpen
|
|
@@ -689,8 +763,8 @@ var toggleLayoutColumnMenu = exports.toggleLayoutColumnMenu = function toggleLay
|
|
|
689
763
|
};
|
|
690
764
|
};
|
|
691
765
|
var deleteLayoutColumn = exports.deleteLayoutColumn = function deleteLayoutColumn(editorAnalyticsAPI) {
|
|
692
|
-
return function (
|
|
693
|
-
var tr =
|
|
766
|
+
return function (_ref1) {
|
|
767
|
+
var tr = _ref1.tr;
|
|
694
768
|
if (!(0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_layout_column_menu', 'isEnabled', true)) {
|
|
695
769
|
return null;
|
|
696
770
|
}
|
|
@@ -1,32 +1,62 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.
|
|
8
|
-
var _react =
|
|
7
|
+
exports.DistributeColumnsDropdownItem = void 0;
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
var _reactIntl = require("react-intl");
|
|
10
10
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
11
11
|
var _editorToolbar = require("@atlaskit/editor-toolbar");
|
|
12
|
-
var
|
|
12
|
+
var _useSelectedLayoutColumns = require("./useSelectedLayoutColumns");
|
|
13
|
+
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); }
|
|
14
|
+
var DistributeColumnsDropdownItem = exports.DistributeColumnsDropdownItem = function DistributeColumnsDropdownItem(_ref) {
|
|
13
15
|
var api = _ref.api;
|
|
14
16
|
var _useIntl = (0, _reactIntl.useIntl)(),
|
|
15
17
|
formatMessage = _useIntl.formatMessage;
|
|
16
|
-
var
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
var selectedLayoutColumns = (0, _useSelectedLayoutColumns.useSelectedLayoutColumns)(api);
|
|
19
|
+
var handleClick = (0, _react.useCallback)(function () {
|
|
20
|
+
var _api$core;
|
|
21
|
+
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(function (props) {
|
|
22
|
+
var _api$layout, _api$layout2;
|
|
23
|
+
var tr = api === null || api === void 0 || (_api$layout = api.layout) === null || _api$layout === void 0 ? void 0 : _api$layout.commands.distributeLayoutColumns(props);
|
|
24
|
+
if (!tr) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
var closedTr = api === null || api === void 0 || (_api$layout2 = api.layout) === null || _api$layout2 === void 0 ? void 0 : _api$layout2.commands.toggleLayoutColumnMenu({
|
|
28
|
+
isOpen: false
|
|
29
|
+
})({
|
|
30
|
+
tr: tr
|
|
31
|
+
});
|
|
32
|
+
return closedTr !== null && closedTr !== void 0 ? closedTr : tr;
|
|
33
|
+
});
|
|
34
|
+
}, [api]);
|
|
35
|
+
|
|
36
|
+
// Hide when selected columns are already evenly distributed — no-op action.
|
|
37
|
+
// Must be before any early return to satisfy rules-of-hooks.
|
|
38
|
+
var isAlreadyUniform = (0, _react.useMemo)(function () {
|
|
39
|
+
if (!selectedLayoutColumns || selectedLayoutColumns.selectedColumns.length < 2) {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
var selectedWidths = selectedLayoutColumns.selectedColumns.map(function (col) {
|
|
43
|
+
return col.node.attrs.width;
|
|
44
|
+
});
|
|
45
|
+
var selectedTotal = selectedWidths.reduce(function (sum, w) {
|
|
46
|
+
return sum + w;
|
|
47
|
+
}, 0);
|
|
48
|
+
var equalWidth = Number((selectedTotal / selectedWidths.length).toFixed(2));
|
|
49
|
+
return selectedWidths.every(function (w) {
|
|
50
|
+
return w === equalWidth;
|
|
51
|
+
});
|
|
52
|
+
}, [selectedLayoutColumns]);
|
|
53
|
+
if (selectedLayoutColumns === undefined || selectedLayoutColumns.selectedColumns.length < 2) {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
if (isAlreadyUniform) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
22
59
|
return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItem, {
|
|
23
60
|
onClick: handleClick
|
|
24
61
|
}, formatMessage(_messages.layoutMessages.distributeColumns));
|
|
25
|
-
};
|
|
26
|
-
var createDistributeColumnsDropdownItem = exports.createDistributeColumnsDropdownItem = function createDistributeColumnsDropdownItem(api) {
|
|
27
|
-
return function () {
|
|
28
|
-
return /*#__PURE__*/_react.default.createElement(DistributeColumnsDropdownItem, {
|
|
29
|
-
api: api
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
62
|
};
|
|
@@ -53,7 +53,11 @@ var getLayoutColumnMenuComponents = exports.getLayoutColumnMenuComponents = func
|
|
|
53
53
|
rank: _keys.LAYOUT_COLUMN_MENU_SECTION_RANK[_keys.INSERT_COLUMN_RIGHT_MENU_ITEM.key]
|
|
54
54
|
})]
|
|
55
55
|
}), _objectSpread(_objectSpread({}, _keys.DISTRIBUTE_COLUMNS_MENU_ITEM), {}, {
|
|
56
|
-
component:
|
|
56
|
+
component: function component() {
|
|
57
|
+
return /*#__PURE__*/_react.default.createElement(_DistributeColumnsDropdownItem.DistributeColumnsDropdownItem, {
|
|
58
|
+
api: api
|
|
59
|
+
});
|
|
60
|
+
},
|
|
57
61
|
parents: [_objectSpread(_objectSpread({}, _keys.LAYOUT_COLUMN_MENU_SECTION), {}, {
|
|
58
62
|
rank: _keys.LAYOUT_COLUMN_MENU_SECTION_RANK[_keys.DISTRIBUTE_COLUMNS_MENU_ITEM.key]
|
|
59
63
|
})]
|
|
@@ -11,7 +11,7 @@ import { fg } from '@atlaskit/platform-feature-flags';
|
|
|
11
11
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
12
12
|
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
13
13
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
14
|
-
import { createDefaultLayoutSection, createMultiColumnLayoutSection, deleteLayoutColumn, insertLayoutColumn, insertLayoutColumnsWithAnalytics, setLayoutColumnValign, toggleLayoutColumnMenu } from './pm-plugins/actions';
|
|
14
|
+
import { createDefaultLayoutSection, createMultiColumnLayoutSection, deleteLayoutColumn, distributeLayoutColumns, insertLayoutColumn, insertLayoutColumnsWithAnalytics, setLayoutColumnValign, toggleLayoutColumnMenu } from './pm-plugins/actions';
|
|
15
15
|
import { default as createLayoutPlugin } from './pm-plugins/main';
|
|
16
16
|
import { pluginKey } from './pm-plugins/plugin-key';
|
|
17
17
|
import { default as createLayoutResizingPlugin } from './pm-plugins/resizing';
|
|
@@ -353,13 +353,17 @@ export const layoutPlugin = ({
|
|
|
353
353
|
var _api$analytics4;
|
|
354
354
|
return deleteLayoutColumn(api === null || api === void 0 ? void 0 : (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions)(props);
|
|
355
355
|
},
|
|
356
|
-
|
|
356
|
+
distributeLayoutColumns: props => {
|
|
357
357
|
var _api$analytics5;
|
|
358
|
-
return
|
|
358
|
+
return distributeLayoutColumns(api === null || api === void 0 ? void 0 : (_api$analytics5 = api.analytics) === null || _api$analytics5 === void 0 ? void 0 : _api$analytics5.actions)(props);
|
|
359
359
|
},
|
|
360
|
-
|
|
360
|
+
insertLayoutColumn: side => {
|
|
361
361
|
var _api$analytics6;
|
|
362
|
-
return
|
|
362
|
+
return insertLayoutColumn(side, api === null || api === void 0 ? void 0 : (_api$analytics6 = api.analytics) === null || _api$analytics6 === void 0 ? void 0 : _api$analytics6.actions);
|
|
363
|
+
},
|
|
364
|
+
setLayoutColumnValign: valign => {
|
|
365
|
+
var _api$analytics7;
|
|
366
|
+
return setLayoutColumnValign(valign, api === null || api === void 0 ? void 0 : (_api$analytics7 = api.analytics) === null || _api$analytics7 === void 0 ? void 0 : _api$analytics7.actions);
|
|
363
367
|
},
|
|
364
368
|
toggleLayoutColumnMenu
|
|
365
369
|
}
|
|
@@ -652,6 +652,74 @@ export const setLayoutColumnValign = (valign, editorAnalyticsAPI) => ({
|
|
|
652
652
|
tr.setMeta('scrollIntoView', false);
|
|
653
653
|
return tr;
|
|
654
654
|
};
|
|
655
|
+
export const distributeLayoutColumns = (editorAnalyticsAPI, inputMethod = INPUT_METHOD.LAYOUT_COLUMN_MENU) => ({
|
|
656
|
+
tr
|
|
657
|
+
}) => {
|
|
658
|
+
if (!expValEqualsNoExposure('platform_editor_layout_column_menu', 'isEnabled', true)) {
|
|
659
|
+
return null;
|
|
660
|
+
}
|
|
661
|
+
const selectedLayoutColumns = getSelectedLayoutColumns(tr.selection);
|
|
662
|
+
if (!selectedLayoutColumns || selectedLayoutColumns.selectedColumns.length < 2) {
|
|
663
|
+
return null;
|
|
664
|
+
}
|
|
665
|
+
const {
|
|
666
|
+
layoutSectionNode,
|
|
667
|
+
layoutSectionPos,
|
|
668
|
+
selectedColumnIndices,
|
|
669
|
+
selectedColumns
|
|
670
|
+
} = selectedLayoutColumns;
|
|
671
|
+
const endIndex = selectedColumnIndices[selectedColumnIndices.length - 1];
|
|
672
|
+
const selectedColumnCount = selectedColumns.length;
|
|
673
|
+
const totalColumnCount = layoutSectionNode.childCount;
|
|
674
|
+
|
|
675
|
+
// Compute equal width for selected columns
|
|
676
|
+
const existingWidths = mapChildren(layoutSectionNode, column => column.attrs.width);
|
|
677
|
+
const selectedTotal = selectedColumnIndices.reduce((sum, idx) => sum + existingWidths[idx], 0);
|
|
678
|
+
const equalWidth = selectedTotal / selectedColumnCount;
|
|
679
|
+
|
|
680
|
+
// Early return if selected columns are already uniformly distributed — avoids spurious undo entry.
|
|
681
|
+
if (selectedColumnIndices.every(idx => existingWidths[idx] === Number(equalWidth.toFixed(2)))) {
|
|
682
|
+
return null;
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
// Build new widths array: selected columns get equal share, unselected unchanged.
|
|
686
|
+
// Assign truncated (2dp) equal widths to all selected cols except the last, which absorbs
|
|
687
|
+
// the rounding remainder so the sum of selected widths equals selectedTotal exactly.
|
|
688
|
+
const selectedIndexSet = new Set(selectedColumnIndices);
|
|
689
|
+
let assignedToSelected = 0;
|
|
690
|
+
let selectedAssignedCount = 0;
|
|
691
|
+
const newWidths = existingWidths.map((w, idx) => {
|
|
692
|
+
if (!selectedIndexSet.has(idx)) {
|
|
693
|
+
return w;
|
|
694
|
+
}
|
|
695
|
+
selectedAssignedCount += 1;
|
|
696
|
+
if (selectedAssignedCount < selectedColumnCount) {
|
|
697
|
+
const truncated = Number(equalWidth.toFixed(2));
|
|
698
|
+
assignedToSelected += truncated;
|
|
699
|
+
return truncated;
|
|
700
|
+
}
|
|
701
|
+
// Last selected column: absorb the remainder to avoid drift
|
|
702
|
+
return Number((selectedTotal - assignedToSelected).toFixed(2));
|
|
703
|
+
});
|
|
704
|
+
|
|
705
|
+
// Apply widths via replaceWith (mirroring forceColumnWidths approach)
|
|
706
|
+
tr.replaceWith(layoutSectionPos + 1, layoutSectionPos + layoutSectionNode.nodeSize - 1, columnWidth(layoutSectionNode, tr.doc.type.schema, newWidths));
|
|
707
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
|
|
708
|
+
action: ACTION.UPDATED,
|
|
709
|
+
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
710
|
+
actionSubjectId: ACTION_SUBJECT_ID.LAYOUT_COLUMN,
|
|
711
|
+
attributes: {
|
|
712
|
+
columnCount: totalColumnCount,
|
|
713
|
+
endIndex,
|
|
714
|
+
inputMethod,
|
|
715
|
+
selectedCount: selectedColumnCount,
|
|
716
|
+
startIndex: selectedColumnIndices[0]
|
|
717
|
+
},
|
|
718
|
+
eventType: EVENT_TYPE.TRACK
|
|
719
|
+
})(tr);
|
|
720
|
+
tr.setMeta('scrollIntoView', false);
|
|
721
|
+
return tr;
|
|
722
|
+
};
|
|
655
723
|
export const toggleLayoutColumnMenu = ({
|
|
656
724
|
anchorPos,
|
|
657
725
|
isOpen
|
|
@@ -1,25 +1,50 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useCallback, useMemo } from 'react';
|
|
2
2
|
import { useIntl } from 'react-intl';
|
|
3
3
|
import { layoutMessages } from '@atlaskit/editor-common/messages';
|
|
4
4
|
import { ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
|
|
5
|
-
|
|
5
|
+
import { useSelectedLayoutColumns } from './useSelectedLayoutColumns';
|
|
6
|
+
export const DistributeColumnsDropdownItem = ({
|
|
6
7
|
api
|
|
7
8
|
}) => {
|
|
8
9
|
const {
|
|
9
10
|
formatMessage
|
|
10
11
|
} = useIntl();
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
const selectedLayoutColumns = useSelectedLayoutColumns(api);
|
|
13
|
+
const handleClick = useCallback(() => {
|
|
14
|
+
var _api$core;
|
|
15
|
+
api === null || api === void 0 ? void 0 : (_api$core = api.core) === null || _api$core === void 0 ? void 0 : _api$core.actions.execute(props => {
|
|
16
|
+
var _api$layout, _api$layout2;
|
|
17
|
+
const tr = api === null || api === void 0 ? void 0 : (_api$layout = api.layout) === null || _api$layout === void 0 ? void 0 : _api$layout.commands.distributeLayoutColumns(props);
|
|
18
|
+
if (!tr) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
const closedTr = api === null || api === void 0 ? void 0 : (_api$layout2 = api.layout) === null || _api$layout2 === void 0 ? void 0 : _api$layout2.commands.toggleLayoutColumnMenu({
|
|
22
|
+
isOpen: false
|
|
23
|
+
})({
|
|
24
|
+
tr
|
|
25
|
+
});
|
|
26
|
+
return closedTr !== null && closedTr !== void 0 ? closedTr : tr;
|
|
27
|
+
});
|
|
28
|
+
}, [api]);
|
|
29
|
+
|
|
30
|
+
// Hide when selected columns are already evenly distributed — no-op action.
|
|
31
|
+
// Must be before any early return to satisfy rules-of-hooks.
|
|
32
|
+
const isAlreadyUniform = useMemo(() => {
|
|
33
|
+
if (!selectedLayoutColumns || selectedLayoutColumns.selectedColumns.length < 2) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
const selectedWidths = selectedLayoutColumns.selectedColumns.map(col => col.node.attrs.width);
|
|
37
|
+
const selectedTotal = selectedWidths.reduce((sum, w) => sum + w, 0);
|
|
38
|
+
const equalWidth = Number((selectedTotal / selectedWidths.length).toFixed(2));
|
|
39
|
+
return selectedWidths.every(w => w === equalWidth);
|
|
40
|
+
}, [selectedLayoutColumns]);
|
|
41
|
+
if (selectedLayoutColumns === undefined || selectedLayoutColumns.selectedColumns.length < 2) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
if (isAlreadyUniform) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
17
47
|
return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
|
|
18
48
|
onClick: handleClick
|
|
19
49
|
}, formatMessage(layoutMessages.distributeColumns));
|
|
20
|
-
};
|
|
21
|
-
export const createDistributeColumnsDropdownItem = api => {
|
|
22
|
-
return () => /*#__PURE__*/React.createElement(DistributeColumnsDropdownItem, {
|
|
23
|
-
api: api
|
|
24
|
-
});
|
|
25
50
|
};
|
|
@@ -3,7 +3,7 @@ import { layoutMessages } from '@atlaskit/editor-common/messages';
|
|
|
3
3
|
import { ToolbarDropdownItemSection } from '@atlaskit/editor-toolbar';
|
|
4
4
|
import { ToolbarMenuContainer } from '@atlaskit/editor-toolbar/toolbar-menu-container';
|
|
5
5
|
import { DeleteColumnDropdownItem } from './DeleteColumnDropdownItem';
|
|
6
|
-
import {
|
|
6
|
+
import { DistributeColumnsDropdownItem } from './DistributeColumnsDropdownItem';
|
|
7
7
|
import { InsertColumnDropdownItem } from './InsertColumnDropdownItem';
|
|
8
8
|
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';
|
|
9
9
|
import { VerticalAlignDropdownItem } from './VerticalAlignDropdownItem';
|
|
@@ -47,7 +47,9 @@ export const getLayoutColumnMenuComponents = ({
|
|
|
47
47
|
}]
|
|
48
48
|
}, {
|
|
49
49
|
...DISTRIBUTE_COLUMNS_MENU_ITEM,
|
|
50
|
-
component:
|
|
50
|
+
component: () => /*#__PURE__*/React.createElement(DistributeColumnsDropdownItem, {
|
|
51
|
+
api: api
|
|
52
|
+
}),
|
|
51
53
|
parents: [{
|
|
52
54
|
...LAYOUT_COLUMN_MENU_SECTION,
|
|
53
55
|
rank: LAYOUT_COLUMN_MENU_SECTION_RANK[DISTRIBUTE_COLUMNS_MENU_ITEM.key]
|
package/dist/esm/layoutPlugin.js
CHANGED
|
@@ -11,7 +11,7 @@ import { fg } from '@atlaskit/platform-feature-flags';
|
|
|
11
11
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
12
12
|
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
13
13
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
14
|
-
import { createDefaultLayoutSection, createMultiColumnLayoutSection, deleteLayoutColumn as _deleteLayoutColumn, insertLayoutColumn as _insertLayoutColumn, insertLayoutColumnsWithAnalytics, setLayoutColumnValign as _setLayoutColumnValign, toggleLayoutColumnMenu } from './pm-plugins/actions';
|
|
14
|
+
import { createDefaultLayoutSection, createMultiColumnLayoutSection, deleteLayoutColumn as _deleteLayoutColumn, distributeLayoutColumns as _distributeLayoutColumns, insertLayoutColumn as _insertLayoutColumn, insertLayoutColumnsWithAnalytics, setLayoutColumnValign as _setLayoutColumnValign, toggleLayoutColumnMenu } from './pm-plugins/actions';
|
|
15
15
|
import { default as createLayoutPlugin } from './pm-plugins/main';
|
|
16
16
|
import { pluginKey } from './pm-plugins/plugin-key';
|
|
17
17
|
import { default as createLayoutResizingPlugin } from './pm-plugins/resizing';
|
|
@@ -374,13 +374,17 @@ export var layoutPlugin = function layoutPlugin(_ref) {
|
|
|
374
374
|
var _api$analytics4;
|
|
375
375
|
return _deleteLayoutColumn(api === null || api === void 0 || (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions)(props);
|
|
376
376
|
},
|
|
377
|
-
|
|
377
|
+
distributeLayoutColumns: function distributeLayoutColumns(props) {
|
|
378
378
|
var _api$analytics5;
|
|
379
|
-
return
|
|
379
|
+
return _distributeLayoutColumns(api === null || api === void 0 || (_api$analytics5 = api.analytics) === null || _api$analytics5 === void 0 ? void 0 : _api$analytics5.actions)(props);
|
|
380
380
|
},
|
|
381
|
-
|
|
381
|
+
insertLayoutColumn: function insertLayoutColumn(side) {
|
|
382
382
|
var _api$analytics6;
|
|
383
|
-
return
|
|
383
|
+
return _insertLayoutColumn(side, api === null || api === void 0 || (_api$analytics6 = api.analytics) === null || _api$analytics6 === void 0 ? void 0 : _api$analytics6.actions);
|
|
384
|
+
},
|
|
385
|
+
setLayoutColumnValign: function setLayoutColumnValign(valign) {
|
|
386
|
+
var _api$analytics7;
|
|
387
|
+
return _setLayoutColumnValign(valign, api === null || api === void 0 || (_api$analytics7 = api.analytics) === null || _api$analytics7 === void 0 ? void 0 : _api$analytics7.actions);
|
|
384
388
|
},
|
|
385
389
|
toggleLayoutColumnMenu: toggleLayoutColumnMenu
|
|
386
390
|
}
|
|
@@ -665,11 +665,85 @@ export var setLayoutColumnValign = function setLayoutColumnValign(valign, editor
|
|
|
665
665
|
return tr;
|
|
666
666
|
};
|
|
667
667
|
};
|
|
668
|
-
export var
|
|
669
|
-
var
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
668
|
+
export var distributeLayoutColumns = function distributeLayoutColumns(editorAnalyticsAPI) {
|
|
669
|
+
var inputMethod = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : INPUT_METHOD.LAYOUT_COLUMN_MENU;
|
|
670
|
+
return function (_ref8) {
|
|
671
|
+
var tr = _ref8.tr;
|
|
672
|
+
if (!expValEqualsNoExposure('platform_editor_layout_column_menu', 'isEnabled', true)) {
|
|
673
|
+
return null;
|
|
674
|
+
}
|
|
675
|
+
var selectedLayoutColumns = getSelectedLayoutColumns(tr.selection);
|
|
676
|
+
if (!selectedLayoutColumns || selectedLayoutColumns.selectedColumns.length < 2) {
|
|
677
|
+
return null;
|
|
678
|
+
}
|
|
679
|
+
var layoutSectionNode = selectedLayoutColumns.layoutSectionNode,
|
|
680
|
+
layoutSectionPos = selectedLayoutColumns.layoutSectionPos,
|
|
681
|
+
selectedColumnIndices = selectedLayoutColumns.selectedColumnIndices,
|
|
682
|
+
selectedColumns = selectedLayoutColumns.selectedColumns;
|
|
683
|
+
var endIndex = selectedColumnIndices[selectedColumnIndices.length - 1];
|
|
684
|
+
var selectedColumnCount = selectedColumns.length;
|
|
685
|
+
var totalColumnCount = layoutSectionNode.childCount;
|
|
686
|
+
|
|
687
|
+
// Compute equal width for selected columns
|
|
688
|
+
var existingWidths = mapChildren(layoutSectionNode, function (column) {
|
|
689
|
+
return column.attrs.width;
|
|
690
|
+
});
|
|
691
|
+
var selectedTotal = selectedColumnIndices.reduce(function (sum, idx) {
|
|
692
|
+
return sum + existingWidths[idx];
|
|
693
|
+
}, 0);
|
|
694
|
+
var equalWidth = selectedTotal / selectedColumnCount;
|
|
695
|
+
|
|
696
|
+
// Early return if selected columns are already uniformly distributed — avoids spurious undo entry.
|
|
697
|
+
if (selectedColumnIndices.every(function (idx) {
|
|
698
|
+
return existingWidths[idx] === Number(equalWidth.toFixed(2));
|
|
699
|
+
})) {
|
|
700
|
+
return null;
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
// Build new widths array: selected columns get equal share, unselected unchanged.
|
|
704
|
+
// Assign truncated (2dp) equal widths to all selected cols except the last, which absorbs
|
|
705
|
+
// the rounding remainder so the sum of selected widths equals selectedTotal exactly.
|
|
706
|
+
var selectedIndexSet = new Set(selectedColumnIndices);
|
|
707
|
+
var assignedToSelected = 0;
|
|
708
|
+
var selectedAssignedCount = 0;
|
|
709
|
+
var newWidths = existingWidths.map(function (w, idx) {
|
|
710
|
+
if (!selectedIndexSet.has(idx)) {
|
|
711
|
+
return w;
|
|
712
|
+
}
|
|
713
|
+
selectedAssignedCount += 1;
|
|
714
|
+
if (selectedAssignedCount < selectedColumnCount) {
|
|
715
|
+
var truncated = Number(equalWidth.toFixed(2));
|
|
716
|
+
assignedToSelected += truncated;
|
|
717
|
+
return truncated;
|
|
718
|
+
}
|
|
719
|
+
// Last selected column: absorb the remainder to avoid drift
|
|
720
|
+
return Number((selectedTotal - assignedToSelected).toFixed(2));
|
|
721
|
+
});
|
|
722
|
+
|
|
723
|
+
// Apply widths via replaceWith (mirroring forceColumnWidths approach)
|
|
724
|
+
tr.replaceWith(layoutSectionPos + 1, layoutSectionPos + layoutSectionNode.nodeSize - 1, columnWidth(layoutSectionNode, tr.doc.type.schema, newWidths));
|
|
725
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent({
|
|
726
|
+
action: ACTION.UPDATED,
|
|
727
|
+
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
728
|
+
actionSubjectId: ACTION_SUBJECT_ID.LAYOUT_COLUMN,
|
|
729
|
+
attributes: {
|
|
730
|
+
columnCount: totalColumnCount,
|
|
731
|
+
endIndex: endIndex,
|
|
732
|
+
inputMethod: inputMethod,
|
|
733
|
+
selectedCount: selectedColumnCount,
|
|
734
|
+
startIndex: selectedColumnIndices[0]
|
|
735
|
+
},
|
|
736
|
+
eventType: EVENT_TYPE.TRACK
|
|
737
|
+
})(tr);
|
|
738
|
+
tr.setMeta('scrollIntoView', false);
|
|
739
|
+
return tr;
|
|
740
|
+
};
|
|
741
|
+
};
|
|
742
|
+
export var toggleLayoutColumnMenu = function toggleLayoutColumnMenu(_ref9) {
|
|
743
|
+
var anchorPos = _ref9.anchorPos,
|
|
744
|
+
isOpen = _ref9.isOpen;
|
|
745
|
+
return function (_ref0) {
|
|
746
|
+
var tr = _ref0.tr;
|
|
673
747
|
tr.setMeta('toggleLayoutColumnMenu', {
|
|
674
748
|
anchorPos: anchorPos,
|
|
675
749
|
isOpen: isOpen
|
|
@@ -679,8 +753,8 @@ export var toggleLayoutColumnMenu = function toggleLayoutColumnMenu(_ref8) {
|
|
|
679
753
|
};
|
|
680
754
|
};
|
|
681
755
|
export var deleteLayoutColumn = function deleteLayoutColumn(editorAnalyticsAPI) {
|
|
682
|
-
return function (
|
|
683
|
-
var tr =
|
|
756
|
+
return function (_ref1) {
|
|
757
|
+
var tr = _ref1.tr;
|
|
684
758
|
if (!expValEqualsNoExposure('platform_editor_layout_column_menu', 'isEnabled', true)) {
|
|
685
759
|
return null;
|
|
686
760
|
}
|
|
@@ -1,25 +1,54 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useCallback, useMemo } from 'react';
|
|
2
2
|
import { useIntl } from 'react-intl';
|
|
3
3
|
import { layoutMessages } from '@atlaskit/editor-common/messages';
|
|
4
4
|
import { ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
|
|
5
|
-
|
|
5
|
+
import { useSelectedLayoutColumns } from './useSelectedLayoutColumns';
|
|
6
|
+
export var DistributeColumnsDropdownItem = function DistributeColumnsDropdownItem(_ref) {
|
|
6
7
|
var api = _ref.api;
|
|
7
8
|
var _useIntl = useIntl(),
|
|
8
9
|
formatMessage = _useIntl.formatMessage;
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
var selectedLayoutColumns = useSelectedLayoutColumns(api);
|
|
11
|
+
var handleClick = useCallback(function () {
|
|
12
|
+
var _api$core;
|
|
13
|
+
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(function (props) {
|
|
14
|
+
var _api$layout, _api$layout2;
|
|
15
|
+
var tr = api === null || api === void 0 || (_api$layout = api.layout) === null || _api$layout === void 0 ? void 0 : _api$layout.commands.distributeLayoutColumns(props);
|
|
16
|
+
if (!tr) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
var closedTr = api === null || api === void 0 || (_api$layout2 = api.layout) === null || _api$layout2 === void 0 ? void 0 : _api$layout2.commands.toggleLayoutColumnMenu({
|
|
20
|
+
isOpen: false
|
|
21
|
+
})({
|
|
22
|
+
tr: tr
|
|
23
|
+
});
|
|
24
|
+
return closedTr !== null && closedTr !== void 0 ? closedTr : tr;
|
|
25
|
+
});
|
|
26
|
+
}, [api]);
|
|
27
|
+
|
|
28
|
+
// Hide when selected columns are already evenly distributed — no-op action.
|
|
29
|
+
// Must be before any early return to satisfy rules-of-hooks.
|
|
30
|
+
var isAlreadyUniform = useMemo(function () {
|
|
31
|
+
if (!selectedLayoutColumns || selectedLayoutColumns.selectedColumns.length < 2) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
var selectedWidths = selectedLayoutColumns.selectedColumns.map(function (col) {
|
|
35
|
+
return col.node.attrs.width;
|
|
36
|
+
});
|
|
37
|
+
var selectedTotal = selectedWidths.reduce(function (sum, w) {
|
|
38
|
+
return sum + w;
|
|
39
|
+
}, 0);
|
|
40
|
+
var equalWidth = Number((selectedTotal / selectedWidths.length).toFixed(2));
|
|
41
|
+
return selectedWidths.every(function (w) {
|
|
42
|
+
return w === equalWidth;
|
|
43
|
+
});
|
|
44
|
+
}, [selectedLayoutColumns]);
|
|
45
|
+
if (selectedLayoutColumns === undefined || selectedLayoutColumns.selectedColumns.length < 2) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
if (isAlreadyUniform) {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
15
51
|
return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
|
|
16
52
|
onClick: handleClick
|
|
17
53
|
}, formatMessage(layoutMessages.distributeColumns));
|
|
18
|
-
};
|
|
19
|
-
export var createDistributeColumnsDropdownItem = function createDistributeColumnsDropdownItem(api) {
|
|
20
|
-
return function () {
|
|
21
|
-
return /*#__PURE__*/React.createElement(DistributeColumnsDropdownItem, {
|
|
22
|
-
api: api
|
|
23
|
-
});
|
|
24
|
-
};
|
|
25
54
|
};
|
|
@@ -6,7 +6,7 @@ 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
8
|
import { DeleteColumnDropdownItem } from './DeleteColumnDropdownItem';
|
|
9
|
-
import {
|
|
9
|
+
import { DistributeColumnsDropdownItem } from './DistributeColumnsDropdownItem';
|
|
10
10
|
import { InsertColumnDropdownItem } from './InsertColumnDropdownItem';
|
|
11
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';
|
|
12
12
|
import { VerticalAlignDropdownItem } from './VerticalAlignDropdownItem';
|
|
@@ -46,7 +46,11 @@ export var getLayoutColumnMenuComponents = function getLayoutColumnMenuComponent
|
|
|
46
46
|
rank: LAYOUT_COLUMN_MENU_SECTION_RANK[INSERT_COLUMN_RIGHT_MENU_ITEM.key]
|
|
47
47
|
})]
|
|
48
48
|
}), _objectSpread(_objectSpread({}, DISTRIBUTE_COLUMNS_MENU_ITEM), {}, {
|
|
49
|
-
component:
|
|
49
|
+
component: function component() {
|
|
50
|
+
return /*#__PURE__*/React.createElement(DistributeColumnsDropdownItem, {
|
|
51
|
+
api: api
|
|
52
|
+
});
|
|
53
|
+
},
|
|
50
54
|
parents: [_objectSpread(_objectSpread({}, LAYOUT_COLUMN_MENU_SECTION), {}, {
|
|
51
55
|
rank: LAYOUT_COLUMN_MENU_SECTION_RANK[DISTRIBUTE_COLUMNS_MENU_ITEM.key]
|
|
52
56
|
})]
|
|
@@ -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 { deleteLayoutColumn, InsertLayoutColumnSide, insertLayoutColumnsWithAnalytics, setLayoutColumnValign, toggleLayoutColumnMenu } from './pm-plugins/actions';
|
|
12
|
+
import type { deleteLayoutColumn, distributeLayoutColumns, 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 = [
|
|
@@ -30,6 +30,7 @@ export type LayoutPlugin = NextEditorPlugin<'layout', {
|
|
|
30
30
|
};
|
|
31
31
|
commands: {
|
|
32
32
|
deleteLayoutColumn: ReturnType<typeof deleteLayoutColumn>;
|
|
33
|
+
distributeLayoutColumns: ReturnType<typeof distributeLayoutColumns>;
|
|
33
34
|
insertLayoutColumn: (side: InsertLayoutColumnSide) => EditorCommand;
|
|
34
35
|
setLayoutColumnValign: (valign: Parameters<typeof setLayoutColumnValign>[0]) => EditorCommand;
|
|
35
36
|
toggleLayoutColumnMenu: typeof toggleLayoutColumnMenu;
|
|
@@ -34,6 +34,7 @@ export type InsertLayoutColumnSide = 'left' | 'right';
|
|
|
34
34
|
export declare function getEffectiveMaxLayoutColumns(): number;
|
|
35
35
|
export declare const insertLayoutColumn: (side: InsertLayoutColumnSide, editorAnalyticsAPI?: EditorAnalyticsAPI) => EditorCommand;
|
|
36
36
|
export declare const setLayoutColumnValign: (valign: Valign, editorAnalyticsAPI?: EditorAnalyticsAPI) => EditorCommand;
|
|
37
|
+
export declare const distributeLayoutColumns: (editorAnalyticsAPI?: EditorAnalyticsAPI, inputMethod?: INPUT_METHOD.LAYOUT_COLUMN_MENU | INPUT_METHOD.FLOATING_TB) => EditorCommand;
|
|
37
38
|
export declare const toggleLayoutColumnMenu: ({ anchorPos, isOpen }: {
|
|
38
39
|
anchorPos?: number;
|
|
39
40
|
isOpen?: boolean;
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
3
|
import type { LayoutPlugin } from '../../layoutPluginType';
|
|
4
|
-
|
|
4
|
+
type DistributeColumnsDropdownItemProps = {
|
|
5
|
+
api: ExtractInjectionAPI<LayoutPlugin> | undefined;
|
|
6
|
+
};
|
|
7
|
+
export declare const DistributeColumnsDropdownItem: ({ api, }: DistributeColumnsDropdownItemProps) => React.JSX.Element | null;
|
|
8
|
+
export {};
|
|
@@ -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 { deleteLayoutColumn, InsertLayoutColumnSide, insertLayoutColumnsWithAnalytics, setLayoutColumnValign, toggleLayoutColumnMenu } from './pm-plugins/actions';
|
|
12
|
+
import type { deleteLayoutColumn, distributeLayoutColumns, 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 = [
|
|
@@ -30,6 +30,7 @@ export type LayoutPlugin = NextEditorPlugin<'layout', {
|
|
|
30
30
|
};
|
|
31
31
|
commands: {
|
|
32
32
|
deleteLayoutColumn: ReturnType<typeof deleteLayoutColumn>;
|
|
33
|
+
distributeLayoutColumns: ReturnType<typeof distributeLayoutColumns>;
|
|
33
34
|
insertLayoutColumn: (side: InsertLayoutColumnSide) => EditorCommand;
|
|
34
35
|
setLayoutColumnValign: (valign: Parameters<typeof setLayoutColumnValign>[0]) => EditorCommand;
|
|
35
36
|
toggleLayoutColumnMenu: typeof toggleLayoutColumnMenu;
|
|
@@ -34,6 +34,7 @@ export type InsertLayoutColumnSide = 'left' | 'right';
|
|
|
34
34
|
export declare function getEffectiveMaxLayoutColumns(): number;
|
|
35
35
|
export declare const insertLayoutColumn: (side: InsertLayoutColumnSide, editorAnalyticsAPI?: EditorAnalyticsAPI) => EditorCommand;
|
|
36
36
|
export declare const setLayoutColumnValign: (valign: Valign, editorAnalyticsAPI?: EditorAnalyticsAPI) => EditorCommand;
|
|
37
|
+
export declare const distributeLayoutColumns: (editorAnalyticsAPI?: EditorAnalyticsAPI, inputMethod?: INPUT_METHOD.LAYOUT_COLUMN_MENU | INPUT_METHOD.FLOATING_TB) => EditorCommand;
|
|
37
38
|
export declare const toggleLayoutColumnMenu: ({ anchorPos, isOpen }: {
|
|
38
39
|
anchorPos?: number;
|
|
39
40
|
isOpen?: boolean;
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
3
|
import type { LayoutPlugin } from '../../layoutPluginType';
|
|
4
|
-
|
|
4
|
+
type DistributeColumnsDropdownItemProps = {
|
|
5
|
+
api: ExtractInjectionAPI<LayoutPlugin> | undefined;
|
|
6
|
+
};
|
|
7
|
+
export declare const DistributeColumnsDropdownItem: ({ api, }: DistributeColumnsDropdownItemProps) => React.JSX.Element | null;
|
|
8
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-layout",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.7.1",
|
|
4
4
|
"description": "Layout plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -45,17 +45,17 @@
|
|
|
45
45
|
"@atlaskit/editor-shared-styles": "^3.11.0",
|
|
46
46
|
"@atlaskit/editor-toolbar": "^1.7.0",
|
|
47
47
|
"@atlaskit/editor-ui-control-model": "^1.2.0",
|
|
48
|
-
"@atlaskit/icon": "^35.
|
|
49
|
-
"@atlaskit/icon-lab": "^6.
|
|
48
|
+
"@atlaskit/icon": "^35.3.0",
|
|
49
|
+
"@atlaskit/icon-lab": "^6.12.0",
|
|
50
50
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
51
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
51
|
+
"@atlaskit/tmp-editor-statsig": "^84.0.0",
|
|
52
52
|
"@atlaskit/tokens": "^13.0.0",
|
|
53
53
|
"@babel/runtime": "^7.0.0",
|
|
54
54
|
"@emotion/react": "^11.7.1",
|
|
55
55
|
"bind-event-listener": "^3.0.0"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
|
-
"@atlaskit/editor-common": "^114.
|
|
58
|
+
"@atlaskit/editor-common": "^114.47.0",
|
|
59
59
|
"react": "^18.2.0",
|
|
60
60
|
"react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
|
|
61
61
|
},
|