@atlaskit/editor-plugin-layout 3.2.2 → 4.0.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 CHANGED
@@ -1,5 +1,19 @@
1
1
  # @atlaskit/editor-plugin-layout
2
2
 
3
+ ## 4.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 4.0.0
10
+
11
+ ### Patch Changes
12
+
13
+ - [`e882e86092666`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/e882e86092666) -
14
+ [ux] Register expand, layout and code block itmes in block menu. Update panel item.
15
+ - Updated dependencies
16
+
3
17
  ## 3.2.2
4
18
 
5
19
  ### Patch Changes
@@ -9,17 +9,20 @@ var _react = _interopRequireDefault(require("react"));
9
9
  var _adfSchema = require("@atlaskit/adf-schema");
10
10
  var _schema = require("@atlaskit/adf-schema/schema");
11
11
  var _analytics = require("@atlaskit/editor-common/analytics");
12
+ var _blockMenu = require("@atlaskit/editor-common/block-menu");
12
13
  var _messages = require("@atlaskit/editor-common/messages");
13
14
  var _quickInsert = require("@atlaskit/editor-common/quick-insert");
14
15
  var _state = require("@atlaskit/editor-prosemirror/state");
15
16
  var _utils = require("@atlaskit/editor-prosemirror/utils");
16
17
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
18
+ var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
17
19
  var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
18
20
  var _actions = require("./pm-plugins/actions");
19
21
  var _main = _interopRequireDefault(require("./pm-plugins/main"));
20
22
  var _pluginKey = require("./pm-plugins/plugin-key");
21
23
  var _resizing = _interopRequireDefault(require("./pm-plugins/resizing"));
22
24
  var _globalStyles = require("./ui/global-styles");
25
+ var _LayoutBlockMenuItem = require("./ui/LayoutBlockMenuItem");
23
26
  var _toolbar = require("./ui/toolbar");
