@atlaskit/editor-plugin-breakout 2.7.2 → 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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
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
+
3
13
  ## 2.7.2
4
14
 
5
15
  ### 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,7 +4,7 @@ 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");
@@ -14,10 +14,13 @@ var WIDTHS = {
14
14
  WIDE: _editorSharedStyles.akEditorCalculatedWideLayoutWidth,
15
15
  MAX: _editorSharedStyles.akEditorFullWidthLayoutWidth
16
16
  };
17
- var GUIDELINE_KEYS = {
18
- lineLength: 'grid',
19
- wide: 'wide',
20
- 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'
21
24
  };
22
25
  var AK_NESTED_DND_GUTTER_OFFSET = 8;
23
26
  var roundToNearest = function roundToNearest(value) {
@@ -48,14 +51,14 @@ var getGuidelines = exports.getGuidelines = (0, _memoizeOne.default)(function (i
48
51
  var fullWidth = width ? Math.min(WIDTHS.MAX, width - 2 * (0, _editorSharedStyles.akEditorGutterPaddingDynamic)() - _editorSharedStyles.akEditorGutterPadding) : undefined;
49
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
56
  x: -roundToNearest(WIDTHS.MIN / 2 + innerPaddingOffset)
54
57
  },
55
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
63
  x: roundToNearest(WIDTHS.MIN / 2 + innerPaddingOffset)
61
64
  },
@@ -64,14 +67,14 @@ var getGuidelines = exports.getGuidelines = (0, _memoizeOne.default)(function (i
64
67
  } else {
65
68
  if (lineLength) {
66
69
  guidelines.push({
67
- key: "".concat(GUIDELINE_KEYS.lineLength, "_left"),
70
+ key: GUIDELINE_KEYS.lineLengthLeft,
68
71
  position: {
69
72
  x: -roundToNearest(lineLength / 2 + innerPaddingOffset)
70
73
  },
71
74
  active: newWidth === lineLength
72
75
  });
73
76
  guidelines.push({
74
- key: "".concat(GUIDELINE_KEYS.lineLength, "_right"),
77
+ key: GUIDELINE_KEYS.lineLengthRight,
75
78
  position: {
76
79
  x: roundToNearest(lineLength / 2 + innerPaddingOffset)
77
80
  },
@@ -80,14 +83,14 @@ var getGuidelines = exports.getGuidelines = (0, _memoizeOne.default)(function (i
80
83
  }
81
84
  }
82
85
  guidelines.push({
83
- key: "".concat(GUIDELINE_KEYS.wide, "_left"),
86
+ key: GUIDELINE_KEYS.wideLeft,
84
87
  position: {
85
88
  x: -roundToNearest(WIDTHS.WIDE / 2 + innerPaddingOffset)
86
89
  },
87
90
  active: newWidth === WIDTHS.WIDE
88
91
  });
89
92
  guidelines.push({
90
- key: "".concat(GUIDELINE_KEYS.wide, "_right"),
93
+ key: GUIDELINE_KEYS.wideRight,
91
94
  position: {
92
95
  x: roundToNearest(WIDTHS.WIDE / 2 + innerPaddingOffset)
93
96
  },
@@ -95,14 +98,14 @@ var getGuidelines = exports.getGuidelines = (0, _memoizeOne.default)(function (i
95
98
  });
96
99
  if (fullWidth) {
97
100
  guidelines.push({
98
- key: "".concat(GUIDELINE_KEYS.fullWidth, "_left"),
101
+ key: GUIDELINE_KEYS.fullWidthLeft,
99
102
  position: {
100
103
  x: -roundToNearest(fullWidth / 2 + innerPaddingOffset)
101
104
  },
102
105
  active: newWidth === fullWidth
103
106
  });
104
107
  guidelines.push({
105
- key: "".concat(GUIDELINE_KEYS.fullWidth, "_right"),
108
+ key: GUIDELINE_KEYS.fullWidthRight,
106
109
  position: {
107
110
  x: roundToNearest(fullWidth / 2 + innerPaddingOffset)
108
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)({
@@ -134,17 +173,22 @@ function createResizerCallbacks(_ref2) {
134
173
  });
135
174
  payloads.push(resizedPayload);
136
175
  }
137
- api === null || api === void 0 || api.core.actions.execute(function (_ref6) {
176
+ api === null || api === void 0 || api.core.actions.execute(function (_ref8) {
138
177
  var _api$userIntent2;
139
- var tr = _ref6.tr;
178
+ var tr = _ref8.tr;
140
179
  (_api$userIntent2 = api.userIntent) === null || _api$userIntent2 === void 0 || _api$userIntent2.commands.setCurrentUserIntent('default')({
141
180
  tr: tr
142
181
  });
143
- tr.setMeta('is-resizer-resizing', false).setMeta('scrollIntoView', false);
144
182
  payloads.forEach(function (payload) {
145
183
  var _api$analytics;
146
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);
147
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
+ }
148
192
  return tr;
149
193
  });
150
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) {
@@ -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;
@@ -7,10 +7,13 @@ const WIDTHS = {
7
7
  WIDE: akEditorCalculatedWideLayoutWidth,
8
8
  MAX: akEditorFullWidthLayoutWidth
9
9
  };
10
- const GUIDELINE_KEYS = {
11
- lineLength: 'grid',
12
- wide: 'wide',
13
- 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'
14
17
  };
15
18
  const AK_NESTED_DND_GUTTER_OFFSET = 8;
16
19
  const roundToNearest = (value, interval = 0.5) => Math.round(value / interval) * interval;
@@ -39,14 +42,14 @@ export const getGuidelines = memoizeOne((isResizing, newWidth, getEditorWidth, n
39
42
  const fullWidth = width ? Math.min(WIDTHS.MAX, width - 2 * akEditorGutterPaddingDynamic() - akEditorGutterPadding) : undefined;
40
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
47
  x: -roundToNearest(WIDTHS.MIN / 2 + innerPaddingOffset)
45
48
  },
46
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
54
  x: roundToNearest(WIDTHS.MIN / 2 + innerPaddingOffset)
52
55
  },
@@ -55,14 +58,14 @@ export const getGuidelines = memoizeOne((isResizing, newWidth, getEditorWidth, n
55
58
  } else {
56
59
  if (lineLength) {
57
60
  guidelines.push({
58
- key: `${GUIDELINE_KEYS.lineLength}_left`,
61
+ key: GUIDELINE_KEYS.lineLengthLeft,
59
62
  position: {
60
63
  x: -roundToNearest(lineLength / 2 + innerPaddingOffset)
61
64
  },
62
65
  active: newWidth === lineLength
63
66
  });
64
67
  guidelines.push({
65
- key: `${GUIDELINE_KEYS.lineLength}_right`,
68
+ key: GUIDELINE_KEYS.lineLengthRight,
66
69
  position: {
67
70
  x: roundToNearest(lineLength / 2 + innerPaddingOffset)
68
71
  },
@@ -71,14 +74,14 @@ export const getGuidelines = memoizeOne((isResizing, newWidth, getEditorWidth, n
71
74
  }
72
75
  }
73
76
  guidelines.push({
74
- key: `${GUIDELINE_KEYS.wide}_left`,
77
+ key: GUIDELINE_KEYS.wideLeft,
75
78
  position: {
76
79
  x: -roundToNearest(WIDTHS.WIDE / 2 + innerPaddingOffset)
77
80
  },
78
81
  active: newWidth === WIDTHS.WIDE
79
82
  });
80
83
  guidelines.push({
81
- key: `${GUIDELINE_KEYS.wide}_right`,
84
+ key: GUIDELINE_KEYS.wideRight,
82
85
  position: {
83
86
  x: roundToNearest(WIDTHS.WIDE / 2 + innerPaddingOffset)
84
87
  },
@@ -86,14 +89,14 @@ export const getGuidelines = memoizeOne((isResizing, newWidth, getEditorWidth, n
86
89
  });
87
90
  if (fullWidth) {
88
91
  guidelines.push({
89
- key: `${GUIDELINE_KEYS.fullWidth}_left`,
92
+ key: GUIDELINE_KEYS.fullWidthLeft,
90
93
  position: {
91
94
  x: -roundToNearest(fullWidth / 2 + innerPaddingOffset)
92
95
  },
93
96
  active: newWidth === fullWidth
94
97
  });
95
98
  guidelines.push({
96
- key: `${GUIDELINE_KEYS.fullWidth}_right`,
99
+ key: GUIDELINE_KEYS.fullWidthRight,
97
100
  position: {
98
101
  x: roundToNearest(fullWidth / 2 + innerPaddingOffset)
99
102
  },
@@ -3,6 +3,7 @@ import { fg } from '@atlaskit/platform-feature-flags';
3
3
  import { setBreakoutWidth } from '../editor-commands/set-breakout-width';
4
4
  import { getGuidelines } from './get-guidelines';
5
5
  import { LOCAL_RESIZE_PROPERTY } from './resizing-mark-view';
6
+ import { resizingPluginKey } from './resizing-plugin';
6
7
  import { generateResizeFrameRatePayloads, generateResizedEventPayload } from './utils/analytics';
7
8
  import { measureFramerate, reduceResizeFrameRateSamples } from './utils/measure-framerate';
8
9
  const RESIZE_RATIO = 2;
@@ -58,6 +59,8 @@ export function createResizerCallbacks({
58
59
  if (fg('platform_editor_breakout_resizing_hello_release')) {
59
60
  startMeasure();
60
61
  }
62
+ const pos = view.posAtDOM(dom, 0);
63
+ node = view.state.doc.nodeAt(pos);
61
64
  api === null || api === void 0 ? void 0 : api.core.actions.execute(({
62
65
  tr
63
66
  }) => {
@@ -66,10 +69,19 @@ export function createResizerCallbacks({
66
69
  tr
67
70
  });
68
71
  tr.setMeta('is-resizer-resizing', true);
72
+ if (fg('platform_editor_breakout_resizing_hello_release')) {
73
+ tr.setMeta(resizingPluginKey, {
74
+ type: 'UPDATE_BREAKOUT_NODE',
75
+ data: {
76
+ node,
77
+ pos,
78
+ start: pos,
79
+ depth: 0
80
+ }
81
+ });
82
+ }
69
83
  return tr;
70
84
  });
71
- const pos = view.posAtDOM(dom, 0);
72
- node = view.state.doc.nodeAt(pos);
73
85
  },
74
86
  onDrag: ({
75
87
  location,
@@ -90,6 +102,33 @@ export function createResizerCallbacks({
90
102
  api === null || api === void 0 ? void 0 : (_api$guideline = api.guideline) === null || _api$guideline === void 0 ? void 0 : (_api$guideline$action = _api$guideline.actions) === null || _api$guideline$action === void 0 ? void 0 : _api$guideline$action.displayGuideline(view)({
91
103
  guidelines
92
104
  });
105
+ if (fg('platform_editor_breakout_resizing_hello_release')) {
106
+ var _api$breakout$sharedS;
107
+ const activeGuideline = guidelines.find(guideline => guideline.active && !guideline.key.startsWith('grid'));
108
+ if (activeGuideline) {
109
+ api === null || api === void 0 ? void 0 : api.core.actions.execute(({
110
+ tr
111
+ }) => {
112
+ tr.setMeta(resizingPluginKey, {
113
+ type: 'UPDATE_ACTIVE_GUIDELINE_KEY',
114
+ data: {
115
+ activeGuidelineKey: activeGuideline.key
116
+ }
117
+ });
118
+ return tr;
119
+ });
120
+ }
121
+ if (!activeGuideline && api !== null && api !== void 0 && (_api$breakout$sharedS = api.breakout.sharedState.currentState()) !== null && _api$breakout$sharedS !== void 0 && _api$breakout$sharedS.activeGuidelineKey) {
122
+ api === null || api === void 0 ? void 0 : api.core.actions.execute(({
123
+ tr
124
+ }) => {
125
+ tr.setMeta(resizingPluginKey, {
126
+ type: 'CLEAR_ACTIVE_GUIDELINE_KEY'
127
+ });
128
+ return tr;
129
+ });
130
+ }
131
+ }
93
132
  contentDOM.style.setProperty(LOCAL_RESIZE_PROPERTY, `${newWidth}px`);
94
133
  },
95
134
  onDrop({
@@ -106,7 +145,7 @@ export function createResizerCallbacks({
106
145
  originalNode: node
107
146
  });
108
147
  }
109
- const isResizedToFullWidth = !!guidelines.find(guideline => guideline.key.includes('full_width') && guideline.active);
148
+ const isResizedToFullWidth = !!guidelines.find(guideline => guideline.key.startsWith('full_width') && guideline.active);
110
149
  guidelines = getGuidelines(false, 0, getEditorWidth);
111
150
  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)({
112
151
  guidelines
@@ -137,11 +176,16 @@ export function createResizerCallbacks({
137
176
  (_api$userIntent2 = api.userIntent) === null || _api$userIntent2 === void 0 ? void 0 : _api$userIntent2.commands.setCurrentUserIntent('default')({
138
177
  tr
139
178
  });
140
- tr.setMeta('is-resizer-resizing', false).setMeta('scrollIntoView', false);
141
179
  payloads.forEach(payload => {
142
180
  var _api$analytics, _api$analytics$action;
143
181
  (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : (_api$analytics$action = _api$analytics.actions) === null || _api$analytics$action === void 0 ? void 0 : _api$analytics$action.attachAnalyticsEvent(payload)(tr);
144
182
  });
183
+ tr.setMeta('is-resizer-resizing', false).setMeta('scrollIntoView', false);
184
+ if (fg('platform_editor_breakout_resizing_hello_release')) {
185
+ tr.setMeta(resizingPluginKey, {
186
+ type: 'RESET_STATE'
187
+ });
188
+ }
145
189
  return tr;
146
190
  });
147
191
  }
@@ -3,6 +3,7 @@ import { stepAddsOneOf } from '@atlaskit/editor-common/utils';
3
3
  import { getChangedNodes, isReplaceDocOperation } from '@atlaskit/editor-common/utils/document';
4
4
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
5
5
  import { akEditorDefaultLayoutWidth, akEditorFullWidthLayoutWidth, akEditorCalculatedWideLayoutWidth } from '@atlaskit/editor-shared-styles';
6
+ import { fg } from '@atlaskit/platform-feature-flags';
6
7
  import { handleKeyDown } from './handle-key-down';
7
8
  import { ResizingMarkView } from './resizing-mark-view';
8
9
  const addBreakoutToResizableNode = ({
@@ -44,9 +45,46 @@ const addBreakoutToResizableNode = ({
44
45
  };
45
46
  };
46
47
  export const resizingPluginKey = new PluginKey('breakout-resizing');
48
+ const pluginState = {
49
+ init() {
50
+ return {
51
+ breakoutNode: undefined,
52
+ activeGuidelineLabel: undefined
53
+ };
54
+ },
55
+ apply(tr, pluginState) {
56
+ const meta = tr.getMeta(resizingPluginKey);
57
+ if (meta) {
58
+ switch (meta.type) {
59
+ case 'UPDATE_BREAKOUT_NODE':
60
+ return {
61
+ ...pluginState,
62
+ breakoutNode: meta.data
63
+ };
64
+ case 'UPDATE_ACTIVE_GUIDELINE_KEY':
65
+ return {
66
+ ...pluginState,
67
+ activeGuidelineKey: meta.data.activeGuidelineKey
68
+ };
69
+ case 'CLEAR_ACTIVE_GUIDELINE_KEY':
70
+ return {
71
+ ...pluginState,
72
+ activeGuidelineKey: undefined
73
+ };
74
+ case 'RESET_STATE':
75
+ return {
76
+ activeGuidelineLabel: undefined,
77
+ breakoutNode: undefined
78
+ };
79
+ }
80
+ }
81
+ return pluginState;
82
+ }
83
+ };
47
84
  export const createResizingPlugin = (api, getIntl, nodeViewPortalProviderAPI, options) => {
48
85
  return new SafePlugin({
49
86
  key: resizingPluginKey,
87
+ state: fg('platform_editor_breakout_resizing_hello_release') ? pluginState : undefined,
50
88
  props: {
51
89
  markViews: {
52
90
  breakout: (mark, view) => {
@@ -0,0 +1,38 @@
1
+ import React from 'react';
2
+ import { ResizerBreakoutModeLabel } from '@atlaskit/editor-common/resizer';
3
+ import { Popup } from '@atlaskit/editor-common/ui';
4
+ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
5
+ import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
6
+ const GUIDELINE_KEY_TO_LAYOUT = {
7
+ wide_left: 'wide',
8
+ wide_right: 'wide',
9
+ full_width_left: 'full-width',
10
+ full_width_right: 'full-width'
11
+ };
12
+ export const GuidelineLabel = ({
13
+ api,
14
+ editorView,
15
+ mountPoint,
16
+ boundariesElement,
17
+ scrollableElement
18
+ }) => {
19
+ const breakoutNode = useSharedPluginStateSelector(api, 'breakout.breakoutNode');
20
+ const activeGuidelineKey = useSharedPluginStateSelector(api, 'breakout.activeGuidelineKey');
21
+ if (!breakoutNode || !activeGuidelineKey) {
22
+ return null;
23
+ }
24
+ const element = findDomRefAtPos(breakoutNode.pos, editorView.domAtPos.bind(editorView));
25
+ return /*#__PURE__*/React.createElement(Popup, {
26
+ target: element && element instanceof HTMLElement ? element : undefined,
27
+ offset: [0, 10],
28
+ alignY: "bottom",
29
+ alignX: "center",
30
+ mountTo: mountPoint,
31
+ boundariesElement: boundariesElement,
32
+ scrollableElement: scrollableElement,
33
+ stick: true,
34
+ forcePlacement: true
35
+ }, /*#__PURE__*/React.createElement(ResizerBreakoutModeLabel, {
36
+ layout: GUIDELINE_KEY_TO_LAYOUT[activeGuidelineKey]
37
+ }));
38
+ };
@@ -13,11 +13,13 @@ import { usePluginStateEffect } from '@atlaskit/editor-common/use-plugin-state-e
13
13
  import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
14
14
  import { akEditorSwoopCubicBezier } from '@atlaskit/editor-shared-styles';
15
15
  import { fg } from '@atlaskit/platform-feature-flags';
16
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
16
17
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
17
18
  import { pluginKey } from './pm-plugins/plugin-key';
18
- import { createResizingPlugin } from './pm-plugins/resizing-plugin';
19
+ import { createResizingPlugin, resizingPluginKey } from './pm-plugins/resizing-plugin';
19
20
  import { findSupportedNodeForBreakout } from './pm-plugins/utils/find-breakout-node';
20
21
  import { getBreakoutMode } from './pm-plugins/utils/get-breakout-mode';
22
+ import { GuidelineLabel } from './ui/GuidelineLabel';
21
23
  import LayoutButton from './ui/LayoutButton';
22
24
  var BreakoutView = /*#__PURE__*/_createClass(function BreakoutView(
23
25
  /**
@@ -77,7 +79,8 @@ function createPlugin(api, _ref) {
77
79
  state: {
78
80
  init: function init() {
79
81
  return {
80
- breakoutNode: undefined
82
+ breakoutNode: undefined,
83
+ activeGuidelineKey: undefined
81
84
  };
82
85
  },
83
86
  apply: function apply(tr, pluginState) {
@@ -197,7 +200,7 @@ export var breakoutPlugin = function breakoutPlugin(_ref4) {
197
200
  return {
198
201
  name: 'breakout',
199
202
  pmPlugins: function pmPlugins() {
200
- if (editorExperiment('platform_editor_breakout_resizing', true)) {
203
+ if (expValEquals('platform_editor_breakout_resizing', 'isEnabled', true)) {
201
204
  return [{
202
205
  name: 'breakout-resizing',
203
206
  plugin: function plugin(_ref5) {
@@ -226,6 +229,16 @@ export var breakoutPlugin = function breakoutPlugin(_ref4) {
226
229
  breakoutNode: undefined
227
230
  };
228
231
  }
232
+ if (expValEquals('platform_editor_breakout_resizing', 'isEnabled', true) && fg('platform_editor_breakout_resizing_hello_release')) {
233
+ var resizingPluginState = resizingPluginKey.getState(editorState);
234
+ if (!resizingPluginState) {
235
+ return {
236
+ breakoutNode: undefined,
237
+ activeGuidelineKey: undefined
238
+ };
239
+ }
240
+ return resizingPluginState;
241
+ }
229
242
  var pluginState = pluginKey.getState(editorState);
230
243
  if (!pluginState) {
231
244
  return {
@@ -239,6 +252,16 @@ export var breakoutPlugin = function breakoutPlugin(_ref4) {
239
252
  popupsMountPoint = _ref6.popupsMountPoint,
240
253
  popupsBoundariesElement = _ref6.popupsBoundariesElement,
241
254
  popupsScrollableElement = _ref6.popupsScrollableElement;
255
+ if (expValEquals('platform_editor_breakout_resizing', 'isEnabled', true) && fg('platform_editor_breakout_resizing_hello_release')) {
256
+ return /*#__PURE__*/React.createElement(GuidelineLabel, {
257
+ api: api,
258
+ editorView: editorView,
259
+ mountPoint: popupsMountPoint,
260
+ boundariesElement: popupsBoundariesElement,
261
+ scrollableElement: popupsScrollableElement
262
+ });
263
+ }
264
+
242
265
  // This is a bit crappy, but should be resolved once we move to a static schema.
243
266
  if (options && !options.allowBreakoutButton) {
244
267
  return null;
@@ -7,10 +7,13 @@ var WIDTHS = {
7
7
  WIDE: akEditorCalculatedWideLayoutWidth,
8
8
  MAX: akEditorFullWidthLayoutWidth
9
9
  };
10
- var GUIDELINE_KEYS = {
11
- lineLength: 'grid',
12
- wide: 'wide',
13
- fullWidth: 'full_width'
10
+ export var 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'
14
17
  };
15
18
  var AK_NESTED_DND_GUTTER_OFFSET = 8;
16
19
  var roundToNearest = function roundToNearest(value) {
@@ -41,14 +44,14 @@ export var getGuidelines = memoizeOne(function (isResizing, newWidth, getEditorW
41
44
  var fullWidth = width ? Math.min(WIDTHS.MAX, width - 2 * akEditorGutterPaddingDynamic() - akEditorGutterPadding) : undefined;
42
45
  if (fg('platform_editor_breakout_resizing_hello_release')) {
43
46
  guidelines.push({
44
- key: "".concat(GUIDELINE_KEYS.lineLength, "_left"),
47
+ key: GUIDELINE_KEYS.lineLengthLeft,
45
48
  position: {
46
49
  x: -roundToNearest(WIDTHS.MIN / 2 + innerPaddingOffset)
47
50
  },
48
51
  active: newWidth === WIDTHS.MIN
49
52
  });
50
53
  guidelines.push({
51
- key: "".concat(GUIDELINE_KEYS.lineLength, "_right"),
54
+ key: GUIDELINE_KEYS.lineLengthRight,
52
55
  position: {
53
56
  x: roundToNearest(WIDTHS.MIN / 2 + innerPaddingOffset)
54
57
  },
@@ -57,14 +60,14 @@ export var getGuidelines = memoizeOne(function (isResizing, newWidth, getEditorW
57
60
  } else {
58
61
  if (lineLength) {
59
62
  guidelines.push({
60
- key: "".concat(GUIDELINE_KEYS.lineLength, "_left"),
63
+ key: GUIDELINE_KEYS.lineLengthLeft,
61
64
  position: {
62
65
  x: -roundToNearest(lineLength / 2 + innerPaddingOffset)
63
66
  },
64
67
  active: newWidth === lineLength
65
68
  });
66
69
  guidelines.push({
67
- key: "".concat(GUIDELINE_KEYS.lineLength, "_right"),
70
+ key: GUIDELINE_KEYS.lineLengthRight,
68
71
  position: {
69
72
  x: roundToNearest(lineLength / 2 + innerPaddingOffset)
70
73
  },
@@ -73,14 +76,14 @@ export var getGuidelines = memoizeOne(function (isResizing, newWidth, getEditorW
73
76
  }
74
77
  }
75
78
  guidelines.push({
76
- key: "".concat(GUIDELINE_KEYS.wide, "_left"),
79
+ key: GUIDELINE_KEYS.wideLeft,
77
80
  position: {
78
81
  x: -roundToNearest(WIDTHS.WIDE / 2 + innerPaddingOffset)
79
82
  },
80
83
  active: newWidth === WIDTHS.WIDE
81
84
  });
82
85
  guidelines.push({
83
- key: "".concat(GUIDELINE_KEYS.wide, "_right"),
86
+ key: GUIDELINE_KEYS.wideRight,
84
87
  position: {
85
88
  x: roundToNearest(WIDTHS.WIDE / 2 + innerPaddingOffset)
86
89
  },
@@ -88,14 +91,14 @@ export var getGuidelines = memoizeOne(function (isResizing, newWidth, getEditorW
88
91
  });
89
92
  if (fullWidth) {
90
93
  guidelines.push({
91
- key: "".concat(GUIDELINE_KEYS.fullWidth, "_left"),
94
+ key: GUIDELINE_KEYS.fullWidthLeft,
92
95
  position: {
93
96
  x: -roundToNearest(fullWidth / 2 + innerPaddingOffset)
94
97
  },
95
98
  active: newWidth === fullWidth
96
99
  });
97
100
  guidelines.push({
98
- key: "".concat(GUIDELINE_KEYS.fullWidth, "_right"),
101
+ key: GUIDELINE_KEYS.fullWidthRight,
99
102
  position: {
100
103
  x: roundToNearest(fullWidth / 2 + innerPaddingOffset)
101
104
  },
@@ -3,6 +3,7 @@ import { fg } from '@atlaskit/platform-feature-flags';
3
3
  import { setBreakoutWidth } from '../editor-commands/set-breakout-width';
4
4
  import { getGuidelines } from './get-guidelines';
5
5
  import { LOCAL_RESIZE_PROPERTY } from './resizing-mark-view';
6
+ import { resizingPluginKey } from './resizing-plugin';
6
7
  import { generateResizeFrameRatePayloads, generateResizedEventPayload } from './utils/analytics';
7
8
  import { measureFramerate, reduceResizeFrameRateSamples } from './utils/measure-framerate';
8
9
  var RESIZE_RATIO = 2;
@@ -56,6 +57,8 @@ export function createResizerCallbacks(_ref2) {
56
57
  if (fg('platform_editor_breakout_resizing_hello_release')) {
57
58
  startMeasure();
58
59
  }
60
+ var pos = view.posAtDOM(dom, 0);
61
+ node = view.state.doc.nodeAt(pos);
59
62
  api === null || api === void 0 || api.core.actions.execute(function (_ref3) {
60
63
  var _api$userIntent;
61
64
  var tr = _ref3.tr;
@@ -63,10 +66,19 @@ export function createResizerCallbacks(_ref2) {
63
66
  tr: tr
64
67
  });
65
68
  tr.setMeta('is-resizer-resizing', true);
69
+ if (fg('platform_editor_breakout_resizing_hello_release')) {
70
+ tr.setMeta(resizingPluginKey, {
71
+ type: 'UPDATE_BREAKOUT_NODE',
72
+ data: {
73
+ node: node,
74
+ pos: pos,
75
+ start: pos,
76
+ depth: 0
77
+ }
78
+ });
79
+ }
66
80
  return tr;
67
81
  });
68
- var pos = view.posAtDOM(dom, 0);
69
- node = view.state.doc.nodeAt(pos);
70
82
  },
71
83
  onDrag: function onDrag(_ref4) {
72
84
  var _node, _api$guideline;
@@ -86,12 +98,39 @@ export function createResizerCallbacks(_ref2) {
86
98
  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)({
87
99
  guidelines: guidelines
88
100
  });
101
+ if (fg('platform_editor_breakout_resizing_hello_release')) {
102
+ var _api$breakout$sharedS;
103
+ var activeGuideline = guidelines.find(function (guideline) {
104
+ return guideline.active && !guideline.key.startsWith('grid');
105
+ });
106
+ if (activeGuideline) {
107
+ api === null || api === void 0 || api.core.actions.execute(function (_ref5) {
108
+ var tr = _ref5.tr;
109
+ tr.setMeta(resizingPluginKey, {
110
+ type: 'UPDATE_ACTIVE_GUIDELINE_KEY',
111
+ data: {
112
+ activeGuidelineKey: activeGuideline.key
113
+ }
114
+ });
115
+ return tr;
116
+ });
117
+ }
118
+ if (!activeGuideline && api !== null && api !== void 0 && (_api$breakout$sharedS = api.breakout.sharedState.currentState()) !== null && _api$breakout$sharedS !== void 0 && _api$breakout$sharedS.activeGuidelineKey) {
119
+ api === null || api === void 0 || api.core.actions.execute(function (_ref6) {
120
+ var tr = _ref6.tr;
121
+ tr.setMeta(resizingPluginKey, {
122
+ type: 'CLEAR_ACTIVE_GUIDELINE_KEY'
123
+ });
124
+ return tr;
125
+ });
126
+ }
127
+ }
89
128
  contentDOM.style.setProperty(LOCAL_RESIZE_PROPERTY, "".concat(newWidth, "px"));
90
129
  },
91
- onDrop: function onDrop(_ref5) {
130
+ onDrop: function onDrop(_ref7) {
92
131
  var _api$guideline2;
93
- var location = _ref5.location,
94
- source = _ref5.source;
132
+ var location = _ref7.location,
133
+ source = _ref7.source;
95
134
  var payloads = [];
96
135
  if (fg('platform_editor_breakout_resizing_hello_release')) {
97
136
  var frameRateSamples = endMeasure();
@@ -102,7 +141,7 @@ export function createResizerCallbacks(_ref2) {
102
141
  });
103
142
  }
104
143
  var isResizedToFullWidth = !!guidelines.find(function (guideline) {
105
- return guideline.key.includes('full_width') && guideline.active;
144
+ return guideline.key.startsWith('full_width') && guideline.active;
106
145
  });
107
146
  guidelines = getGuidelines(false, 0, getEditorWidth);
108
147
  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)({
@@ -127,17 +166,22 @@ export function createResizerCallbacks(_ref2) {
127
166
  });
128
167
  payloads.push(resizedPayload);
129
168
  }
130
- api === null || api === void 0 || api.core.actions.execute(function (_ref6) {
169
+ api === null || api === void 0 || api.core.actions.execute(function (_ref8) {
131
170
  var _api$userIntent2;
132
- var tr = _ref6.tr;
171
+ var tr = _ref8.tr;
133
172
  (_api$userIntent2 = api.userIntent) === null || _api$userIntent2 === void 0 || _api$userIntent2.commands.setCurrentUserIntent('default')({
134
173
  tr: tr
135
174
  });
136
- tr.setMeta('is-resizer-resizing', false).setMeta('scrollIntoView', false);
137
175
  payloads.forEach(function (payload) {
138
176
  var _api$analytics;
139
177
  (_api$analytics = api.analytics) === null || _api$analytics === void 0 || (_api$analytics = _api$analytics.actions) === null || _api$analytics === void 0 || _api$analytics.attachAnalyticsEvent(payload)(tr);
140
178
  });
179
+ tr.setMeta('is-resizer-resizing', false).setMeta('scrollIntoView', false);
180
+ if (fg('platform_editor_breakout_resizing_hello_release')) {
181
+ tr.setMeta(resizingPluginKey, {
182
+ type: 'RESET_STATE'
183
+ });
184
+ }
141
185
  return tr;
142
186
  });
143
187
  }
@@ -1,8 +1,12 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ 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; }
3
+ 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) { _defineProperty(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; }
1
4
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
5
  import { stepAddsOneOf } from '@atlaskit/editor-common/utils';
3
6
  import { getChangedNodes, isReplaceDocOperation } from '@atlaskit/editor-common/utils/document';
4
7
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
5
8
  import { akEditorDefaultLayoutWidth, akEditorFullWidthLayoutWidth, akEditorCalculatedWideLayoutWidth } from '@atlaskit/editor-shared-styles';
9
+ import { fg } from '@atlaskit/platform-feature-flags';
6
10
  import { handleKeyDown } from './handle-key-down';
7
11
  import { ResizingMarkView } from './resizing-mark-view';
8
12
  var addBreakoutToResizableNode = function addBreakoutToResizableNode(_ref) {
@@ -43,9 +47,43 @@ var addBreakoutToResizableNode = function addBreakoutToResizableNode(_ref) {
43
47
  };
44
48
  };
45
49
  export var resizingPluginKey = new PluginKey('breakout-resizing');
50
+ var pluginState = {
51
+ init: function init() {
52
+ return {
53
+ breakoutNode: undefined,
54
+ activeGuidelineLabel: undefined
55
+ };
56
+ },
57
+ apply: function apply(tr, pluginState) {
58
+ var meta = tr.getMeta(resizingPluginKey);
59
+ if (meta) {
60
+ switch (meta.type) {
61
+ case 'UPDATE_BREAKOUT_NODE':
62
+ return _objectSpread(_objectSpread({}, pluginState), {}, {
63
+ breakoutNode: meta.data
64
+ });
65
+ case 'UPDATE_ACTIVE_GUIDELINE_KEY':
66
+ return _objectSpread(_objectSpread({}, pluginState), {}, {
67
+ activeGuidelineKey: meta.data.activeGuidelineKey
68
+ });
69
+ case 'CLEAR_ACTIVE_GUIDELINE_KEY':
70
+ return _objectSpread(_objectSpread({}, pluginState), {}, {
71
+ activeGuidelineKey: undefined
72
+ });
73
+ case 'RESET_STATE':
74
+ return {
75
+ activeGuidelineLabel: undefined,
76
+ breakoutNode: undefined
77
+ };
78
+ }
79
+ }
80
+ return pluginState;
81
+ }
82
+ };
46
83
  export var createResizingPlugin = function createResizingPlugin(api, getIntl, nodeViewPortalProviderAPI, options) {
47
84
  return new SafePlugin({
48
85
  key: resizingPluginKey,
86
+ state: fg('platform_editor_breakout_resizing_hello_release') ? pluginState : undefined,
49
87
  props: {
50
88
  markViews: {
51
89
  breakout: function breakout(mark, view) {
@@ -0,0 +1,37 @@
1
+ import React from 'react';
2
+ import { ResizerBreakoutModeLabel } from '@atlaskit/editor-common/resizer';
3
+ import { Popup } from '@atlaskit/editor-common/ui';
4
+ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
5
+ import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
6
+ var GUIDELINE_KEY_TO_LAYOUT = {
7
+ wide_left: 'wide',
8
+ wide_right: 'wide',
9
+ full_width_left: 'full-width',
10
+ full_width_right: 'full-width'
11
+ };
12
+ export var GuidelineLabel = function GuidelineLabel(_ref) {
13
+ var api = _ref.api,
14
+ editorView = _ref.editorView,
15
+ mountPoint = _ref.mountPoint,
16
+ boundariesElement = _ref.boundariesElement,
17
+ scrollableElement = _ref.scrollableElement;
18
+ var breakoutNode = useSharedPluginStateSelector(api, 'breakout.breakoutNode');
19
+ var activeGuidelineKey = useSharedPluginStateSelector(api, 'breakout.activeGuidelineKey');
20
+ if (!breakoutNode || !activeGuidelineKey) {
21
+ return null;
22
+ }
23
+ var element = findDomRefAtPos(breakoutNode.pos, editorView.domAtPos.bind(editorView));
24
+ return /*#__PURE__*/React.createElement(Popup, {
25
+ target: element && element instanceof HTMLElement ? element : undefined,
26
+ offset: [0, 10],
27
+ alignY: "bottom",
28
+ alignX: "center",
29
+ mountTo: mountPoint,
30
+ boundariesElement: boundariesElement,
31
+ scrollableElement: scrollableElement,
32
+ stick: true,
33
+ forcePlacement: true
34
+ }, /*#__PURE__*/React.createElement(ResizerBreakoutModeLabel, {
35
+ layout: GUIDELINE_KEY_TO_LAYOUT[activeGuidelineKey]
36
+ }));
37
+ };
@@ -8,8 +8,10 @@ import type { InteractionPlugin } from '@atlaskit/editor-plugin-interaction';
8
8
  import type { UserIntentPlugin } from '@atlaskit/editor-plugin-user-intent';
9
9
  import type { WidthPlugin } from '@atlaskit/editor-plugin-width';
10
10
  import type { ContentNodeWithPos } from '@atlaskit/editor-prosemirror/utils';
11
+ import { ActiveGuidelineKey } from './pm-plugins/resizing-plugin';
11
12
  export interface BreakoutPluginState {
12
13
  breakoutNode: ContentNodeWithPos | undefined;
14
+ activeGuidelineKey: ActiveGuidelineKey | undefined;
13
15
  }
14
16
  export interface BreakoutPluginOptions {
15
17
  allowBreakoutButton?: boolean;
@@ -1,4 +1,12 @@
1
1
  import { GuidelineConfig } from '@atlaskit/editor-common/guideline';
2
2
  import { EditorContainerWidth } from '@atlaskit/editor-common/types';
3
3
  import { NodeType } from '@atlaskit/editor-prosemirror/model';
4
+ export declare const GUIDELINE_KEYS: {
5
+ readonly lineLengthLeft: "grid_left";
6
+ readonly lineLengthRight: "grid_right";
7
+ readonly wideLeft: "wide_left";
8
+ readonly wideRight: "wide_right";
9
+ readonly fullWidthLeft: "full_width_left";
10
+ readonly fullWidthRight: "full_width_right";
11
+ };
4
12
  export declare const getGuidelines: import("memoize-one").MemoizedFn<(isResizing: boolean, newWidth: number, getEditorWidth: () => EditorContainerWidth | undefined, nodeType?: NodeType | undefined) => GuidelineConfig[]>;
@@ -4,6 +4,11 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
4
4
  import { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
5
5
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
6
6
  import { BreakoutPlugin } from '../breakoutPluginType';
7
- import type { BreakoutPluginOptions } from '../breakoutPluginType';
8
- export declare const resizingPluginKey: PluginKey<any>;
9
- export declare const createResizingPlugin: (api: ExtractInjectionAPI<BreakoutPlugin> | undefined, getIntl: () => IntlShape, nodeViewPortalProviderAPI: PortalProviderAPI, options?: BreakoutPluginOptions) => SafePlugin<any>;
7
+ import type { BreakoutPluginOptions, BreakoutPluginState } from '../breakoutPluginType';
8
+ import { GUIDELINE_KEYS } from './get-guidelines';
9
+ export declare const resizingPluginKey: PluginKey<BreakoutPluginState>;
10
+ export type ActiveGuidelineKey = Exclude<(typeof GUIDELINE_KEYS)[keyof typeof GUIDELINE_KEYS], 'grid_left' | 'grid_right'>;
11
+ export declare const createResizingPlugin: (api: ExtractInjectionAPI<BreakoutPlugin> | undefined, getIntl: () => IntlShape, nodeViewPortalProviderAPI: PortalProviderAPI, options?: BreakoutPluginOptions) => SafePlugin<BreakoutPluginState | {
12
+ activeGuidelineLabel: undefined;
13
+ breakoutNode: undefined;
14
+ }>;
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
+ import { EditorView } from '@atlaskit/editor-prosemirror/view';
4
+ import { BreakoutPlugin } from '../breakoutPluginType';
5
+ type GuidelineLabelProps = {
6
+ api: ExtractInjectionAPI<BreakoutPlugin> | undefined;
7
+ editorView: EditorView;
8
+ mountPoint?: HTMLElement;
9
+ boundariesElement?: HTMLElement;
10
+ scrollableElement?: HTMLElement;
11
+ };
12
+ export declare const GuidelineLabel: ({ api, editorView, mountPoint, boundariesElement, scrollableElement, }: GuidelineLabelProps) => React.JSX.Element | null;
13
+ export {};
@@ -8,8 +8,10 @@ import type { InteractionPlugin } from '@atlaskit/editor-plugin-interaction';
8
8
  import type { UserIntentPlugin } from '@atlaskit/editor-plugin-user-intent';
9
9
  import type { WidthPlugin } from '@atlaskit/editor-plugin-width';
10
10
  import type { ContentNodeWithPos } from '@atlaskit/editor-prosemirror/utils';
11
+ import { ActiveGuidelineKey } from './pm-plugins/resizing-plugin';
11
12
  export interface BreakoutPluginState {
12
13
  breakoutNode: ContentNodeWithPos | undefined;
14
+ activeGuidelineKey: ActiveGuidelineKey | undefined;
13
15
  }
14
16
  export interface BreakoutPluginOptions {
15
17
  allowBreakoutButton?: boolean;
@@ -1,4 +1,12 @@
1
1
  import { GuidelineConfig } from '@atlaskit/editor-common/guideline';
2
2
  import { EditorContainerWidth } from '@atlaskit/editor-common/types';
3
3
  import { NodeType } from '@atlaskit/editor-prosemirror/model';
4
+ export declare const GUIDELINE_KEYS: {
5
+ readonly lineLengthLeft: "grid_left";
6
+ readonly lineLengthRight: "grid_right";
7
+ readonly wideLeft: "wide_left";
8
+ readonly wideRight: "wide_right";
9
+ readonly fullWidthLeft: "full_width_left";
10
+ readonly fullWidthRight: "full_width_right";
11
+ };
4
12
  export declare const getGuidelines: import("memoize-one").MemoizedFn<(isResizing: boolean, newWidth: number, getEditorWidth: () => EditorContainerWidth | undefined, nodeType?: NodeType | undefined) => GuidelineConfig[]>;
@@ -4,6 +4,11 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
4
4
  import { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
5
5
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
6
6
  import { BreakoutPlugin } from '../breakoutPluginType';
7
- import type { BreakoutPluginOptions } from '../breakoutPluginType';
8
- export declare const resizingPluginKey: PluginKey<any>;
9
- export declare const createResizingPlugin: (api: ExtractInjectionAPI<BreakoutPlugin> | undefined, getIntl: () => IntlShape, nodeViewPortalProviderAPI: PortalProviderAPI, options?: BreakoutPluginOptions) => SafePlugin<any>;
7
+ import type { BreakoutPluginOptions, BreakoutPluginState } from '../breakoutPluginType';
8
+ import { GUIDELINE_KEYS } from './get-guidelines';
9
+ export declare const resizingPluginKey: PluginKey<BreakoutPluginState>;
10
+ export type ActiveGuidelineKey = Exclude<(typeof GUIDELINE_KEYS)[keyof typeof GUIDELINE_KEYS], 'grid_left' | 'grid_right'>;
11
+ export declare const createResizingPlugin: (api: ExtractInjectionAPI<BreakoutPlugin> | undefined, getIntl: () => IntlShape, nodeViewPortalProviderAPI: PortalProviderAPI, options?: BreakoutPluginOptions) => SafePlugin<BreakoutPluginState | {
12
+ activeGuidelineLabel: undefined;
13
+ breakoutNode: undefined;
14
+ }>;
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
+ import { EditorView } from '@atlaskit/editor-prosemirror/view';
4
+ import { BreakoutPlugin } from '../breakoutPluginType';
5
+ type GuidelineLabelProps = {
6
+ api: ExtractInjectionAPI<BreakoutPlugin> | undefined;
7
+ editorView: EditorView;
8
+ mountPoint?: HTMLElement;
9
+ boundariesElement?: HTMLElement;
10
+ scrollableElement?: HTMLElement;
11
+ };
12
+ export declare const GuidelineLabel: ({ api, editorView, mountPoint, boundariesElement, scrollableElement, }: GuidelineLabelProps) => React.JSX.Element | null;
13
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-breakout",
3
- "version": "2.7.2",
3
+ "version": "2.7.3",
4
4
  "description": "Breakout plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -34,8 +34,8 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "@atlaskit/adf-schema": "^47.6.0",
37
- "@atlaskit/editor-common": "^106.5.0",
38
- "@atlaskit/editor-plugin-block-controls": "^3.16.0",
37
+ "@atlaskit/editor-common": "^106.6.0",
38
+ "@atlaskit/editor-plugin-block-controls": "^3.17.0",
39
39
  "@atlaskit/editor-plugin-editor-disabled": "^2.0.0",
40
40
  "@atlaskit/editor-plugin-editor-viewmode": "^4.0.0",
41
41
  "@atlaskit/editor-plugin-guideline": "^2.0.0",
@@ -48,7 +48,7 @@
48
48
  "@atlaskit/platform-feature-flags": "^1.1.0",
49
49
  "@atlaskit/pragmatic-drag-and-drop": "^1.7.0",
50
50
  "@atlaskit/theme": "^18.0.0",
51
- "@atlaskit/tmp-editor-statsig": "^6.1.0",
51
+ "@atlaskit/tmp-editor-statsig": "^6.2.0",
52
52
  "@atlaskit/tokens": "^5.1.0",
53
53
  "@atlaskit/tooltip": "^20.3.0",
54
54
  "@babel/runtime": "^7.0.0",