@atlaskit/editor-plugin-breakout 2.4.3 → 2.5.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,28 @@
1
1
  # @atlaskit/editor-plugin-breakout
2
2
 
3
+ ## 2.5.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#164129](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/164129)
8
+ [`ef34428363521`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/ef34428363521) -
9
+ [ux] ED-28058 fix left drag handle experience for new resizing under
10
+ platform_editor_breakout_resizing
11
+ - Updated dependencies
12
+
13
+ ## 2.5.0
14
+
15
+ ### Minor Changes
16
+
17
+ - [#163976](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/163976)
18
+ [`668e81e097994`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/668e81e097994) -
19
+ [ux] [ED-28113] this change saves the width as 1800 when resizing to the fullWidth guideline under
20
+ the new resizing experience behind platform_editor_breakout_resizing
21
+
22
+ ### Patch Changes
23
+
24
+ - Updated dependencies
25
+
3
26
  ## 2.4.3
4
27
 
5
28
  ### Patch Changes
@@ -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
+ });
@@ -11,7 +11,7 @@ var createPragmaticResizer = exports.createPragmaticResizer = function createPra
11
11
  var onDragStart = _ref.onDragStart,
12
12
  onDrag = _ref.onDrag,
13
13
  _onDrop = _ref.onDrop;
