@atlaskit/editor-plugin-breakout 12.3.3 → 12.3.4

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,13 @@
1
1
  # @atlaskit/editor-plugin-breakout
2
2
 
3
+ ## 12.3.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [`c5b1fc41ef2a8`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/c5b1fc41ef2a8) -
8
+ Fix keyboard resizing for full-width breakout nodes
9
+ - Updated dependencies
10
+
3
11
  ## 12.3.3
4
12
 
5
13
  ### Patch Changes
@@ -11,7 +11,13 @@ var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
11
11
  var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
12
12
  var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
13
13
  var _setBreakoutWidth = require("../editor-commands/set-breakout-width");
14
+ var _resizeWidth = require("./resize-width");
14
15
  var KEYBOARD_RESIZE_STEP = 10;
16
+ var getKeyboardResizeWidth = function getKeyboardResizeWidth(currentWidth, step, api) {
17
+ var containerWidth = (0, _resizeWidth.getResizeContainerWidth)(api);
18
+ var resizeStartWidth = Math.min(currentWidth, containerWidth);
19
+ return (0, _resizeWidth.clampWidthToResizeBounds)(resizeStartWidth + step, containerWidth);
20
+ };
15
21
  var getAncestorResizableNode = function getAncestorResizableNode(view, breakoutResizableNodes) {
16
22
  var selection = view.state.selection;
17
23
  if (selection instanceof _state.NodeSelection) {
@@ -63,12 +69,22 @@ var handleKeyDown = exports.handleKeyDown = function handleKeyDown(api) {
63
69
  });
64
70
  if (breakoutMark) {
65
71
  var step = event.code === 'BracketRight' ? KEYBOARD_RESIZE_STEP : -KEYBOARD_RESIZE_STEP;
66
- var newWidth = breakoutMark.attrs.width + step;
67
- if (newWidth < _editorSharedStyles.akEditorFullWidthLayoutWidth && newWidth > _editorSharedStyles.akEditorDefaultLayoutWidth) {
68
- var _api$editorViewMode;
69
- var isEditMode = (api === null || api === void 0 || (_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 || (_api$editorViewMode = _api$editorViewMode.sharedState.currentState()) === null || _api$editorViewMode === void 0 ? void 0 : _api$editorViewMode.mode) === 'edit';
70
- (0, _setBreakoutWidth.setBreakoutWidth)(breakoutMark.attrs.width + step, breakoutMark.attrs.mode, pos, isEditMode)(view.state, view.dispatch);
71
- view.focus();
72
+ if ((0, _expValEquals.expValEquals)('platform_editor_lovability_breakout_resizing_fixes', 'isEnabled', true)) {
73
+ var newWidth = getKeyboardResizeWidth(breakoutMark.attrs.width, step, api);
74
+ if (newWidth !== breakoutMark.attrs.width) {
75
+ var _api$editorViewMode;
76
+ var isEditMode = (api === null || api === void 0 || (_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 || (_api$editorViewMode = _api$editorViewMode.sharedState.currentState()) === null || _api$editorViewMode === void 0 ? void 0 : _api$editorViewMode.mode) === 'edit';
77
+ (0, _setBreakoutWidth.setBreakoutWidth)(newWidth, breakoutMark.attrs.mode, pos, isEditMode)(view.state, view.dispatch);
78
+ view.focus();
79
+ }
80
+ } else {
81
+ var _newWidth = breakoutMark.attrs.width + step;
82
+ if (_newWidth < _editorSharedStyles.akEditorFullWidthLayoutWidth && _newWidth > _editorSharedStyles.akEditorDefaultLayoutWidth) {
83
+ var _api$editorViewMode2;
84
+ var _isEditMode = (api === null || api === void 0 || (_api$editorViewMode2 = api.editorViewMode) === null || _api$editorViewMode2 === void 0 || (_api$editorViewMode2 = _api$editorViewMode2.sharedState.currentState()) === null || _api$editorViewMode2 === void 0 ? void 0 : _api$editorViewMode2.mode) === 'edit';
85
+ (0, _setBreakoutWidth.setBreakoutWidth)(breakoutMark.attrs.width + step, breakoutMark.attrs.mode, pos, _isEditMode)(view.state, view.dispatch);
86
+ view.focus();
87
+ }
72
88
  }
73
89
  return true;
74
90
  }
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getResizeHardMax = exports.getResizeContainerWidth = exports.clampWidthToResizeBounds = exports.WIDTHS = void 0;
7
+ var _constants = require("@atlaskit/editor-shared-styles/constants");
8
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
9
+ var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
10
+ var WIDTHS = exports.WIDTHS = {
11
+ FULL: _constants.akEditorFullWidthLayoutWidth,
12
+ MAX: _constants.akEditorMaxLayoutWidth,
13
+ MIN: _constants.akEditorDefaultLayoutWidth,
14
+ WIDE: _constants.akEditorCalculatedWideLayoutWidth
15
+ };
16
+ var getResizeContainerWidth = exports.getResizeContainerWidth = function getResizeContainerWidth(api) {
17
+ var _api$width$sharedStat, _api$width$sharedStat2;
18
+ var editorWidth = (_api$width$sharedStat = api === null || api === void 0 || (_api$width$sharedStat2 = api.width.sharedState) === null || _api$width$sharedStat2 === void 0 || (_api$width$sharedStat2 = _api$width$sharedStat2.currentState()) === null || _api$width$sharedStat2 === void 0 ? void 0 : _api$width$sharedStat2.width) !== null && _api$width$sharedStat !== void 0 ? _api$width$sharedStat : 0;
19
+ var padding = editorWidth <= _constants.akEditorFullPageNarrowBreakout && (0, _experiments.editorExperiment)('platform_editor_preview_panel_responsiveness', true, {
20
+ exposure: true
21
+ }) ? _constants.akEditorGutterPaddingReduced : (0, _constants.akEditorGutterPaddingDynamic)();
22
+ return editorWidth - 2 * padding - _constants.akEditorGutterPadding;
23
+ };
24
+ var getResizeHardMax = exports.getResizeHardMax = function getResizeHardMax(containerWidth) {
25
+ return (0, _expValEquals.expValEquals)('editor_tinymce_full_width_mode', 'isEnabled', true) || (0, _expValEquals.expValEquals)('confluence_max_width_content_appearance', 'isEnabled', true) ? Math.min(containerWidth, WIDTHS.MAX) : Math.min(containerWidth, WIDTHS.FULL);
26
+ };
27
+ var clampWidthToResizeBounds = exports.clampWidthToResizeBounds = function clampWidthToResizeBounds(proposedWidth, containerWidth) {
28
+ return Math.max(WIDTHS.MIN, Math.min(proposedWidth, getResizeHardMax(containerWidth)));
29
+ };
@@ -5,42 +5,30 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.createResizerCallbacks = createResizerCallbacks;
7
7
  exports.getProposedWidth = getProposedWidth;
8
- var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
9
8
  var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
10
- var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
11
9
  var _setBreakoutWidth = require("../editor-commands/set-breakout-width");
12
10
  var _getGuidelines = require("./get-guidelines");
11
+ var _resizeWidth = require("./resize-width");
13
12
  var _resizingMarkView = require("./resizing-mark-view");
14
13
  var _resizingPlugin = require("./resizing-plugin");
15
14
  var _analytics = require("./utils/analytics");
16
15
  var _measureFramerate2 = require("./utils/measure-framerate");
17
16
  var RESIZE_RATIO = 2;
18
17
  var SNAP_GAP = 10;
19
- var WIDTHS = {
20
- MIN: _editorSharedStyles.akEditorDefaultLayoutWidth,
21
- WIDE: _editorSharedStyles.akEditorCalculatedWideLayoutWidth,
22
- FULL: _editorSharedStyles.akEditorFullWidthLayoutWidth,
23
- MAX: _editorSharedStyles.akEditorMaxLayoutWidth
24
- };
25
18
  function getProposedWidth(_ref) {
26
- var _api$width$sharedStat;
27
19
  var initialWidth = _ref.initialWidth,
28
20
  location = _ref.location,
29
21
  api = _ref.api,
30
22
  source = _ref.source;
31
23
  var directionMultiplier = source.data.handleSide === 'left' ? -1 : 1;
32
24
  var diffX = (location.current.input.clientX - location.initial.input.clientX) * RESIZE_RATIO * directionMultiplier;
33
- var width = (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;
34
- var padding = width <= _editorSharedStyles.akEditorFullPageNarrowBreakout && (0, _experiments.editorExperiment)('platform_editor_preview_panel_responsiveness', true, {
35
- exposure: true
36
- }) ? _editorSharedStyles.akEditorGutterPaddingReduced : (0, _editorSharedStyles.akEditorGutterPaddingDynamic)();
37
- var containerWidth = width - 2 * padding - _editorSharedStyles.akEditorGutterPadding;
25
+ var containerWidth = (0, _resizeWidth.getResizeContainerWidth)(api);
38
26
 
39
27
  // the node width may be greater than the container width so we resize using the smaller value
40
28
  var proposedWidth = Math.min(initialWidth, containerWidth) + diffX;
41
- var snapPoints = [WIDTHS.MIN, WIDTHS.WIDE, Math.min(containerWidth, WIDTHS.FULL)];
29
+ var snapPoints = [_resizeWidth.WIDTHS.MIN, _resizeWidth.WIDTHS.WIDE, Math.min(containerWidth, _resizeWidth.WIDTHS.FULL)];
42
30
  if ((0, _expValEquals.expValEquals)('editor_tinymce_full_width_mode', 'isEnabled', true) || (0, _expValEquals.expValEquals)('confluence_max_width_content_appearance', 'isEnabled', true)) {
43
- snapPoints.push(Math.min(containerWidth, WIDTHS.MAX));
31
+ snapPoints.push(Math.min(containerWidth, _resizeWidth.WIDTHS.MAX));
44
32
  }
45
33
  for (var _i = 0, _snapPoints = snapPoints; _i < _snapPoints.length; _i++) {
46
34
  var snapPoint = _snapPoints[_i];
@@ -48,8 +36,7 @@ function getProposedWidth(_ref) {
48
36
  return snapPoint;
49
37
  }
50
38
  }
51
- var hardMax = (0, _expValEquals.expValEquals)('editor_tinymce_full_width_mode', 'isEnabled', true) || (0, _expValEquals.expValEquals)('confluence_max_width_content_appearance', 'isEnabled', true) ? Math.min(containerWidth, WIDTHS.MAX) : Math.min(containerWidth, WIDTHS.FULL);
52
- return Math.max(WIDTHS.MIN, Math.min(proposedWidth, hardMax));
39
+ return (0, _resizeWidth.clampWidthToResizeBounds)(proposedWidth, containerWidth);
53
40
  }
54
41
  function createResizerCallbacks(_ref2) {
55
42
  var dom = _ref2.dom,
@@ -161,7 +148,7 @@ function createResizerCallbacks(_ref2) {
161
148
  var pos = view.posAtDOM(dom, 0);
162
149
  var mode = mark.attrs.mode;
163
150
  var initialWidth = mark.attrs.width;
164
- var newWidth = isResizedToFullWidth ? WIDTHS.FULL : getProposedWidth({
151
+ var newWidth = isResizedToFullWidth ? _resizeWidth.WIDTHS.FULL : getProposedWidth({
165
152
  initialWidth: initialWidth,
166
153
  location: location,
167
154
  api: api,
@@ -169,7 +156,7 @@ function createResizerCallbacks(_ref2) {
169
156
  });
170
157
  if ((0, _expValEquals.expValEquals)('editor_tinymce_full_width_mode', 'isEnabled', true) || (0, _expValEquals.expValEquals)('confluence_max_width_content_appearance', 'isEnabled', true)) {
171
158
  if (isResizedToMaxWidth) {
172
- newWidth = WIDTHS.MAX;
159
+ newWidth = _resizeWidth.WIDTHS.MAX;
173
160
  }
174
161
  }
175
162
  var isEditMode = (api === null || api === void 0 || (_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 || (_api$editorViewMode = _api$editorViewMode.sharedState.currentState()) === null || _api$editorViewMode === void 0 ? void 0 : _api$editorViewMode.mode) === 'edit';
@@ -5,7 +5,13 @@ import { akEditorDefaultLayoutWidth, akEditorFullWidthLayoutWidth } from '@atlas
5
5
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
6
6
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
7
7
  import { setBreakoutWidth } from '../editor-commands/set-breakout-width';
8
+ import { clampWidthToResizeBounds, getResizeContainerWidth } from './resize-width';
8
9
  const KEYBOARD_RESIZE_STEP = 10;
10
+ const getKeyboardResizeWidth = (currentWidth, step, api) => {
11
+ const containerWidth = getResizeContainerWidth(api);
12
+ const resizeStartWidth = Math.min(currentWidth, containerWidth);
13
+ return clampWidthToResizeBounds(resizeStartWidth + step, containerWidth);
14
+ };
9
15
  const getAncestorResizableNode = (view, breakoutResizableNodes) => {
10
16
  const selection = view.state.selection;
11
17
  if (selection instanceof NodeSelection) {
@@ -57,12 +63,22 @@ export const handleKeyDown = api => (view, event) => {
57
63
  const breakoutMark = node === null || node === void 0 ? void 0 : node.marks.find(mark => mark.type.name === 'breakout');
58
64
  if (breakoutMark) {
59
65
  const step = event.code === 'BracketRight' ? KEYBOARD_RESIZE_STEP : -KEYBOARD_RESIZE_STEP;
60
- const newWidth = breakoutMark.attrs.width + step;
61
- if (newWidth < akEditorFullWidthLayoutWidth && newWidth > akEditorDefaultLayoutWidth) {
62
- var _api$editorViewMode, _api$editorViewMode$s;
63
- const isEditMode = (api === null || api === void 0 ? void 0 : (_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 ? void 0 : (_api$editorViewMode$s = _api$editorViewMode.sharedState.currentState()) === null || _api$editorViewMode$s === void 0 ? void 0 : _api$editorViewMode$s.mode) === 'edit';
64
- setBreakoutWidth(breakoutMark.attrs.width + step, breakoutMark.attrs.mode, pos, isEditMode)(view.state, view.dispatch);
65
- view.focus();
66
+ if (expValEquals('platform_editor_lovability_breakout_resizing_fixes', 'isEnabled', true)) {
67
+ const newWidth = getKeyboardResizeWidth(breakoutMark.attrs.width, step, api);
68
+ if (newWidth !== breakoutMark.attrs.width) {
69
+ var _api$editorViewMode, _api$editorViewMode$s;
70
+ const isEditMode = (api === null || api === void 0 ? void 0 : (_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 ? void 0 : (_api$editorViewMode$s = _api$editorViewMode.sharedState.currentState()) === null || _api$editorViewMode$s === void 0 ? void 0 : _api$editorViewMode$s.mode) === 'edit';
71
+ setBreakoutWidth(newWidth, breakoutMark.attrs.mode, pos, isEditMode)(view.state, view.dispatch);
72
+ view.focus();
73
+ }
74
+ } else {
75
+ const newWidth = breakoutMark.attrs.width + step;
76
+ if (newWidth < akEditorFullWidthLayoutWidth && newWidth > akEditorDefaultLayoutWidth) {
77
+ var _api$editorViewMode2, _api$editorViewMode2$;
78
+ const isEditMode = (api === null || api === void 0 ? void 0 : (_api$editorViewMode2 = api.editorViewMode) === null || _api$editorViewMode2 === void 0 ? void 0 : (_api$editorViewMode2$ = _api$editorViewMode2.sharedState.currentState()) === null || _api$editorViewMode2$ === void 0 ? void 0 : _api$editorViewMode2$.mode) === 'edit';
79
+ setBreakoutWidth(breakoutMark.attrs.width + step, breakoutMark.attrs.mode, pos, isEditMode)(view.state, view.dispatch);
80
+ view.focus();
81
+ }
66
82
  }
67
83
  return true;
68
84
  }
@@ -0,0 +1,24 @@
1
+ import { akEditorCalculatedWideLayoutWidth, akEditorDefaultLayoutWidth, akEditorFullPageNarrowBreakout, akEditorFullWidthLayoutWidth, akEditorGutterPadding, akEditorGutterPaddingDynamic, akEditorGutterPaddingReduced, akEditorMaxLayoutWidth } from '@atlaskit/editor-shared-styles/constants';
2
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
3
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
4
+ const WIDTHS = {
5
+ FULL: akEditorFullWidthLayoutWidth,
6
+ MAX: akEditorMaxLayoutWidth,
7
+ MIN: akEditorDefaultLayoutWidth,
8
+ WIDE: akEditorCalculatedWideLayoutWidth
9
+ };
10
+ export { WIDTHS };
11
+ export const getResizeContainerWidth = api => {
12
+ var _api$width$sharedStat, _api$width$sharedStat2, _api$width$sharedStat3;
13
+ const editorWidth = (_api$width$sharedStat = api === null || api === void 0 ? void 0 : (_api$width$sharedStat2 = api.width.sharedState) === null || _api$width$sharedStat2 === void 0 ? void 0 : (_api$width$sharedStat3 = _api$width$sharedStat2.currentState()) === null || _api$width$sharedStat3 === void 0 ? void 0 : _api$width$sharedStat3.width) !== null && _api$width$sharedStat !== void 0 ? _api$width$sharedStat : 0;
14
+ const padding = editorWidth <= akEditorFullPageNarrowBreakout && editorExperiment('platform_editor_preview_panel_responsiveness', true, {
15
+ exposure: true
16
+ }) ? akEditorGutterPaddingReduced : akEditorGutterPaddingDynamic();
17
+ return editorWidth - 2 * padding - akEditorGutterPadding;
18
+ };
19
+ export const getResizeHardMax = containerWidth => {
20
+ return expValEquals('editor_tinymce_full_width_mode', 'isEnabled', true) || expValEquals('confluence_max_width_content_appearance', 'isEnabled', true) ? Math.min(containerWidth, WIDTHS.MAX) : Math.min(containerWidth, WIDTHS.FULL);
21
+ };
22
+ export const clampWidthToResizeBounds = (proposedWidth, containerWidth) => {
23
+ return Math.max(WIDTHS.MIN, Math.min(proposedWidth, getResizeHardMax(containerWidth)));
24
+ };
@@ -1,34 +1,22 @@
1
- import { akEditorGutterPaddingDynamic, akEditorGutterPadding, akEditorGutterPaddingReduced, akEditorFullPageNarrowBreakout, akEditorDefaultLayoutWidth, akEditorFullWidthLayoutWidth, akEditorCalculatedWideLayoutWidth, akEditorMaxLayoutWidth } from '@atlaskit/editor-shared-styles';
2
1
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
3
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
4
2
  import { setBreakoutWidth } from '../editor-commands/set-breakout-width';
5
3
  import { getGuidelines } from './get-guidelines';
4
+ import { clampWidthToResizeBounds, getResizeContainerWidth, WIDTHS } from './resize-width';
6
5
  import { LOCAL_RESIZE_PROPERTY } from './resizing-mark-view';
7
6
  import { resizingPluginKey } from './resizing-plugin';
8
7
  import { generateResizeFrameRatePayloads, generateResizedEventPayload } from './utils/analytics';
9
8
  import { measureFramerate, reduceResizeFrameRateSamples } from './utils/measure-framerate';
10
9
  const RESIZE_RATIO = 2;
11
10
  const SNAP_GAP = 10;
12
- const WIDTHS = {
13
- MIN: akEditorDefaultLayoutWidth,
14
- WIDE: akEditorCalculatedWideLayoutWidth,
15
- FULL: akEditorFullWidthLayoutWidth,
16
- MAX: akEditorMaxLayoutWidth
17
- };
18
11
  export function getProposedWidth({
19
12
  initialWidth,
20
13
  location,
21
14
  api,
22
15
  source
23
16
  }) {
24
- var _api$width$sharedStat, _api$width$sharedStat2;
25
17
  const directionMultiplier = source.data.handleSide === 'left' ? -1 : 1;
26
18
  const diffX = (location.current.input.clientX - location.initial.input.clientX) * RESIZE_RATIO * directionMultiplier;
27
- const width = (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;
28
- const padding = width <= akEditorFullPageNarrowBreakout && editorExperiment('platform_editor_preview_panel_responsiveness', true, {
29
- exposure: true
30
- }) ? akEditorGutterPaddingReduced : akEditorGutterPaddingDynamic();
31
- const containerWidth = width - 2 * padding - akEditorGutterPadding;
19
+ const containerWidth = getResizeContainerWidth(api);
32
20
 
33
21
  // the node width may be greater than the container width so we resize using the smaller value
34
22
  const proposedWidth = Math.min(initialWidth, containerWidth) + diffX;
@@ -41,8 +29,7 @@ export function getProposedWidth({
41
29
  return snapPoint;
42
30
  }
43
31
  }
44
- const hardMax = expValEquals('editor_tinymce_full_width_mode', 'isEnabled', true) || expValEquals('confluence_max_width_content_appearance', 'isEnabled', true) ? Math.min(containerWidth, WIDTHS.MAX) : Math.min(containerWidth, WIDTHS.FULL);
45
- return Math.max(WIDTHS.MIN, Math.min(proposedWidth, hardMax));
32
+ return clampWidthToResizeBounds(proposedWidth, containerWidth);
46
33
  }
47
34
  export function createResizerCallbacks({
48
35
  dom,
@@ -5,7 +5,13 @@ import { akEditorDefaultLayoutWidth, akEditorFullWidthLayoutWidth } from '@atlas
5
5
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
6
6
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
7
7
  import { setBreakoutWidth } from '../editor-commands/set-breakout-width';
8
+ import { clampWidthToResizeBounds, getResizeContainerWidth } from './resize-width';
8
9
  var KEYBOARD_RESIZE_STEP = 10;
10
+ var getKeyboardResizeWidth = function getKeyboardResizeWidth(currentWidth, step, api) {
11
+ var containerWidth = getResizeContainerWidth(api);
12
+ var resizeStartWidth = Math.min(currentWidth, containerWidth);
13
+ return clampWidthToResizeBounds(resizeStartWidth + step, containerWidth);
14
+ };
9
15
  var getAncestorResizableNode = function getAncestorResizableNode(view, breakoutResizableNodes) {
10
16
  var selection = view.state.selection;
11
17
  if (selection instanceof NodeSelection) {
@@ -57,12 +63,22 @@ export var handleKeyDown = function handleKeyDown(api) {
57
63
  });
58
64
  if (breakoutMark) {
59
65
  var step = event.code === 'BracketRight' ? KEYBOARD_RESIZE_STEP : -KEYBOARD_RESIZE_STEP;
60
- var newWidth = breakoutMark.attrs.width + step;
61
- if (newWidth < akEditorFullWidthLayoutWidth && newWidth > akEditorDefaultLayoutWidth) {
62
- var _api$editorViewMode;
63
- var isEditMode = (api === null || api === void 0 || (_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 || (_api$editorViewMode = _api$editorViewMode.sharedState.currentState()) === null || _api$editorViewMode === void 0 ? void 0 : _api$editorViewMode.mode) === 'edit';
64
- setBreakoutWidth(breakoutMark.attrs.width + step, breakoutMark.attrs.mode, pos, isEditMode)(view.state, view.dispatch);
65
- view.focus();
66
+ if (expValEquals('platform_editor_lovability_breakout_resizing_fixes', 'isEnabled', true)) {
67
+ var newWidth = getKeyboardResizeWidth(breakoutMark.attrs.width, step, api);
68
+ if (newWidth !== breakoutMark.attrs.width) {
69
+ var _api$editorViewMode;
70
+ var isEditMode = (api === null || api === void 0 || (_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 || (_api$editorViewMode = _api$editorViewMode.sharedState.currentState()) === null || _api$editorViewMode === void 0 ? void 0 : _api$editorViewMode.mode) === 'edit';
71
+ setBreakoutWidth(newWidth, breakoutMark.attrs.mode, pos, isEditMode)(view.state, view.dispatch);
72
+ view.focus();
73
+ }
74
+ } else {
75
+ var _newWidth = breakoutMark.attrs.width + step;
76
+ if (_newWidth < akEditorFullWidthLayoutWidth && _newWidth > akEditorDefaultLayoutWidth) {
77
+ var _api$editorViewMode2;
78
+ var _isEditMode = (api === null || api === void 0 || (_api$editorViewMode2 = api.editorViewMode) === null || _api$editorViewMode2 === void 0 || (_api$editorViewMode2 = _api$editorViewMode2.sharedState.currentState()) === null || _api$editorViewMode2 === void 0 ? void 0 : _api$editorViewMode2.mode) === 'edit';
79
+ setBreakoutWidth(breakoutMark.attrs.width + step, breakoutMark.attrs.mode, pos, _isEditMode)(view.state, view.dispatch);
80
+ view.focus();
81
+ }
66
82
  }
67
83
  return true;
68
84
  }
@@ -0,0 +1,24 @@
1
+ import { akEditorCalculatedWideLayoutWidth, akEditorDefaultLayoutWidth, akEditorFullPageNarrowBreakout, akEditorFullWidthLayoutWidth, akEditorGutterPadding, akEditorGutterPaddingDynamic, akEditorGutterPaddingReduced, akEditorMaxLayoutWidth } from '@atlaskit/editor-shared-styles/constants';
2
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
3
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
4
+ var WIDTHS = {
5
+ FULL: akEditorFullWidthLayoutWidth,
6
+ MAX: akEditorMaxLayoutWidth,
7
+ MIN: akEditorDefaultLayoutWidth,
8
+ WIDE: akEditorCalculatedWideLayoutWidth
9
+ };
10
+ export { WIDTHS };
11
+ export var getResizeContainerWidth = function getResizeContainerWidth(api) {
12
+ var _api$width$sharedStat, _api$width$sharedStat2;
13
+ var editorWidth = (_api$width$sharedStat = api === null || api === void 0 || (_api$width$sharedStat2 = api.width.sharedState) === null || _api$width$sharedStat2 === void 0 || (_api$width$sharedStat2 = _api$width$sharedStat2.currentState()) === null || _api$width$sharedStat2 === void 0 ? void 0 : _api$width$sharedStat2.width) !== null && _api$width$sharedStat !== void 0 ? _api$width$sharedStat : 0;
14
+ var padding = editorWidth <= akEditorFullPageNarrowBreakout && editorExperiment('platform_editor_preview_panel_responsiveness', true, {
15
+ exposure: true
16
+ }) ? akEditorGutterPaddingReduced : akEditorGutterPaddingDynamic();
17
+ return editorWidth - 2 * padding - akEditorGutterPadding;
18
+ };
19
+ export var getResizeHardMax = function getResizeHardMax(containerWidth) {
20
+ return expValEquals('editor_tinymce_full_width_mode', 'isEnabled', true) || expValEquals('confluence_max_width_content_appearance', 'isEnabled', true) ? Math.min(containerWidth, WIDTHS.MAX) : Math.min(containerWidth, WIDTHS.FULL);
21
+ };
22
+ export var clampWidthToResizeBounds = function clampWidthToResizeBounds(proposedWidth, containerWidth) {
23
+ return Math.max(WIDTHS.MIN, Math.min(proposedWidth, getResizeHardMax(containerWidth)));
24
+ };
@@ -1,33 +1,21 @@
1
- import { akEditorGutterPaddingDynamic, akEditorGutterPadding, akEditorGutterPaddingReduced, akEditorFullPageNarrowBreakout, akEditorDefaultLayoutWidth, akEditorFullWidthLayoutWidth, akEditorCalculatedWideLayoutWidth, akEditorMaxLayoutWidth } from '@atlaskit/editor-shared-styles';
2
1
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
3
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
4
2
  import { setBreakoutWidth } from '../editor-commands/set-breakout-width';
5
3
  import { getGuidelines } from './get-guidelines';
4
+ import { clampWidthToResizeBounds, getResizeContainerWidth, WIDTHS } from './resize-width';
6
5
  import { LOCAL_RESIZE_PROPERTY } from './resizing-mark-view';
7
6
  import { resizingPluginKey } from './resizing-plugin';
8
7
  import { generateResizeFrameRatePayloads, generateResizedEventPayload } from './utils/analytics';
9
8
  import { measureFramerate, reduceResizeFrameRateSamples } from './utils/measure-framerate';
10
9
  var RESIZE_RATIO = 2;
11
10
  var SNAP_GAP = 10;
12
- var WIDTHS = {
13
- MIN: akEditorDefaultLayoutWidth,
14
- WIDE: akEditorCalculatedWideLayoutWidth,
15
- FULL: akEditorFullWidthLayoutWidth,
16
- MAX: akEditorMaxLayoutWidth
17
- };
18
11
  export function getProposedWidth(_ref) {
19
- var _api$width$sharedStat;
20
12
  var initialWidth = _ref.initialWidth,
21
13
  location = _ref.location,
22
14
  api = _ref.api,
23
15
  source = _ref.source;
24
16
  var directionMultiplier = source.data.handleSide === 'left' ? -1 : 1;
25
17
  var diffX = (location.current.input.clientX - location.initial.input.clientX) * RESIZE_RATIO * directionMultiplier;
26
- var width = (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;
27
- var padding = width <= akEditorFullPageNarrowBreakout && editorExperiment('platform_editor_preview_panel_responsiveness', true, {
28
- exposure: true
29
- }) ? akEditorGutterPaddingReduced : akEditorGutterPaddingDynamic();
30
- var containerWidth = width - 2 * padding - akEditorGutterPadding;
18
+ var containerWidth = getResizeContainerWidth(api);
31
19
 
32
20
  // the node width may be greater than the container width so we resize using the smaller value
33
21
  var proposedWidth = Math.min(initialWidth, containerWidth) + diffX;
@@ -41,8 +29,7 @@ export function getProposedWidth(_ref) {
41
29
  return snapPoint;
42
30
  }
43
31
  }
44
- var hardMax = expValEquals('editor_tinymce_full_width_mode', 'isEnabled', true) || expValEquals('confluence_max_width_content_appearance', 'isEnabled', true) ? Math.min(containerWidth, WIDTHS.MAX) : Math.min(containerWidth, WIDTHS.FULL);
45
- return Math.max(WIDTHS.MIN, Math.min(proposedWidth, hardMax));
32
+ return clampWidthToResizeBounds(proposedWidth, containerWidth);
46
33
  }
47
34
  export function createResizerCallbacks(_ref2) {
48
35
  var dom = _ref2.dom,
@@ -0,0 +1,12 @@
1
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
2
+ import type { BreakoutPlugin } from '../breakoutPluginType';
3
+ declare const WIDTHS: {
4
+ FULL: number;
5
+ MAX: number;
6
+ MIN: number;
7
+ WIDE: number;
8
+ };
9
+ export { WIDTHS };
10
+ export declare const getResizeContainerWidth: (api: ExtractInjectionAPI<BreakoutPlugin> | undefined) => number;
11
+ export declare const getResizeHardMax: (containerWidth: number) => number;
12
+ export declare const clampWidthToResizeBounds: (proposedWidth: number, containerWidth: number) => number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-breakout",
3
- "version": "12.3.3",
3
+ "version": "12.3.4",
4
4
  "description": "Breakout plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -35,7 +35,7 @@
35
35
  "@atlaskit/platform-feature-flags": "^2.0.0",
36
36
  "@atlaskit/pragmatic-drag-and-drop": "^2.0.0",
37
37
  "@atlaskit/theme": "^26.1.0",
38
- "@atlaskit/tmp-editor-statsig": "^130.0.0",
38
+ "@atlaskit/tmp-editor-statsig": "^130.2.0",
39
39
  "@atlaskit/tokens": "^16.1.0",
40
40
  "@atlaskit/tooltip": "^23.1.0",
41
41
  "@babel/runtime": "^7.0.0",
@@ -45,7 +45,7 @@
45
45
  "uuid": "^3.1.0"
46
46
  },
47
47
  "peerDependencies": {
48
- "@atlaskit/editor-common": "^116.33.0",
48
+ "@atlaskit/editor-common": "^116.34.0",
49
49
  "react": "^18.2.0",
50
50
  "react-dom": "^18.2.0",
51
51
  "react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"