@atlaskit/editor-plugin-breakout 2.7.1 → 2.7.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.
Files changed (30) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/dist/cjs/breakoutPlugin.js +25 -2
  3. package/dist/cjs/pm-plugins/get-guidelines.js +37 -17
  4. package/dist/cjs/pm-plugins/resizer-callbacks.js +61 -9
  5. package/dist/cjs/pm-plugins/resizing-plugin.js +39 -0
  6. package/dist/cjs/pm-plugins/utils/analytics.js +16 -1
  7. package/dist/cjs/ui/GuidelineLabel.js +44 -0
  8. package/dist/es2019/breakoutPlugin.js +26 -3
  9. package/dist/es2019/pm-plugins/get-guidelines.js +36 -16
  10. package/dist/es2019/pm-plugins/resizer-callbacks.js +57 -5
  11. package/dist/es2019/pm-plugins/resizing-plugin.js +38 -0
  12. package/dist/es2019/pm-plugins/utils/analytics.js +16 -0
  13. package/dist/es2019/ui/GuidelineLabel.js +38 -0
  14. package/dist/esm/breakoutPlugin.js +26 -3
  15. package/dist/esm/pm-plugins/get-guidelines.js +36 -16
  16. package/dist/esm/pm-plugins/resizer-callbacks.js +62 -10
  17. package/dist/esm/pm-plugins/resizing-plugin.js +38 -0
  18. package/dist/esm/pm-plugins/utils/analytics.js +15 -0
  19. package/dist/esm/ui/GuidelineLabel.js +37 -0
  20. package/dist/types/breakoutPluginType.d.ts +2 -0
  21. package/dist/types/pm-plugins/get-guidelines.d.ts +8 -0
  22. package/dist/types/pm-plugins/resizing-plugin.d.ts +8 -3
  23. package/dist/types/pm-plugins/utils/analytics.d.ts +5 -0
  24. package/dist/types/ui/GuidelineLabel.d.ts +13 -0
  25. package/dist/types-ts4.5/breakoutPluginType.d.ts +2 -0
  26. package/dist/types-ts4.5/pm-plugins/get-guidelines.d.ts +8 -0
  27. package/dist/types-ts4.5/pm-plugins/resizing-plugin.d.ts +8 -3
  28. package/dist/types-ts4.5/pm-plugins/utils/analytics.d.ts +5 -0
  29. package/dist/types-ts4.5/ui/GuidelineLabel.d.ts +13 -0
  30. package/package.json +4 -4
package/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # @atlaskit/editor-plugin-breakout
2
2
 
