@atlaskit/editor-plugin-layout 10.3.1 → 10.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/cjs/layoutPlugin.js +5 -1
- package/dist/cjs/pm-plugins/actions.js +30 -5
- package/dist/cjs/ui/LayoutColumnMenu/VerticalAlignDropdownItem.js +40 -0
- package/dist/cjs/ui/LayoutColumnMenu/VerticalAlignNestedMenu.js +39 -0
- package/dist/cjs/ui/LayoutColumnMenu/components.js +59 -22
- package/dist/cjs/ui/LayoutColumnMenu/index.js +23 -4
- package/dist/cjs/ui/LayoutColumnMenu/keys.js +58 -0
- package/dist/cjs/ui/LayoutColumnMenu/useCurrentLayoutColumnValign.js +22 -0
- package/dist/cjs/ui/LayoutColumnMenu/verticalAlignIcons.js +18 -0
- package/dist/es2019/layoutPlugin.js +7 -3
- package/dist/es2019/pm-plugins/actions.js +27 -0
- package/dist/es2019/ui/LayoutColumnMenu/VerticalAlignDropdownItem.js +35 -0
- package/dist/es2019/ui/LayoutColumnMenu/VerticalAlignNestedMenu.js +35 -0
- package/dist/es2019/ui/LayoutColumnMenu/components.js +54 -18
- package/dist/es2019/ui/LayoutColumnMenu/index.js +24 -5
- package/dist/es2019/ui/LayoutColumnMenu/keys.js +61 -0
- package/dist/es2019/ui/LayoutColumnMenu/useCurrentLayoutColumnValign.js +14 -0
- package/dist/es2019/ui/LayoutColumnMenu/verticalAlignIcons.js +11 -0
- package/dist/esm/layoutPlugin.js +7 -3
- package/dist/esm/pm-plugins/actions.js +29 -4
- package/dist/esm/ui/LayoutColumnMenu/VerticalAlignDropdownItem.js +32 -0
- package/dist/esm/ui/LayoutColumnMenu/VerticalAlignNestedMenu.js +32 -0
- package/dist/esm/ui/LayoutColumnMenu/components.js +51 -14
- package/dist/esm/ui/LayoutColumnMenu/index.js +24 -5
- package/dist/esm/ui/LayoutColumnMenu/keys.js +51 -0
- package/dist/esm/ui/LayoutColumnMenu/useCurrentLayoutColumnValign.js +16 -0
- package/dist/esm/ui/LayoutColumnMenu/verticalAlignIcons.js +11 -0
- package/dist/types/layoutPluginType.d.ts +2 -1
- package/dist/types/pm-plugins/actions.d.ts +2 -0
- package/dist/types/ui/LayoutColumnMenu/VerticalAlignDropdownItem.d.ts +14 -0
- package/dist/types/ui/LayoutColumnMenu/VerticalAlignNestedMenu.d.ts +8 -0
- package/dist/types/ui/LayoutColumnMenu/components.d.ts +0 -4
- package/dist/types/ui/LayoutColumnMenu/keys.d.ts +13 -0
- package/dist/types/ui/LayoutColumnMenu/useCurrentLayoutColumnValign.d.ts +11 -0
- package/dist/types/ui/LayoutColumnMenu/verticalAlignIcons.d.ts +5 -0
- package/dist/types-ts4.5/layoutPluginType.d.ts +2 -1
- package/dist/types-ts4.5/pm-plugins/actions.d.ts +2 -0
- package/dist/types-ts4.5/ui/LayoutColumnMenu/VerticalAlignDropdownItem.d.ts +14 -0
- package/dist/types-ts4.5/ui/LayoutColumnMenu/VerticalAlignNestedMenu.d.ts +8 -0
- package/dist/types-ts4.5/ui/LayoutColumnMenu/components.d.ts +0 -4
- package/dist/types-ts4.5/ui/LayoutColumnMenu/keys.d.ts +13 -0
- package/dist/types-ts4.5/ui/LayoutColumnMenu/useCurrentLayoutColumnValign.d.ts +11 -0
- package/dist/types-ts4.5/ui/LayoutColumnMenu/verticalAlignIcons.d.ts +5 -0
- package/package.json +9 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-layout
|
|
2
2
|
|
|
3
|
+
## 10.3.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`0197bccd3d244`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/0197bccd3d244) -
|
|
8
|
+
Add vertical alignment options to layout column menus and rendering.
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
11
|
+
## 10.3.2
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies
|
|
16
|
+
|
|
3
17
|
## 10.3.1
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/dist/cjs/layoutPlugin.js
CHANGED
|
@@ -94,7 +94,10 @@ var layoutPlugin = exports.layoutPlugin = function layoutPlugin(_ref) {
|
|
|
94
94
|
node: (0, _experiments.editorExperiment)('advanced_layouts', true) ? (0, _platformFeatureFlags.fg)('platform_editor_adf_with_localid') ? _schema.layoutSectionWithSingleColumnLocalId : _schema.layoutSectionWithSingleColumn : (0, _platformFeatureFlags.fg)('platform_editor_adf_with_localid') ? _adfSchema.layoutSectionWithLocalId : _adfSchema.layoutSection
|
|
95
95
|
}, {
|
|
96
96
|
name: 'layoutColumn',
|
|
97
|
-
node: (0,
|
|
97
|
+
node: (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_layout_column_menu', 'isEnabled', true) ?
|
|
98
|
+
// `layoutColumnStage0` includes both `valign` and `localId` attrs, so it remains
|
|
99
|
+
// compatible with `platform_editor_adf_with_localid` when both flags are enabled.
|
|
100
|
+
_adfSchema.layoutColumnStage0 : (0, _platformFeatureFlags.fg)('platform_editor_adf_with_localid') ? _adfSchema.layoutColumnWithLocalId : _adfSchema.layoutColumn
|
|
98
101
|
}];
|
|
99
102
|
},
|
|
100
103
|
pmPlugins: function pmPlugins() {
|
|
@@ -306,6 +309,7 @@ var layoutPlugin = exports.layoutPlugin = function layoutPlugin(_ref) {
|
|
|
306
309
|
return _pluginKey.pluginKey.getState(editorState);
|
|
307
310
|
},
|
|
308
311
|
commands: {
|
|
312
|
+
setLayoutColumnValign: _actions.setLayoutColumnValign,
|
|
309
313
|
toggleLayoutColumnMenu: _actions.toggleLayoutColumnMenu
|
|
310
314
|
}
|
|
311
315
|
};
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.fixColumnStructure = exports.fixColumnSizes = 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
|
-
exports.toggleLayoutColumnMenu = exports.setPresetLayout = exports.insertLayoutColumnsWithAnalytics = exports.insertLayoutColumns = exports.getSelectedLayout = exports.getPresetLayout = void 0;
|
|
9
|
+
exports.toggleLayoutColumnMenu = exports.setPresetLayout = exports.setLayoutColumnValign = exports.insertLayoutColumnsWithAnalytics = exports.insertLayoutColumns = exports.getSelectedLayout = exports.getPresetLayout = void 0;
|
|
10
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
11
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
12
12
|
var _editorAnalytics = require("@atlaskit/editor-common/editor-analytics");
|
|
@@ -15,6 +15,7 @@ var _model = require("@atlaskit/editor-prosemirror/model");
|
|
|
15
15
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
16
16
|
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
17
17
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
18
|
+
var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
|
|
18
19
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
19
20
|
var _consts = require("./consts");
|
|
20
21
|
var _pluginKey = require("./plugin-key");
|
|
@@ -548,10 +549,34 @@ var formatLayoutName = function formatLayoutName(layout) {
|
|
|
548
549
|
return _analytics.LAYOUT_TYPE.THREE_WITH_SIDEBARS;
|
|
549
550
|
}
|
|
550
551
|
};
|
|
551
|
-
var
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
552
|
+
var setLayoutColumnValign = exports.setLayoutColumnValign = function setLayoutColumnValign(valign) {
|
|
553
|
+
return function (_ref4) {
|
|
554
|
+
var tr = _ref4.tr;
|
|
555
|
+
if (!(0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_layout_column_menu', 'isEnabled', true)) {
|
|
556
|
+
return null;
|
|
557
|
+
}
|
|
558
|
+
var layoutColumn = tr.doc.type.schema.nodes.layoutColumn;
|
|
559
|
+
var selectedColumn = tr.selection instanceof _state.NodeSelection && tr.selection.node.type === layoutColumn ? {
|
|
560
|
+
node: tr.selection.node,
|
|
561
|
+
pos: tr.selection.from
|
|
562
|
+
} : undefined;
|
|
563
|
+
if (!selectedColumn) {
|
|
564
|
+
return null;
|
|
565
|
+
}
|
|
566
|
+
if (selectedColumn.node.attrs.valign === valign) {
|
|
567
|
+
return null;
|
|
568
|
+
}
|
|
569
|
+
tr.setNodeMarkup(selectedColumn.pos, selectedColumn.node.type, _objectSpread(_objectSpread({}, selectedColumn.node.attrs), {}, {
|
|
570
|
+
valign: valign
|
|
571
|
+
}));
|
|
572
|
+
tr.setMeta('scrollIntoView', false);
|
|
573
|
+
return tr;
|
|
574
|
+
};
|
|
575
|
+
};
|
|
576
|
+
var toggleLayoutColumnMenu = exports.toggleLayoutColumnMenu = function toggleLayoutColumnMenu(_ref5) {
|
|
577
|
+
var isOpen = _ref5.isOpen;
|
|
578
|
+
return function (_ref6) {
|
|
579
|
+
var tr = _ref6.tr;
|
|
555
580
|
tr.setMeta('toggleLayoutColumnMenu', {
|
|
556
581
|
isOpen: isOpen
|
|
557
582
|
});
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.VerticalAlignDropdownItem = void 0;
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _reactIntl = require("react-intl");
|
|
10
|
+
var _editorToolbar = require("@atlaskit/editor-toolbar");
|
|
11
|
+
var _useCurrentLayoutColumnValign = require("./useCurrentLayoutColumnValign");
|
|
12
|
+
var _verticalAlignIcons = require("./verticalAlignIcons");
|
|
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 VerticalAlignDropdownItem = exports.VerticalAlignDropdownItem = function VerticalAlignDropdownItem(_ref) {
|
|
15
|
+
var api = _ref.api,
|
|
16
|
+
label = _ref.label,
|
|
17
|
+
value = _ref.value;
|
|
18
|
+
var _useIntl = (0, _reactIntl.useIntl)(),
|
|
19
|
+
formatMessage = _useIntl.formatMessage;
|
|
20
|
+
var _useCurrentLayoutColu = (0, _useCurrentLayoutColumnValign.useCurrentLayoutColumnValign)(api),
|
|
21
|
+
currentValign = _useCurrentLayoutColu.currentValign,
|
|
22
|
+
selectedColumn = _useCurrentLayoutColu.selectedColumn;
|
|
23
|
+
var Icon = _verticalAlignIcons.VERTICAL_ALIGN_ICONS[value];
|
|
24
|
+
var onClick = (0, _react.useCallback)(function () {
|
|
25
|
+
var _api$core, _api$layout;
|
|
26
|
+
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));
|
|
27
|
+
}, [api, value]);
|
|
28
|
+
if (!selectedColumn) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItem, {
|
|
32
|
+
elemBefore: /*#__PURE__*/_react.default.createElement(Icon, {
|
|
33
|
+
label: "",
|
|
34
|
+
size: "small"
|
|
35
|
+
}),
|
|
36
|
+
isSelected: currentValign === value,
|
|
37
|
+
onClick: onClick,
|
|
38
|
+
testId: "layout-column-align-".concat(value)
|
|
39
|
+
}, formatMessage(label));
|
|
40
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.VerticalAlignNestedMenu = void 0;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _reactIntl = require("react-intl");
|
|
10
|
+
var _messages = require("@atlaskit/editor-common/messages");
|
|
11
|
+
var _editorToolbar = require("@atlaskit/editor-toolbar");
|
|
12
|
+
var _useCurrentLayoutColumnValign = require("./useCurrentLayoutColumnValign");
|
|
13
|
+
var _verticalAlignIcons = require("./verticalAlignIcons");
|
|
14
|
+
var VerticalAlignNestedMenu = exports.VerticalAlignNestedMenu = function VerticalAlignNestedMenu(_ref) {
|
|
15
|
+
var api = _ref.api,
|
|
16
|
+
children = _ref.children;
|
|
17
|
+
var _useIntl = (0, _reactIntl.useIntl)(),
|
|
18
|
+
formatMessage = _useIntl.formatMessage;
|
|
19
|
+
var _useCurrentLayoutColu = (0, _useCurrentLayoutColumnValign.useCurrentLayoutColumnValign)(api),
|
|
20
|
+
currentValign = _useCurrentLayoutColu.currentValign,
|
|
21
|
+
selectedColumn = _useCurrentLayoutColu.selectedColumn;
|
|
22
|
+
var TriggerIcon = currentValign ? _verticalAlignIcons.VERTICAL_ALIGN_ICONS[currentValign] : _editorToolbar.LayoutIcon;
|
|
23
|
+
if (!selectedColumn) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarNestedDropdownMenu, {
|
|
27
|
+
elemBefore: /*#__PURE__*/_react.default.createElement(TriggerIcon, {
|
|
28
|
+
label: "",
|
|
29
|
+
size: "small"
|
|
30
|
+
}),
|
|
31
|
+
elemAfter: /*#__PURE__*/_react.default.createElement(_editorToolbar.NestedDropdownRightIcon, {
|
|
32
|
+
label: "",
|
|
33
|
+
size: "small"
|
|
34
|
+
}),
|
|
35
|
+
text: formatMessage(_messages.layoutMessages.alignColumn),
|
|
36
|
+
testId: "layout-column-align-menu",
|
|
37
|
+
dropdownTestId: "layout-column-align-dropdown"
|
|
38
|
+
}, children);
|
|
39
|
+
};
|
|
@@ -4,28 +4,18 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.getLayoutColumnMenuComponents = exports.LAYOUT_COLUMN_MENU_FALLBACKS =
|
|
7
|
+
exports.getLayoutColumnMenuComponents = exports.LAYOUT_COLUMN_MENU_FALLBACKS = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _react = _interopRequireDefault(require("react"));
|
|
10
|
+
var _messages = require("@atlaskit/editor-common/messages");
|
|
10
11
|
var _editorToolbar = require("@atlaskit/editor-toolbar");
|
|
11
12
|
var _toolbarMenuContainer = require("@atlaskit/editor-toolbar/toolbar-menu-container");
|
|
12
13
|
var _DistributeColumnsDropdownItem = require("./DistributeColumnsDropdownItem");
|
|
14
|
+
var _keys = require("./keys");
|
|
15
|
+
var _VerticalAlignDropdownItem = require("./VerticalAlignDropdownItem");
|
|
16
|
+
var _VerticalAlignNestedMenu = require("./VerticalAlignNestedMenu");
|
|
13
17
|
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; }
|
|
14
18
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
15
|
-
var LAYOUT_COLUMN_MENU = exports.LAYOUT_COLUMN_MENU = {
|
|
16
|
-
key: 'layout-column-menu',
|
|
17
|
-
type: 'menu'
|
|
18
|
-
};
|
|
19
|
-
var LAYOUT_COLUMN_MENU_SECTION = {
|
|
20
|
-
key: 'layout-column-menu-section',
|
|
21
|
-
type: 'menu-section'
|
|
22
|
-
};
|
|
23
|
-
var DISTRIBUTE_COLUMNS_MENU_ITEM = {
|
|
24
|
-
key: 'layout-column-menu-distribute-columns-item',
|
|
25
|
-
type: 'menu-item'
|
|
26
|
-
};
|
|
27
|
-
var LAYOUT_COLUMN_MENU_RANK = (0, _defineProperty2.default)({}, LAYOUT_COLUMN_MENU_SECTION.key, 0);
|
|
28
|
-
var LAYOUT_COLUMN_MENU_SECTION_RANK = (0, _defineProperty2.default)({}, DISTRIBUTE_COLUMNS_MENU_ITEM.key, 0);
|
|
29
19
|
var LAYOUT_COLUMN_MENU_FALLBACKS = exports.LAYOUT_COLUMN_MENU_FALLBACKS = {
|
|
30
20
|
'menu-section': function menuSection(_ref) {
|
|
31
21
|
var children = _ref.children;
|
|
@@ -34,16 +24,63 @@ var LAYOUT_COLUMN_MENU_FALLBACKS = exports.LAYOUT_COLUMN_MENU_FALLBACKS = {
|
|
|
34
24
|
};
|
|
35
25
|
var getLayoutColumnMenuComponents = exports.getLayoutColumnMenuComponents = function getLayoutColumnMenuComponents(_ref2) {
|
|
36
26
|
var api = _ref2.api;
|
|
37
|
-
return [_objectSpread(_objectSpread({}, LAYOUT_COLUMN_MENU), {}, {
|
|
27
|
+
return [_objectSpread(_objectSpread({}, _keys.LAYOUT_COLUMN_MENU), {}, {
|
|
38
28
|
component: _toolbarMenuContainer.ToolbarMenuContainer
|
|
39
|
-
}), _objectSpread(_objectSpread({}, LAYOUT_COLUMN_MENU_SECTION), {}, {
|
|
40
|
-
parents: [_objectSpread(_objectSpread({}, LAYOUT_COLUMN_MENU), {}, {
|
|
41
|
-
rank: LAYOUT_COLUMN_MENU_RANK[LAYOUT_COLUMN_MENU_SECTION.key]
|
|
29
|
+
}), _objectSpread(_objectSpread({}, _keys.LAYOUT_COLUMN_MENU_SECTION), {}, {
|
|
30
|
+
parents: [_objectSpread(_objectSpread({}, _keys.LAYOUT_COLUMN_MENU), {}, {
|
|
31
|
+
rank: _keys.LAYOUT_COLUMN_MENU_RANK[_keys.LAYOUT_COLUMN_MENU_SECTION.key]
|
|
42
32
|
})]
|
|
43
|
-
}), _objectSpread(_objectSpread({}, DISTRIBUTE_COLUMNS_MENU_ITEM), {}, {
|
|
33
|
+
}), _objectSpread(_objectSpread({}, _keys.DISTRIBUTE_COLUMNS_MENU_ITEM), {}, {
|
|
44
34
|
component: (0, _DistributeColumnsDropdownItem.createDistributeColumnsDropdownItem)(api),
|
|
45
|
-
parents: [_objectSpread(_objectSpread({}, LAYOUT_COLUMN_MENU_SECTION), {}, {
|
|
46
|
-
rank: LAYOUT_COLUMN_MENU_SECTION_RANK[DISTRIBUTE_COLUMNS_MENU_ITEM.key]
|
|
35
|
+
parents: [_objectSpread(_objectSpread({}, _keys.LAYOUT_COLUMN_MENU_SECTION), {}, {
|
|
36
|
+
rank: _keys.LAYOUT_COLUMN_MENU_SECTION_RANK[_keys.DISTRIBUTE_COLUMNS_MENU_ITEM.key]
|
|
37
|
+
})]
|
|
38
|
+
}), _objectSpread(_objectSpread({}, _keys.VERTICAL_ALIGN_MENU), {}, {
|
|
39
|
+
component: function component(_ref3) {
|
|
40
|
+
var children = _ref3.children;
|
|
41
|
+
return /*#__PURE__*/_react.default.createElement(_VerticalAlignNestedMenu.VerticalAlignNestedMenu, {
|
|
42
|
+
api: api
|
|
43
|
+
}, children);
|
|
44
|
+
},
|
|
45
|
+
parents: [_objectSpread(_objectSpread({}, _keys.LAYOUT_COLUMN_MENU_SECTION), {}, {
|
|
46
|
+
rank: _keys.LAYOUT_COLUMN_MENU_SECTION_RANK[_keys.VERTICAL_ALIGN_MENU.key]
|
|
47
|
+
})]
|
|
48
|
+
}), _objectSpread(_objectSpread({}, _keys.LAYOUT_COLUMN_VERTICAL_ALIGN_MENU_SECTION), {}, {
|
|
49
|
+
parents: [_objectSpread(_objectSpread({}, _keys.VERTICAL_ALIGN_MENU), {}, {
|
|
50
|
+
rank: _keys.VERTICAL_ALIGN_MENU_RANK[_keys.LAYOUT_COLUMN_VERTICAL_ALIGN_MENU_SECTION.key]
|
|
51
|
+
})]
|
|
52
|
+
}), _objectSpread(_objectSpread({}, _keys.VERTICAL_ALIGN_TOP_MENU_ITEM), {}, {
|
|
53
|
+
component: function component() {
|
|
54
|
+
return /*#__PURE__*/_react.default.createElement(_VerticalAlignDropdownItem.VerticalAlignDropdownItem, {
|
|
55
|
+
api: api,
|
|
56
|
+
label: _messages.layoutMessages.alignColumnTop,
|
|
57
|
+
value: "top"
|
|
58
|
+
});
|
|
59
|
+
},
|
|
60
|
+
parents: [_objectSpread(_objectSpread({}, _keys.LAYOUT_COLUMN_VERTICAL_ALIGN_MENU_SECTION), {}, {
|
|
61
|
+
rank: _keys.VERTICAL_ALIGN_MENU_SECTION_RANK[_keys.VERTICAL_ALIGN_TOP_MENU_ITEM.key]
|
|
62
|
+
})]
|
|
63
|
+
}), _objectSpread(_objectSpread({}, _keys.VERTICAL_ALIGN_MIDDLE_MENU_ITEM), {}, {
|
|
64
|
+
component: function component() {
|
|
65
|
+
return /*#__PURE__*/_react.default.createElement(_VerticalAlignDropdownItem.VerticalAlignDropdownItem, {
|
|
66
|
+
api: api,
|
|
67
|
+
label: _messages.layoutMessages.alignColumnMiddle,
|
|
68
|
+
value: "middle"
|
|
69
|
+
});
|
|
70
|
+
},
|
|
71
|
+
parents: [_objectSpread(_objectSpread({}, _keys.LAYOUT_COLUMN_VERTICAL_ALIGN_MENU_SECTION), {}, {
|
|
72
|
+
rank: _keys.VERTICAL_ALIGN_MENU_SECTION_RANK[_keys.VERTICAL_ALIGN_MIDDLE_MENU_ITEM.key]
|
|
73
|
+
})]
|
|
74
|
+
}), _objectSpread(_objectSpread({}, _keys.VERTICAL_ALIGN_BOTTOM_MENU_ITEM), {}, {
|
|
75
|
+
component: function component() {
|
|
76
|
+
return /*#__PURE__*/_react.default.createElement(_VerticalAlignDropdownItem.VerticalAlignDropdownItem, {
|
|
77
|
+
api: api,
|
|
78
|
+
label: _messages.layoutMessages.alignColumnBottom,
|
|
79
|
+
value: "bottom"
|
|
80
|
+
});
|
|
81
|
+
},
|
|
82
|
+
parents: [_objectSpread(_objectSpread({}, _keys.LAYOUT_COLUMN_VERTICAL_ALIGN_MENU_SECTION), {}, {
|
|
83
|
+
rank: _keys.VERTICAL_ALIGN_MENU_SECTION_RANK[_keys.VERTICAL_ALIGN_BOTTOM_MENU_ITEM.key]
|
|
47
84
|
})]
|
|
48
85
|
})];
|
|
49
86
|
};
|
|
@@ -15,6 +15,7 @@ var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
|
15
15
|
var _editorToolbar = require("@atlaskit/editor-toolbar");
|
|
16
16
|
var _editorUiControlModel = require("@atlaskit/editor-ui-control-model");
|
|
17
17
|
var _components = require("./components");
|
|
18
|
+
var _keys = require("./keys");
|
|
18
19
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
19
20
|
var PopupWithListeners = (0, _uiReact.withReactEditorViewOuterListeners)(_ui.Popup);
|
|
20
21
|
var LAYOUT_COLUMN_MENU_POPUP_OFFSET = [0, 10];
|
|
@@ -44,18 +45,34 @@ var LayoutColumnMenu = exports.LayoutColumnMenu = /*#__PURE__*/_react.default.me
|
|
|
44
45
|
}),
|
|
45
46
|
isLayoutColumnMenuOpen = _useSharedPluginState.isLayoutColumnMenuOpen,
|
|
46
47
|
selection = _useSharedPluginState.selection;
|
|
48
|
+
var setOutsideClickTargetRef = (0, _react.useContext)(_uiReact.OutsideClickTargetRefContext);
|
|
49
|
+
var menuRef = (0, _react.useRef)(null);
|
|
47
50
|
var closeLayoutColumnMenu = (0, _react.useCallback)(function () {
|
|
48
51
|
var _api$core, _api$layout;
|
|
49
52
|
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({
|
|
50
53
|
isOpen: false
|
|
51
54
|
}));
|
|
52
55
|
}, [api]);
|
|
56
|
+
var handleClickOutside = (0, _react.useCallback)(function (event) {
|
|
57
|
+
var _menuRef$current;
|
|
58
|
+
if (event.target instanceof Node && (_menuRef$current = menuRef.current) !== null && _menuRef$current !== void 0 && _menuRef$current.contains(event.target)) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
if (event.target instanceof Element && event.target.closest('[data-toolbar-nested-dropdown-menu]')) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
closeLayoutColumnMenu();
|
|
65
|
+
}, [closeLayoutColumnMenu]);
|
|
53
66
|
var handleSetIsOpen = (0, _react.useCallback)(function (isOpen) {
|
|
54
67
|
if (!isOpen) {
|
|
55
68
|
closeLayoutColumnMenu();
|
|
56
69
|
}
|
|
57
70
|
}, [closeLayoutColumnMenu]);
|
|
58
|
-
var
|
|
71
|
+
var handleMenuRef = (0, _react.useCallback)(function (el) {
|
|
72
|
+
setOutsideClickTargetRef === null || setOutsideClickTargetRef === void 0 || setOutsideClickTargetRef(el);
|
|
73
|
+
menuRef.current = el;
|
|
74
|
+
}, [setOutsideClickTargetRef]);
|
|
75
|
+
var components = (_api$uiControlRegistr = api === null || api === void 0 || (_api$uiControlRegistr2 = api.uiControlRegistry) === null || _api$uiControlRegistr2 === void 0 ? void 0 : _api$uiControlRegistr2.actions.getComponents(_keys.LAYOUT_COLUMN_MENU.key)) !== null && _api$uiControlRegistr !== void 0 ? _api$uiControlRegistr : [];
|
|
59
76
|
var target = isLayoutColumnMenuOpen ? getLayoutColumnMenuTarget(editorView, selection === null || selection === void 0 ? void 0 : selection.from) : null;
|
|
60
77
|
var hasValidTarget = target instanceof HTMLElement;
|
|
61
78
|
(0, _react.useEffect)(function () {
|
|
@@ -76,8 +93,10 @@ var LayoutColumnMenu = exports.LayoutColumnMenu = /*#__PURE__*/_react.default.me
|
|
|
76
93
|
alignY: "top",
|
|
77
94
|
forcePlacement: true,
|
|
78
95
|
offset: LAYOUT_COLUMN_MENU_POPUP_OFFSET,
|
|
79
|
-
handleClickOutside:
|
|
96
|
+
handleClickOutside: handleClickOutside,
|
|
80
97
|
handleEscapeKeydown: closeLayoutColumnMenu
|
|
98
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
99
|
+
ref: handleMenuRef
|
|
81
100
|
}, /*#__PURE__*/_react.default.createElement(_toolbar.EditorToolbarProvider, {
|
|
82
101
|
editorView: editorView
|
|
83
102
|
}, /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownMenuProvider, {
|
|
@@ -86,6 +105,6 @@ var LayoutColumnMenu = exports.LayoutColumnMenu = /*#__PURE__*/_react.default.me
|
|
|
86
105
|
}, /*#__PURE__*/_react.default.createElement(_editorUiControlModel.SurfaceRenderer, {
|
|
87
106
|
components: components,
|
|
88
107
|
fallbacks: _components.LAYOUT_COLUMN_MENU_FALLBACKS,
|
|
89
|
-
surface:
|
|
90
|
-
}))));
|
|
108
|
+
surface: _keys.LAYOUT_COLUMN_MENU
|
|
109
|
+
})))));
|
|
91
110
|
});
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.VERTICAL_ALIGN_TOP_MENU_ITEM = exports.VERTICAL_ALIGN_MIDDLE_MENU_ITEM = exports.VERTICAL_ALIGN_MENU_SECTION_RANK = exports.VERTICAL_ALIGN_MENU_RANK = exports.VERTICAL_ALIGN_MENU = exports.VERTICAL_ALIGN_BOTTOM_MENU_ITEM = exports.LAYOUT_COLUMN_VERTICAL_ALIGN_MENU_SECTION = exports.LAYOUT_COLUMN_MENU_SECTION_RANK = exports.LAYOUT_COLUMN_MENU_SECTION = exports.LAYOUT_COLUMN_MENU_RANK = exports.LAYOUT_COLUMN_MENU = exports.DISTRIBUTE_COLUMNS_MENU_ITEM = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
// --- Menu surface ---
|
|
10
|
+
|
|
11
|
+
var LAYOUT_COLUMN_MENU = exports.LAYOUT_COLUMN_MENU = {
|
|
12
|
+
type: 'menu',
|
|
13
|
+
key: 'layout-column-menu'
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
// --- Sections ---
|
|
17
|
+
|
|
18
|
+
var LAYOUT_COLUMN_MENU_SECTION = exports.LAYOUT_COLUMN_MENU_SECTION = {
|
|
19
|
+
type: 'menu-section',
|
|
20
|
+
key: 'layout-column-menu-section'
|
|
21
|
+
};
|
|
22
|
+
var LAYOUT_COLUMN_VERTICAL_ALIGN_MENU_SECTION = exports.LAYOUT_COLUMN_VERTICAL_ALIGN_MENU_SECTION = {
|
|
23
|
+
type: 'menu-section',
|
|
24
|
+
key: 'layout-column-vertical-align-menu-section'
|
|
25
|
+
};
|
|
26
|
+
var LAYOUT_COLUMN_MENU_RANK = exports.LAYOUT_COLUMN_MENU_RANK = (0, _defineProperty2.default)({}, LAYOUT_COLUMN_MENU_SECTION.key, 100);
|
|
27
|
+
|
|
28
|
+
// --- Menus ---
|
|
29
|
+
|
|
30
|
+
var VERTICAL_ALIGN_MENU = exports.VERTICAL_ALIGN_MENU = {
|
|
31
|
+
type: 'nested-menu',
|
|
32
|
+
key: 'layout-column-menu-vertical-align-menu'
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
// --- Items ---
|
|
36
|
+
|
|
37
|
+
var DISTRIBUTE_COLUMNS_MENU_ITEM = exports.DISTRIBUTE_COLUMNS_MENU_ITEM = {
|
|
38
|
+
type: 'menu-item',
|
|
39
|
+
key: 'layout-column-menu-distribute-columns-item'
|
|
40
|
+
};
|
|
41
|
+
var VERTICAL_ALIGN_TOP_MENU_ITEM = exports.VERTICAL_ALIGN_TOP_MENU_ITEM = {
|
|
42
|
+
type: 'menu-item',
|
|
43
|
+
key: 'layout-column-menu-vertical-align-top-item'
|
|
44
|
+
};
|
|
45
|
+
var VERTICAL_ALIGN_MIDDLE_MENU_ITEM = exports.VERTICAL_ALIGN_MIDDLE_MENU_ITEM = {
|
|
46
|
+
type: 'menu-item',
|
|
47
|
+
key: 'layout-column-menu-vertical-align-middle-item'
|
|
48
|
+
};
|
|
49
|
+
var VERTICAL_ALIGN_BOTTOM_MENU_ITEM = exports.VERTICAL_ALIGN_BOTTOM_MENU_ITEM = {
|
|
50
|
+
type: 'menu-item',
|
|
51
|
+
key: 'layout-column-menu-vertical-align-bottom-item'
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// --- Item ranks within sections ---
|
|
55
|
+
|
|
56
|
+
var LAYOUT_COLUMN_MENU_SECTION_RANK = exports.LAYOUT_COLUMN_MENU_SECTION_RANK = (0, _defineProperty2.default)((0, _defineProperty2.default)({}, DISTRIBUTE_COLUMNS_MENU_ITEM.key, 100), VERTICAL_ALIGN_MENU.key, 200);
|
|
57
|
+
var VERTICAL_ALIGN_MENU_RANK = exports.VERTICAL_ALIGN_MENU_RANK = (0, _defineProperty2.default)({}, LAYOUT_COLUMN_VERTICAL_ALIGN_MENU_SECTION.key, 100);
|
|
58
|
+
var VERTICAL_ALIGN_MENU_SECTION_RANK = exports.VERTICAL_ALIGN_MENU_SECTION_RANK = (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, VERTICAL_ALIGN_TOP_MENU_ITEM.key, 100), VERTICAL_ALIGN_MIDDLE_MENU_ITEM.key, 200), VERTICAL_ALIGN_BOTTOM_MENU_ITEM.key, 300);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useCurrentLayoutColumnValign = exports.getCurrentLayoutColumnValign = void 0;
|
|
7
|
+
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
8
|
+
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
9
|
+
var getCurrentLayoutColumnValign = exports.getCurrentLayoutColumnValign = function getCurrentLayoutColumnValign(selection) {
|
|
10
|
+
var selectedColumn = selection instanceof _state.NodeSelection && selection.node.type.name === 'layoutColumn' ? selection.node : undefined;
|
|
11
|
+
var currentValign = selectedColumn === null || selectedColumn === void 0 ? void 0 : selectedColumn.attrs.valign;
|
|
12
|
+
return {
|
|
13
|
+
currentValign: currentValign,
|
|
14
|
+
selectedColumn: selectedColumn
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
var useCurrentLayoutColumnValign = exports.useCurrentLayoutColumnValign = function useCurrentLayoutColumnValign(api) {
|
|
18
|
+
return (0, _hooks.useSharedPluginStateWithSelector)(api, ['selection'], function (states) {
|
|
19
|
+
var _states$selectionStat;
|
|
20
|
+
return getCurrentLayoutColumnValign((_states$selectionStat = states.selectionState) === null || _states$selectionStat === void 0 ? void 0 : _states$selectionStat.selection);
|
|
21
|
+
});
|
|
22
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.VERTICAL_ALIGN_ICONS = void 0;
|
|
8
|
+
var _alignContentBottom = _interopRequireDefault(require("@atlaskit/icon-lab/core/align-content-bottom"));
|
|
9
|
+
var _alignContentCenterVertical = _interopRequireDefault(require("@atlaskit/icon-lab/core/align-content-center-vertical"));
|
|
10
|
+
var _alignContentTop = _interopRequireDefault(require("@atlaskit/icon-lab/core/align-content-top"));
|
|
11
|
+
// Disable no-re-export here, this is a useful mapping file for icon lookup used in multiple places
|
|
12
|
+
/* eslint-disable @atlaskit/editor/no-re-export */
|
|
13
|
+
|
|
14
|
+
var VERTICAL_ALIGN_ICONS = exports.VERTICAL_ALIGN_ICONS = {
|
|
15
|
+
top: _alignContentTop.default,
|
|
16
|
+
middle: _alignContentCenterVertical.default,
|
|
17
|
+
bottom: _alignContentBottom.default
|
|
18
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { layoutColumn, layoutColumnWithLocalId, layoutSection, layoutSectionWithLocalId } from '@atlaskit/adf-schema';
|
|
2
|
+
import { layoutColumn, layoutColumnStage0, layoutColumnWithLocalId, layoutSection, layoutSectionWithLocalId } from '@atlaskit/adf-schema';
|
|
3
3
|
import { layoutSectionWithSingleColumn, layoutSectionWithSingleColumnLocalId } from '@atlaskit/adf-schema/schema';
|
|
4
4
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
5
5
|
import { TRANSFORM_STRUCTURE_LAYOUT_MENU_ITEM, TRANSFORM_STRUCTURE_MENU_SECTION, TRANSFORM_STRUCTURE_MENU_SECTION_RANK } from '@atlaskit/editor-common/block-menu';
|
|
@@ -10,7 +10,7 @@ import { findParentNode } from '@atlaskit/editor-prosemirror/utils';
|
|
|
10
10
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
11
11
|
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
12
12
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
13
|
-
import { createDefaultLayoutSection, createMultiColumnLayoutSection, insertLayoutColumnsWithAnalytics, toggleLayoutColumnMenu } from './pm-plugins/actions';
|
|
13
|
+
import { createDefaultLayoutSection, createMultiColumnLayoutSection, insertLayoutColumnsWithAnalytics, setLayoutColumnValign, toggleLayoutColumnMenu } from './pm-plugins/actions';
|
|
14
14
|
import { default as createLayoutPlugin } from './pm-plugins/main';
|
|
15
15
|
import { pluginKey } from './pm-plugins/plugin-key';
|
|
16
16
|
import { default as createLayoutResizingPlugin } from './pm-plugins/resizing';
|
|
@@ -86,7 +86,10 @@ export const layoutPlugin = ({
|
|
|
86
86
|
node: editorExperiment('advanced_layouts', true) ? fg('platform_editor_adf_with_localid') ? layoutSectionWithSingleColumnLocalId : layoutSectionWithSingleColumn : fg('platform_editor_adf_with_localid') ? layoutSectionWithLocalId : layoutSection
|
|
87
87
|
}, {
|
|
88
88
|
name: 'layoutColumn',
|
|
89
|
-
node:
|
|
89
|
+
node: expValEqualsNoExposure('platform_editor_layout_column_menu', 'isEnabled', true) ?
|
|
90
|
+
// `layoutColumnStage0` includes both `valign` and `localId` attrs, so it remains
|
|
91
|
+
// compatible with `platform_editor_adf_with_localid` when both flags are enabled.
|
|
92
|
+
layoutColumnStage0 : fg('platform_editor_adf_with_localid') ? layoutColumnWithLocalId : layoutColumn
|
|
90
93
|
}];
|
|
91
94
|
},
|
|
92
95
|
pmPlugins() {
|
|
@@ -287,6 +290,7 @@ export const layoutPlugin = ({
|
|
|
287
290
|
return pluginKey.getState(editorState);
|
|
288
291
|
},
|
|
289
292
|
commands: {
|
|
293
|
+
setLayoutColumnValign,
|
|
290
294
|
toggleLayoutColumnMenu
|
|
291
295
|
}
|
|
292
296
|
};
|
|
@@ -5,6 +5,7 @@ import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
|
|
|
5
5
|
import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
6
6
|
import { safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
7
7
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
8
|
+
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
8
9
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
9
10
|
import { EVEN_DISTRIBUTED_COL_WIDTHS } from './consts';
|
|
10
11
|
import { pluginKey } from './plugin-key';
|
|
@@ -525,6 +526,32 @@ const formatLayoutName = layout => {
|
|
|
525
526
|
return LAYOUT_TYPE.THREE_WITH_SIDEBARS;
|
|
526
527
|
}
|
|
527
528
|
};
|
|
529
|
+
export const setLayoutColumnValign = valign => ({
|
|
530
|
+
tr
|
|
531
|
+
}) => {
|
|
532
|
+
if (!expValEqualsNoExposure('platform_editor_layout_column_menu', 'isEnabled', true)) {
|
|
533
|
+
return null;
|
|
534
|
+
}
|
|
535
|
+
const {
|
|
536
|
+
layoutColumn
|
|
537
|
+
} = tr.doc.type.schema.nodes;
|
|
538
|
+
const selectedColumn = tr.selection instanceof NodeSelection && tr.selection.node.type === layoutColumn ? {
|
|
539
|
+
node: tr.selection.node,
|
|
540
|
+
pos: tr.selection.from
|
|
541
|
+
} : undefined;
|
|
542
|
+
if (!selectedColumn) {
|
|
543
|
+
return null;
|
|
544
|
+
}
|
|
545
|
+
if (selectedColumn.node.attrs.valign === valign) {
|
|
546
|
+
return null;
|
|
547
|
+
}
|
|
548
|
+
tr.setNodeMarkup(selectedColumn.pos, selectedColumn.node.type, {
|
|
549
|
+
...selectedColumn.node.attrs,
|
|
550
|
+
valign
|
|
551
|
+
});
|
|
552
|
+
tr.setMeta('scrollIntoView', false);
|
|
553
|
+
return tr;
|
|
554
|
+
};
|
|
528
555
|
export const toggleLayoutColumnMenu = ({
|
|
529
556
|
isOpen
|
|
530
557
|
}) => ({
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
|
+
import { useIntl } from 'react-intl';
|
|
3
|
+
import { ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
|
|
4
|
+
import { useCurrentLayoutColumnValign } from './useCurrentLayoutColumnValign';
|
|
5
|
+
import { VERTICAL_ALIGN_ICONS } from './verticalAlignIcons';
|
|
6
|
+
export const VerticalAlignDropdownItem = ({
|
|
7
|
+
api,
|
|
8
|
+
label,
|
|
9
|
+
value
|
|
10
|
+
}) => {
|
|
11
|
+
const {
|
|
12
|
+
formatMessage
|
|
13
|
+
} = useIntl();
|
|
14
|
+
const {
|
|
15
|
+
currentValign,
|
|
16
|
+
selectedColumn
|
|
17
|
+
} = useCurrentLayoutColumnValign(api);
|
|
18
|
+
const Icon = VERTICAL_ALIGN_ICONS[value];
|
|
19
|
+
const onClick = useCallback(() => {
|
|
20
|
+
var _api$core, _api$layout;
|
|
21
|
+
api === null || api === void 0 ? void 0 : (_api$core = api.core) === null || _api$core === void 0 ? void 0 : _api$core.actions.execute(api === null || api === void 0 ? void 0 : (_api$layout = api.layout) === null || _api$layout === void 0 ? void 0 : _api$layout.commands.setLayoutColumnValign(value));
|
|
22
|
+
}, [api, value]);
|
|
23
|
+
if (!selectedColumn) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
|
|
27
|
+
elemBefore: /*#__PURE__*/React.createElement(Icon, {
|
|
28
|
+
label: "",
|
|
29
|
+
size: "small"
|
|
30
|
+
}),
|
|
31
|
+
isSelected: currentValign === value,
|
|
32
|
+
onClick: onClick,
|
|
33
|
+
testId: `layout-column-align-${value}`
|
|
34
|
+
}, formatMessage(label));
|
|
35
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useIntl } from 'react-intl';
|
|
3
|
+
import { layoutMessages } from '@atlaskit/editor-common/messages';
|
|
4
|
+
import { LayoutIcon, NestedDropdownRightIcon, ToolbarNestedDropdownMenu } from '@atlaskit/editor-toolbar';
|
|
5
|
+
import { useCurrentLayoutColumnValign } from './useCurrentLayoutColumnValign';
|
|
6
|
+
import { VERTICAL_ALIGN_ICONS } from './verticalAlignIcons';
|
|
7
|
+
export const VerticalAlignNestedMenu = ({
|
|
8
|
+
api,
|
|
9
|
+
children
|
|
10
|
+
}) => {
|
|
11
|
+
const {
|
|
12
|
+
formatMessage
|
|
13
|
+
} = useIntl();
|
|
14
|
+
const {
|
|
15
|
+
currentValign,
|
|
16
|
+
selectedColumn
|
|
17
|
+
} = useCurrentLayoutColumnValign(api);
|
|
18
|
+
const TriggerIcon = currentValign ? VERTICAL_ALIGN_ICONS[currentValign] : LayoutIcon;
|
|
19
|
+
if (!selectedColumn) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
return /*#__PURE__*/React.createElement(ToolbarNestedDropdownMenu, {
|
|
23
|
+
elemBefore: /*#__PURE__*/React.createElement(TriggerIcon, {
|
|
24
|
+
label: "",
|
|
25
|
+
size: "small"
|
|
26
|
+
}),
|
|
27
|
+
elemAfter: /*#__PURE__*/React.createElement(NestedDropdownRightIcon, {
|
|
28
|
+
label: "",
|
|
29
|
+
size: "small"
|
|
30
|
+
}),
|
|
31
|
+
text: formatMessage(layoutMessages.alignColumn),
|
|
32
|
+
testId: "layout-column-align-menu",
|
|
33
|
+
dropdownTestId: "layout-column-align-dropdown"
|
|
34
|
+
}, children);
|
|
35
|
+
};
|