@atlaskit/editor-plugin-breakout 6.1.4 → 6.2.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 +25 -0
- package/dist/cjs/pm-plugins/get-guidelines.js +24 -3
- package/dist/cjs/pm-plugins/resizer-callbacks.js +21 -4
- package/dist/cjs/ui/GuidelineLabel.js +3 -1
- package/dist/es2019/pm-plugins/get-guidelines.js +25 -4
- package/dist/es2019/pm-plugins/resizer-callbacks.js +20 -5
- package/dist/es2019/ui/GuidelineLabel.js +3 -1
- package/dist/esm/pm-plugins/get-guidelines.js +25 -4
- package/dist/esm/pm-plugins/resizer-callbacks.js +22 -5
- package/dist/esm/ui/GuidelineLabel.js +3 -1
- package/dist/types/pm-plugins/get-guidelines.d.ts +2 -0
- package/dist/types-ts4.5/pm-plugins/get-guidelines.d.ts +2 -0
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-breakout
|
|
2
2
|
|
|
3
|
+
## 6.2.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`a05464ea42678`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/a05464ea42678) -
|
|
8
|
+
EDITOR-2791 bump adf-schema
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
11
|
+
## 6.2.0
|
|
12
|
+
|
|
13
|
+
### Minor Changes
|
|
14
|
+
|
|
15
|
+
- [`81ac927e830b5`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/81ac927e830b5) -
|
|
16
|
+
[ux] EDITOR-2866: Add max-width support and guideline wiring for node custom resizers
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- Updated dependencies
|
|
21
|
+
|
|
22
|
+
## 6.1.5
|
|
23
|
+
|
|
24
|
+
### Patch Changes
|
|
25
|
+
|
|
26
|
+
- Updated dependencies
|
|
27
|
+
|
|
3
28
|
## 6.1.4
|
|
4
29
|
|
|
5
30
|
### Patch Changes
|
|
@@ -8,11 +8,13 @@ exports.getGuidelines = exports.GUIDELINE_KEYS = void 0;
|
|
|
8
8
|
var _memoizeOne = _interopRequireDefault(require("memoize-one"));
|
|
9
9
|
var _styles = require("@atlaskit/editor-common/styles");
|
|
10
10
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
11
|
+
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
11
12
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
12
13
|
var WIDTHS = {
|
|
13
14
|
MIN: _editorSharedStyles.akEditorDefaultLayoutWidth,
|
|
14
15
|
WIDE: _editorSharedStyles.akEditorCalculatedWideLayoutWidth,
|
|
15
|
-
|
|
16
|
+
FULL: _editorSharedStyles.akEditorFullWidthLayoutWidth,
|
|
17
|
+
MAX: _editorSharedStyles.akEditorMaxLayoutWidth
|
|
16
18
|
};
|
|
17
19
|
var GUIDELINE_KEYS = exports.GUIDELINE_KEYS = {
|
|
18
20
|
lineLengthLeft: 'grid_left',
|
|
@@ -20,7 +22,9 @@ var GUIDELINE_KEYS = exports.GUIDELINE_KEYS = {
|
|
|
20
22
|
wideLeft: 'wide_left',
|
|
21
23
|
wideRight: 'wide_right',
|
|
22
24
|
fullWidthLeft: 'full_width_left',
|
|
23
|
-
fullWidthRight: 'full_width_right'
|
|
25
|
+
fullWidthRight: 'full_width_right',
|
|
26
|
+
maxWidthLeft: 'max_width_left',
|
|
27
|
+
maxWidthRight: 'max_width_right'
|
|
24
28
|
};
|
|
25
29
|
var AK_NESTED_DND_GUTTER_OFFSET = 8;
|
|
26
30
|
var roundToNearest = function roundToNearest(value) {
|
|
@@ -50,7 +54,8 @@ var getGuidelines = exports.getGuidelines = (0, _memoizeOne.default)(function (i
|
|
|
50
54
|
var padding = width && width <= _editorSharedStyles.akEditorFullPageNarrowBreakout && (0, _experiments.editorExperiment)('platform_editor_preview_panel_responsiveness', true, {
|
|
51
55
|
exposure: true
|
|
52
56
|
}) ? _editorSharedStyles.akEditorGutterPaddingReduced : (0, _editorSharedStyles.akEditorGutterPaddingDynamic)();
|
|
53
|
-
var fullWidth = width ? Math.min(WIDTHS.
|
|
57
|
+
var fullWidth = width ? Math.min(WIDTHS.FULL, width - 2 * padding - _editorSharedStyles.akEditorGutterPadding) : undefined;
|
|
58
|
+
var maxWidth = width && (0, _expValEquals.expValEquals)('editor_tinymce_full_width_mode', 'isEnabled', true) ? Math.min(WIDTHS.MAX, width - 2 * padding - _editorSharedStyles.akEditorGutterPadding) : undefined;
|
|
54
59
|
guidelines.push({
|
|
55
60
|
key: GUIDELINE_KEYS.lineLengthLeft,
|
|
56
61
|
position: {
|
|
@@ -95,5 +100,21 @@ var getGuidelines = exports.getGuidelines = (0, _memoizeOne.default)(function (i
|
|
|
95
100
|
active: newWidth === fullWidth
|
|
96
101
|
});
|
|
97
102
|
}
|
|
103
|
+
if (maxWidth) {
|
|
104
|
+
guidelines.push({
|
|
105
|
+
key: GUIDELINE_KEYS.maxWidthLeft,
|
|
106
|
+
position: {
|
|
107
|
+
x: -roundToNearest(maxWidth / 2 + innerPaddingOffset)
|
|
108
|
+
},
|
|
109
|
+
active: newWidth === maxWidth
|
|
110
|
+
});
|
|
111
|
+
guidelines.push({
|
|
112
|
+
key: GUIDELINE_KEYS.maxWidthRight,
|
|
113
|
+
position: {
|
|
114
|
+
x: roundToNearest(maxWidth / 2 + innerPaddingOffset)
|
|
115
|
+
},
|
|
116
|
+
active: newWidth === maxWidth
|
|
117
|
+
});
|
|
118
|
+
}
|
|
98
119
|
return guidelines;
|
|
99
120
|
});
|
|
@@ -7,6 +7,7 @@ exports.createResizerCallbacks = createResizerCallbacks;
|
|
|
7
7
|
exports.getProposedWidth = getProposedWidth;
|
|
8
8
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
9
9
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
10
|
+
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
10
11
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
11
12
|
var _setBreakoutWidth = require("../editor-commands/set-breakout-width");
|
|
12
13
|
var _getGuidelines = require("./get-guidelines");
|
|
@@ -19,7 +20,8 @@ var SNAP_GAP = 10;
|
|
|
19
20
|
var WIDTHS = {
|
|
20
21
|
MIN: _editorSharedStyles.akEditorDefaultLayoutWidth,
|
|
21
22
|
WIDE: _editorSharedStyles.akEditorCalculatedWideLayoutWidth,
|
|
22
|
-
|
|
23
|
+
FULL: _editorSharedStyles.akEditorFullWidthLayoutWidth,
|
|
24
|
+
MAX: _editorSharedStyles.akEditorMaxLayoutWidth
|
|
23
25
|
};
|
|
24
26
|
function getProposedWidth(_ref) {
|
|
25
27
|
var _api$width$sharedStat;
|
|
@@ -37,14 +39,18 @@ function getProposedWidth(_ref) {
|
|
|
37
39
|
|
|
38
40
|
// the node width may be greater than the container width so we resize using the smaller value
|
|
39
41
|
var proposedWidth = Math.min(initialWidth, containerWidth) + diffX;
|
|
40
|
-
var snapPoints = [WIDTHS.MIN, WIDTHS.WIDE, Math.min(containerWidth, WIDTHS.
|
|
42
|
+
var snapPoints = [WIDTHS.MIN, WIDTHS.WIDE, Math.min(containerWidth, WIDTHS.FULL)];
|
|
43
|
+
if ((0, _expValEquals.expValEquals)('editor_tinymce_full_width_mode', 'isEnabled', true)) {
|
|
44
|
+
snapPoints.push(Math.min(containerWidth, WIDTHS.MAX));
|
|
45
|
+
}
|
|
41
46
|
for (var _i = 0, _snapPoints = snapPoints; _i < _snapPoints.length; _i++) {
|
|
42
47
|
var snapPoint = _snapPoints[_i];
|
|
43
48
|
if (snapPoint - SNAP_GAP < proposedWidth && snapPoint + SNAP_GAP > proposedWidth) {
|
|
44
49
|
return snapPoint;
|
|
45
50
|
}
|
|
46
51
|
}
|
|
47
|
-
|
|
52
|
+
var hardMax = (0, _expValEquals.expValEquals)('editor_tinymce_full_width_mode', 'isEnabled', true) ? Math.min(containerWidth, WIDTHS.MAX) : Math.min(containerWidth, WIDTHS.FULL);
|
|
53
|
+
return Math.max(WIDTHS.MIN, Math.min(proposedWidth, hardMax));
|
|
48
54
|
}
|
|
49
55
|
function createResizerCallbacks(_ref2) {
|
|
50
56
|
var dom = _ref2.dom,
|
|
@@ -147,6 +153,12 @@ function createResizerCallbacks(_ref2) {
|
|
|
147
153
|
var isResizedToFullWidth = !!guidelines.find(function (guideline) {
|
|
148
154
|
return guideline.key.startsWith('full_width') && guideline.active;
|
|
149
155
|
});
|
|
156
|
+
var isResizedToMaxWidth = false;
|
|
157
|
+
if ((0, _expValEquals.expValEquals)('editor_tinymce_full_width_mode', 'isEnabled', true)) {
|
|
158
|
+
isResizedToMaxWidth = !!guidelines.find(function (guideline) {
|
|
159
|
+
return guideline.key.startsWith('max_width') && guideline.active;
|
|
160
|
+
});
|
|
161
|
+
}
|
|
150
162
|
guidelines = (0, _getGuidelines.getGuidelines)(false, 0, getEditorWidth);
|
|
151
163
|
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)({
|
|
152
164
|
guidelines: guidelines
|
|
@@ -154,12 +166,17 @@ function createResizerCallbacks(_ref2) {
|
|
|
154
166
|
var pos = view.posAtDOM(dom, 0);
|
|
155
167
|
var mode = mark.attrs.mode;
|
|
156
168
|
var initialWidth = mark.attrs.width;
|
|
157
|
-
var newWidth = isResizedToFullWidth ? WIDTHS.
|
|
169
|
+
var newWidth = isResizedToFullWidth ? WIDTHS.FULL : getProposedWidth({
|
|
158
170
|
initialWidth: initialWidth,
|
|
159
171
|
location: location,
|
|
160
172
|
api: api,
|
|
161
173
|
source: source
|
|
162
174
|
});
|
|
175
|
+
if ((0, _expValEquals.expValEquals)('editor_tinymce_full_width_mode', 'isEnabled', true)) {
|
|
176
|
+
if (isResizedToMaxWidth) {
|
|
177
|
+
newWidth = WIDTHS.MAX;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
163
180
|
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';
|
|
164
181
|
(0, _setBreakoutWidth.setBreakoutWidth)(newWidth, mode, pos, isEditMode)(view.state, view.dispatch);
|
|
165
182
|
if ((0, _platformFeatureFlags.fg)('platform_editor_breakout_resizing_width_changes')) {
|
|
@@ -14,7 +14,9 @@ var GUIDELINE_KEY_TO_LAYOUT = {
|
|
|
14
14
|
wide_left: 'wide',
|
|
15
15
|
wide_right: 'wide',
|
|
16
16
|
full_width_left: 'full-width',
|
|
17
|
-
full_width_right: 'full-width'
|
|
17
|
+
full_width_right: 'full-width',
|
|
18
|
+
max_width_left: 'max',
|
|
19
|
+
max_width_right: 'max'
|
|
18
20
|
};
|
|
19
21
|
var GuidelineLabel = exports.GuidelineLabel = function GuidelineLabel(_ref) {
|
|
20
22
|
var api = _ref.api,
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import memoizeOne from 'memoize-one';
|
|
2
2
|
import { EXPAND_CONTAINER_PADDING, LAYOUT_COLUMN_PADDING, resizerHandleThumbWidth } from '@atlaskit/editor-common/styles';
|
|
3
|
-
import { akEditorGutterPaddingDynamic, akEditorGutterPadding, akEditorGutterPaddingReduced, akEditorFullPageNarrowBreakout, akEditorCalculatedWideLayoutWidth, akEditorFullWidthLayoutWidth, akEditorDefaultLayoutWidth } from '@atlaskit/editor-shared-styles';
|
|
3
|
+
import { akEditorGutterPaddingDynamic, akEditorGutterPadding, akEditorGutterPaddingReduced, akEditorFullPageNarrowBreakout, akEditorCalculatedWideLayoutWidth, akEditorFullWidthLayoutWidth, akEditorDefaultLayoutWidth, akEditorMaxLayoutWidth } from '@atlaskit/editor-shared-styles';
|
|
4
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
4
5
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
5
6
|
const WIDTHS = {
|
|
6
7
|
MIN: akEditorDefaultLayoutWidth,
|
|
7
8
|
WIDE: akEditorCalculatedWideLayoutWidth,
|
|
8
|
-
|
|
9
|
+
FULL: akEditorFullWidthLayoutWidth,
|
|
10
|
+
MAX: akEditorMaxLayoutWidth
|
|
9
11
|
};
|
|
10
12
|
export const GUIDELINE_KEYS = {
|
|
11
13
|
lineLengthLeft: 'grid_left',
|
|
@@ -13,7 +15,9 @@ export const GUIDELINE_KEYS = {
|
|
|
13
15
|
wideLeft: 'wide_left',
|
|
14
16
|
wideRight: 'wide_right',
|
|
15
17
|
fullWidthLeft: 'full_width_left',
|
|
16
|
-
fullWidthRight: 'full_width_right'
|
|
18
|
+
fullWidthRight: 'full_width_right',
|
|
19
|
+
maxWidthLeft: 'max_width_left',
|
|
20
|
+
maxWidthRight: 'max_width_right'
|
|
17
21
|
};
|
|
18
22
|
const AK_NESTED_DND_GUTTER_OFFSET = 8;
|
|
19
23
|
const roundToNearest = (value, interval = 0.5) => Math.round(value / interval) * interval;
|
|
@@ -41,7 +45,8 @@ export const getGuidelines = memoizeOne((isResizing, newWidth, getEditorWidth, n
|
|
|
41
45
|
const padding = width && width <= akEditorFullPageNarrowBreakout && editorExperiment('platform_editor_preview_panel_responsiveness', true, {
|
|
42
46
|
exposure: true
|
|
43
47
|
}) ? akEditorGutterPaddingReduced : akEditorGutterPaddingDynamic();
|
|
44
|
-
const fullWidth = width ? Math.min(WIDTHS.
|
|
48
|
+
const fullWidth = width ? Math.min(WIDTHS.FULL, width - 2 * padding - akEditorGutterPadding) : undefined;
|
|
49
|
+
const maxWidth = width && expValEquals('editor_tinymce_full_width_mode', 'isEnabled', true) ? Math.min(WIDTHS.MAX, width - 2 * padding - akEditorGutterPadding) : undefined;
|
|
45
50
|
guidelines.push({
|
|
46
51
|
key: GUIDELINE_KEYS.lineLengthLeft,
|
|
47
52
|
position: {
|
|
@@ -86,5 +91,21 @@ export const getGuidelines = memoizeOne((isResizing, newWidth, getEditorWidth, n
|
|
|
86
91
|
active: newWidth === fullWidth
|
|
87
92
|
});
|
|
88
93
|
}
|
|
94
|
+
if (maxWidth) {
|
|
95
|
+
guidelines.push({
|
|
96
|
+
key: GUIDELINE_KEYS.maxWidthLeft,
|
|
97
|
+
position: {
|
|
98
|
+
x: -roundToNearest(maxWidth / 2 + innerPaddingOffset)
|
|
99
|
+
},
|
|
100
|
+
active: newWidth === maxWidth
|
|
101
|
+
});
|
|
102
|
+
guidelines.push({
|
|
103
|
+
key: GUIDELINE_KEYS.maxWidthRight,
|
|
104
|
+
position: {
|
|
105
|
+
x: roundToNearest(maxWidth / 2 + innerPaddingOffset)
|
|
106
|
+
},
|
|
107
|
+
active: newWidth === maxWidth
|
|
108
|
+
});
|
|
109
|
+
}
|
|
89
110
|
return guidelines;
|
|
90
111
|
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { akEditorGutterPaddingDynamic, akEditorGutterPadding, akEditorGutterPaddingReduced, akEditorFullPageNarrowBreakout, akEditorDefaultLayoutWidth, akEditorFullWidthLayoutWidth, akEditorCalculatedWideLayoutWidth } from '@atlaskit/editor-shared-styles';
|
|
1
|
+
import { akEditorGutterPaddingDynamic, akEditorGutterPadding, akEditorGutterPaddingReduced, akEditorFullPageNarrowBreakout, akEditorDefaultLayoutWidth, akEditorFullWidthLayoutWidth, akEditorCalculatedWideLayoutWidth, akEditorMaxLayoutWidth } from '@atlaskit/editor-shared-styles';
|
|
2
2
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
3
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
3
4
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
4
5
|
import { setBreakoutWidth } from '../editor-commands/set-breakout-width';
|
|
5
6
|
import { getGuidelines } from './get-guidelines';
|
|
@@ -12,7 +13,8 @@ const SNAP_GAP = 10;
|
|
|
12
13
|
const WIDTHS = {
|
|
13
14
|
MIN: akEditorDefaultLayoutWidth,
|
|
14
15
|
WIDE: akEditorCalculatedWideLayoutWidth,
|
|
15
|
-
|
|
16
|
+
FULL: akEditorFullWidthLayoutWidth,
|
|
17
|
+
MAX: akEditorMaxLayoutWidth
|
|
16
18
|
};
|
|
17
19
|
export function getProposedWidth({
|
|
18
20
|
initialWidth,
|
|
@@ -31,13 +33,17 @@ export function getProposedWidth({
|
|
|
31
33
|
|
|
32
34
|
// the node width may be greater than the container width so we resize using the smaller value
|
|
33
35
|
const proposedWidth = Math.min(initialWidth, containerWidth) + diffX;
|
|
34
|
-
const snapPoints = [WIDTHS.MIN, WIDTHS.WIDE, Math.min(containerWidth, WIDTHS.
|
|
36
|
+
const snapPoints = [WIDTHS.MIN, WIDTHS.WIDE, Math.min(containerWidth, WIDTHS.FULL)];
|
|
37
|
+
if (expValEquals('editor_tinymce_full_width_mode', 'isEnabled', true)) {
|
|
38
|
+
snapPoints.push(Math.min(containerWidth, WIDTHS.MAX));
|
|
39
|
+
}
|
|
35
40
|
for (const snapPoint of snapPoints) {
|
|
36
41
|
if (snapPoint - SNAP_GAP < proposedWidth && snapPoint + SNAP_GAP > proposedWidth) {
|
|
37
42
|
return snapPoint;
|
|
38
43
|
}
|
|
39
44
|
}
|
|
40
|
-
|
|
45
|
+
const hardMax = expValEquals('editor_tinymce_full_width_mode', 'isEnabled', true) ? Math.min(containerWidth, WIDTHS.MAX) : Math.min(containerWidth, WIDTHS.FULL);
|
|
46
|
+
return Math.max(WIDTHS.MIN, Math.min(proposedWidth, hardMax));
|
|
41
47
|
}
|
|
42
48
|
export function createResizerCallbacks({
|
|
43
49
|
dom,
|
|
@@ -143,6 +149,10 @@ export function createResizerCallbacks({
|
|
|
143
149
|
originalNode: node
|
|
144
150
|
});
|
|
145
151
|
const isResizedToFullWidth = !!guidelines.find(guideline => guideline.key.startsWith('full_width') && guideline.active);
|
|
152
|
+
let isResizedToMaxWidth = false;
|
|
153
|
+
if (expValEquals('editor_tinymce_full_width_mode', 'isEnabled', true)) {
|
|
154
|
+
isResizedToMaxWidth = !!guidelines.find(guideline => guideline.key.startsWith('max_width') && guideline.active);
|
|
155
|
+
}
|
|
146
156
|
guidelines = getGuidelines(false, 0, getEditorWidth);
|
|
147
157
|
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)({
|
|
148
158
|
guidelines
|
|
@@ -150,12 +160,17 @@ export function createResizerCallbacks({
|
|
|
150
160
|
const pos = view.posAtDOM(dom, 0);
|
|
151
161
|
const mode = mark.attrs.mode;
|
|
152
162
|
const initialWidth = mark.attrs.width;
|
|
153
|
-
|
|
163
|
+
let newWidth = isResizedToFullWidth ? WIDTHS.FULL : getProposedWidth({
|
|
154
164
|
initialWidth,
|
|
155
165
|
location,
|
|
156
166
|
api,
|
|
157
167
|
source
|
|
158
168
|
});
|
|
169
|
+
if (expValEquals('editor_tinymce_full_width_mode', 'isEnabled', true)) {
|
|
170
|
+
if (isResizedToMaxWidth) {
|
|
171
|
+
newWidth = WIDTHS.MAX;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
159
174
|
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';
|
|
160
175
|
setBreakoutWidth(newWidth, mode, pos, isEditMode)(view.state, view.dispatch);
|
|
161
176
|
if (fg('platform_editor_breakout_resizing_width_changes')) {
|
|
@@ -7,7 +7,9 @@ const GUIDELINE_KEY_TO_LAYOUT = {
|
|
|
7
7
|
wide_left: 'wide',
|
|
8
8
|
wide_right: 'wide',
|
|
9
9
|
full_width_left: 'full-width',
|
|
10
|
-
full_width_right: 'full-width'
|
|
10
|
+
full_width_right: 'full-width',
|
|
11
|
+
max_width_left: 'max',
|
|
12
|
+
max_width_right: 'max'
|
|
11
13
|
};
|
|
12
14
|
export const GuidelineLabel = ({
|
|
13
15
|
api,
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import memoizeOne from 'memoize-one';
|
|
2
2
|
import { EXPAND_CONTAINER_PADDING, LAYOUT_COLUMN_PADDING, resizerHandleThumbWidth } from '@atlaskit/editor-common/styles';
|
|
3
|
-
import { akEditorGutterPaddingDynamic, akEditorGutterPadding, akEditorGutterPaddingReduced, akEditorFullPageNarrowBreakout, akEditorCalculatedWideLayoutWidth, akEditorFullWidthLayoutWidth, akEditorDefaultLayoutWidth } from '@atlaskit/editor-shared-styles';
|
|
3
|
+
import { akEditorGutterPaddingDynamic, akEditorGutterPadding, akEditorGutterPaddingReduced, akEditorFullPageNarrowBreakout, akEditorCalculatedWideLayoutWidth, akEditorFullWidthLayoutWidth, akEditorDefaultLayoutWidth, akEditorMaxLayoutWidth } from '@atlaskit/editor-shared-styles';
|
|
4
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
4
5
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
5
6
|
var WIDTHS = {
|
|
6
7
|
MIN: akEditorDefaultLayoutWidth,
|
|
7
8
|
WIDE: akEditorCalculatedWideLayoutWidth,
|
|
8
|
-
|
|
9
|
+
FULL: akEditorFullWidthLayoutWidth,
|
|
10
|
+
MAX: akEditorMaxLayoutWidth
|
|
9
11
|
};
|
|
10
12
|
export var GUIDELINE_KEYS = {
|
|
11
13
|
lineLengthLeft: 'grid_left',
|
|
@@ -13,7 +15,9 @@ export var GUIDELINE_KEYS = {
|
|
|
13
15
|
wideLeft: 'wide_left',
|
|
14
16
|
wideRight: 'wide_right',
|
|
15
17
|
fullWidthLeft: 'full_width_left',
|
|
16
|
-
fullWidthRight: 'full_width_right'
|
|
18
|
+
fullWidthRight: 'full_width_right',
|
|
19
|
+
maxWidthLeft: 'max_width_left',
|
|
20
|
+
maxWidthRight: 'max_width_right'
|
|
17
21
|
};
|
|
18
22
|
var AK_NESTED_DND_GUTTER_OFFSET = 8;
|
|
19
23
|
var roundToNearest = function roundToNearest(value) {
|
|
@@ -43,7 +47,8 @@ export var getGuidelines = memoizeOne(function (isResizing, newWidth, getEditorW
|
|
|
43
47
|
var padding = width && width <= akEditorFullPageNarrowBreakout && editorExperiment('platform_editor_preview_panel_responsiveness', true, {
|
|
44
48
|
exposure: true
|
|
45
49
|
}) ? akEditorGutterPaddingReduced : akEditorGutterPaddingDynamic();
|
|
46
|
-
var fullWidth = width ? Math.min(WIDTHS.
|
|
50
|
+
var fullWidth = width ? Math.min(WIDTHS.FULL, width - 2 * padding - akEditorGutterPadding) : undefined;
|
|
51
|
+
var maxWidth = width && expValEquals('editor_tinymce_full_width_mode', 'isEnabled', true) ? Math.min(WIDTHS.MAX, width - 2 * padding - akEditorGutterPadding) : undefined;
|
|
47
52
|
guidelines.push({
|
|
48
53
|
key: GUIDELINE_KEYS.lineLengthLeft,
|
|
49
54
|
position: {
|
|
@@ -88,5 +93,21 @@ export var getGuidelines = memoizeOne(function (isResizing, newWidth, getEditorW
|
|
|
88
93
|
active: newWidth === fullWidth
|
|
89
94
|
});
|
|
90
95
|
}
|
|
96
|
+
if (maxWidth) {
|
|
97
|
+
guidelines.push({
|
|
98
|
+
key: GUIDELINE_KEYS.maxWidthLeft,
|
|
99
|
+
position: {
|
|
100
|
+
x: -roundToNearest(maxWidth / 2 + innerPaddingOffset)
|
|
101
|
+
},
|
|
102
|
+
active: newWidth === maxWidth
|
|
103
|
+
});
|
|
104
|
+
guidelines.push({
|
|
105
|
+
key: GUIDELINE_KEYS.maxWidthRight,
|
|
106
|
+
position: {
|
|
107
|
+
x: roundToNearest(maxWidth / 2 + innerPaddingOffset)
|
|
108
|
+
},
|
|
109
|
+
active: newWidth === maxWidth
|
|
110
|
+
});
|
|
111
|
+
}
|
|
91
112
|
return guidelines;
|
|
92
113
|
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { akEditorGutterPaddingDynamic, akEditorGutterPadding, akEditorGutterPaddingReduced, akEditorFullPageNarrowBreakout, akEditorDefaultLayoutWidth, akEditorFullWidthLayoutWidth, akEditorCalculatedWideLayoutWidth } from '@atlaskit/editor-shared-styles';
|
|
1
|
+
import { akEditorGutterPaddingDynamic, akEditorGutterPadding, akEditorGutterPaddingReduced, akEditorFullPageNarrowBreakout, akEditorDefaultLayoutWidth, akEditorFullWidthLayoutWidth, akEditorCalculatedWideLayoutWidth, akEditorMaxLayoutWidth } from '@atlaskit/editor-shared-styles';
|
|
2
2
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
3
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
3
4
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
4
5
|
import { setBreakoutWidth } from '../editor-commands/set-breakout-width';
|
|
5
6
|
import { getGuidelines } from './get-guidelines';
|
|
@@ -12,7 +13,8 @@ var SNAP_GAP = 10;
|
|
|
12
13
|
var WIDTHS = {
|
|
13
14
|
MIN: akEditorDefaultLayoutWidth,
|
|
14
15
|
WIDE: akEditorCalculatedWideLayoutWidth,
|
|
15
|
-
|
|
16
|
+
FULL: akEditorFullWidthLayoutWidth,
|
|
17
|
+
MAX: akEditorMaxLayoutWidth
|
|
16
18
|
};
|
|
17
19
|
export function getProposedWidth(_ref) {
|
|
18
20
|
var _api$width$sharedStat;
|
|
@@ -30,14 +32,18 @@ export function getProposedWidth(_ref) {
|
|
|
30
32
|
|
|
31
33
|
// the node width may be greater than the container width so we resize using the smaller value
|
|
32
34
|
var proposedWidth = Math.min(initialWidth, containerWidth) + diffX;
|
|
33
|
-
var snapPoints = [WIDTHS.MIN, WIDTHS.WIDE, Math.min(containerWidth, WIDTHS.
|
|
35
|
+
var snapPoints = [WIDTHS.MIN, WIDTHS.WIDE, Math.min(containerWidth, WIDTHS.FULL)];
|
|
36
|
+
if (expValEquals('editor_tinymce_full_width_mode', 'isEnabled', true)) {
|
|
37
|
+
snapPoints.push(Math.min(containerWidth, WIDTHS.MAX));
|
|
38
|
+
}
|
|
34
39
|
for (var _i = 0, _snapPoints = snapPoints; _i < _snapPoints.length; _i++) {
|
|
35
40
|
var snapPoint = _snapPoints[_i];
|
|
36
41
|
if (snapPoint - SNAP_GAP < proposedWidth && snapPoint + SNAP_GAP > proposedWidth) {
|
|
37
42
|
return snapPoint;
|
|
38
43
|
}
|
|
39
44
|
}
|
|
40
|
-
|
|
45
|
+
var hardMax = expValEquals('editor_tinymce_full_width_mode', 'isEnabled', true) ? Math.min(containerWidth, WIDTHS.MAX) : Math.min(containerWidth, WIDTHS.FULL);
|
|
46
|
+
return Math.max(WIDTHS.MIN, Math.min(proposedWidth, hardMax));
|
|
41
47
|
}
|
|
42
48
|
export function createResizerCallbacks(_ref2) {
|
|
43
49
|
var dom = _ref2.dom,
|
|
@@ -140,6 +146,12 @@ export function createResizerCallbacks(_ref2) {
|
|
|
140
146
|
var isResizedToFullWidth = !!guidelines.find(function (guideline) {
|
|
141
147
|
return guideline.key.startsWith('full_width') && guideline.active;
|
|
142
148
|
});
|
|
149
|
+
var isResizedToMaxWidth = false;
|
|
150
|
+
if (expValEquals('editor_tinymce_full_width_mode', 'isEnabled', true)) {
|
|
151
|
+
isResizedToMaxWidth = !!guidelines.find(function (guideline) {
|
|
152
|
+
return guideline.key.startsWith('max_width') && guideline.active;
|
|
153
|
+
});
|
|
154
|
+
}
|
|
143
155
|
guidelines = getGuidelines(false, 0, getEditorWidth);
|
|
144
156
|
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)({
|
|
145
157
|
guidelines: guidelines
|
|
@@ -147,12 +159,17 @@ export function createResizerCallbacks(_ref2) {
|
|
|
147
159
|
var pos = view.posAtDOM(dom, 0);
|
|
148
160
|
var mode = mark.attrs.mode;
|
|
149
161
|
var initialWidth = mark.attrs.width;
|
|
150
|
-
var newWidth = isResizedToFullWidth ? WIDTHS.
|
|
162
|
+
var newWidth = isResizedToFullWidth ? WIDTHS.FULL : getProposedWidth({
|
|
151
163
|
initialWidth: initialWidth,
|
|
152
164
|
location: location,
|
|
153
165
|
api: api,
|
|
154
166
|
source: source
|
|
155
167
|
});
|
|
168
|
+
if (expValEquals('editor_tinymce_full_width_mode', 'isEnabled', true)) {
|
|
169
|
+
if (isResizedToMaxWidth) {
|
|
170
|
+
newWidth = WIDTHS.MAX;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
156
173
|
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';
|
|
157
174
|
setBreakoutWidth(newWidth, mode, pos, isEditMode)(view.state, view.dispatch);
|
|
158
175
|
if (fg('platform_editor_breakout_resizing_width_changes')) {
|
|
@@ -7,7 +7,9 @@ var GUIDELINE_KEY_TO_LAYOUT = {
|
|
|
7
7
|
wide_left: 'wide',
|
|
8
8
|
wide_right: 'wide',
|
|
9
9
|
full_width_left: 'full-width',
|
|
10
|
-
full_width_right: 'full-width'
|
|
10
|
+
full_width_right: 'full-width',
|
|
11
|
+
max_width_left: 'max',
|
|
12
|
+
max_width_right: 'max'
|
|
11
13
|
};
|
|
12
14
|
export var GuidelineLabel = function GuidelineLabel(_ref) {
|
|
13
15
|
var api = _ref.api,
|
|
@@ -8,5 +8,7 @@ export declare const GUIDELINE_KEYS: {
|
|
|
8
8
|
readonly wideRight: "wide_right";
|
|
9
9
|
readonly fullWidthLeft: "full_width_left";
|
|
10
10
|
readonly fullWidthRight: "full_width_right";
|
|
11
|
+
readonly maxWidthLeft: "max_width_left";
|
|
12
|
+
readonly maxWidthRight: "max_width_right";
|
|
11
13
|
};
|
|
12
14
|
export declare const getGuidelines: import("memoize-one").MemoizedFn<(isResizing: boolean, newWidth: number, getEditorWidth: () => EditorContainerWidth | undefined, nodeType?: NodeType | undefined) => GuidelineConfig[]>;
|
|
@@ -8,5 +8,7 @@ export declare const GUIDELINE_KEYS: {
|
|
|
8
8
|
readonly wideRight: "wide_right";
|
|
9
9
|
readonly fullWidthLeft: "full_width_left";
|
|
10
10
|
readonly fullWidthRight: "full_width_right";
|
|
11
|
+
readonly maxWidthLeft: "max_width_left";
|
|
12
|
+
readonly maxWidthRight: "max_width_right";
|
|
11
13
|
};
|
|
12
14
|
export declare const getGuidelines: import("memoize-one").MemoizedFn<(isResizing: boolean, newWidth: number, getEditorWidth: () => EditorContainerWidth | undefined, nodeType?: NodeType | undefined) => GuidelineConfig[]>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-breakout",
|
|
3
|
-
"version": "6.1
|
|
3
|
+
"version": "6.2.1",
|
|
4
4
|
"description": "Breakout plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
],
|
|
30
30
|
"atlaskit:src": "src/index.ts",
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@atlaskit/adf-schema": "^51.
|
|
33
|
-
"@atlaskit/editor-plugin-block-controls": "^7.
|
|
32
|
+
"@atlaskit/adf-schema": "^51.4.0",
|
|
33
|
+
"@atlaskit/editor-plugin-block-controls": "^7.7.0",
|
|
34
34
|
"@atlaskit/editor-plugin-editor-disabled": "^6.1.0",
|
|
35
35
|
"@atlaskit/editor-plugin-editor-viewmode": "^8.0.0",
|
|
36
36
|
"@atlaskit/editor-plugin-guideline": "^6.0.0",
|
|
@@ -38,14 +38,14 @@
|
|
|
38
38
|
"@atlaskit/editor-plugin-user-intent": "^4.0.0",
|
|
39
39
|
"@atlaskit/editor-plugin-width": "^7.0.0",
|
|
40
40
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
41
|
-
"@atlaskit/editor-shared-styles": "^3.
|
|
42
|
-
"@atlaskit/icon": "^
|
|
41
|
+
"@atlaskit/editor-shared-styles": "^3.10.0",
|
|
42
|
+
"@atlaskit/icon": "^29.0.0",
|
|
43
43
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
44
44
|
"@atlaskit/pragmatic-drag-and-drop": "^1.7.0",
|
|
45
45
|
"@atlaskit/theme": "^21.0.0",
|
|
46
|
-
"@atlaskit/tmp-editor-statsig": "^13.
|
|
46
|
+
"@atlaskit/tmp-editor-statsig": "^13.38.0",
|
|
47
47
|
"@atlaskit/tokens": "^8.0.0",
|
|
48
|
-
"@atlaskit/tooltip": "^20.
|
|
48
|
+
"@atlaskit/tooltip": "^20.9.0",
|
|
49
49
|
"@babel/runtime": "^7.0.0",
|
|
50
50
|
"@emotion/react": "^11.7.1",
|
|
51
51
|
"bind-event-listener": "^3.0.0",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"uuid": "^3.1.0"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@atlaskit/editor-common": "^110.
|
|
56
|
+
"@atlaskit/editor-common": "^110.32.0",
|
|
57
57
|
"react": "^18.2.0",
|
|
58
58
|
"react-dom": "^18.2.0",
|
|
59
59
|
"react-intl-next": "npm:react-intl@^5.18.1"
|