14
- var registerHandle = function registerHandle(handleElement) {
14
+ var registerHandle = function registerHandle(handleElement, handleSide) {
15
15
  return (0, _adapter.draggable)({
16
16
  element: handleElement,
17
17
  onGenerateDragPreview: function onGenerateDragPreview(_ref2) {
@@ -21,6 +21,11 @@ var createPragmaticResizer = exports.createPragmaticResizer = function createPra
21
21
  });
22
22
  _preventUnhandled.preventUnhandled.start();
23
23
  },
24
+ getInitialData: function getInitialData() {
25
+ return {
26
+ handleSide: handleSide
27
+ };
28
+ },
24
29
  onDragStart: onDragStart,
25
30
  onDrag: onDrag,
26
31
  onDrop: function onDrop(args) {
@@ -47,8 +52,8 @@ var createPragmaticResizer = exports.createPragmaticResizer = function createPra
47
52
  };
48
53
  var rightHandle = createHandle('right');
49
54
  var leftHandle = createHandle('left');
50
- var rightHandleCleanup = registerHandle(rightHandle);
51
- var leftHandleCleanup = registerHandle(leftHandle);
55
+ var rightHandleCleanup = registerHandle(rightHandle, 'right');
56
+ var leftHandleCleanup = registerHandle(leftHandle, 'left');
52
57
  return {
53
58
  rightHandle: rightHandle,
54
59
  leftHandle: leftHandle,
@@ -18,13 +18,17 @@ function getProposedWidth(_ref) {
18
18
  var _api$width$sharedStat;
19
19
  var initialWidth = _ref.initialWidth,
20
20
  location = _ref.location,
21
- api = _ref.api;
22
- var diffX = (location.current.input.clientX - location.initial.input.clientX) * RESIZE_RATIO;
23
- var proposedWidth = initialWidth + diffX;
21
+ api = _ref.api,
22
+ source = _ref.source;
23
+ var directionMultiplier = source.data.handleSide === 'left' ? -1 : 1;
24
+ var diffX = (location.current.input.clientX - location.initial.input.clientX) * RESIZE_RATIO * directionMultiplier;
24
25
 
25
26
  // TODO: ED-28024 - add snapping logic
26
27
 
27
28
  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;
29
+
30
+ // the node width may be greater than the container width so we resize using the smaller value
31
+ var proposedWidth = Math.min(initialWidth, containerWidth) + diffX;
28
32
  return Math.min(Math.max(WIDTHS.MIN, Math.min(proposedWidth, containerWidth)), WIDTHS.MAX);
29
33
  }
30
34
  function createResizerCallbacks(_ref2) {
@@ -34,6 +38,7 @@ function createResizerCallbacks(_ref2) {
34
38
  mark = _ref2.mark,
35
39
  api = _ref2.api;
36
40
  var node = null;
41
+ var guidelines = [];
37
42
  var getEditorWidth = function getEditorWidth() {
38
43
  var _api$width;
39
44
  return api === null || api === void 0 || (_api$width = api.width) === null || _api$width === void 0 ? void 0 : _api$width.sharedState.currentState();
@@ -48,14 +53,16 @@ function createResizerCallbacks(_ref2) {
48
53
  },
49
54
  onDrag: function onDrag(_ref3) {
50
55
  var _node, _api$guideline;
51
- var location = _ref3.location;
56
+ var location = _ref3.location,
57
+ source = _ref3.source;
52
58
  var initialWidth = mark.attrs.width;
53
59
  var newWidth = getProposedWidth({
54
60
  initialWidth: initialWidth,
55
61
  location: location,
56
- api: api
62
+ api: api,
63
+ source: source
57
64
  });
58
- var guidelines = (0, _getGuidelines.getGuidelines)(true, newWidth, getEditorWidth, (_node = node) === null || _node === void 0 ? void 0 : _node.type);
65
+ guidelines = (0, _getGuidelines.getGuidelines)(true, newWidth, getEditorWidth, (_node = node) === null || _node === void 0 ? void 0 : _node.type);
59
66
  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
67
  guidelines: guidelines
61
68
  });
@@ -63,18 +70,23 @@ function createResizerCallbacks(_ref2) {
63
70
  },
64
71
  onDrop: function onDrop(_ref4) {
65
72
  var _api$guideline2, _api$userIntent2;
66
- var location = _ref4.location;
67
- var guidelines = (0, _getGuidelines.getGuidelines)(false, 0, getEditorWidth);
73
+ var location = _ref4.location,
74
+ source = _ref4.source;
75
+ var isResizedToFullWidth = !!guidelines.find(function (guideline) {
76
+ return guideline.key.includes('full_width') && guideline.active;
77
+ });
78
+ guidelines = (0, _getGuidelines.getGuidelines)(false, 0, getEditorWidth);
68
79
  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
80
  guidelines: guidelines
70
81
  });
71
82
  var pos = view.posAtDOM(dom, 0);
72
83
  var mode = mark.attrs.mode;
73
84
  var initialWidth = mark.attrs.width;
74
- var newWidth = getProposedWidth({
85
+ var newWidth = isResizedToFullWidth ? WIDTHS.MAX : getProposedWidth({
75
86
  initialWidth: initialWidth,
76
87
  location: location,
77
- api: api
88
+ api: api,
89
+ source: source
78
90
  });
79
91
  (0, _setBreakoutWidth.setBreakoutWidth)(newWidth, mode, pos)(view.state, view.dispatch);
80
92
  contentDOM.style.removeProperty(_resizingMarkView.LOCAL_RESIZE_PROPERTY);
@@ -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
+ });
@@ -6,7 +6,7 @@ export const createPragmaticResizer = ({
6
6
  onDrag,
7
7
  onDrop
8
8
  }) => {
9
- const registerHandle = handleElement => {
9
+ const registerHandle = (handleElement, handleSide) => {
10
10
  return draggable({
11
11
  element: handleElement,
12
12
  onGenerateDragPreview: ({
@@ -17,6 +17,9 @@ export const createPragmaticResizer = ({
17
17
  });
18
18
  preventUnhandled.start();
19
19
  },
20
+ getInitialData: () => ({
21
+ handleSide
22
+ }),
20
23
  onDragStart,
21
24
  onDrag,
22
25
  onDrop(args) {
@@ -43,8 +46,8 @@ export const createPragmaticResizer = ({
43
46
  };
44
47
  const rightHandle = createHandle('right');
45
48
  const leftHandle = createHandle('left');
46
- const rightHandleCleanup = registerHandle(rightHandle);
47
- const leftHandleCleanup = registerHandle(leftHandle);
49
+ const rightHandleCleanup = registerHandle(rightHandle, 'right');
50
+ const leftHandleCleanup = registerHandle(leftHandle, 'left');
48
51
  return {
49
52
  rightHandle,
50
53
  leftHandle,
@@ -10,15 +10,19 @@ const WIDTHS = {
10
10
  export function getProposedWidth({
11
11
  initialWidth,
12
12
  location,
13
- api
13
+ api,
14
+ source
14
15
  }) {
15
16
  var _api$width$sharedStat, _api$width$sharedStat2;
16
- const diffX = (location.current.input.clientX - location.initial.input.clientX) * RESIZE_RATIO;
17
- const proposedWidth = initialWidth + diffX;
17
+ const directionMultiplier = source.data.handleSide === 'left' ? -1 : 1;
18
+ const diffX = (location.current.input.clientX - location.initial.input.clientX) * RESIZE_RATIO * directionMultiplier;
18
19
 
19
20
  // TODO: ED-28024 - add snapping logic
20
21
 
21
22
  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;
23
+
24
+ // the node width may be greater than the container width so we resize using the smaller value
25
+ const proposedWidth = Math.min(initialWidth, containerWidth) + diffX;
22
26
  return Math.min(Math.max(WIDTHS.MIN, Math.min(proposedWidth, containerWidth)), WIDTHS.MAX);
23
27
  }
24
28
  export function createResizerCallbacks({
@@ -29,6 +33,7 @@ export function createResizerCallbacks({
29
33
  api
30
34
  }) {
31
35
  let node = null;
36
+ let guidelines = [];
32
37
  const getEditorWidth = () => {
33
38
  var _api$width;
34
39
  return api === null || api === void 0 ? void 0 : (_api$width = api.width) === null || _api$width === void 0 ? void 0 : _api$width.sharedState.currentState();
@@ -42,36 +47,41 @@ export function createResizerCallbacks({
42
47
  node = view.state.doc.nodeAt(pos);
43
48
  },
44
49
  onDrag: ({
45
- location
50
+ location,
51
+ source
46
52
  }) => {
47
53
  var _node, _api$guideline, _api$guideline$action;
48
54
  const initialWidth = mark.attrs.width;
49
55
  const newWidth = getProposedWidth({
50
56
  initialWidth,
51
57
  location,
52
- api
58
+ api,
59
+ source
53
60
  });
54
- const guidelines = getGuidelines(true, newWidth, getEditorWidth, (_node = node) === null || _node === void 0 ? void 0 : _node.type);
61
+ guidelines = getGuidelines(true, newWidth, getEditorWidth, (_node = node) === null || _node === void 0 ? void 0 : _node.type);
55
62
  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
63
  guidelines
57
64
  });
58
65
  contentDOM.style.setProperty(LOCAL_RESIZE_PROPERTY, `${newWidth}px`);
59
66
  },
60
67
  onDrop({
61
- location
68
+ location,
69
+ source
62
70
  }) {
63
71
  var _api$guideline2, _api$guideline2$actio, _api$userIntent2;
64
- const guidelines = getGuidelines(false, 0, getEditorWidth);
72
+ const isResizedToFullWidth = !!guidelines.find(guideline => guideline.key.includes('full_width') && guideline.active);
73
+ guidelines = getGuidelines(false, 0, getEditorWidth);
65
74
  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
75
  guidelines
67
76
  });
68
77
  const pos = view.posAtDOM(dom, 0);
69
78
  const mode = mark.attrs.mode;
70
79
  const initialWidth = mark.attrs.width;
71
- const newWidth = getProposedWidth({
80
+ const newWidth = isResizedToFullWidth ? WIDTHS.MAX : getProposedWidth({
72
81
  initialWidth,
73
82
  location,
74
- api
83
+ api,
84
+ source
75
85
  });
76
86
  setBreakoutWidth(newWidth, mode, pos)(view.state, view.dispatch);
77
87
  contentDOM.style.removeProperty(LOCAL_RESIZE_PROPERTY);
@@ -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
+ });
@@ -5,7 +5,7 @@ export var createPragmaticResizer = function createPragmaticResizer(_ref) {
5
5
  var onDragStart = _ref.onDragStart,
6
6
  onDrag = _ref.onDrag,
7
7
  _onDrop = _ref.onDrop;
8
- var registerHandle = function registerHandle(handleElement) {
8
+ var registerHandle = function registerHandle(handleElement, handleSide) {
9
9
  return draggable({
10
10
  element: handleElement,
11
11
  onGenerateDragPreview: function onGenerateDragPreview(_ref2) {
@@ -15,6 +15,11 @@ export var createPragmaticResizer = function createPragmaticResizer(_ref) {
15
15
  });
16
16
  preventUnhandled.start();
17
17
  },
18
+ getInitialData: function getInitialData() {
19
+ return {
20
+ handleSide: handleSide
21
+ };
22
+ },
18
23
  onDragStart: onDragStart,
19
24
  onDrag: onDrag,
20
25
  onDrop: function onDrop(args) {
@@ -41,8 +46,8 @@ export var createPragmaticResizer = function createPragmaticResizer(_ref) {
41
46
  };
42
47
  var rightHandle = createHandle('right');
43
48
  var leftHandle = createHandle('left');
44
- var rightHandleCleanup = registerHandle(rightHandle);
45
- var leftHandleCleanup = registerHandle(leftHandle);
49
+ var rightHandleCleanup = registerHandle(rightHandle, 'right');
50
+ var leftHandleCleanup = registerHandle(leftHandle, 'left');
46
51
  return {
47
52
  rightHandle: rightHandle,
48
53
  leftHandle: leftHandle,
@@ -11,13 +11,17 @@ export function getProposedWidth(_ref) {
11
11
  var _api$width$sharedStat;
12
12
  var initialWidth = _ref.initialWidth,
13
13
  location = _ref.location,
14
- api = _ref.api;
15
- var diffX = (location.current.input.clientX - location.initial.input.clientX) * RESIZE_RATIO;
16
- var proposedWidth = initialWidth + diffX;
14
+ api = _ref.api,
15
+ source = _ref.source;
16
+ var directionMultiplier = source.data.handleSide === 'left' ? -1 : 1;
17
+ var diffX = (location.current.input.clientX - location.initial.input.clientX) * RESIZE_RATIO * directionMultiplier;
17
18
 
18
19
  // TODO: ED-28024 - add snapping logic
19
20
 
20
21
  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;
22
+
23
+ // the node width may be greater than the container width so we resize using the smaller value
24
+ var proposedWidth = Math.min(initialWidth, containerWidth) + diffX;
21
25
  return Math.min(Math.max(WIDTHS.MIN, Math.min(proposedWidth, containerWidth)), WIDTHS.MAX);
22
26
  }
23
27
  export function createResizerCallbacks(_ref2) {
@@ -27,6 +31,7 @@ export function createResizerCallbacks(_ref2) {
27
31
  mark = _ref2.mark,
28
32
  api = _ref2.api;
29
33
  var node = null;
34
+ var guidelines = [];
30
35
  var getEditorWidth = function getEditorWidth() {
31
36
  var _api$width;
32
37
  return api === null || api === void 0 || (_api$width = api.width) === null || _api$width === void 0 ? void 0 : _api$width.sharedState.currentState();
@@ -41,14 +46,16 @@ export function createResizerCallbacks(_ref2) {
41
46
  },
42
47
  onDrag: function onDrag(_ref3) {
43
48
  var _node, _api$guideline;
44
- var location = _ref3.location;
49
+ var location = _ref3.location,
50
+ source = _ref3.source;
45
51
  var initialWidth = mark.attrs.width;
46
52
  var newWidth = getProposedWidth({
47
53
  initialWidth: initialWidth,
48
54
  location: location,
49
- api: api
55
+ api: api,
56
+ source: source
50
57
  });
51
- var guidelines = getGuidelines(true, newWidth, getEditorWidth, (_node = node) === null || _node === void 0 ? void 0 : _node.type);
58
+ guidelines = getGuidelines(true, newWidth, getEditorWidth, (_node = node) === null || _node === void 0 ? void 0 : _node.type);
52
59
  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
60
  guidelines: guidelines
54
61
  });
@@ -56,18 +63,23 @@ export function createResizerCallbacks(_ref2) {
56
63
  },
57
64
  onDrop: function onDrop(_ref4) {
58
65
  var _api$guideline2, _api$userIntent2;
59
- var location = _ref4.location;
60
- var guidelines = getGuidelines(false, 0, getEditorWidth);
66
+ var location = _ref4.location,
67
+ source = _ref4.source;
68
+ var isResizedToFullWidth = !!guidelines.find(function (guideline) {
69
+ return guideline.key.includes('full_width') && guideline.active;
70
+ });
71
+ guidelines = getGuidelines(false, 0, getEditorWidth);
61
72
  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
73
  guidelines: guidelines
63
74
  });
64
75
  var pos = view.posAtDOM(dom, 0);
65
76
  var mode = mark.attrs.mode;
66
77
  var initialWidth = mark.attrs.width;
67
- var newWidth = getProposedWidth({
78
+ var newWidth = isResizedToFullWidth ? WIDTHS.MAX : getProposedWidth({
68
79
  initialWidth: initialWidth,
69
80
  location: location,
70
- api: api
81
+ api: api,
82
+ source: source
71
83
  });
72
84
  setBreakoutWidth(newWidth, mode, pos)(view.state, view.dispatch);
73
85
  contentDOM.style.removeProperty(LOCAL_RESIZE_PROPERTY);
@@ -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,12 +1,14 @@
1
1
  import { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
2
2
  import { Mark } from '@atlaskit/editor-prosemirror/model';
3
3
  import { EditorView } from '@atlaskit/editor-prosemirror/view';
4
+ import { ElementDragPayload } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
4
5
  import { BaseEventPayload, DragLocationHistory, ElementDragType } from '@atlaskit/pragmatic-drag-and-drop/types';
5
6
  import { BreakoutPlugin } from '../breakoutPluginType';
6
- export declare function getProposedWidth({ initialWidth, location, api, }: {
7
+ export declare function getProposedWidth({ initialWidth, location, api, source }: {
7
8
  initialWidth: number;
8
9
  location: DragLocationHistory;
9
10
  api: ExtractInjectionAPI<BreakoutPlugin> | undefined;
11
+ source: ElementDragPayload;
10
12
  }): number;
11
13
  export declare function createResizerCallbacks({ dom, contentDOM, view, mark, api, }: {
12
14
  dom: HTMLElement;
@@ -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,12 +1,14 @@
1
1
  import { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
2
2
  import { Mark } from '@atlaskit/editor-prosemirror/model';
3
3
  import { EditorView } from '@atlaskit/editor-prosemirror/view';
4
+ import { ElementDragPayload } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
4
5
  import { BaseEventPayload, DragLocationHistory, ElementDragType } from '@atlaskit/pragmatic-drag-and-drop/types';
5
6
  import { BreakoutPlugin } from '../breakoutPluginType';
6
- export declare function getProposedWidth({ initialWidth, location, api, }: {
7
+ export declare function getProposedWidth({ initialWidth, location, api, source }: {
7
8
  initialWidth: number;
8
9
  location: DragLocationHistory;
9
10
  api: ExtractInjectionAPI<BreakoutPlugin> | undefined;
11
+ source: ElementDragPayload;
10
12
  }): number;
11
13
  export declare function createResizerCallbacks({ dom, contentDOM, view, mark, api, }: {
12
14
  dom: HTMLElement;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-breakout",
3
- "version": "2.4.3",
3
+ "version": "2.5.1",
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.8.0",
51
+ "@atlaskit/tmp-editor-statsig": "^5.10.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",