24
27
  /**
25
28
  * This function is used to set the selection into
@@ -56,6 +59,19 @@ var layoutPlugin = exports.layoutPlugin = function layoutPlugin(_ref) {
56
59
  var allowAdvancedSingleColumnLayout = (0, _experiments.editorExperiment)('advanced_layouts', true) && (0, _experiments.editorExperiment)('single_column_layouts', true, {
57
60
  exposure: true
58
61
  });
62
+ if ((0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu', 'isEnabled', true)) {
63
+ var _api$blockMenu;
64
+ api === null || api === void 0 || (_api$blockMenu = api.blockMenu) === null || _api$blockMenu === void 0 || _api$blockMenu.actions.registerBlockMenuComponents([{
65
+ type: 'block-menu-item',
66
+ key: _blockMenu.FORMAT_LAYOUT_MENU_ITEM.key,
67
+ parent: {
68
+ type: 'block-menu-section',
69
+ key: _blockMenu.FORMAT_MENU_ITEM.key,
70
+ rank: _blockMenu.FORMAT_NESTED_MENU_RANK[_blockMenu.FORMAT_LAYOUT_MENU_ITEM.key]
71
+ },
72
+ component: (0, _LayoutBlockMenuItem.createLayoutBlockMenuItem)(api)
73
+ }]);
74
+ }
59
75
  return {
60
76
  name: 'layout',
61
77
  nodes: function nodes() {
@@ -11,18 +11,22 @@ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/creat
11
11
  var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
12
12
  var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
13
13
  var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
14
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
14
15
  var _react = _interopRequireWildcard(require("react"));
15
16
  var _hooks = require("@atlaskit/editor-common/hooks");
16
17
  var _reactNodeView = _interopRequireDefault(require("@atlaskit/editor-common/react-node-view"));
17
18
  var _resizer = require("@atlaskit/editor-common/resizer");
18
19
  var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
19
20
  var _model = require("@atlaskit/editor-prosemirror/model");
21
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
20
22
  var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
21
23
  var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
22
24
  var _utils = require("../pm-plugins/utils");
23
25
  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); }
24
26
  function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
25
27
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
28
+ 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; }
29
+ 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; }
26
30
  var layoutDynamicFullWidthGuidelineOffset = 16;
27
31
  var isEmptyParagraph = function isEmptyParagraph(node) {
28
32
  return !!node && node.type.name === 'paragraph' && !node.childCount;
@@ -110,12 +114,14 @@ var LayoutBreakoutResizer = function LayoutBreakoutResizer(_ref) {
110
114
  dynamicFullWidthGuidelineOffset: layoutDynamicFullWidthGuidelineOffset
111
115
  });
112
116
  };
113
- var toDOM = function toDOM() {
117
+ var toDOM = function toDOM(node) {
114
118
  return ['div', {
115
119
  class: 'layout-section-container'
116
- }, ['div', {
120
+ }, ['div', _objectSpread({
117
121
  'data-layout-section': true
118
- }, 0]];
122
+ }, (0, _platformFeatureFlags.fg)('platform_editor_adf_with_localid') && {
123
+ 'data-local-id': node.attrs.localId
124
+ }), 0]];
119
125
  };
120
126
 
121
127
  /**
@@ -152,7 +158,7 @@ var LayoutSectionView = exports.LayoutSectionView = /*#__PURE__*/function (_Reac
152
158
  return (0, _createClass2.default)(LayoutSectionView, [{
153
159
  key: "getContentDOM",
154
160
  value: function getContentDOM() {
155
- var _ref2 = _model.DOMSerializer.renderSpec(document, toDOM()),
161
+ var _ref2 = _model.DOMSerializer.renderSpec(document, toDOM(this.node)),
156
162
  container = _ref2.dom,
157
163
  contentDOM = _ref2.contentDOM;
158
164
 
@@ -161,6 +167,9 @@ var LayoutSectionView = exports.LayoutSectionView = /*#__PURE__*/function (_Reac
161
167
  this.layoutDOM = container.querySelector('[data-layout-section]');
162
168
  this.layoutDOM.setAttribute('data-column-rule-style', this.node.attrs.columnRuleStyle);
163
169
  this.layoutDOM.setAttribute('data-empty-layout', Boolean(this.isEmpty).toString());
170
+ if ((0, _platformFeatureFlags.fg)('platform_editor_adf_with_localid')) {
171
+ this.layoutDOM.setAttribute('data-local-id', this.node.attrs.localId);
172
+ }
164
173
  return {
165
174
  dom: container,
166
175
  contentDOM: contentDOM
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof = require("@babel/runtime/helpers/typeof");
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.createLayoutBlockMenuItem = void 0;
9
+ var _react = _interopRequireWildcard(require("react"));
10
+ var _reactIntlNext = require("react-intl-next");
11
+ var _messages = require("@atlaskit/editor-common/messages");
12
+ var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
13
+ var _state = require("@atlaskit/editor-prosemirror/state");
14
+ var _editorToolbar = require("@atlaskit/editor-toolbar");
15
+ var _layoutTwoColumns = _interopRequireDefault(require("@atlaskit/icon/core/layout-two-columns"));
16
+ 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); }
17
+ var LayoutBlockMenuItem = function LayoutBlockMenuItem(_ref) {
18
+ var api = _ref.api;
19
+ var _useIntl = (0, _reactIntlNext.useIntl)(),
20
+ formatMessage = _useIntl.formatMessage;
21
+ var selection = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'selection.selection');
22
+ var isLayoutSelected = (0, _react.useMemo)(function () {
23
+ if (!selection) {
24
+ return false;
25
+ }
26
+ if (selection instanceof _state.NodeSelection) {
27
+ return selection.node.type.name === 'layoutSection';
28
+ }
29
+ return false;
30
+ }, [selection]);
31
+ var handleClick = function handleClick() {
32
+ var _api$blockMenu;
33
+ api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 || (_api$blockMenu = api.blockMenu) === null || _api$blockMenu === void 0 ? void 0 : _api$blockMenu.commands.formatNode('layout'));
34
+ };
35
+ return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItem, {
36
+ onClick: handleClick,
37
+ isSelected: isLayoutSelected,
38
+ elemBefore: /*#__PURE__*/_react.default.createElement(_layoutTwoColumns.default, {
39
+ label: ""
40
+ })
41
+ }, formatMessage(_messages.blockMenuMessages.layout));
42
+ };
43
+ var createLayoutBlockMenuItem = exports.createLayoutBlockMenuItem = function createLayoutBlockMenuItem(api) {
44
+ return function () {
45
+ return /*#__PURE__*/_react.default.createElement(LayoutBlockMenuItem, {
46
+ api: api
47
+ });
48
+ };
49
+ };
@@ -2,17 +2,20 @@ import React from 'react';
2
2
  import { layoutColumn, layoutSection, layoutColumnWithLocalId, 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
+ import { FORMAT_MENU_ITEM, FORMAT_LAYOUT_MENU_ITEM, FORMAT_NESTED_MENU_RANK } from '@atlaskit/editor-common/block-menu';
5
6
  import { layoutMessages, toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
6
7
  import { IconFiveColumnLayout, IconFourColumnLayout, IconLayout, IconOneColumnLayout, IconThreeColumnLayout, IconTwoColumnLayout } from '@atlaskit/editor-common/quick-insert';
7
8
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
8
9
  import { findParentNode } from '@atlaskit/editor-prosemirror/utils';
9
10
  import { fg } from '@atlaskit/platform-feature-flags';
11
+ import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
10
12
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
11
13
  import { createDefaultLayoutSection, createMultiColumnLayoutSection, insertLayoutColumnsWithAnalytics } from './pm-plugins/actions';
12
14
  import { default as createLayoutPlugin } from './pm-plugins/main';
13
15
  import { pluginKey } from './pm-plugins/plugin-key';
14
16
  import { default as createLayoutResizingPlugin } from './pm-plugins/resizing';
15
17
  import { GlobalStylesWrapper } from './ui/global-styles';
18
+ import { createLayoutBlockMenuItem } from './ui/LayoutBlockMenuItem';
16
19
  import { buildToolbar } from './ui/toolbar';
17
20
 
18
21
  /**
@@ -49,6 +52,19 @@ export const layoutPlugin = ({
49
52
  const allowAdvancedSingleColumnLayout = editorExperiment('advanced_layouts', true) && editorExperiment('single_column_layouts', true, {
50
53
  exposure: true
51
54
  });
55
+ if (expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true)) {
56
+ var _api$blockMenu;
57
+ api === null || api === void 0 ? void 0 : (_api$blockMenu = api.blockMenu) === null || _api$blockMenu === void 0 ? void 0 : _api$blockMenu.actions.registerBlockMenuComponents([{
58
+ type: 'block-menu-item',
59
+ key: FORMAT_LAYOUT_MENU_ITEM.key,
60
+ parent: {
61
+ type: 'block-menu-section',
62
+ key: FORMAT_MENU_ITEM.key,
63
+ rank: FORMAT_NESTED_MENU_RANK[FORMAT_LAYOUT_MENU_ITEM.key]
64
+ },
65
+ component: createLayoutBlockMenuItem(api)
66
+ }]);
67
+ }
52
68
  return {
53
69
  name: 'layout',
54
70
  nodes() {
@@ -4,6 +4,7 @@ import ReactNodeView from '@atlaskit/editor-common/react-node-view';
4
4
  import { BreakoutResizer, ignoreResizerMutations } from '@atlaskit/editor-common/resizer';
5
5
  import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
6
6
  import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
7
+ import { fg } from '@atlaskit/platform-feature-flags';
7
8
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
8
9
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
9
10
  import { selectIntoLayout } from '../pm-plugins/utils';
@@ -96,10 +97,13 @@ const LayoutBreakoutResizer = ({
96
97
  dynamicFullWidthGuidelineOffset: layoutDynamicFullWidthGuidelineOffset
97
98
  });
98
99
  };
99
- const toDOM = () => ['div', {
100
+ const toDOM = node => ['div', {
100
101
  class: 'layout-section-container'
101
102
  }, ['div', {
102
- 'data-layout-section': true
103
+ 'data-layout-section': true,
104
+ ...(fg('platform_editor_adf_with_localid') && {
105
+ 'data-local-id': node.attrs.localId
106
+ })
103
107
  }, 0]];
104
108
 
105
109
  /**
@@ -133,13 +137,16 @@ export class LayoutSectionView extends ReactNodeView {
133
137
  const {
134
138
  dom: container,
135
139
  contentDOM
136
- } = DOMSerializer.renderSpec(document, toDOM());
140
+ } = DOMSerializer.renderSpec(document, toDOM(this.node));
137
141
 
138
142
  // Ignored via go/ees005
139
143
  // eslint-disable-next-line @atlaskit/editor/no-as-casting
140
144
  this.layoutDOM = container.querySelector('[data-layout-section]');
141
145
  this.layoutDOM.setAttribute('data-column-rule-style', this.node.attrs.columnRuleStyle);
142
146
  this.layoutDOM.setAttribute('data-empty-layout', Boolean(this.isEmpty).toString());
147
+ if (fg('platform_editor_adf_with_localid')) {
148
+ this.layoutDOM.setAttribute('data-local-id', this.node.attrs.localId);
149
+ }
143
150
  return {
144
151
  dom: container,
145
152
  contentDOM
@@ -0,0 +1,40 @@
1
+ import React, { useMemo } from 'react';
2
+ import { useIntl } from 'react-intl-next';
3
+ import { blockMenuMessages } from '@atlaskit/editor-common/messages';
4
+ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
5
+ import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
6
+ import { ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
7
+ import LayoutTwoColumnsIcon from '@atlaskit/icon/core/layout-two-columns';
8
+ const LayoutBlockMenuItem = ({
9
+ api
10
+ }) => {
11
+ const {
12
+ formatMessage
13
+ } = useIntl();
14
+ const selection = useSharedPluginStateSelector(api, 'selection.selection');
15
+ const isLayoutSelected = useMemo(() => {
16
+ if (!selection) {
17
+ return false;
18
+ }
19
+ if (selection instanceof NodeSelection) {
20
+ return selection.node.type.name === 'layoutSection';
21
+ }
22
+ return false;
23
+ }, [selection]);
24
+ const handleClick = () => {
25
+ var _api$blockMenu;
26
+ api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 ? void 0 : (_api$blockMenu = api.blockMenu) === null || _api$blockMenu === void 0 ? void 0 : _api$blockMenu.commands.formatNode('layout'));
27
+ };
28
+ return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
29
+ onClick: handleClick,
30
+ isSelected: isLayoutSelected,
31
+ elemBefore: /*#__PURE__*/React.createElement(LayoutTwoColumnsIcon, {
32
+ label: ""
33
+ })
34
+ }, formatMessage(blockMenuMessages.layout));
35
+ };
36
+ export const createLayoutBlockMenuItem = api => {
37
+ return () => /*#__PURE__*/React.createElement(LayoutBlockMenuItem, {
38
+ api: api
39
+ });
40
+ };
@@ -2,17 +2,20 @@ import React from 'react';
2
2
  import { layoutColumn, layoutSection, layoutColumnWithLocalId, 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
+ import { FORMAT_MENU_ITEM, FORMAT_LAYOUT_MENU_ITEM, FORMAT_NESTED_MENU_RANK } from '@atlaskit/editor-common/block-menu';
5
6
  import { layoutMessages, toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
6
7
  import { IconFiveColumnLayout, IconFourColumnLayout, IconLayout, IconOneColumnLayout, IconThreeColumnLayout, IconTwoColumnLayout } from '@atlaskit/editor-common/quick-insert';
7
8
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
8
9
  import { findParentNode } from '@atlaskit/editor-prosemirror/utils';
9
10
  import { fg } from '@atlaskit/platform-feature-flags';
11
+ import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
10
12
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
11
13
  import { createDefaultLayoutSection, createMultiColumnLayoutSection, insertLayoutColumnsWithAnalytics } from './pm-plugins/actions';
12
14
  import { default as createLayoutPlugin } from './pm-plugins/main';
13
15
  import { pluginKey } from './pm-plugins/plugin-key';
14
16
  import { default as createLayoutResizingPlugin } from './pm-plugins/resizing';
15
17
  import { GlobalStylesWrapper } from './ui/global-styles';
18
+ import { createLayoutBlockMenuItem } from './ui/LayoutBlockMenuItem';
16
19
  import { buildToolbar } from './ui/toolbar';
17
20
 
18
21
  /**
@@ -50,6 +53,19 @@ export var layoutPlugin = function layoutPlugin(_ref) {
50
53
  var allowAdvancedSingleColumnLayout = editorExperiment('advanced_layouts', true) && editorExperiment('single_column_layouts', true, {
51
54
  exposure: true
52
55
  });
56
+ if (expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true)) {
57
+ var _api$blockMenu;
58
+ api === null || api === void 0 || (_api$blockMenu = api.blockMenu) === null || _api$blockMenu === void 0 || _api$blockMenu.actions.registerBlockMenuComponents([{
59
+ type: 'block-menu-item',
60
+ key: FORMAT_LAYOUT_MENU_ITEM.key,
61
+ parent: {
62
+ type: 'block-menu-section',
63
+ key: FORMAT_MENU_ITEM.key,
64
+ rank: FORMAT_NESTED_MENU_RANK[FORMAT_LAYOUT_MENU_ITEM.key]
65
+ },
66
+ component: createLayoutBlockMenuItem(api)
67
+ }]);
68
+ }
53
69
  return {
54
70
  name: 'layout',
55
71
  nodes: function nodes() {
@@ -3,14 +3,18 @@ import _createClass from "@babel/runtime/helpers/createClass";
3
3
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
4
4
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
5
5
  import _inherits from "@babel/runtime/helpers/inherits";
6
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
6
7
  function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
7
8
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
9
+ 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; }
10
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
8
11
  import React, { useCallback } from 'react';
9
12
  import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
10
13
  import ReactNodeView from '@atlaskit/editor-common/react-node-view';
11
14
  import { BreakoutResizer, ignoreResizerMutations } from '@atlaskit/editor-common/resizer';
12
15
  import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
13
16
  import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
17
+ import { fg } from '@atlaskit/platform-feature-flags';
14
18
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
15
19
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
16
20
  import { selectIntoLayout } from '../pm-plugins/utils';
@@ -101,12 +105,14 @@ var LayoutBreakoutResizer = function LayoutBreakoutResizer(_ref) {
101
105
  dynamicFullWidthGuidelineOffset: layoutDynamicFullWidthGuidelineOffset
102
106
  });
103
107
  };
104
- var toDOM = function toDOM() {
108
+ var toDOM = function toDOM(node) {
105
109
  return ['div', {
106
110
  class: 'layout-section-container'
107
- }, ['div', {
111
+ }, ['div', _objectSpread({
108
112
  'data-layout-section': true
109
- }, 0]];
113
+ }, fg('platform_editor_adf_with_localid') && {
114
+ 'data-local-id': node.attrs.localId
115
+ }), 0]];
110
116
  };
111
117
 
112
118
  /**
@@ -143,7 +149,7 @@ export var LayoutSectionView = /*#__PURE__*/function (_ReactNodeView) {
143
149
  return _createClass(LayoutSectionView, [{
144
150
  key: "getContentDOM",
145
151
  value: function getContentDOM() {
146
- var _ref2 = DOMSerializer.renderSpec(document, toDOM()),
152
+ var _ref2 = DOMSerializer.renderSpec(document, toDOM(this.node)),
147
153
  container = _ref2.dom,
148
154
  contentDOM = _ref2.contentDOM;
149
155
 
@@ -152,6 +158,9 @@ export var LayoutSectionView = /*#__PURE__*/function (_ReactNodeView) {
152
158
  this.layoutDOM = container.querySelector('[data-layout-section]');
153
159
  this.layoutDOM.setAttribute('data-column-rule-style', this.node.attrs.columnRuleStyle);
154
160
  this.layoutDOM.setAttribute('data-empty-layout', Boolean(this.isEmpty).toString());
161
+ if (fg('platform_editor_adf_with_localid')) {
162
+ this.layoutDOM.setAttribute('data-local-id', this.node.attrs.localId);
163
+ }
155
164
  return {
156
165
  dom: container,
157
166
  contentDOM: contentDOM
@@ -0,0 +1,40 @@
1
+ import React, { useMemo } from 'react';
2
+ import { useIntl } from 'react-intl-next';
3
+ import { blockMenuMessages } from '@atlaskit/editor-common/messages';
4
+ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
5
+ import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
6
+ import { ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
7
+ import LayoutTwoColumnsIcon from '@atlaskit/icon/core/layout-two-columns';
8
+ var LayoutBlockMenuItem = function LayoutBlockMenuItem(_ref) {
9
+ var api = _ref.api;
10
+ var _useIntl = useIntl(),
11
+ formatMessage = _useIntl.formatMessage;
12
+ var selection = useSharedPluginStateSelector(api, 'selection.selection');
13
+ var isLayoutSelected = useMemo(function () {
14
+ if (!selection) {
15
+ return false;
16
+ }
17
+ if (selection instanceof NodeSelection) {
18
+ return selection.node.type.name === 'layoutSection';
19
+ }
20
+ return false;
21
+ }, [selection]);
22
+ var handleClick = function handleClick() {
23
+ var _api$blockMenu;
24
+ api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 || (_api$blockMenu = api.blockMenu) === null || _api$blockMenu === void 0 ? void 0 : _api$blockMenu.commands.formatNode('layout'));
25
+ };
26
+ return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
27
+ onClick: handleClick,
28
+ isSelected: isLayoutSelected,
29
+ elemBefore: /*#__PURE__*/React.createElement(LayoutTwoColumnsIcon, {
30
+ label: ""
31
+ })
32
+ }, formatMessage(blockMenuMessages.layout));
33
+ };
34
+ export var createLayoutBlockMenuItem = function createLayoutBlockMenuItem(api) {
35
+ return function () {
36
+ return /*#__PURE__*/React.createElement(LayoutBlockMenuItem, {
37
+ api: api
38
+ });
39
+ };
40
+ };
@@ -1,5 +1,6 @@
1
1
  import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
2
2
  import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
3
+ import type { BlockMenuPlugin } from '@atlaskit/editor-plugin-block-menu';
3
4
  import type { DecorationsPlugin } from '@atlaskit/editor-plugin-decorations';
4
5
  import type { EditorDisabledPlugin } from '@atlaskit/editor-plugin-editor-disabled';
5
6
  import type { GuidelinePlugin } from '@atlaskit/editor-plugin-guideline';
@@ -15,7 +16,8 @@ export type LayoutPluginDependencies = [
15
16
  OptionalPlugin<WidthPlugin>,
16
17
  OptionalPlugin<EditorDisabledPlugin>,
17
18
  OptionalPlugin<GuidelinePlugin>,
18
- OptionalPlugin<InteractionPlugin>
19
+ OptionalPlugin<InteractionPlugin>,
20
+ OptionalPlugin<BlockMenuPlugin>
19
21
  ];
20
22
  export type LayoutPlugin = NextEditorPlugin<'layout', {
21
23
  actions: {
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
+ import type { LayoutPlugin } from '../layoutPluginType';
4
+ export declare const createLayoutBlockMenuItem: (api: ExtractInjectionAPI<LayoutPlugin>) => () => React.JSX.Element;
@@ -1,5 +1,6 @@
1
1
  import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
2
2
  import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
3
+ import type { BlockMenuPlugin } from '@atlaskit/editor-plugin-block-menu';
3
4
  import type { DecorationsPlugin } from '@atlaskit/editor-plugin-decorations';
4
5
  import type { EditorDisabledPlugin } from '@atlaskit/editor-plugin-editor-disabled';
5
6
  import type { GuidelinePlugin } from '@atlaskit/editor-plugin-guideline';
@@ -15,7 +16,8 @@ export type LayoutPluginDependencies = [
15
16
  OptionalPlugin<WidthPlugin>,
16
17
  OptionalPlugin<EditorDisabledPlugin>,
17
18
  OptionalPlugin<GuidelinePlugin>,
18
- OptionalPlugin<InteractionPlugin>
19
+ OptionalPlugin<InteractionPlugin>,
20
+ OptionalPlugin<BlockMenuPlugin>
19
21
  ];
20
22
  export type LayoutPlugin = NextEditorPlugin<'layout', {
21
23
  actions: {
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
+ import type { LayoutPlugin } from '../layoutPluginType';
4
+ export declare const createLayoutBlockMenuItem: (api: ExtractInjectionAPI<LayoutPlugin>) => () => React.JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-layout",
3
- "version": "3.2.2",
3
+ "version": "4.0.1",
4
4
  "description": "Layout plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -30,25 +30,27 @@
30
30
  "atlaskit:src": "src/index.ts",
31
31
  "dependencies": {
32
32
  "@atlaskit/adf-schema": "^50.2.3",
33
- "@atlaskit/editor-plugin-analytics": "^3.0.0",
34
- "@atlaskit/editor-plugin-decorations": "^3.1.0",
35
- "@atlaskit/editor-plugin-editor-disabled": "^3.0.0",
36
- "@atlaskit/editor-plugin-guideline": "^3.0.0",
37
- "@atlaskit/editor-plugin-interaction": "^5.0.0",
38
- "@atlaskit/editor-plugin-selection": "^3.2.0",
39
- "@atlaskit/editor-plugin-width": "^4.0.0",
33
+ "@atlaskit/editor-plugin-analytics": "^4.0.0",
34
+ "@atlaskit/editor-plugin-block-menu": "^1.0.0",
35
+ "@atlaskit/editor-plugin-decorations": "^4.0.0",
36
+ "@atlaskit/editor-plugin-editor-disabled": "^4.0.0",
37
+ "@atlaskit/editor-plugin-guideline": "^4.0.0",
38
+ "@atlaskit/editor-plugin-interaction": "^6.0.0",
39
+ "@atlaskit/editor-plugin-selection": "^4.0.0",
40
+ "@atlaskit/editor-plugin-width": "^5.0.0",
40
41
  "@atlaskit/editor-prosemirror": "7.0.0",
41
42
  "@atlaskit/editor-shared-styles": "^3.6.0",
43
+ "@atlaskit/editor-toolbar": "^0.7.0",
42
44
  "@atlaskit/icon": "^28.1.0",
43
45
  "@atlaskit/icon-lab": "^5.7.0",
44
46
  "@atlaskit/platform-feature-flags": "^1.1.0",
45
- "@atlaskit/tmp-editor-statsig": "^11.9.0",
47
+ "@atlaskit/tmp-editor-statsig": "^12.2.0",
46
48
  "@atlaskit/tokens": "^6.1.0",
47
49
  "@babel/runtime": "^7.0.0",
48
50
  "@emotion/react": "^11.7.1"
49
51
  },
50
52
  "peerDependencies": {
51
- "@atlaskit/editor-common": "^107.33.0",
53
+ "@atlaskit/editor-common": "^108.1.0",
52
54
  "react": "^18.2.0",
53
55
  "react-intl-next": "npm:react-intl@^5.18.1"
54
56
  },