@atlaskit/editor-plugin-breakout 2.4.2 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,30 @@
1
1
  # @atlaskit/editor-plugin-breakout
2
2
 
3
+ ## 2.5.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#163976](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/163976)
8
+ [`668e81e097994`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/668e81e097994) -
9
+ [ux] [ED-28113] this change saves the width as 1800 when resizing to the fullWidth guideline under
10
+ the new resizing experience behind platform_editor_breakout_resizing
11
+
12
+ ### Patch Changes
13
+
14
+ - Updated dependencies
15
+
16
+ ## 2.4.3
17
+
18
+ ### Patch Changes
19
+
20
+ - [#163965](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/163965)
21
+ [`c08b8e623a378`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/c08b8e623a378) -
22
+ [ED-28046] Reduce the number of times the layout button re-renders
23
+ - [#164762](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/164762)
24
+ [`e716071496267`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/e716071496267) -
25
+ [ux] Fix for expands and codeblocks so they keep their settings after resize.
26
+ - Updated dependencies
27
+
3
28
  ## 2.4.2
4
29
 
5
30
  ### Patch Changes
@@ -1,18 +1,21 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof = require("@babel/runtime/helpers/typeof");
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
7
8
  exports.breakoutPlugin = void 0;
9
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
8
10
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
11
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
12
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
- var _react = _interopRequireDefault(require("react"));
13
+ var _react = _interopRequireWildcard(require("react"));
12
14
  var _adfSchema = require("@atlaskit/adf-schema");
13
15
  var _hooks = require("@atlaskit/editor-common/hooks");
14
16
  var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
15
17
  var _styles = require("@atlaskit/editor-common/styles");
18
+ var _usePluginStateEffect = require("@atlaskit/editor-common/use-plugin-state-effect");
16
19
  var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
17
20
  var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
18
21
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
@@ -20,7 +23,9 @@ var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
20
23
  var _pluginKey = require("./pm-plugins/plugin-key");
21
24
  var _resizingPlugin = require("./pm-plugins/resizing-plugin");
22
25
  var _findBreakoutNode = require("./pm-plugins/utils/find-breakout-node");
26
+ var _getBreakoutMode = require("./pm-plugins/utils/get-breakout-mode");
23
27
  var _LayoutButton = _interopRequireDefault(require("./ui/LayoutButton"));
28
+ 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
29
  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; }
25
30
  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
31
  var BreakoutView = /*#__PURE__*/(0, _createClass2.default)(function BreakoutView(
@@ -126,13 +131,12 @@ var useOldHook = function useOldHook(api) {
126
131
  };
127
132
  };
128
133
  var useNewHook = function useNewHook(api) {
129
- var breakoutNode = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'breakout.breakoutNode');
130
134
  var isDragging = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'blockControls.isDragging');
131
135
  var isPMDragging = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'blockControls.isPMDragging');
132
136
  var mode = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'editorViewMode.mode');
133
137
  var editorDisabled = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'editorDisabled.editorDisabled');
134
138
  return {
135
- breakoutNode: breakoutNode,
139
+ breakoutNode: undefined,
136
140
  isDragging: isDragging,
137
141
  isPMDragging: isPMDragging,
138
142
  mode: mode,
@@ -153,6 +157,27 @@ var LayoutButtonWrapper = function LayoutButtonWrapper(_ref2) {
153
157
  isPMDragging = _useSharedState.isPMDragging,
154
158
  mode = _useSharedState.mode,
155
159
  editorDisabled = _useSharedState.editorDisabled;
160
+ var _useState = (0, _react.useState)(false),
161
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
162
+ breakoutNodePresent = _useState2[0],
163
+ setBreakoutNodePresent = _useState2[1];
164
+ var _useState3 = (0, _react.useState)((0, _getBreakoutMode.getBreakoutMode)(editorView.state)),
165
+ _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
166
+ breakoutMode = _useState4[0],
167
+ setBreakoutMode = _useState4[1];
168
+ (0, _usePluginStateEffect.usePluginStateEffect)(api, ['breakout'], function (_ref3) {
169
+ var breakoutState = _ref3.breakoutState;
170
+ if (breakoutState !== null && breakoutState !== void 0 && breakoutState.breakoutNode && !breakoutNodePresent) {
171
+ setBreakoutNodePresent(true);
172
+ }
173
+ if (!(breakoutState !== null && breakoutState !== void 0 && breakoutState.breakoutNode) && breakoutNodePresent) {
174
+ setBreakoutNodePresent(false);
175
+ }
176
+ var nextBreakoutMode = (0, _getBreakoutMode.getBreakoutMode)(editorView.state);
177
+ if (nextBreakoutMode !== breakoutMode) {
178
+ setBreakoutMode(nextBreakoutMode);
179
+ }
180
+ });
156
181
  var interactionState = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'interaction.interactionState');
157
182
  if (interactionState === 'hasNotHadInteraction' && (0, _platformFeatureFlags.fg)('platform_editor_hide_expand_selection_states')) {
158
183
  return null;
@@ -170,12 +195,14 @@ var LayoutButtonWrapper = function LayoutButtonWrapper(_ref2) {
170
195
  boundariesElement: boundariesElement,
171
196
  scrollableElement: scrollableElement,
172
197
  node: (_breakoutNode$node = breakoutNode === null || breakoutNode === void 0 ? void 0 : breakoutNode.node) !== null && _breakoutNode$node !== void 0 ? _breakoutNode$node : null,
173
- isLivePage: isEditMode
198
+ isLivePage: isEditMode,
199
+ isBreakoutNodePresent: breakoutNodePresent,
200
+ breakoutMode: breakoutMode
174
201
  }) : null;
175
202
  };
