@atlaskit/editor-common 105.8.2 → 105.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @atlaskit/editor-common
2
2
 
3
+ ## 105.8.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [#158601](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/158601)
8
+ [`7dfac59b4421f`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/7dfac59b4421f) -
9
+ ED-27401: Updated layout guidelines
10
+ - Updated dependencies
11
+
3
12
  ## 105.8.2
4
13
 
5
14
  ### Patch Changes
@@ -17,7 +17,7 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return
17
17
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
18
18
  var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
19
19
  var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
20
- var packageVersion = "105.8.2";
20
+ var packageVersion = "105.8.3";
21
21
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
22
22
  // Remove URL as it has UGC
23
23
  // Ignored via go/ees007
@@ -93,6 +93,8 @@ var RESIZE_STEP_VALUE = 10;
93
93
  * @param root0.editorAnalyticsApi
94
94
  * @param root0.displayGapCursor
95
95
  * @param root0.onResizeStart
96
+ * @param root0.dynamicFullWidthGuidelineOffset
97
+ * @returns BreakoutResizer component
96
98
  * @example
97
99
  */
98
100
  var BreakoutResizer = exports.BreakoutResizer = function BreakoutResizer(_ref) {
@@ -106,7 +108,8 @@ var BreakoutResizer = exports.BreakoutResizer = function BreakoutResizer(_ref) {
106
108
  displayGuidelines = _ref.displayGuidelines,
107
109
  editorAnalyticsApi = _ref.editorAnalyticsApi,
108
110
  displayGapCursor = _ref.displayGapCursor,
109
- onResizeStart = _ref.onResizeStart;
111
+ onResizeStart = _ref.onResizeStart,
112
+ dynamicFullWidthGuidelineOffset = _ref.dynamicFullWidthGuidelineOffset;
110
113
  var _useState = (0, _react.useState)({
111
114
  minWidth: undefined,
112
115
  maxWidth: undefined,
@@ -120,7 +123,7 @@ var BreakoutResizer = exports.BreakoutResizer = function BreakoutResizer(_ref) {
120
123
  setResizingState = _useState2[1];
121
124
  var areResizeMetaKeysPressed = (0, _react.useRef)(false);
122
125
  var resizerRef = (0, _react.useRef)(null);
123
- var _useBreakoutGuideline = (0, _useBreakoutGuidelines.useBreakoutGuidelines)(getEditorWidth, isResizing && (0, _experiments.editorExperiment)('single_column_layouts', true)),
126
+ var _useBreakoutGuideline = (0, _useBreakoutGuidelines.useBreakoutGuidelines)(getEditorWidth, isResizing && (0, _experiments.editorExperiment)('single_column_layouts', true), dynamicFullWidthGuidelineOffset),
124
127
  snaps = _useBreakoutGuideline.snaps,
125
128
  currentLayout = _useBreakoutGuideline.currentLayout,
126
129
  guidelines = _useBreakoutGuideline.guidelines,
@@ -10,11 +10,22 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
10
10
  var _react = require("react");
11
11
  var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
12
12
  var SNAP_GAP = exports.SNAP_GAP = 8;
13
+ var GUIDELINE_KEYS = {
14
+ lineLength: 'grid',
15
+ wide: 'wide',
16
+ fullWidth: 'full_width'
17
+ };
18
+ var CURRENT_LAYOUT_KEYS = {
19
+ lineLength: 'center',
20
+ wide: 'wide',
21
+ fullWidth: 'full-width'
22
+ };
13
23
  var roundToNearest = function roundToNearest(value) {
14
24
  var interval = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0.5;
15
25
  return Math.round(value / interval) * interval;
16
26
  };
17
27
  function useBreakoutGuidelines(getEditorWidth, isResizing) {
28
+ var dynamicFullWidthGuidelineOffset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
18
29
  var widthState = getEditorWidth();
19
30
  var _useMemo = (0, _react.useMemo)(function () {
20
31
  if (!isResizing) {
@@ -24,93 +35,80 @@ function useBreakoutGuidelines(getEditorWidth, isResizing) {
24
35
  width = _ref.width,
25
36
  lineLength = _ref.lineLength;
26
37
  var wide = lineLength ? Math.round(lineLength * _editorSharedStyles.breakoutWideScaleRatio) : undefined;
27
- var fullWidth = width ? Math.min(width - (0, _editorSharedStyles.akEditorGutterPaddingDynamic)() * 2) : undefined;
38
+ var layoutCalculatedWidth = width ? width - ((0, _editorSharedStyles.akEditorGutterPaddingDynamic)() + dynamicFullWidthGuidelineOffset) * 2 : undefined;
39
+ var fullWidth = width && layoutCalculatedWidth ? Math.min(layoutCalculatedWidth, _editorSharedStyles.akEditorFullWidthLayoutWidth) : undefined;
28
40
  return {
29
41
  wide: wide,
30
42
  fullWidth: fullWidth,
31
43
  lineLength: lineLength
32
44
  };
33
- }, [widthState, isResizing]),
45
+ }, [widthState, isResizing, dynamicFullWidthGuidelineOffset]),
34
46
  lineLength = _useMemo.lineLength,
35
47
  wide = _useMemo.wide,
36
48
  fullWidth = _useMemo.fullWidth;
37
- var snaps = (0, _react.useMemo)(function () {
38
- if (!isResizing) {
49
+
50
+ // calculate snapping width
51
+ var defaultSnappingWidths = (0, _react.useMemo)(function () {
52
+ if (!fullWidth || !wide || !lineLength || fullWidth <= lineLength) {
39
53
  return null;
40
54
  }
41
- var xSnaps = [];
42
- if (typeof lineLength === 'number') {
43
- xSnaps.push(lineLength);
55
+ if (fullWidth - wide > SNAP_GAP) {
56
+ return {
57
+ lineLength: lineLength,
58
+ wide: wide,
59
+ fullWidth: fullWidth
60
+ };
44
61
  }
45
- if (typeof wide === 'number') {
46
- xSnaps.push(wide);
62
+ if (fullWidth <= wide && fullWidth - lineLength > SNAP_GAP) {
63
+ return {
64
+ lineLength: lineLength,
65
+ fullWidth: fullWidth
66
+ };
47
67
  }
48
- if (typeof fullWidth === 'number') {
49
- xSnaps.push(fullWidth - _editorSharedStyles.akEditorGutterPadding);
68
+ return null;
69
+ }, [fullWidth, lineLength, wide]);
70
+ var snaps = (0, _react.useMemo)(function () {
71
+ if (!isResizing || !defaultSnappingWidths) {
72
+ return null;
50
73
  }
51
74
  return {
52
- x: xSnaps
75
+ x: Object.values(defaultSnappingWidths)
53
76
  };
54
- }, [isResizing, wide, fullWidth, lineLength]);
77
+ }, [defaultSnappingWidths, isResizing]);
78
+
79
+ // calculate guidelines, and calculate which lines are active
55
80
  var _useState = (0, _react.useState)(null),
56
81
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
57
82
  currentLayout = _useState2[0],
58
83
  setCurrentLayout = _useState2[1];
59
84
  var guidelines = (0, _react.useMemo)(function () {
60
85
  var guidelines = [];
61
- if (!isResizing) {
86
+ if (!defaultSnappingWidths) {
62
87
  return guidelines;
63
88
  }
64
- if (lineLength) {
65
- guidelines.push({
66
- key: 'grid_left',
67
- position: {
68
- x: -roundToNearest(lineLength / 2)
69
- },
70
- active: currentLayout === 'center'
71
- });
72
- guidelines.push({
73
- key: 'grid_right',
74
- position: {
75
- x: roundToNearest(lineLength / 2)
76
- },
77
- active: currentLayout === 'center'
78
- });
79
- }
80
- if (wide) {
81
- guidelines.push({
82
- key: 'wide_left',
83
- position: {
84
- x: -roundToNearest(wide / 2)
85
- },
86
- active: currentLayout === 'wide'
87
- });
88
- guidelines.push({
89
- key: 'wide_right',
90
- position: {
91
- x: roundToNearest(wide / 2)
92
- },
93
- active: currentLayout === 'wide'
94
- });
95
- }
96
- if (fullWidth) {
97
- guidelines.push({
98
- key: 'full_width_left',
99
- position: {
100
- x: -roundToNearest(fullWidth / 2)
101
- },
102
- active: currentLayout === 'full-width'
103
- });
104
- guidelines.push({
105
- key: 'full_width_right',
106
- position: {
107
- x: roundToNearest(fullWidth) / 2
108
- },
109
- active: currentLayout === 'full-width'
110
- });
111
- }
89
+ Object.entries(defaultSnappingWidths).map(function (_ref2) {
90
+ var _ref3 = (0, _slicedToArray2.default)(_ref2, 2),
91
+ key = _ref3[0],
92
+ value = _ref3[1];
93
+ if (value) {
94
+ guidelines.push({
95
+ key: "".concat(GUIDELINE_KEYS[key], "_left"),
96
+ position: {
97
+ x: -roundToNearest(value / 2)
98
+ },
99
+ active: currentLayout === CURRENT_LAYOUT_KEYS[key]
100
+ });
101
+ guidelines.push({
102
+ key: "".concat(GUIDELINE_KEYS[key], "_right"),
103
+ position: {
104
+ x: roundToNearest(value / 2)
105
+ },
106
+ active: currentLayout === CURRENT_LAYOUT_KEYS[key]
107
+ });
108
+ }
109
+ });
112
110
  return guidelines;
113
- }, [isResizing, lineLength, wide, fullWidth, currentLayout]);
111
+ }, [defaultSnappingWidths, currentLayout]);
114
112
  var setCurrentWidth = (0, _react.useCallback)(function (newWidth) {
115
113
  if (typeof newWidth !== 'number') {
116
114
  setCurrentLayout(null);
@@ -23,7 +23,7 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
23
23
  * @jsx jsx
24
24
  */ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
25
25
  var packageName = "@atlaskit/editor-common";
26
- var packageVersion = "105.8.2";
26
+ var packageVersion = "105.8.3";
27
27
  var halfFocusRing = 1;
28
28
  var dropOffset = '0, 8';
29
29
  // Ignored via go/ees005
@@ -1,7 +1,7 @@
1
1
  import { isFedRamp } from './environment';
2
2
  const SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
3
3
  const packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
4
- const packageVersion = "105.8.2";
4
+ const packageVersion = "105.8.3";
5
5
  const sanitiseSentryEvents = (data, _hint) => {
6
6
  // Remove URL as it has UGC
7
7
  // Ignored via go/ees007
@@ -82,6 +82,8 @@ const RESIZE_STEP_VALUE = 10;
82
82
  * @param root0.editorAnalyticsApi
83
83
  * @param root0.displayGapCursor
84
84
  * @param root0.onResizeStart
85
+ * @param root0.dynamicFullWidthGuidelineOffset
86
+ * @returns BreakoutResizer component
85
87
  * @example
86
88
  */
87
89
  const BreakoutResizer = ({
@@ -95,7 +97,8 @@ const BreakoutResizer = ({
95
97
  displayGuidelines,
96
98
  editorAnalyticsApi,
97
99
  displayGapCursor,
98
- onResizeStart
100
+ onResizeStart,
101
+ dynamicFullWidthGuidelineOffset
99
102
  }) => {
100
103
  const [{
101
104
  minWidth,
@@ -113,7 +116,7 @@ const BreakoutResizer = ({
113
116
  currentLayout,
114
117
  guidelines,
115
118
  setCurrentWidth
116
- } = useBreakoutGuidelines(getEditorWidth, isResizing && editorExperiment('single_column_layouts', true));
119
+ } = useBreakoutGuidelines(getEditorWidth, isResizing && editorExperiment('single_column_layouts', true), dynamicFullWidthGuidelineOffset);
117
120
  useEffect(() => {
118
121
  if (displayGuidelines) {
119
122
  displayGuidelines(guidelines || []);
@@ -1,8 +1,18 @@
1
1
  import { useCallback, useMemo, useState } from 'react';
2
- import { akEditorGutterPadding, akEditorGutterPaddingDynamic, breakoutWideScaleRatio } from '@atlaskit/editor-shared-styles';
2
+ import { akEditorFullWidthLayoutWidth, akEditorGutterPadding, akEditorGutterPaddingDynamic, breakoutWideScaleRatio } from '@atlaskit/editor-shared-styles';
3
3
  export const SNAP_GAP = 8;
4
+ const GUIDELINE_KEYS = {
5
+ lineLength: 'grid',
6
+ wide: 'wide',
7
+ fullWidth: 'full_width'
8
+ };
9
+ const CURRENT_LAYOUT_KEYS = {
10
+ lineLength: 'center',
11
+ wide: 'wide',
12
+ fullWidth: 'full-width'
13
+ };
4
14
  const roundToNearest = (value, interval = 0.5) => Math.round(value / interval) * interval;
5
- export function useBreakoutGuidelines(getEditorWidth, isResizing) {
15
+ export function useBreakoutGuidelines(getEditorWidth, isResizing, dynamicFullWidthGuidelineOffset = 0) {
6
16
  const widthState = getEditorWidth();
7
17
  const {
8
18
  lineLength,
@@ -17,87 +27,71 @@ export function useBreakoutGuidelines(getEditorWidth, isResizing) {
17
27
  lineLength
18
28
  } = widthState || {};
19
29
  const wide = lineLength ? Math.round(lineLength * breakoutWideScaleRatio) : undefined;
20
- const fullWidth = width ? Math.min(width - akEditorGutterPaddingDynamic() * 2) : undefined;
30
+ const layoutCalculatedWidth = width ? width - (akEditorGutterPaddingDynamic() + dynamicFullWidthGuidelineOffset) * 2 : undefined;
31
+ const fullWidth = width && layoutCalculatedWidth ? Math.min(layoutCalculatedWidth, akEditorFullWidthLayoutWidth) : undefined;
21
32
  return {
22
33
  wide,
23
34
  fullWidth,
24
35
  lineLength
25
36
  };
26
- }, [widthState, isResizing]);
27
- const snaps = useMemo(() => {
28
- if (!isResizing) {
37
+ }, [widthState, isResizing, dynamicFullWidthGuidelineOffset]);
38
+
39
+ // calculate snapping width
40
+ const defaultSnappingWidths = useMemo(() => {
41
+ if (!fullWidth || !wide || !lineLength || fullWidth <= lineLength) {
29
42
  return null;
30
43
  }
31
- const xSnaps = [];
32
- if (typeof lineLength === 'number') {
33
- xSnaps.push(lineLength);
44
+ if (fullWidth - wide > SNAP_GAP) {
45
+ return {
46
+ lineLength,
47
+ wide,
48
+ fullWidth
49
+ };
34
50
  }
35
- if (typeof wide === 'number') {
36
- xSnaps.push(wide);
51
+ if (fullWidth <= wide && fullWidth - lineLength > SNAP_GAP) {
52
+ return {
53
+ lineLength,
54
+ fullWidth
55
+ };
37
56
  }
38
- if (typeof fullWidth === 'number') {
39
- xSnaps.push(fullWidth - akEditorGutterPadding);
57
+ return null;
58
+ }, [fullWidth, lineLength, wide]);
59
+ const snaps = useMemo(() => {
60
+ if (!isResizing || !defaultSnappingWidths) {
61
+ return null;
40
62
  }
41
63
  return {
42
- x: xSnaps
64
+ x: Object.values(defaultSnappingWidths)
43
65
  };
44
- }, [isResizing, wide, fullWidth, lineLength]);
66
+ }, [defaultSnappingWidths, isResizing]);
67
+
68
+ // calculate guidelines, and calculate which lines are active
45
69
  const [currentLayout, setCurrentLayout] = useState(null);
46
70
  const guidelines = useMemo(() => {
47
71
  const guidelines = [];
48
- if (!isResizing) {
72
+ if (!defaultSnappingWidths) {
49
73
  return guidelines;
50
74
  }
51
- if (lineLength) {
52
- guidelines.push({
53
- key: 'grid_left',
54
- position: {
55
- x: -roundToNearest(lineLength / 2)
56
- },
57
- active: currentLayout === 'center'
58
- });
59
- guidelines.push({
60
- key: 'grid_right',
61
- position: {
62
- x: roundToNearest(lineLength / 2)
63
- },
64
- active: currentLayout === 'center'
65
- });
66
- }
67
- if (wide) {
68
- guidelines.push({
69
- key: 'wide_left',
70
- position: {
71
- x: -roundToNearest(wide / 2)
72
- },
73
- active: currentLayout === 'wide'
74
- });
75
- guidelines.push({
76
- key: 'wide_right',
77
- position: {
78
- x: roundToNearest(wide / 2)
79
- },
80
- active: currentLayout === 'wide'
81
- });
82
- }
83
- if (fullWidth) {
84
- guidelines.push({
85
- key: 'full_width_left',
86
- position: {
87
- x: -roundToNearest(fullWidth / 2)
88
- },
89
- active: currentLayout === 'full-width'
90
- });
91
- guidelines.push({
92
- key: 'full_width_right',
93
- position: {
94
- x: roundToNearest(fullWidth) / 2
95
- },
96
- active: currentLayout === 'full-width'
97
- });
98
- }
75
+ Object.entries(defaultSnappingWidths).map(([key, value]) => {
76
+ if (value) {
77
+ guidelines.push({
78
+ key: `${GUIDELINE_KEYS[key]}_left`,
79
+ position: {
80
+ x: -roundToNearest(value / 2)
81
+ },
82
+ active: currentLayout === CURRENT_LAYOUT_KEYS[key]
83
+ });
84
+ guidelines.push({
85
+ key: `${GUIDELINE_KEYS[key]}_right`,
86
+ position: {
87
+ x: roundToNearest(value / 2)
88
+ },
89
+ active: currentLayout === CURRENT_LAYOUT_KEYS[key]
90
+ });
91
+ }
92
+ });
99
93
  return guidelines;
100
- }, [isResizing, lineLength, wide, fullWidth, currentLayout]);
94
+ }, [defaultSnappingWidths, currentLayout]);
101
95
  const setCurrentWidth = useCallback(newWidth => {
102
96
  if (typeof newWidth !== 'number') {
103
97
  setCurrentLayout(null);
@@ -13,7 +13,7 @@ import withAnalyticsContext from '@atlaskit/analytics-next/withAnalyticsContext'
13
13
  import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
14
14
  import Layer from '../Layer';
15
15
  const packageName = "@atlaskit/editor-common";
16
- const packageVersion = "105.8.2";
16
+ const packageVersion = "105.8.3";
17
17
  const halfFocusRing = 1;
18
18
  const dropOffset = '0, 8';
19
19
  // Ignored via go/ees005
@@ -7,7 +7,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
7
7
  import { isFedRamp } from './environment';
8
8
  var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
9
9
  var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
10
- var packageVersion = "105.8.2";
10
+ var packageVersion = "105.8.3";
11
11
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
12
12
  // Remove URL as it has UGC
13
13
  // Ignored via go/ees007
@@ -83,6 +83,8 @@ var RESIZE_STEP_VALUE = 10;
83
83
  * @param root0.editorAnalyticsApi
84
84
  * @param root0.displayGapCursor
85
85
  * @param root0.onResizeStart
86
+ * @param root0.dynamicFullWidthGuidelineOffset
87
+ * @returns BreakoutResizer component
86
88
  * @example
87
89
  */
88
90
  var BreakoutResizer = function BreakoutResizer(_ref) {
@@ -96,7 +98,8 @@ var BreakoutResizer = function BreakoutResizer(_ref) {
96
98
  displayGuidelines = _ref.displayGuidelines,
97
99
  editorAnalyticsApi = _ref.editorAnalyticsApi,
98
100
  displayGapCursor = _ref.displayGapCursor,
99
- onResizeStart = _ref.onResizeStart;
101
+ onResizeStart = _ref.onResizeStart,
102
+ dynamicFullWidthGuidelineOffset = _ref.dynamicFullWidthGuidelineOffset;
100
103
  var _useState = useState({
101
104
  minWidth: undefined,
102
105
  maxWidth: undefined,
@@ -110,7 +113,7 @@ var BreakoutResizer = function BreakoutResizer(_ref) {
110
113
  setResizingState = _useState2[1];
111
114
  var areResizeMetaKeysPressed = useRef(false);
112
115
  var resizerRef = useRef(null);
113
- var _useBreakoutGuideline = useBreakoutGuidelines(getEditorWidth, isResizing && editorExperiment('single_column_layouts', true)),
116
+ var _useBreakoutGuideline = useBreakoutGuidelines(getEditorWidth, isResizing && editorExperiment('single_column_layouts', true), dynamicFullWidthGuidelineOffset),
114
117
  snaps = _useBreakoutGuideline.snaps,
115
118
  currentLayout = _useBreakoutGuideline.currentLayout,
116
119
  guidelines = _useBreakoutGuideline.guidelines,
@@ -1,12 +1,23 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
2
  import { useCallback, useMemo, useState } from 'react';
3
- import { akEditorGutterPadding, akEditorGutterPaddingDynamic, breakoutWideScaleRatio } from '@atlaskit/editor-shared-styles';
3
+ import { akEditorFullWidthLayoutWidth, akEditorGutterPadding, akEditorGutterPaddingDynamic, breakoutWideScaleRatio } from '@atlaskit/editor-shared-styles';
4
4
  export var SNAP_GAP = 8;
5
+ var GUIDELINE_KEYS = {
6
+ lineLength: 'grid',
7
+ wide: 'wide',
8
+ fullWidth: 'full_width'
9
+ };
10
+ var CURRENT_LAYOUT_KEYS = {
11
+ lineLength: 'center',
12
+ wide: 'wide',
13
+ fullWidth: 'full-width'
14
+ };
5
15
  var roundToNearest = function roundToNearest(value) {
6
16
  var interval = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0.5;
7
17
  return Math.round(value / interval) * interval;
8
18
  };
9
19
  export function useBreakoutGuidelines(getEditorWidth, isResizing) {
20
+ var dynamicFullWidthGuidelineOffset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
10
21
  var widthState = getEditorWidth();
11
22
  var _useMemo = useMemo(function () {
12
23
  if (!isResizing) {
@@ -16,93 +27,80 @@ export function useBreakoutGuidelines(getEditorWidth, isResizing) {
16
27
  width = _ref.width,
17
28
  lineLength = _ref.lineLength;
18
29
  var wide = lineLength ? Math.round(lineLength * breakoutWideScaleRatio) : undefined;
19
- var fullWidth = width ? Math.min(width - akEditorGutterPaddingDynamic() * 2) : undefined;
30
+ var layoutCalculatedWidth = width ? width - (akEditorGutterPaddingDynamic() + dynamicFullWidthGuidelineOffset) * 2 : undefined;
31
+ var fullWidth = width && layoutCalculatedWidth ? Math.min(layoutCalculatedWidth, akEditorFullWidthLayoutWidth) : undefined;
20
32
  return {
21
33
  wide: wide,
22
34
  fullWidth: fullWidth,
23
35
  lineLength: lineLength
24
36
  };
25
- }, [widthState, isResizing]),
37
+ }, [widthState, isResizing, dynamicFullWidthGuidelineOffset]),
26
38
  lineLength = _useMemo.lineLength,
27
39
  wide = _useMemo.wide,
28
40
  fullWidth = _useMemo.fullWidth;
29
- var snaps = useMemo(function () {
30
- if (!isResizing) {
41
+
42
+ // calculate snapping width
43
+ var defaultSnappingWidths = useMemo(function () {
44
+ if (!fullWidth || !wide || !lineLength || fullWidth <= lineLength) {
31
45
  return null;
32
46
  }
33
- var xSnaps = [];
34
- if (typeof lineLength === 'number') {
35
- xSnaps.push(lineLength);
47
+ if (fullWidth - wide > SNAP_GAP) {
48
+ return {
49
+ lineLength: lineLength,
50
+ wide: wide,
51
+ fullWidth: fullWidth
52
+ };
36
53
  }
37
- if (typeof wide === 'number') {
38
- xSnaps.push(wide);
54
+ if (fullWidth <= wide && fullWidth - lineLength > SNAP_GAP) {
55
+ return {
56
+ lineLength: lineLength,
57
+ fullWidth: fullWidth
58
+ };
39
59
  }
40
- if (typeof fullWidth === 'number') {
41
- xSnaps.push(fullWidth - akEditorGutterPadding);
60
+ return null;
61
+ }, [fullWidth, lineLength, wide]);
62
+ var snaps = useMemo(function () {
63
+ if (!isResizing || !defaultSnappingWidths) {
64
+ return null;
42
65
  }
43
66
  return {
44
- x: xSnaps
67
+ x: Object.values(defaultSnappingWidths)
45
68
  };
46
- }, [isResizing, wide, fullWidth, lineLength]);
69
+ }, [defaultSnappingWidths, isResizing]);
70
+
71
+ // calculate guidelines, and calculate which lines are active
47
72
  var _useState = useState(null),
48
73
  _useState2 = _slicedToArray(_useState, 2),
49
74
  currentLayout = _useState2[0],
50
75
  setCurrentLayout = _useState2[1];
51
76
  var guidelines = useMemo(function () {
52
77
  var guidelines = [];
53
- if (!isResizing) {
78
+ if (!defaultSnappingWidths) {
54
79
  return guidelines;
55
80
  }
56
- if (lineLength) {
57
- guidelines.push({
58
- key: 'grid_left',
59
- position: {
60
- x: -roundToNearest(lineLength / 2)
61
- },
62
- active: currentLayout === 'center'
63
- });
64
- guidelines.push({
65
- key: 'grid_right',
66
- position: {
67
- x: roundToNearest(lineLength / 2)
68
- },
69
- active: currentLayout === 'center'
70
- });
71
- }
72
- if (wide) {
73
- guidelines.push({
74
- key: 'wide_left',
75
- position: {
76
- x: -roundToNearest(wide / 2)
77
- },
78
- active: currentLayout === 'wide'
79
- });
80
- guidelines.push({
81
- key: 'wide_right',
82
- position: {
83
- x: roundToNearest(wide / 2)
84
- },
85
- active: currentLayout === 'wide'
86
- });
87
- }
88
- if (fullWidth) {
89
- guidelines.push({
90
- key: 'full_width_left',
91
- position: {
92
- x: -roundToNearest(fullWidth / 2)
93
- },
94
- active: currentLayout === 'full-width'
95
- });
96
- guidelines.push({
97
- key: 'full_width_right',
98
- position: {
99
- x: roundToNearest(fullWidth) / 2
100
- },
101
- active: currentLayout === 'full-width'
102
- });
103
- }
81
+ Object.entries(defaultSnappingWidths).map(function (_ref2) {
82
+ var _ref3 = _slicedToArray(_ref2, 2),
83
+ key = _ref3[0],
84
+ value = _ref3[1];
85
+ if (value) {
86
+ guidelines.push({
87
+ key: "".concat(GUIDELINE_KEYS[key], "_left"),
88
+ position: {
89
+ x: -roundToNearest(value / 2)
90
+ },
91
+ active: currentLayout === CURRENT_LAYOUT_KEYS[key]
92
+ });
93
+ guidelines.push({
94
+ key: "".concat(GUIDELINE_KEYS[key], "_right"),
95
+ position: {
96
+ x: roundToNearest(value / 2)
97
+ },
98
+ active: currentLayout === CURRENT_LAYOUT_KEYS[key]
99
+ });
100
+ }
101
+ });
104
102
  return guidelines;
105
- }, [isResizing, lineLength, wide, fullWidth, currentLayout]);
103
+ }, [defaultSnappingWidths, currentLayout]);
106
104
  var setCurrentWidth = useCallback(function (newWidth) {
107
105
  if (typeof newWidth !== 'number') {
108
106
  setCurrentLayout(null);
@@ -20,7 +20,7 @@ import withAnalyticsContext from '@atlaskit/analytics-next/withAnalyticsContext'
20
20
  import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
21
21
  import Layer from '../Layer';
22
22
  var packageName = "@atlaskit/editor-common";
23
- var packageVersion = "105.8.2";
23
+ var packageVersion = "105.8.3";
24
24
  var halfFocusRing = 1;
25
25
  var dropOffset = '0, 8';
26
26
  // Ignored via go/ees005
@@ -20,6 +20,7 @@ type BreakoutResizerProps = {
20
20
  displayGuidelines?: (guidelines: GuidelineConfig[]) => void;
21
21
  displayGapCursor: (toggle: boolean) => boolean;
22
22
  onResizeStart?: () => void;
23
+ dynamicFullWidthGuidelineOffset?: number;
23
24
  };
24
25
  /**
25
26
  * BreakoutResizer is a common component used to resize nodes that support the 'Breakout' mark, so it requires
@@ -38,7 +39,9 @@ type BreakoutResizerProps = {
38
39
  * @param root0.editorAnalyticsApi
39
40
  * @param root0.displayGapCursor
40
41
  * @param root0.onResizeStart
42
+ * @param root0.dynamicFullWidthGuidelineOffset
43
+ * @returns BreakoutResizer component
41
44
  * @example
42
45
  */
43
- declare const BreakoutResizer: ({ editorView, nodeType, getPos, getRef, disabled, getEditorWidth, parentRef, displayGuidelines, editorAnalyticsApi, displayGapCursor, onResizeStart, }: BreakoutResizerProps) => React.JSX.Element;
46
+ declare const BreakoutResizer: ({ editorView, nodeType, getPos, getRef, disabled, getEditorWidth, parentRef, displayGuidelines, editorAnalyticsApi, displayGapCursor, onResizeStart, dynamicFullWidthGuidelineOffset, }: BreakoutResizerProps) => React.JSX.Element;
44
47
  export { BreakoutResizer };
@@ -1,8 +1,8 @@
1
- import type { GuidelineConfig } from '../guideline';
1
+ import { type GuidelineConfig } from '../guideline';
2
2
  import type { BreakoutMode, EditorContainerWidth } from '../types';
3
3
  import type { Snap } from './types';
4
4
  export declare const SNAP_GAP = 8;
5
- export declare function useBreakoutGuidelines(getEditorWidth: () => EditorContainerWidth | undefined, isResizing: boolean): {
5
+ export declare function useBreakoutGuidelines(getEditorWidth: () => EditorContainerWidth | undefined, isResizing: boolean, dynamicFullWidthGuidelineOffset?: number): {
6
6
  snaps: Snap | null;
7
7
  currentLayout: BreakoutMode | null;
8
8
  guidelines: GuidelineConfig[];
@@ -20,6 +20,7 @@ type BreakoutResizerProps = {
20
20
  displayGuidelines?: (guidelines: GuidelineConfig[]) => void;
21
21
  displayGapCursor: (toggle: boolean) => boolean;
22
22
  onResizeStart?: () => void;
23
+ dynamicFullWidthGuidelineOffset?: number;
23
24
  };
24
25
  /**
25
26
  * BreakoutResizer is a common component used to resize nodes that support the 'Breakout' mark, so it requires
@@ -38,7 +39,9 @@ type BreakoutResizerProps = {
38
39
  * @param root0.editorAnalyticsApi
39
40
  * @param root0.displayGapCursor
40
41
  * @param root0.onResizeStart
42
+ * @param root0.dynamicFullWidthGuidelineOffset
43
+ * @returns BreakoutResizer component
41
44
  * @example
42
45
  */
43
- declare const BreakoutResizer: ({ editorView, nodeType, getPos, getRef, disabled, getEditorWidth, parentRef, displayGuidelines, editorAnalyticsApi, displayGapCursor, onResizeStart, }: BreakoutResizerProps) => React.JSX.Element;
46
+ declare const BreakoutResizer: ({ editorView, nodeType, getPos, getRef, disabled, getEditorWidth, parentRef, displayGuidelines, editorAnalyticsApi, displayGapCursor, onResizeStart, dynamicFullWidthGuidelineOffset, }: BreakoutResizerProps) => React.JSX.Element;
44
47
  export { BreakoutResizer };
@@ -1,8 +1,8 @@
1
- import type { GuidelineConfig } from '../guideline';
1
+ import { type GuidelineConfig } from '../guideline';
2
2
  import type { BreakoutMode, EditorContainerWidth } from '../types';
3
3
  import type { Snap } from './types';
4
4
  export declare const SNAP_GAP = 8;
5
- export declare function useBreakoutGuidelines(getEditorWidth: () => EditorContainerWidth | undefined, isResizing: boolean): {
5
+ export declare function useBreakoutGuidelines(getEditorWidth: () => EditorContainerWidth | undefined, isResizing: boolean, dynamicFullWidthGuidelineOffset?: number): {
6
6
  snaps: Snap | null;
7
7
  currentLayout: BreakoutMode | null;
8
8
  guidelines: GuidelineConfig[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-common",
3
- "version": "105.8.2",
3
+ "version": "105.8.3",
4
4
  "description": "A package that contains common classes and components for editor and renderer",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"