3
+ ## 2.7.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [#169885](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/169885)
8
+ [`b0f7d84248010`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/b0f7d84248010) -
9
+ Add label popup to contentComponent which renders when a guideline is active. Add
10
+ activeGuidelineKey to breakout plugin state to use with the label.
11
+ - Updated dependencies
12
+
13
+ ## 2.7.2
14
+
15
+ ### Patch Changes
16
+
17
+ - [#168573](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/168573)
18
+ [`8c337a8701dfb`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/8c337a8701dfb) -
19
+ Adds resized analytics for nodes that support breakout mark.
20
+ - [#169278](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/169278)
21
+ [`3ff87a0248416`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/3ff87a0248416) -
22
+ [ux] ED-28232 fix guidelines location on full width pages for new resizing experience behind
23
+ platform_editor_breakout_resizing
24
+ - Updated dependencies
25
+
3
26
  ## 2.7.1
4
27
 
5
28
  ### Patch Changes
@@ -19,11 +19,13 @@ var _usePluginStateEffect = require("@atlaskit/editor-common/use-plugin-state-ef
19
19
  var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
20
20
  var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
21
21
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
22
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
22
23
  var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
23
24
  var _pluginKey = require("./pm-plugins/plugin-key");
24
25
  var _resizingPlugin = require("./pm-plugins/resizing-plugin");
25
26
  var _findBreakoutNode = require("./pm-plugins/utils/find-breakout-node");
26
27
  var _getBreakoutMode = require("./pm-plugins/utils/get-breakout-mode");
28
+ var _GuidelineLabel = require("./ui/GuidelineLabel");
27
29
  var _LayoutButton = _interopRequireDefault(require("./ui/LayoutButton"));
28
30
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
29
31
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
@@ -86,7 +88,8 @@ function createPlugin(api, _ref) {
86
88
  state: {
87
89
  init: function init() {
88
90
  return {
89
- breakoutNode: undefined
91
+ breakoutNode: undefined,
92
+ activeGuidelineKey: undefined
90
93
  };
91
94
  },
92
95
  apply: function apply(tr, pluginState) {
@@ -206,7 +209,7 @@ var breakoutPlugin = exports.breakoutPlugin = function breakoutPlugin(_ref4) {
206
209
  return {
207
210
  name: 'breakout',
208
211
  pmPlugins: function pmPlugins() {
209
- if ((0, _experiments.editorExperiment)('platform_editor_breakout_resizing', true)) {
212
+ if ((0, _expValEquals.expValEquals)('platform_editor_breakout_resizing', 'isEnabled', true)) {
210
213
  return [{
211
214
  name: 'breakout-resizing',
212
215
  plugin: function plugin(_ref5) {
@@ -235,6 +238,16 @@ var breakoutPlugin = exports.breakoutPlugin = function breakoutPlugin(_ref4) {
235
238
  breakoutNode: undefined
236
239
  };
237
240
  }
241
+ if ((0, _expValEquals.expValEquals)('platform_editor_breakout_resizing', 'isEnabled', true) && (0, _platformFeatureFlags.fg)('platform_editor_breakout_resizing_hello_release')) {
242
+ var resizingPluginState = _resizingPlugin.resizingPluginKey.getState(editorState);
243
+ if (!resizingPluginState) {
244
+ return {
245
+ breakoutNode: undefined,
246
+ activeGuidelineKey: undefined
247
+ };
248
+ }
249
+ return resizingPluginState;
250
+ }
238
251
  var pluginState = _pluginKey.pluginKey.getState(editorState);
239
252
  if (!pluginState) {
240
253
  return {
@@ -248,6 +261,16 @@ var breakoutPlugin = exports.breakoutPlugin = function breakoutPlugin(_ref4) {
248
261
  popupsMountPoint = _ref6.popupsMountPoint,
249
262
  popupsBoundariesElement = _ref6.popupsBoundariesElement,
250
263
  popupsScrollableElement = _ref6.popupsScrollableElement;
264
+ if ((0, _expValEquals.expValEquals)('platform_editor_breakout_resizing', 'isEnabled', true) && (0, _platformFeatureFlags.fg)('platform_editor_breakout_resizing_hello_release')) {
265
+ return /*#__PURE__*/_react.default.createElement(_GuidelineLabel.GuidelineLabel, {
266
+ api: api,
267
+ editorView: editorView,
268
+ mountPoint: popupsMountPoint,
269
+ boundariesElement: popupsBoundariesElement,
270
+ scrollableElement: popupsScrollableElement
271
+ });
272
+ }
273
+
251
274
  // This is a bit crappy, but should be resolved once we move to a static schema.
252
275
  if (options && !options.allowBreakoutButton) {
253
276
  return null;
@@ -4,19 +4,23 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.getGuidelines = void 0;
7
+ 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 _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
11
12
  var WIDTHS = {
12
13
  MIN: _editorSharedStyles.akEditorDefaultLayoutWidth,
13
14
  WIDE: _editorSharedStyles.akEditorCalculatedWideLayoutWidth,
14
15
  MAX: _editorSharedStyles.akEditorFullWidthLayoutWidth
15
16
  };
16
- var GUIDELINE_KEYS = {
17
- lineLength: 'grid',
18
- wide: 'wide',
19
- fullWidth: 'full_width'
17
+ var GUIDELINE_KEYS = exports.GUIDELINE_KEYS = {
18
+ lineLengthLeft: 'grid_left',
19
+ lineLengthRight: 'grid_right',
20
+ wideLeft: 'wide_left',
21
+ wideRight: 'wide_right',
22
+ fullWidthLeft: 'full_width_left',
23
+ fullWidthRight: 'full_width_right'
20
24
  };
21
25
  var AK_NESTED_DND_GUTTER_OFFSET = 8;
22
26
  var roundToNearest = function roundToNearest(value) {
@@ -44,33 +48,49 @@ var getGuidelines = exports.getGuidelines = (0, _memoizeOne.default)(function (i
44
48
  var _ref = getEditorWidth() || {},
45
49
  width = _ref.width,
46
50
  lineLength = _ref.lineLength;
47
- // TODO: ED-28109 - use breakoutWideScaleRatio to calculate wide guideline
48
51
  var fullWidth = width ? Math.min(WIDTHS.MAX, width - 2 * (0, _editorSharedStyles.akEditorGutterPaddingDynamic)() - _editorSharedStyles.akEditorGutterPadding) : undefined;
49
- if (lineLength) {
52
+ if ((0, _platformFeatureFlags.fg)('platform_editor_breakout_resizing_hello_release')) {
50
53
  guidelines.push({
51
- key: "".concat(GUIDELINE_KEYS.lineLength, "_left"),
54
+ key: GUIDELINE_KEYS.lineLengthLeft,
52
55
  position: {
53
- x: -roundToNearest(lineLength / 2 + innerPaddingOffset)
56
+ x: -roundToNearest(WIDTHS.MIN / 2 + innerPaddingOffset)
54
57
  },
55
- active: newWidth === lineLength
58
+ active: newWidth === WIDTHS.MIN
56
59
  });
57
60
  guidelines.push({
58
- key: "".concat(GUIDELINE_KEYS.lineLength, "_right"),
61
+ key: GUIDELINE_KEYS.lineLengthRight,
59
62
  position: {
60
- x: roundToNearest(lineLength / 2 + innerPaddingOffset)
63
+ x: roundToNearest(WIDTHS.MIN / 2 + innerPaddingOffset)
61
64
  },
62
- active: newWidth === lineLength
65
+ active: newWidth === WIDTHS.MIN
63
66
  });
67
+ } else {
68
+ if (lineLength) {
69
+ guidelines.push({
70
+ key: GUIDELINE_KEYS.lineLengthLeft,
71
+ position: {
72
+ x: -roundToNearest(lineLength / 2 + innerPaddingOffset)
73
+ },
74
+ active: newWidth === lineLength
75
+ });
76
+ guidelines.push({
77
+ key: GUIDELINE_KEYS.lineLengthRight,
78
+ position: {
79
+ x: roundToNearest(lineLength / 2 + innerPaddingOffset)
80
+ },
81
+ active: newWidth === lineLength
82
+ });
83
+ }
64
84
  }
65
85
  guidelines.push({
66
- key: "".concat(GUIDELINE_KEYS.wide, "_left"),
86
+ key: GUIDELINE_KEYS.wideLeft,
67
87
  position: {
68
88
  x: -roundToNearest(WIDTHS.WIDE / 2 + innerPaddingOffset)
69
89
  },
70
90
  active: newWidth === WIDTHS.WIDE
71
91
  });
72
92
  guidelines.push({
73
- key: "".concat(GUIDELINE_KEYS.wide, "_right"),
93
+ key: GUIDELINE_KEYS.wideRight,
74
94
  position: {
75
95
  x: roundToNearest(WIDTHS.WIDE / 2 + innerPaddingOffset)
76
96
  },
@@ -78,14 +98,14 @@ var getGuidelines = exports.getGuidelines = (0, _memoizeOne.default)(function (i
78
98
  });
79
99
  if (fullWidth) {
80
100
  guidelines.push({
81
- key: "".concat(GUIDELINE_KEYS.fullWidth, "_left"),
101
+ key: GUIDELINE_KEYS.fullWidthLeft,
82
102
  position: {
83
103
  x: -roundToNearest(fullWidth / 2 + innerPaddingOffset)
84
104
  },
85
105
  active: newWidth === fullWidth
86
106
  });
87
107
  guidelines.push({
88
- key: "".concat(GUIDELINE_KEYS.fullWidth, "_right"),
108
+ key: GUIDELINE_KEYS.fullWidthRight,
89
109
  position: {
90
110
  x: roundToNearest(fullWidth / 2 + innerPaddingOffset)
91
111
  },
@@ -10,6 +10,7 @@ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
10
10
  var _setBreakoutWidth = require("../editor-commands/set-breakout-width");
11
11
  var _getGuidelines = require("./get-guidelines");
12
12
  var _resizingMarkView = require("./resizing-mark-view");
13
+ var _resizingPlugin = require("./resizing-plugin");
13
14
  var _analytics = require("./utils/analytics");
14
15
  var _measureFramerate2 = require("./utils/measure-framerate");
15
16
  var RESIZE_RATIO = 2;
@@ -63,6 +64,8 @@ function createResizerCallbacks(_ref2) {
63
64
  if ((0, _platformFeatureFlags.fg)('platform_editor_breakout_resizing_hello_release')) {
64
65
  startMeasure();
65
66
  }
67
+ var pos = view.posAtDOM(dom, 0);
68
+ node = view.state.doc.nodeAt(pos);
66
69
  api === null || api === void 0 || api.core.actions.execute(function (_ref3) {
67
70
  var _api$userIntent;
68
71
  var tr = _ref3.tr;
@@ -70,10 +73,19 @@ function createResizerCallbacks(_ref2) {
70
73
  tr: tr
71
74
  });
72
75
  tr.setMeta('is-resizer-resizing', true);
76
+ if ((0, _platformFeatureFlags.fg)('platform_editor_breakout_resizing_hello_release')) {
77
+ tr.setMeta(_resizingPlugin.resizingPluginKey, {
78
+ type: 'UPDATE_BREAKOUT_NODE',
79
+ data: {
80
+ node: node,
81
+ pos: pos,
82
+ start: pos,
83
+ depth: 0
84
+ }
85
+ });
86
+ }
73
87
  return tr;
74
88
  });
75
- var pos = view.posAtDOM(dom, 0);
76
- node = view.state.doc.nodeAt(pos);
77
89
  },
78
90
  onDrag: function onDrag(_ref4) {
79
91
  var _node, _api$guideline;
@@ -93,12 +105,39 @@ function createResizerCallbacks(_ref2) {
93
105
  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)({
94
106
  guidelines: guidelines
95
107
  });
108
+ if ((0, _platformFeatureFlags.fg)('platform_editor_breakout_resizing_hello_release')) {
109
+ var _api$breakout$sharedS;
110
+ var activeGuideline = guidelines.find(function (guideline) {
111
+ return guideline.active && !guideline.key.startsWith('grid');
112
+ });
113
+ if (activeGuideline) {
114
+ api === null || api === void 0 || api.core.actions.execute(function (_ref5) {
115
+ var tr = _ref5.tr;
116
+ tr.setMeta(_resizingPlugin.resizingPluginKey, {
117
+ type: 'UPDATE_ACTIVE_GUIDELINE_KEY',
118
+ data: {
119
+ activeGuidelineKey: activeGuideline.key
120
+ }
121
+ });
122
+ return tr;
123
+ });
124
+ }
125
+ if (!activeGuideline && api !== null && api !== void 0 && (_api$breakout$sharedS = api.breakout.sharedState.currentState()) !== null && _api$breakout$sharedS !== void 0 && _api$breakout$sharedS.activeGuidelineKey) {
126
+ api === null || api === void 0 || api.core.actions.execute(function (_ref6) {
127
+ var tr = _ref6.tr;
128
+ tr.setMeta(_resizingPlugin.resizingPluginKey, {
129
+ type: 'CLEAR_ACTIVE_GUIDELINE_KEY'
130
+ });
131
+ return tr;
132
+ });
133
+ }
134
+ }
96
135
  contentDOM.style.setProperty(_resizingMarkView.LOCAL_RESIZE_PROPERTY, "".concat(newWidth, "px"));
97
136
  },
98
- onDrop: function onDrop(_ref5) {
137
+ onDrop: function onDrop(_ref7) {
99
138
  var _api$guideline2;
100
- var location = _ref5.location,
101
- source = _ref5.source;
139
+ var location = _ref7.location,
140
+ source = _ref7.source;
102
141
  var payloads = [];
103
142
  if ((0, _platformFeatureFlags.fg)('platform_editor_breakout_resizing_hello_release')) {
104
143
  var frameRateSamples = endMeasure();
@@ -109,7 +148,7 @@ function createResizerCallbacks(_ref2) {
109
148
  });
110
149
  }
111
150
  var isResizedToFullWidth = !!guidelines.find(function (guideline) {
112
- return guideline.key.includes('full_width') && guideline.active;
151
+ return guideline.key.startsWith('full_width') && guideline.active;
113
152
  });
114
153
  guidelines = (0, _getGuidelines.getGuidelines)(false, 0, getEditorWidth);
115
154
  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)({
@@ -126,17 +165,30 @@ function createResizerCallbacks(_ref2) {
126
165
  });
127
166
  (0, _setBreakoutWidth.setBreakoutWidth)(newWidth, mode, pos)(view.state, view.dispatch);
128
167
  contentDOM.style.removeProperty(_resizingMarkView.LOCAL_RESIZE_PROPERTY);
129
- api === null || api === void 0 || api.core.actions.execute(function (_ref6) {
168
+ if (node && (0, _platformFeatureFlags.fg)('platform_editor_breakout_resizing_hello_release')) {
169
+ var resizedPayload = (0, _analytics.generateResizedEventPayload)({
170
+ node: node,
171
+ prevWidth: initialWidth,
172
+ newWidth: newWidth
173
+ });
174
+ payloads.push(resizedPayload);
175
+ }
176
+ api === null || api === void 0 || api.core.actions.execute(function (_ref8) {
130
177
  var _api$userIntent2;
131
- var tr = _ref6.tr;
178
+ var tr = _ref8.tr;
132
179
  (_api$userIntent2 = api.userIntent) === null || _api$userIntent2 === void 0 || _api$userIntent2.commands.setCurrentUserIntent('default')({
133
180
  tr: tr
134
181
  });
135
- tr.setMeta('is-resizer-resizing', false).setMeta('scrollIntoView', false);
136
182
  payloads.forEach(function (payload) {
137
183
  var _api$analytics;
138
184
  (_api$analytics = api.analytics) === null || _api$analytics === void 0 || (_api$analytics = _api$analytics.actions) === null || _api$analytics === void 0 || _api$analytics.attachAnalyticsEvent(payload)(tr);
139
185
  });
186
+ tr.setMeta('is-resizer-resizing', false).setMeta('scrollIntoView', false);
187
+ if ((0, _platformFeatureFlags.fg)('platform_editor_breakout_resizing_hello_release')) {
188
+ tr.setMeta(_resizingPlugin.resizingPluginKey, {
189
+ type: 'RESET_STATE'
190
+ });
191
+ }
140
192
  return tr;
141
193
  });
142
194
  }
@@ -1,16 +1,21 @@
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.resizingPluginKey = exports.createResizingPlugin = void 0;
8
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
7
9
  var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
8
10
  var _utils = require("@atlaskit/editor-common/utils");
9
11
  var _document = require("@atlaskit/editor-common/utils/document");
10
12
  var _state = require("@atlaskit/editor-prosemirror/state");
11
13
  var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
14
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
12
15
  var _handleKeyDown = require("./handle-key-down");
13
16
  var _resizingMarkView = require("./resizing-mark-view");
17
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
18
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
14
19
  var addBreakoutToResizableNode = function addBreakoutToResizableNode(_ref) {
15
20
  var node = _ref.node,
16
21
  pos = _ref.pos,
@@ -49,9 +54,43 @@ var addBreakoutToResizableNode = function addBreakoutToResizableNode(_ref) {
49
54
  };
50
55
  };
51
56
  var resizingPluginKey = exports.resizingPluginKey = new _state.PluginKey('breakout-resizing');
57
+ var pluginState = {
58
+ init: function init() {
59
+ return {
60
+ breakoutNode: undefined,
61
+ activeGuidelineLabel: undefined
62
+ };
63
+ },
64
+ apply: function apply(tr, pluginState) {
65
+ var meta = tr.getMeta(resizingPluginKey);
66
+ if (meta) {
67
+ switch (meta.type) {
68
+ case 'UPDATE_BREAKOUT_NODE':
69
+ return _objectSpread(_objectSpread({}, pluginState), {}, {
70
+ breakoutNode: meta.data
71
+ });
72
+ case 'UPDATE_ACTIVE_GUIDELINE_KEY':
73
+ return _objectSpread(_objectSpread({}, pluginState), {}, {
74
+ activeGuidelineKey: meta.data.activeGuidelineKey
75
+ });
76
+ case 'CLEAR_ACTIVE_GUIDELINE_KEY':
77
+ return _objectSpread(_objectSpread({}, pluginState), {}, {
78
+ activeGuidelineKey: undefined
79
+ });
80
+ case 'RESET_STATE':
81
+ return {
82
+ activeGuidelineLabel: undefined,
83
+ breakoutNode: undefined
84
+ };
85
+ }
86
+ }
87
+ return pluginState;
88
+ }
89
+ };
52
90
  var createResizingPlugin = exports.createResizingPlugin = function createResizingPlugin(api, getIntl, nodeViewPortalProviderAPI, options) {
53
91
  return new _safePlugin.SafePlugin({
54
92
  key: resizingPluginKey,
93
+ state: (0, _platformFeatureFlags.fg)('platform_editor_breakout_resizing_hello_release') ? pluginState : undefined,
55
94
  props: {
56
95
  markViews: {
57
96
  breakout: function breakout(mark, view) {
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.generateResizeFrameRatePayloads = void 0;
6
+ exports.generateResizedEventPayload = exports.generateResizeFrameRatePayloads = void 0;
7
7
  var _analytics = require("@atlaskit/editor-common/analytics");
8
8
  var generateResizeFrameRatePayloads = exports.generateResizeFrameRatePayloads = function generateResizeFrameRatePayloads(props) {
9
9
  return props.frameRateSamples.map(function (frameRateSample, index) {
@@ -20,4 +20,19 @@ var generateResizeFrameRatePayloads = exports.generateResizeFrameRatePayloads =
20
20
  }
21
21
  };
22
22
  });
23
+ };
24
+ var generateResizedEventPayload = exports.generateResizedEventPayload = function generateResizedEventPayload(_ref) {
25
+ var node = _ref.node,
26
+ prevWidth = _ref.prevWidth,
27
+ newWidth = _ref.newWidth;
28
+ return {
29
+ action: _analytics.ACTION.RESIZED,
30
+ actionSubject: _analytics.ACTION_SUBJECT.ELEMENT,
31
+ eventType: _analytics.EVENT_TYPE.TRACK,
32
+ attributes: {
33
+ nodeType: node.type.name,
34
+ prevWidth: prevWidth,
35
+ newWidth: newWidth
36
+ }
37
+ };
23
38
  };
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.GuidelineLabel = void 0;
8
+ var _react = _interopRequireDefault(require("react"));
9
+ var _resizer = require("@atlaskit/editor-common/resizer");
10
+ var _ui = require("@atlaskit/editor-common/ui");
11
+ var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
12
+ var _utils = require("@atlaskit/editor-prosemirror/utils");
13
+ var GUIDELINE_KEY_TO_LAYOUT = {
14
+ wide_left: 'wide',
15
+ wide_right: 'wide',
16
+ full_width_left: 'full-width',
17
+ full_width_right: 'full-width'
18
+ };
19
+ var GuidelineLabel = exports.GuidelineLabel = function GuidelineLabel(_ref) {
20
+ var api = _ref.api,
21
+ editorView = _ref.editorView,
22
+ mountPoint = _ref.mountPoint,
23
+ boundariesElement = _ref.boundariesElement,
24
+ scrollableElement = _ref.scrollableElement;
25
+ var breakoutNode = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'breakout.breakoutNode');
26
+ var activeGuidelineKey = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'breakout.activeGuidelineKey');
27
+ if (!breakoutNode || !activeGuidelineKey) {
28
+ return null;
29
+ }
30
+ var element = (0, _utils.findDomRefAtPos)(breakoutNode.pos, editorView.domAtPos.bind(editorView));
31
+ return /*#__PURE__*/_react.default.createElement(_ui.Popup, {
32
+ target: element && element instanceof HTMLElement ? element : undefined,
33
+ offset: [0, 10],
34
+ alignY: "bottom",
35
+ alignX: "center",
36
+ mountTo: mountPoint,
37
+ boundariesElement: boundariesElement,
38
+ scrollableElement: scrollableElement,
39
+ stick: true,
40
+ forcePlacement: true
41
+ }, /*#__PURE__*/_react.default.createElement(_resizer.ResizerBreakoutModeLabel, {
42
+ layout: GUIDELINE_KEY_TO_LAYOUT[activeGuidelineKey]
43
+ }));
44
+ };
@@ -7,11 +7,13 @@ import { usePluginStateEffect } from '@atlaskit/editor-common/use-plugin-state-e
7
7
  import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
8
8
  import { akEditorSwoopCubicBezier } from '@atlaskit/editor-shared-styles';
9
9
  import { fg } from '@atlaskit/platform-feature-flags';
10
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
10
11
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
11
12
  import { pluginKey } from './pm-plugins/plugin-key';
12
- import { createResizingPlugin } from './pm-plugins/resizing-plugin';
13
+ import { createResizingPlugin, resizingPluginKey } from './pm-plugins/resizing-plugin';
13
14
  import { findSupportedNodeForBreakout } from './pm-plugins/utils/find-breakout-node';
14
15
  import { getBreakoutMode } from './pm-plugins/utils/get-breakout-mode';
16
+ import { GuidelineLabel } from './ui/GuidelineLabel';
15
17
  import LayoutButton from './ui/LayoutButton';
16
18
  class BreakoutView {
17
19
  constructor(
@@ -73,7 +75,8 @@ function createPlugin(api, {
73
75
  state: {
74
76
  init() {
75
77
  return {
76
- breakoutNode: undefined
78
+ breakoutNode: undefined,
79
+ activeGuidelineKey: undefined
77
80
  };
78
81
  },
79
82
  apply(tr, pluginState) {
@@ -192,7 +195,7 @@ export const breakoutPlugin = ({
192
195
  }) => ({
193
196
  name: 'breakout',
194
197
  pmPlugins() {
195
- if (editorExperiment('platform_editor_breakout_resizing', true)) {
198
+ if (expValEquals('platform_editor_breakout_resizing', 'isEnabled', true)) {
196
199
  return [{
197
200
  name: 'breakout-resizing',
198
201
  plugin: ({
@@ -218,6 +221,16 @@ export const breakoutPlugin = ({
218
221
  breakoutNode: undefined
219
222
  };
220
223
  }
224
+ if (expValEquals('platform_editor_breakout_resizing', 'isEnabled', true) && fg('platform_editor_breakout_resizing_hello_release')) {
225
+ const resizingPluginState = resizingPluginKey.getState(editorState);
226
+ if (!resizingPluginState) {
227
+ return {
228
+ breakoutNode: undefined,
229
+ activeGuidelineKey: undefined
230
+ };
231
+ }
232
+ return resizingPluginState;
233
+ }
221
234
  const pluginState = pluginKey.getState(editorState);
222
235
  if (!pluginState) {
223
236
  return {
@@ -232,6 +245,16 @@ export const breakoutPlugin = ({
232
245
  popupsBoundariesElement,
233
246
  popupsScrollableElement
234
247
  }) {
248
+ if (expValEquals('platform_editor_breakout_resizing', 'isEnabled', true) && fg('platform_editor_breakout_resizing_hello_release')) {
249
+ return /*#__PURE__*/React.createElement(GuidelineLabel, {
250
+ api: api,
251
+ editorView: editorView,
252
+ mountPoint: popupsMountPoint,
253
+ boundariesElement: popupsBoundariesElement,
254
+ scrollableElement: popupsScrollableElement
255
+ });
256
+ }
257
+
235
258
  // This is a bit crappy, but should be resolved once we move to a static schema.
236
259
  if (options && !options.allowBreakoutButton) {
237
260
  return null;
@@ -1,15 +1,19 @@
1
1
  import memoizeOne from 'memoize-one';
2
2
  import { EXPAND_CONTAINER_PADDING, LAYOUT_COLUMN_PADDING, resizerHandleThumbWidth } from '@atlaskit/editor-common/styles';
3
3
  import { akEditorGutterPaddingDynamic, akEditorGutterPadding, akEditorCalculatedWideLayoutWidth, akEditorFullWidthLayoutWidth, akEditorDefaultLayoutWidth } from '@atlaskit/editor-shared-styles';
4
+ import { fg } from '@atlaskit/platform-feature-flags';
4
5
  const WIDTHS = {
5
6
  MIN: akEditorDefaultLayoutWidth,
6
7
  WIDE: akEditorCalculatedWideLayoutWidth,
7
8
  MAX: akEditorFullWidthLayoutWidth
8
9
  };
9
- const GUIDELINE_KEYS = {
10
- lineLength: 'grid',
11
- wide: 'wide',
12
- fullWidth: 'full_width'
10
+ export const GUIDELINE_KEYS = {
11
+ lineLengthLeft: 'grid_left',
12
+ lineLengthRight: 'grid_right',
13
+ wideLeft: 'wide_left',
14
+ wideRight: 'wide_right',
15
+ fullWidthLeft: 'full_width_left',
16
+ fullWidthRight: 'full_width_right'
13
17
  };
14
18
  const AK_NESTED_DND_GUTTER_OFFSET = 8;
15
19
  const roundToNearest = (value, interval = 0.5) => Math.round(value / interval) * interval;
@@ -35,33 +39,49 @@ export const getGuidelines = memoizeOne((isResizing, newWidth, getEditorWidth, n
35
39
  width,
36
40
  lineLength
37
41
  } = getEditorWidth() || {};
38
- // TODO: ED-28109 - use breakoutWideScaleRatio to calculate wide guideline
39
42
  const fullWidth = width ? Math.min(WIDTHS.MAX, width - 2 * akEditorGutterPaddingDynamic() - akEditorGutterPadding) : undefined;
40
- if (lineLength) {
43
+ if (fg('platform_editor_breakout_resizing_hello_release')) {
41
44
  guidelines.push({
42
- key: `${GUIDELINE_KEYS.lineLength}_left`,
45
+ key: GUIDELINE_KEYS.lineLengthLeft,
43
46
  position: {
44
- x: -roundToNearest(lineLength / 2 + innerPaddingOffset)
47
+ x: -roundToNearest(WIDTHS.MIN / 2 + innerPaddingOffset)
45
48
  },
46
- active: newWidth === lineLength
49
+ active: newWidth === WIDTHS.MIN
47
50
  });
48
51
  guidelines.push({
49
- key: `${GUIDELINE_KEYS.lineLength}_right`,
52
+ key: GUIDELINE_KEYS.lineLengthRight,
50
53
  position: {
51
- x: roundToNearest(lineLength / 2 + innerPaddingOffset)
54
+ x: roundToNearest(WIDTHS.MIN / 2 + innerPaddingOffset)
52
55
  },
53
- active: newWidth === lineLength
56
+ active: newWidth === WIDTHS.MIN
54
57
  });
58
+ } else {
59
+ if (lineLength) {
60
+ guidelines.push({
61
+ key: GUIDELINE_KEYS.lineLengthLeft,
62
+ position: {
63
+ x: -roundToNearest(lineLength / 2 + innerPaddingOffset)
64
+ },
65
+ active: newWidth === lineLength
66
+ });
67
+ guidelines.push({
68
+ key: GUIDELINE_KEYS.lineLengthRight,
69
+ position: {
70
+ x: roundToNearest(lineLength / 2 + innerPaddingOffset)
71
+ },
72
+ active: newWidth === lineLength
73
+ });
74
+ }
55
75
  }
56
76
  guidelines.push({
57
- key: `${GUIDELINE_KEYS.wide}_left`,
77
+ key: GUIDELINE_KEYS.wideLeft,
58
78
  position: {
59
79
  x: -roundToNearest(WIDTHS.WIDE / 2 + innerPaddingOffset)
60
80
  },
61
81
  active: newWidth === WIDTHS.WIDE
62
82
  });
63
83
  guidelines.push({
64
- key: `${GUIDELINE_KEYS.wide}_right`,
84
+ key: GUIDELINE_KEYS.wideRight,
65
85
  position: {
66
86
  x: roundToNearest(WIDTHS.WIDE / 2 + innerPaddingOffset)
67
87
  },
@@ -69,14 +89,14 @@ export const getGuidelines = memoizeOne((isResizing, newWidth, getEditorWidth, n
69
89
  });
70
90
  if (fullWidth) {
71
91
  guidelines.push({
72
- key: `${GUIDELINE_KEYS.fullWidth}_left`,
92
+ key: GUIDELINE_KEYS.fullWidthLeft,
73
93
  position: {
74
94
  x: -roundToNearest(fullWidth / 2 + innerPaddingOffset)
75
95
  },
76
96
  active: newWidth === fullWidth
77
97
  });
78
98
  guidelines.push({
79
- key: `${GUIDELINE_KEYS.fullWidth}_right`,
99
+ key: GUIDELINE_KEYS.fullWidthRight,
80
100
  position: {
81
101
  x: roundToNearest(fullWidth / 2 + innerPaddingOffset)
82
102
  },