176
- var breakoutPlugin = exports.breakoutPlugin = function breakoutPlugin(_ref3) {
177
- var options = _ref3.config,
178
- api = _ref3.api;
203
+ var breakoutPlugin = exports.breakoutPlugin = function breakoutPlugin(_ref4) {
204
+ var options = _ref4.config,
205
+ api = _ref4.api;
179
206
  return {
180
207
  name: 'breakout',
181
208
  pmPlugins: function pmPlugins() {
@@ -214,11 +241,11 @@ var breakoutPlugin = exports.breakoutPlugin = function breakoutPlugin(_ref3) {
214
241
  }
215
242
  return pluginState;
216
243
  },
217
- contentComponent: function contentComponent(_ref4) {
218
- var editorView = _ref4.editorView,
219
- popupsMountPoint = _ref4.popupsMountPoint,
220
- popupsBoundariesElement = _ref4.popupsBoundariesElement,
221
- popupsScrollableElement = _ref4.popupsScrollableElement;
244
+ contentComponent: function contentComponent(_ref5) {
245
+ var editorView = _ref5.editorView,
246
+ popupsMountPoint = _ref5.popupsMountPoint,
247
+ popupsBoundariesElement = _ref5.popupsBoundariesElement,
248
+ popupsScrollableElement = _ref5.popupsScrollableElement;
222
249
  // This is a bit crappy, but should be resolved once we move to a static schema.
223
250
  if (options && !options.allowBreakoutButton) {
224
251
  return null;
@@ -4,7 +4,8 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.setBreakoutWidth = setBreakoutWidth;
7
- // TODO: ED-28029 - add fixes for expands and codeblocks
7
+ var _codeBlock = require("@atlaskit/editor-common/code-block");
8
+ var _singlePlayerExpand = require("../pm-plugins/utils/single-player-expand");
8
9
  function setBreakoutWidth(width, mode, pos, isLivePage) {
9
10
  return function (state, dispatch) {
10
11
  var node = state.doc.nodeAt(pos);
@@ -15,6 +16,20 @@ function setBreakoutWidth(width, mode, pos, isLivePage) {
15
16
  width: width,
16
17
  mode: mode
17
18
  })]);
19
+ if (node.type === state.schema.nodes.expand) {
20
+ (0, _singlePlayerExpand.updateExpandedStateNew)({
21
+ tr: tr,
22
+ node: node,
23
+ pos: pos,
24
+ isLivePage: isLivePage
25
+ });
26
+ } else if (node.type === state.schema.nodes.codeBlock) {
27
+ var newNode = tr.doc.nodeAt(pos);
28
+ var oldNode = node;
29
+ if (newNode) {
30
+ (0, _codeBlock.transferCodeBlockWrappedValue)(oldNode, newNode);
31
+ }
32
+ }
18
33
  if (dispatch) {
19
34
  dispatch(tr);
20
35
  }
@@ -1,9 +1,11 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
7
  exports.getGuidelines = void 0;
8
+ var _memoizeOne = _interopRequireDefault(require("memoize-one"));
7
9
  var _styles = require("@atlaskit/editor-common/styles");
8
10
  var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
9
11
  var WIDTHS = {
@@ -15,18 +17,28 @@ var GUIDELINE_KEYS = {
15
17
  wide: 'wide',
16
18
  fullWidth: 'full_width'
17
19
  };
20
+ var AK_NESTED_DND_GUTTER_OFFSET = 8;
18
21
  var roundToNearest = function roundToNearest(value) {
19
22
  var interval = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0.5;
20
23
  return Math.round(value / interval) * interval;
21
24
  };
22
- var getGuidelines = exports.getGuidelines = function getGuidelines(isResizing, newWidth, getEditorWidth, nodeType) {
25
+ var getGuidelines = exports.getGuidelines = (0, _memoizeOne.default)(function (isResizing, newWidth, getEditorWidth, nodeType) {
23
26
  var guidelines = [];
24
27
  if (!isResizing) {
25
28
  return guidelines;
26
29
  }
27
30
  var innerPaddingOffset = 0;
28
- if (nodeType && nodeType.name === 'expand') {
29
- innerPaddingOffset = _styles.resizerHandleThumbWidth;
31
+ if (nodeType) {
32
+ switch (nodeType.name) {
33
+ case 'expand':
34
+ innerPaddingOffset = _styles.EXPAND_CONTAINER_PADDING + _styles.resizerHandleThumbWidth + AK_NESTED_DND_GUTTER_OFFSET;
35
+ break;
36
+ case 'layoutSection':
37
+ innerPaddingOffset = _styles.LAYOUT_COLUMN_PADDING + AK_NESTED_DND_GUTTER_OFFSET;
38
+ break;
39
+ default:
40
+ break;
41
+ }
30
42
  }
31
43
  var _ref = getEditorWidth() || {},
32
44
  width = _ref.width,
@@ -81,4 +93,4 @@ var getGuidelines = exports.getGuidelines = function getGuidelines(isResizing, n
81
93
  });
82
94
  }
83
95
  return guidelines;
84
- };
96
+ });
@@ -20,11 +20,13 @@ function getProposedWidth(_ref) {
20
20
  location = _ref.location,
21
21
  api = _ref.api;
22
22
  var diffX = (location.current.input.clientX - location.initial.input.clientX) * RESIZE_RATIO;
23
- var proposedWidth = initialWidth + diffX;
24
23
 
25
24
  // TODO: ED-28024 - add snapping logic
26
25
 
27
26
  var containerWidth = ((api === null || api === void 0 || (_api$width$sharedStat = api.width.sharedState) === null || _api$width$sharedStat === void 0 || (_api$width$sharedStat = _api$width$sharedStat.currentState()) === null || _api$width$sharedStat === void 0 ? void 0 : _api$width$sharedStat.width) || 0) - 2 * (0, _editorSharedStyles.akEditorGutterPaddingDynamic)() - _editorSharedStyles.akEditorGutterPadding;
27
+
28
+ // the node width may be greater than the container width so we resize using the smaller value
29
+ var proposedWidth = Math.min(initialWidth, containerWidth) + diffX;
28
30
  return Math.min(Math.max(WIDTHS.MIN, Math.min(proposedWidth, containerWidth)), WIDTHS.MAX);
29
31
  }
30
32
  function createResizerCallbacks(_ref2) {
@@ -34,6 +36,7 @@ function createResizerCallbacks(_ref2) {
34
36
  mark = _ref2.mark,
35
37
  api = _ref2.api;
36
38
  var node = null;
39
+ var guidelines = [];
37
40
  var getEditorWidth = function getEditorWidth() {
38
41
  var _api$width;
39
42
  return api === null || api === void 0 || (_api$width = api.width) === null || _api$width === void 0 ? void 0 : _api$width.sharedState.currentState();
@@ -55,7 +58,7 @@ function createResizerCallbacks(_ref2) {
55
58
  location: location,
56
59
  api: api
57
60
  });
58
- var guidelines = (0, _getGuidelines.getGuidelines)(true, newWidth, getEditorWidth, (_node = node) === null || _node === void 0 ? void 0 : _node.type);
61
+ guidelines = (0, _getGuidelines.getGuidelines)(true, newWidth, getEditorWidth, (_node = node) === null || _node === void 0 ? void 0 : _node.type);
59
62
  api === null || api === void 0 || (_api$guideline = api.guideline) === null || _api$guideline === void 0 || (_api$guideline = _api$guideline.actions) === null || _api$guideline === void 0 || _api$guideline.displayGuideline(view)({
60
63
  guidelines: guidelines
61
64
  });
@@ -64,14 +67,17 @@ function createResizerCallbacks(_ref2) {
64
67
  onDrop: function onDrop(_ref4) {
65
68
  var _api$guideline2, _api$userIntent2;
66
69
  var location = _ref4.location;
67
- var guidelines = (0, _getGuidelines.getGuidelines)(false, 0, getEditorWidth);
70
+ var isResizedToFullWidth = !!guidelines.find(function (guideline) {
71
+ return guideline.key.includes('full_width') && guideline.active;
72
+ });
73
+ guidelines = (0, _getGuidelines.getGuidelines)(false, 0, getEditorWidth);
68
74
  api === null || api === void 0 || (_api$guideline2 = api.guideline) === null || _api$guideline2 === void 0 || (_api$guideline2 = _api$guideline2.actions) === null || _api$guideline2 === void 0 || _api$guideline2.displayGuideline(view)({
69
75
  guidelines: guidelines
70
76
  });
71
77
  var pos = view.posAtDOM(dom, 0);
72
78
  var mode = mark.attrs.mode;
73
79
  var initialWidth = mark.attrs.width;
74
- var newWidth = getProposedWidth({
80
+ var newWidth = isResizedToFullWidth ? WIDTHS.MAX : getProposedWidth({
75
81
  initialWidth: initialWidth,
76
82
  location: location,
77
83
  api: api
@@ -3,15 +3,38 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.updateExpandedState = void 0;
6
+ exports.updateExpandedStateNew = exports.updateExpandedState = void 0;
7
7
  var _expand = require("@atlaskit/editor-common/expand");
8
8
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
9
- var updateExpandedState = exports.updateExpandedState = function updateExpandedState(tr, node, isLivePage) {
9
+ var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
10
+ var updateExpandedStateNew = exports.updateExpandedStateNew = function updateExpandedStateNew(_ref) {
11
+ var tr = _ref.tr,
12
+ node = _ref.node,
13
+ pos = _ref.pos,
14
+ isLivePage = _ref.isLivePage;
10
15
  if (isLivePage || (0, _platformFeatureFlags.fg)('platform-editor-single-player-expand')) {
11
- var wasExpandExpanded = _expand.expandedState.get(node.node);
12
- var newExpand = tr.doc.nodeAt(node.pos);
16
+ var wasExpandExpanded = _expand.expandedState.get(node);
17
+ var newExpand = tr.doc.nodeAt(pos);
13
18
  if (wasExpandExpanded !== undefined && newExpand) {
14
19
  _expand.expandedState.set(newExpand, wasExpandExpanded);
15
20
  }
16
21
  }
22
+ };
23
+ var updateExpandedState = exports.updateExpandedState = function updateExpandedState(tr, node, isLivePage) {
24
+ if ((0, _experiments.editorExperiment)('platform_editor_breakout_resizing', true)) {
25
+ updateExpandedStateNew({
26
+ tr: tr,
27
+ node: node.node,
28
+ pos: node.pos,
29
+ isLivePage: isLivePage
30
+ });
31
+ } else {
32
+ if (isLivePage || (0, _platformFeatureFlags.fg)('platform-editor-single-player-expand')) {
33
+ var wasExpandExpanded = _expand.expandedState.get(node.node);
34
+ var newExpand = tr.doc.nodeAt(node.pos);
35
+ if (wasExpandExpanded !== undefined && newExpand) {
36
+ _expand.expandedState.set(newExpand, wasExpandExpanded);
37
+ }
38
+ }
39
+ }
17
40
  };
@@ -20,6 +20,7 @@ var _collapse = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/coll
20
20
  var _expand = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/expand"));
21
21
  var _colors = require("@atlaskit/theme/colors");
22
22
  var _constants = require("@atlaskit/theme/constants");
23
+ var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
23
24
  var _removeBreakout = require("../editor-commands/remove-breakout");
24
25
  var _setBreakoutMode = require("../editor-commands/set-breakout-mode");
25
26
  var _pluginKey = require("../pm-plugins/plugin-key");
@@ -66,7 +67,9 @@ var LayoutButton = function LayoutButton(_ref) {
66
67
  scrollableElement = _ref.scrollableElement,
67
68
  editorView = _ref.editorView,
68
69
  node = _ref.node,
69
- isLivePage = _ref.isLivePage;
70
+ isLivePage = _ref.isLivePage,
71
+ isBreakoutNodePresent = _ref.isBreakoutNodePresent,
72
+ breakoutModeProp = _ref.breakoutMode;
70
73
  var handleClick = (0, _react.useCallback)(function (breakoutMode) {
71
74
  var state = editorView.state,
72
75
  dispatch = editorView.dispatch;
@@ -77,10 +80,11 @@ var LayoutButton = function LayoutButton(_ref) {
77
80
  }
78
81
  }, [editorView, isLivePage]);
79
82
  var state = editorView.state;
80
- if (!node || !(0, _isBreakoutMarkAllowed.isBreakoutMarkAllowed)(state)) {
83
+ var exitCondition = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? !isBreakoutNodePresent : !node;
84
+ if (exitCondition || !(0, _isBreakoutMarkAllowed.isBreakoutMarkAllowed)(state)) {
81
85
  return null;
82
86
  }
83
- var breakoutMode = (0, _getBreakoutMode.getBreakoutMode)(editorView.state);
87
+ var breakoutMode = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? breakoutModeProp : (0, _getBreakoutMode.getBreakoutMode)(editorView.state);
84
88
  var titleMessage = (0, _utils.getTitle)(breakoutMode);
85
89
  var title = formatMessage(titleMessage);
86
90
  var nextBreakoutMode = (0, _utils.getNextBreakoutMode)(breakoutMode);
@@ -1,8 +1,9 @@
1
- import React from 'react';
1
+ import React, { useState } from 'react';
2
2
  import { breakout } from '@atlaskit/adf-schema';
3
3
  import { useSharedPluginState, sharedPluginStateHookMigratorFactory } from '@atlaskit/editor-common/hooks';
4
4
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
5
5
  import { BreakoutCssClassName } from '@atlaskit/editor-common/styles';
6
+ import { usePluginStateEffect } from '@atlaskit/editor-common/use-plugin-state-effect';
6
7
  import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
7
8
  import { akEditorSwoopCubicBezier } from '@atlaskit/editor-shared-styles';
8
9
  import { fg } from '@atlaskit/platform-feature-flags';
@@ -10,6 +11,7 @@ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
10
11
  import { pluginKey } from './pm-plugins/plugin-key';
11
12
  import { createResizingPlugin } from './pm-plugins/resizing-plugin';
12
13
  import { findSupportedNodeForBreakout } from './pm-plugins/utils/find-breakout-node';
14
+ import { getBreakoutMode } from './pm-plugins/utils/get-breakout-mode';
13
15
  import LayoutButton from './ui/LayoutButton';
14
16
  class BreakoutView {
15
17
  constructor(
@@ -118,13 +120,12 @@ const useOldHook = api => {
118
120
  };
119
121
  };
120
122
  const useNewHook = api => {
121
- const breakoutNode = useSharedPluginStateSelector(api, 'breakout.breakoutNode');
122
123
  const isDragging = useSharedPluginStateSelector(api, 'blockControls.isDragging');
123
124
  const isPMDragging = useSharedPluginStateSelector(api, 'blockControls.isPMDragging');
124
125
  const mode = useSharedPluginStateSelector(api, 'editorViewMode.mode');
125
126
  const editorDisabled = useSharedPluginStateSelector(api, 'editorDisabled.editorDisabled');
126
127
  return {
127
- breakoutNode,
128
+ breakoutNode: undefined,
128
129
  isDragging,
129
130
  isPMDragging,
130
131
  mode,
@@ -147,6 +148,22 @@ const LayoutButtonWrapper = ({
147
148
  mode,
148
149
  editorDisabled
149
150
  } = useSharedState(api);
151
+ const [breakoutNodePresent, setBreakoutNodePresent] = useState(false);
152
+ const [breakoutMode, setBreakoutMode] = useState(getBreakoutMode(editorView.state));
153
+ usePluginStateEffect(api, ['breakout'], ({
154
+ breakoutState
155
+ }) => {
156
+ if (breakoutState !== null && breakoutState !== void 0 && breakoutState.breakoutNode && !breakoutNodePresent) {
157
+ setBreakoutNodePresent(true);
158
+ }
159
+ if (!(breakoutState !== null && breakoutState !== void 0 && breakoutState.breakoutNode) && breakoutNodePresent) {
160
+ setBreakoutNodePresent(false);
161
+ }
162
+ const nextBreakoutMode = getBreakoutMode(editorView.state);
163
+ if (nextBreakoutMode !== breakoutMode) {
164
+ setBreakoutMode(nextBreakoutMode);
165
+ }
166
+ });
150
167
  const interactionState = useSharedPluginStateSelector(api, 'interaction.interactionState');
151
168
  if (interactionState === 'hasNotHadInteraction' && fg('platform_editor_hide_expand_selection_states')) {
152
169
  return null;
@@ -164,7 +181,9 @@ const LayoutButtonWrapper = ({
164
181
  boundariesElement: boundariesElement,
165
182
  scrollableElement: scrollableElement,
166
183
  node: (_breakoutNode$node = breakoutNode === null || breakoutNode === void 0 ? void 0 : breakoutNode.node) !== null && _breakoutNode$node !== void 0 ? _breakoutNode$node : null,
167
- isLivePage: isEditMode
184
+ isLivePage: isEditMode,
185
+ isBreakoutNodePresent: breakoutNodePresent,
186
+ breakoutMode: breakoutMode
168
187
  }) : null;
169
188
  };
170
189
  export const breakoutPlugin = ({
@@ -1,4 +1,5 @@
1
- // TODO: ED-28029 - add fixes for expands and codeblocks
1
+ import { transferCodeBlockWrappedValue } from '@atlaskit/editor-common/code-block';
2
+ import { updateExpandedStateNew } from '../pm-plugins/utils/single-player-expand';
2
3
  export function setBreakoutWidth(width, mode, pos, isLivePage) {
3
4
  return (state, dispatch) => {
4
5
  const node = state.doc.nodeAt(pos);
@@ -9,6 +10,20 @@ export function setBreakoutWidth(width, mode, pos, isLivePage) {
9
10
  width,
10
11
  mode
11
12
  })]);
13
+ if (node.type === state.schema.nodes.expand) {
14
+ updateExpandedStateNew({
15
+ tr,
16
+ node,
17
+ pos,
18
+ isLivePage
19
+ });
20
+ } else if (node.type === state.schema.nodes.codeBlock) {
21
+ const newNode = tr.doc.nodeAt(pos);
22
+ const oldNode = node;
23
+ if (newNode) {
24
+ transferCodeBlockWrappedValue(oldNode, newNode);
25
+ }
26
+ }
12
27
  if (dispatch) {
13
28
  dispatch(tr);
14
29
  }
@@ -1,4 +1,5 @@
1
- import { resizerHandleThumbWidth } from '@atlaskit/editor-common/styles';
1
+ import memoizeOne from 'memoize-one';
2
+ import { EXPAND_CONTAINER_PADDING, LAYOUT_COLUMN_PADDING, resizerHandleThumbWidth } from '@atlaskit/editor-common/styles';
2
3
  import { akEditorGutterPaddingDynamic, akEditorGutterPadding, akEditorCalculatedWideLayoutWidth, akEditorFullWidthLayoutWidth, akEditorDefaultLayoutWidth } from '@atlaskit/editor-shared-styles';
3
4
  const WIDTHS = {
4
5
  MIN: akEditorDefaultLayoutWidth,
@@ -9,15 +10,25 @@ const GUIDELINE_KEYS = {
9
10
  wide: 'wide',
10
11
  fullWidth: 'full_width'
11
12
  };
13
+ const AK_NESTED_DND_GUTTER_OFFSET = 8;
12
14
  const roundToNearest = (value, interval = 0.5) => Math.round(value / interval) * interval;
13
- export const getGuidelines = (isResizing, newWidth, getEditorWidth, nodeType) => {
15
+ export const getGuidelines = memoizeOne((isResizing, newWidth, getEditorWidth, nodeType) => {
14
16
  const guidelines = [];
15
17
  if (!isResizing) {
16
18
  return guidelines;
17
19
  }
18
20
  let innerPaddingOffset = 0;
19
- if (nodeType && nodeType.name === 'expand') {
20
- innerPaddingOffset = resizerHandleThumbWidth;
21
+ if (nodeType) {
22
+ switch (nodeType.name) {
23
+ case 'expand':
24
+ innerPaddingOffset = EXPAND_CONTAINER_PADDING + resizerHandleThumbWidth + AK_NESTED_DND_GUTTER_OFFSET;
25
+ break;
26
+ case 'layoutSection':
27
+ innerPaddingOffset = LAYOUT_COLUMN_PADDING + AK_NESTED_DND_GUTTER_OFFSET;
28
+ break;
29
+ default:
30
+ break;
31
+ }
21
32
  }
22
33
  const {
23
34
  width,
@@ -73,4 +84,4 @@ export const getGuidelines = (isResizing, newWidth, getEditorWidth, nodeType) =>
73
84
  });
74
85
  }
75
86
  return guidelines;
76
- };
87
+ });
@@ -14,11 +14,13 @@ export function getProposedWidth({
14
14
  }) {
15
15
  var _api$width$sharedStat, _api$width$sharedStat2;
16
16
  const diffX = (location.current.input.clientX - location.initial.input.clientX) * RESIZE_RATIO;
17
- const proposedWidth = initialWidth + diffX;
18
17
 
19
18
  // TODO: ED-28024 - add snapping logic
20
19
 
21
20
  const containerWidth = ((api === null || api === void 0 ? void 0 : (_api$width$sharedStat = api.width.sharedState) === null || _api$width$sharedStat === void 0 ? void 0 : (_api$width$sharedStat2 = _api$width$sharedStat.currentState()) === null || _api$width$sharedStat2 === void 0 ? void 0 : _api$width$sharedStat2.width) || 0) - 2 * akEditorGutterPaddingDynamic() - akEditorGutterPadding;
21
+
22
+ // the node width may be greater than the container width so we resize using the smaller value
23
+ const proposedWidth = Math.min(initialWidth, containerWidth) + diffX;
22
24
  return Math.min(Math.max(WIDTHS.MIN, Math.min(proposedWidth, containerWidth)), WIDTHS.MAX);
23
25
  }
24
26
  export function createResizerCallbacks({
@@ -29,6 +31,7 @@ export function createResizerCallbacks({
29
31
  api
30
32
  }) {
31
33
  let node = null;
34
+ let guidelines = [];
32
35
  const getEditorWidth = () => {
33
36
  var _api$width;
34
37
  return api === null || api === void 0 ? void 0 : (_api$width = api.width) === null || _api$width === void 0 ? void 0 : _api$width.sharedState.currentState();
@@ -51,7 +54,7 @@ export function createResizerCallbacks({
51
54
  location,
52
55
  api
53
56
  });
54
- const guidelines = getGuidelines(true, newWidth, getEditorWidth, (_node = node) === null || _node === void 0 ? void 0 : _node.type);
57
+ guidelines = getGuidelines(true, newWidth, getEditorWidth, (_node = node) === null || _node === void 0 ? void 0 : _node.type);
55
58
  api === null || api === void 0 ? void 0 : (_api$guideline = api.guideline) === null || _api$guideline === void 0 ? void 0 : (_api$guideline$action = _api$guideline.actions) === null || _api$guideline$action === void 0 ? void 0 : _api$guideline$action.displayGuideline(view)({
56
59
  guidelines
57
60
  });
@@ -61,14 +64,15 @@ export function createResizerCallbacks({
61
64
  location
62
65
  }) {
63
66
  var _api$guideline2, _api$guideline2$actio, _api$userIntent2;
64
- const guidelines = getGuidelines(false, 0, getEditorWidth);
67
+ const isResizedToFullWidth = !!guidelines.find(guideline => guideline.key.includes('full_width') && guideline.active);
68
+ guidelines = getGuidelines(false, 0, getEditorWidth);
65
69
  api === null || api === void 0 ? void 0 : (_api$guideline2 = api.guideline) === null || _api$guideline2 === void 0 ? void 0 : (_api$guideline2$actio = _api$guideline2.actions) === null || _api$guideline2$actio === void 0 ? void 0 : _api$guideline2$actio.displayGuideline(view)({
66
70
  guidelines
67
71
  });
68
72
  const pos = view.posAtDOM(dom, 0);
69
73
  const mode = mark.attrs.mode;
70
74
  const initialWidth = mark.attrs.width;
71
- const newWidth = getProposedWidth({
75
+ const newWidth = isResizedToFullWidth ? WIDTHS.MAX : getProposedWidth({
72
76
  initialWidth,
73
77
  location,
74
78
  api
@@ -1,11 +1,35 @@
1
1
  import { expandedState } from '@atlaskit/editor-common/expand';
2
2
  import { fg } from '@atlaskit/platform-feature-flags';
3
- export const updateExpandedState = (tr, node, isLivePage) => {
3
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
4
+ export const updateExpandedStateNew = ({
5
+ tr,
6
+ node,
7
+ pos,
8
+ isLivePage
9
+ }) => {
4
10
  if (isLivePage || fg('platform-editor-single-player-expand')) {
5
- const wasExpandExpanded = expandedState.get(node.node);
6
- const newExpand = tr.doc.nodeAt(node.pos);
11
+ const wasExpandExpanded = expandedState.get(node);
12
+ const newExpand = tr.doc.nodeAt(pos);
7
13
  if (wasExpandExpanded !== undefined && newExpand) {
8
14
  expandedState.set(newExpand, wasExpandExpanded);
9
15
  }
10
16
  }
17
+ };
18
+ export const updateExpandedState = (tr, node, isLivePage) => {
19
+ if (editorExperiment('platform_editor_breakout_resizing', true)) {
20
+ updateExpandedStateNew({
21
+ tr,
22
+ node: node.node,
23
+ pos: node.pos,
24
+ isLivePage
25
+ });
26
+ } else {
27
+ if (isLivePage || fg('platform-editor-single-player-expand')) {
28
+ const wasExpandExpanded = expandedState.get(node.node);
29
+ const newExpand = tr.doc.nodeAt(node.pos);
30
+ if (wasExpandExpanded !== undefined && newExpand) {
31
+ expandedState.set(newExpand, wasExpandExpanded);
32
+ }
33
+ }
34
+ }
11
35
  };
@@ -19,6 +19,7 @@ import CollapseIcon from '@atlaskit/icon/glyph/editor/collapse';
19
19
  import ExpandIcon from '@atlaskit/icon/glyph/editor/expand';
20
20
  import { B300, N20A, N300 } from '@atlaskit/theme/colors';
21
21
  import { layers } from '@atlaskit/theme/constants';
22
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
22
23
  import { removeBreakout } from '../editor-commands/remove-breakout';
23
24
  import { setBreakoutMode } from '../editor-commands/set-breakout-mode';
24
25
  import { getPluginState } from '../pm-plugins/plugin-key';
@@ -60,7 +61,9 @@ const LayoutButton = ({
60
61
  scrollableElement,
61
62
  editorView,
62
63
  node,
63
- isLivePage
64
+ isLivePage,
65
+ isBreakoutNodePresent,
66
+ breakoutMode: breakoutModeProp
64
67
  }) => {
65
68
  const handleClick = useCallback(breakoutMode => {
66
69
  const {
@@ -76,10 +79,11 @@ const LayoutButton = ({
76
79
  const {
77
80
  state
78
81
  } = editorView;
79
- if (!node || !isBreakoutMarkAllowed(state)) {
82
+ const exitCondition = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? !isBreakoutNodePresent : !node;
83
+ if (exitCondition || !isBreakoutMarkAllowed(state)) {
80
84
  return null;
81
85
  }
82
- const breakoutMode = getBreakoutMode(editorView.state);
86
+ const breakoutMode = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? breakoutModeProp : getBreakoutMode(editorView.state);
83
87
  const titleMessage = getTitle(breakoutMode);
84
88
  const title = formatMessage(titleMessage);
85
89
  const nextBreakoutMode = getNextBreakoutMode(breakoutMode);
@@ -1,13 +1,15 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
1
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
3
  import _createClass from "@babel/runtime/helpers/createClass";
3
4
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
4
5
  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; }
5
6
  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; }
6
- import React from 'react';
7
+ import React, { useState } from 'react';
7
8
  import { breakout } from '@atlaskit/adf-schema';
8
9
  import { useSharedPluginState, sharedPluginStateHookMigratorFactory } from '@atlaskit/editor-common/hooks';
9
10
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
10
11
  import { BreakoutCssClassName } from '@atlaskit/editor-common/styles';
12
+ import { usePluginStateEffect } from '@atlaskit/editor-common/use-plugin-state-effect';
11
13
  import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
12
14
  import { akEditorSwoopCubicBezier } from '@atlaskit/editor-shared-styles';
13
15
  import { fg } from '@atlaskit/platform-feature-flags';
@@ -15,6 +17,7 @@ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
15
17
  import { pluginKey } from './pm-plugins/plugin-key';
16
18
  import { createResizingPlugin } from './pm-plugins/resizing-plugin';
17
19
  import { findSupportedNodeForBreakout } from './pm-plugins/utils/find-breakout-node';
20
+ import { getBreakoutMode } from './pm-plugins/utils/get-breakout-mode';
18
21
  import LayoutButton from './ui/LayoutButton';
19
22
  var BreakoutView = /*#__PURE__*/_createClass(function BreakoutView(
20
23
  /**
@@ -119,13 +122,12 @@ var useOldHook = function useOldHook(api) {
119
122
  };
120
123
  };
121
124
  var useNewHook = function useNewHook(api) {
122
- var breakoutNode = useSharedPluginStateSelector(api, 'breakout.breakoutNode');
123
125
  var isDragging = useSharedPluginStateSelector(api, 'blockControls.isDragging');
124
126
  var isPMDragging = useSharedPluginStateSelector(api, 'blockControls.isPMDragging');
125
127
  var mode = useSharedPluginStateSelector(api, 'editorViewMode.mode');
126
128
  var editorDisabled = useSharedPluginStateSelector(api, 'editorDisabled.editorDisabled');
127
129
  return {
128
- breakoutNode: breakoutNode,
130
+ breakoutNode: undefined,
129
131
  isDragging: isDragging,
130
132
  isPMDragging: isPMDragging,
131
133
  mode: mode,
@@ -146,6 +148,27 @@ var LayoutButtonWrapper = function LayoutButtonWrapper(_ref2) {
146
148
  isPMDragging = _useSharedState.isPMDragging,
147
149
  mode = _useSharedState.mode,
148
150
  editorDisabled = _useSharedState.editorDisabled;
151
+ var _useState = useState(false),
152
+ _useState2 = _slicedToArray(_useState, 2),
153
+ breakoutNodePresent = _useState2[0],
154
+ setBreakoutNodePresent = _useState2[1];
155
+ var _useState3 = useState(getBreakoutMode(editorView.state)),
156
+ _useState4 = _slicedToArray(_useState3, 2),
157
+ breakoutMode = _useState4[0],
158
+ setBreakoutMode = _useState4[1];
159
+ usePluginStateEffect(api, ['breakout'], function (_ref3) {
160
+ var breakoutState = _ref3.breakoutState;
161
+ if (breakoutState !== null && breakoutState !== void 0 && breakoutState.breakoutNode && !breakoutNodePresent) {
162
+ setBreakoutNodePresent(true);
163
+ }
164
+ if (!(breakoutState !== null && breakoutState !== void 0 && breakoutState.breakoutNode) && breakoutNodePresent) {
165
+ setBreakoutNodePresent(false);
166
+ }
167
+ var nextBreakoutMode = getBreakoutMode(editorView.state);
168
+ if (nextBreakoutMode !== breakoutMode) {
169
+ setBreakoutMode(nextBreakoutMode);
170
+ }
171
+ });
149
172
  var interactionState = useSharedPluginStateSelector(api, 'interaction.interactionState');
150
173
  if (interactionState === 'hasNotHadInteraction' && fg('platform_editor_hide_expand_selection_states')) {
151
174
  return null;
@@ -163,12 +186,14 @@ var LayoutButtonWrapper = function LayoutButtonWrapper(_ref2) {
163
186
  boundariesElement: boundariesElement,
164
187
  scrollableElement: scrollableElement,
165
188
  node: (_breakoutNode$node = breakoutNode === null || breakoutNode === void 0 ? void 0 : breakoutNode.node) !== null && _breakoutNode$node !== void 0 ? _breakoutNode$node : null,
166
- isLivePage: isEditMode
189
+ isLivePage: isEditMode,
190
+ isBreakoutNodePresent: breakoutNodePresent,
191
+ breakoutMode: breakoutMode
167
192
  }) : null;
168
193
  };
169
- export var breakoutPlugin = function breakoutPlugin(_ref3) {
170
- var options = _ref3.config,
171
- api = _ref3.api;
194
+ export var breakoutPlugin = function breakoutPlugin(_ref4) {
195
+ var options = _ref4.config,
196
+ api = _ref4.api;
172
197
  return {
173
198
  name: 'breakout',
174
199
  pmPlugins: function pmPlugins() {
@@ -207,11 +232,11 @@ export var breakoutPlugin = function breakoutPlugin(_ref3) {
207
232
  }
208
233
  return pluginState;
209
234
  },
210
- contentComponent: function contentComponent(_ref4) {
211
- var editorView = _ref4.editorView,
212
- popupsMountPoint = _ref4.popupsMountPoint,
213
- popupsBoundariesElement = _ref4.popupsBoundariesElement,
214
- popupsScrollableElement = _ref4.popupsScrollableElement;
235
+ contentComponent: function contentComponent(_ref5) {
236
+ var editorView = _ref5.editorView,
237
+ popupsMountPoint = _ref5.popupsMountPoint,
238
+ popupsBoundariesElement = _ref5.popupsBoundariesElement,
239
+ popupsScrollableElement = _ref5.popupsScrollableElement;
215
240
  // This is a bit crappy, but should be resolved once we move to a static schema.
216
241
  if (options && !options.allowBreakoutButton) {
217
242
  return null;
@@ -1,4 +1,5 @@
1
- // TODO: ED-28029 - add fixes for expands and codeblocks
1
+ import { transferCodeBlockWrappedValue } from '@atlaskit/editor-common/code-block';
2
+ import { updateExpandedStateNew } from '../pm-plugins/utils/single-player-expand';
2
3
  export function setBreakoutWidth(width, mode, pos, isLivePage) {
3
4
  return function (state, dispatch) {
4
5
  var node = state.doc.nodeAt(pos);
@@ -9,6 +10,20 @@ export function setBreakoutWidth(width, mode, pos, isLivePage) {
9
10
  width: width,
10
11
  mode: mode
11
12
  })]);
13
+ if (node.type === state.schema.nodes.expand) {
14
+ updateExpandedStateNew({
15
+ tr: tr,
16
+ node: node,
17
+ pos: pos,
18
+ isLivePage: isLivePage
19
+ });
20
+ } else if (node.type === state.schema.nodes.codeBlock) {
21
+ var newNode = tr.doc.nodeAt(pos);
22
+ var oldNode = node;
23
+ if (newNode) {
24
+ transferCodeBlockWrappedValue(oldNode, newNode);
25
+ }
26
+ }
12
27
  if (dispatch) {
13
28
  dispatch(tr);
14
29
  }
@@ -1,4 +1,5 @@
1
- import { resizerHandleThumbWidth } from '@atlaskit/editor-common/styles';
1
+ import memoizeOne from 'memoize-one';
2
+ import { EXPAND_CONTAINER_PADDING, LAYOUT_COLUMN_PADDING, resizerHandleThumbWidth } from '@atlaskit/editor-common/styles';
2
3
  import { akEditorGutterPaddingDynamic, akEditorGutterPadding, akEditorCalculatedWideLayoutWidth, akEditorFullWidthLayoutWidth, akEditorDefaultLayoutWidth } from '@atlaskit/editor-shared-styles';
3
4
  var WIDTHS = {
4
5
  MIN: akEditorDefaultLayoutWidth,
@@ -9,18 +10,28 @@ var GUIDELINE_KEYS = {
9
10
  wide: 'wide',
10
11
  fullWidth: 'full_width'
11
12
  };
13
+ var AK_NESTED_DND_GUTTER_OFFSET = 8;
12
14
  var roundToNearest = function roundToNearest(value) {
13
15
  var interval = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0.5;
14
16
  return Math.round(value / interval) * interval;
15
17
  };
16
- export var getGuidelines = function getGuidelines(isResizing, newWidth, getEditorWidth, nodeType) {
18
+ export var getGuidelines = memoizeOne(function (isResizing, newWidth, getEditorWidth, nodeType) {
17
19
  var guidelines = [];
18
20
  if (!isResizing) {
19
21
  return guidelines;
20
22
  }
21
23
  var innerPaddingOffset = 0;
22
- if (nodeType && nodeType.name === 'expand') {
23
- innerPaddingOffset = resizerHandleThumbWidth;
24
+ if (nodeType) {
25
+ switch (nodeType.name) {
26
+ case 'expand':
27
+ innerPaddingOffset = EXPAND_CONTAINER_PADDING + resizerHandleThumbWidth + AK_NESTED_DND_GUTTER_OFFSET;
28
+ break;
29
+ case 'layoutSection':
30
+ innerPaddingOffset = LAYOUT_COLUMN_PADDING + AK_NESTED_DND_GUTTER_OFFSET;
31
+ break;
32
+ default:
33
+ break;
34
+ }
24
35
  }
25
36
  var _ref = getEditorWidth() || {},
26
37
  width = _ref.width,
@@ -75,4 +86,4 @@ export var getGuidelines = function getGuidelines(isResizing, newWidth, getEdito
75
86
  });
76
87
  }
77
88
  return guidelines;
78
- };
89
+ });
@@ -13,11 +13,13 @@ export function getProposedWidth(_ref) {
13
13
  location = _ref.location,
14
14
  api = _ref.api;
15
15
  var diffX = (location.current.input.clientX - location.initial.input.clientX) * RESIZE_RATIO;
16
- var proposedWidth = initialWidth + diffX;
17
16
 
18
17
  // TODO: ED-28024 - add snapping logic
19
18
 
20
19
  var containerWidth = ((api === null || api === void 0 || (_api$width$sharedStat = api.width.sharedState) === null || _api$width$sharedStat === void 0 || (_api$width$sharedStat = _api$width$sharedStat.currentState()) === null || _api$width$sharedStat === void 0 ? void 0 : _api$width$sharedStat.width) || 0) - 2 * akEditorGutterPaddingDynamic() - akEditorGutterPadding;
20
+
21
+ // the node width may be greater than the container width so we resize using the smaller value
22
+ var proposedWidth = Math.min(initialWidth, containerWidth) + diffX;
21
23
  return Math.min(Math.max(WIDTHS.MIN, Math.min(proposedWidth, containerWidth)), WIDTHS.MAX);
22
24
  }
23
25
  export function createResizerCallbacks(_ref2) {
@@ -27,6 +29,7 @@ export function createResizerCallbacks(_ref2) {
27
29
  mark = _ref2.mark,
28
30
  api = _ref2.api;
29
31
  var node = null;
32
+ var guidelines = [];
30
33
  var getEditorWidth = function getEditorWidth() {
31
34
  var _api$width;
32
35
  return api === null || api === void 0 || (_api$width = api.width) === null || _api$width === void 0 ? void 0 : _api$width.sharedState.currentState();
@@ -48,7 +51,7 @@ export function createResizerCallbacks(_ref2) {
48
51
  location: location,
49
52
  api: api
50
53
  });
51
- var guidelines = getGuidelines(true, newWidth, getEditorWidth, (_node = node) === null || _node === void 0 ? void 0 : _node.type);
54
+ guidelines = getGuidelines(true, newWidth, getEditorWidth, (_node = node) === null || _node === void 0 ? void 0 : _node.type);
52
55
  api === null || api === void 0 || (_api$guideline = api.guideline) === null || _api$guideline === void 0 || (_api$guideline = _api$guideline.actions) === null || _api$guideline === void 0 || _api$guideline.displayGuideline(view)({
53
56
  guidelines: guidelines
54
57
  });
@@ -57,14 +60,17 @@ export function createResizerCallbacks(_ref2) {
57
60
  onDrop: function onDrop(_ref4) {
58
61
  var _api$guideline2, _api$userIntent2;
59
62
  var location = _ref4.location;
60
- var guidelines = getGuidelines(false, 0, getEditorWidth);
63
+ var isResizedToFullWidth = !!guidelines.find(function (guideline) {
64
+ return guideline.key.includes('full_width') && guideline.active;
65
+ });
66
+ guidelines = getGuidelines(false, 0, getEditorWidth);
61
67
  api === null || api === void 0 || (_api$guideline2 = api.guideline) === null || _api$guideline2 === void 0 || (_api$guideline2 = _api$guideline2.actions) === null || _api$guideline2 === void 0 || _api$guideline2.displayGuideline(view)({
62
68
  guidelines: guidelines
63
69
  });
64
70
  var pos = view.posAtDOM(dom, 0);
65
71
  var mode = mark.attrs.mode;
66
72
  var initialWidth = mark.attrs.width;
67
- var newWidth = getProposedWidth({
73
+ var newWidth = isResizedToFullWidth ? WIDTHS.MAX : getProposedWidth({
68
74
  initialWidth: initialWidth,
69
75
  location: location,
70
76
  api: api
@@ -1,11 +1,34 @@
1
1
  import { expandedState } from '@atlaskit/editor-common/expand';
2
2
  import { fg } from '@atlaskit/platform-feature-flags';
3
- export var updateExpandedState = function updateExpandedState(tr, node, isLivePage) {
3
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
4
+ export var updateExpandedStateNew = function updateExpandedStateNew(_ref) {
5
+ var tr = _ref.tr,
6
+ node = _ref.node,
7
+ pos = _ref.pos,
8
+ isLivePage = _ref.isLivePage;
4
9
  if (isLivePage || fg('platform-editor-single-player-expand')) {
5
- var wasExpandExpanded = expandedState.get(node.node);
6
- var newExpand = tr.doc.nodeAt(node.pos);
10
+ var wasExpandExpanded = expandedState.get(node);
11
+ var newExpand = tr.doc.nodeAt(pos);
7
12
  if (wasExpandExpanded !== undefined && newExpand) {
8
13
  expandedState.set(newExpand, wasExpandExpanded);
9
14
  }
10
15
  }
16
+ };
17
+ export var updateExpandedState = function updateExpandedState(tr, node, isLivePage) {
18
+ if (editorExperiment('platform_editor_breakout_resizing', true)) {
19
+ updateExpandedStateNew({
20
+ tr: tr,
21
+ node: node.node,
22
+ pos: node.pos,
23
+ isLivePage: isLivePage
24
+ });
25
+ } else {
26
+ if (isLivePage || fg('platform-editor-single-player-expand')) {
27
+ var wasExpandExpanded = expandedState.get(node.node);
28
+ var newExpand = tr.doc.nodeAt(node.pos);
29
+ if (wasExpandExpanded !== undefined && newExpand) {
30
+ expandedState.set(newExpand, wasExpandExpanded);
31
+ }
32
+ }
33
+ }
11
34
  };
@@ -19,6 +19,7 @@ import CollapseIcon from '@atlaskit/icon/glyph/editor/collapse';
19
19
  import ExpandIcon from '@atlaskit/icon/glyph/editor/expand';
20
20
  import { B300, N20A, N300 } from '@atlaskit/theme/colors';
21
21
  import { layers } from '@atlaskit/theme/constants';
22
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
22
23
  import { removeBreakout } from '../editor-commands/remove-breakout';
23
24
  import { setBreakoutMode } from '../editor-commands/set-breakout-mode';
24
25
  import { getPluginState } from '../pm-plugins/plugin-key';
@@ -58,7 +59,9 @@ var LayoutButton = function LayoutButton(_ref) {
58
59
  scrollableElement = _ref.scrollableElement,
59
60
  editorView = _ref.editorView,
60
61
  node = _ref.node,
61
- isLivePage = _ref.isLivePage;
62
+ isLivePage = _ref.isLivePage,
63
+ isBreakoutNodePresent = _ref.isBreakoutNodePresent,
64
+ breakoutModeProp = _ref.breakoutMode;
62
65
  var handleClick = useCallback(function (breakoutMode) {
63
66
  var state = editorView.state,
64
67
  dispatch = editorView.dispatch;
@@ -69,10 +72,11 @@ var LayoutButton = function LayoutButton(_ref) {
69
72
  }
70
73
  }, [editorView, isLivePage]);
71
74
  var state = editorView.state;
72
- if (!node || !isBreakoutMarkAllowed(state)) {
75
+ var exitCondition = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? !isBreakoutNodePresent : !node;
76
+ if (exitCondition || !isBreakoutMarkAllowed(state)) {
73
77
  return null;
74
78
  }
75
- var breakoutMode = getBreakoutMode(editorView.state);
79
+ var breakoutMode = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? breakoutModeProp : getBreakoutMode(editorView.state);
76
80
  var titleMessage = getTitle(breakoutMode);
77
81
  var title = formatMessage(titleMessage);
78
82
  var nextBreakoutMode = getNextBreakoutMode(breakoutMode);
@@ -1,4 +1,4 @@
1
1
  import { GuidelineConfig } from '@atlaskit/editor-common/guideline';
2
2
  import { EditorContainerWidth } from '@atlaskit/editor-common/types';
3
3
  import { NodeType } from '@atlaskit/editor-prosemirror/model';
4
- export declare const getGuidelines: (isResizing: boolean, newWidth: number, getEditorWidth: () => EditorContainerWidth | undefined, nodeType?: NodeType | undefined) => GuidelineConfig[];
4
+ export declare const getGuidelines: import("memoize-one").MemoizedFn<(isResizing: boolean, newWidth: number, getEditorWidth: () => EditorContainerWidth | undefined, nodeType?: NodeType | undefined) => GuidelineConfig[]>;
@@ -1,3 +1,12 @@
1
+ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
1
2
  import type { Transaction } from '@atlaskit/editor-prosemirror/state';
2
3
  import type { ContentNodeWithPos } from '@atlaskit/editor-prosemirror/utils';
4
+ interface UpdateExpandedStateNew {
5
+ tr: Transaction;
6
+ node: PMNode;
7
+ pos: number;
8
+ isLivePage?: boolean;
9
+ }
10
+ export declare const updateExpandedStateNew: ({ tr, node, pos, isLivePage }: UpdateExpandedStateNew) => void;
3
11
  export declare const updateExpandedState: (tr: Transaction, node: ContentNodeWithPos, isLivePage?: boolean) => void;
12
+ export {};
@@ -1,5 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import type { WrappedComponentProps } from 'react-intl-next';
3
+ import type { BreakoutMode } from '@atlaskit/editor-common/types';
3
4
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
4
5
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
5
6
  export interface Props {
@@ -10,6 +11,8 @@ export interface Props {
10
11
  scrollableElement?: HTMLElement;
11
12
  handleClick?: Function;
12
13
  isLivePage?: boolean;
14
+ isBreakoutNodePresent: boolean;
15
+ breakoutMode: BreakoutMode | undefined;
13
16
  }
14
17
  declare const _default: import("react").FC<import("react-intl-next").WithIntlProps<Props & WrappedComponentProps>> & {
15
18
  WrappedComponent: import("react").ComponentType<Props & WrappedComponentProps>;
@@ -1,4 +1,4 @@
1
1
  import { GuidelineConfig } from '@atlaskit/editor-common/guideline';
2
2
  import { EditorContainerWidth } from '@atlaskit/editor-common/types';
3
3
  import { NodeType } from '@atlaskit/editor-prosemirror/model';
4
- export declare const getGuidelines: (isResizing: boolean, newWidth: number, getEditorWidth: () => EditorContainerWidth | undefined, nodeType?: NodeType | undefined) => GuidelineConfig[];
4
+ export declare const getGuidelines: import("memoize-one").MemoizedFn<(isResizing: boolean, newWidth: number, getEditorWidth: () => EditorContainerWidth | undefined, nodeType?: NodeType | undefined) => GuidelineConfig[]>;
@@ -1,3 +1,12 @@
1
+ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
1
2
  import type { Transaction } from '@atlaskit/editor-prosemirror/state';
2
3
  import type { ContentNodeWithPos } from '@atlaskit/editor-prosemirror/utils';
4
+ interface UpdateExpandedStateNew {
5
+ tr: Transaction;
6
+ node: PMNode;
7
+ pos: number;
8
+ isLivePage?: boolean;
9
+ }
10
+ export declare const updateExpandedStateNew: ({ tr, node, pos, isLivePage }: UpdateExpandedStateNew) => void;
3
11
  export declare const updateExpandedState: (tr: Transaction, node: ContentNodeWithPos, isLivePage?: boolean) => void;
12
+ export {};
@@ -1,5 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import type { WrappedComponentProps } from 'react-intl-next';
3
+ import type { BreakoutMode } from '@atlaskit/editor-common/types';
3
4
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
4
5
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
5
6
  export interface Props {
@@ -10,6 +11,8 @@ export interface Props {
10
11
  scrollableElement?: HTMLElement;
11
12
  handleClick?: Function;
12
13
  isLivePage?: boolean;
14
+ isBreakoutNodePresent: boolean;
15
+ breakoutMode: BreakoutMode | undefined;
13
16
  }
14
17
  declare const _default: import("react").FC<import("react-intl-next").WithIntlProps<Props & WrappedComponentProps>> & {
15
18
  WrappedComponent: import("react").ComponentType<Props & WrappedComponentProps>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-breakout",
3
- "version": "2.4.2",
3
+ "version": "2.5.0",
4
4
  "description": "Breakout plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -48,10 +48,11 @@
48
48
  "@atlaskit/platform-feature-flags": "^1.1.0",
49
49
  "@atlaskit/pragmatic-drag-and-drop": "^1.7.0",
50
50
  "@atlaskit/theme": "^18.0.0",
51
- "@atlaskit/tmp-editor-statsig": "^5.7.0",
51
+ "@atlaskit/tmp-editor-statsig": "^5.8.0",
52
52
  "@atlaskit/tokens": "^5.0.0",
53
53
  "@babel/runtime": "^7.0.0",
54
- "@emotion/react": "^11.7.1"
54
+ "@emotion/react": "^11.7.1",
55
+ "memoize-one": "^6.0.0"
55
56
  },
56
57
  "peerDependencies": {
57
58
  "react": "^18.2.0",