@atlaskit/editor-plugin-breakout 2.4.1 → 2.4.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 (36) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/cjs/breakoutPlugin.js +39 -12
  3. package/dist/cjs/editor-commands/set-breakout-width.js +16 -1
  4. package/dist/cjs/pm-plugins/get-guidelines.js +5 -2
  5. package/dist/cjs/pm-plugins/pragmatic-resizer.js +60 -0
  6. package/dist/cjs/pm-plugins/resizer-callbacks.js +4 -4
  7. package/dist/cjs/pm-plugins/resizing-mark-view.js +3 -68
  8. package/dist/cjs/pm-plugins/utils/single-player-expand.js +27 -4
  9. package/dist/cjs/ui/LayoutButton.js +7 -3
  10. package/dist/es2019/breakoutPlugin.js +23 -4
  11. package/dist/es2019/editor-commands/set-breakout-width.js +16 -1
  12. package/dist/es2019/pm-plugins/get-guidelines.js +5 -2
  13. package/dist/es2019/pm-plugins/pragmatic-resizer.js +56 -0
  14. package/dist/es2019/pm-plugins/resizer-callbacks.js +5 -5
  15. package/dist/es2019/pm-plugins/resizing-mark-view.js +2 -69
  16. package/dist/es2019/pm-plugins/utils/single-player-expand.js +27 -3
  17. package/dist/es2019/ui/LayoutButton.js +7 -3
  18. package/dist/esm/breakoutPlugin.js +37 -12
  19. package/dist/esm/editor-commands/set-breakout-width.js +16 -1
  20. package/dist/esm/pm-plugins/get-guidelines.js +5 -2
  21. package/dist/esm/pm-plugins/pragmatic-resizer.js +54 -0
  22. package/dist/esm/pm-plugins/resizer-callbacks.js +5 -5
  23. package/dist/esm/pm-plugins/resizing-mark-view.js +2 -67
  24. package/dist/esm/pm-plugins/utils/single-player-expand.js +26 -3
  25. package/dist/esm/ui/LayoutButton.js +7 -3
  26. package/dist/types/pm-plugins/pragmatic-resizer.d.ts +10 -0
  27. package/dist/types/pm-plugins/resizer-callbacks.d.ts +6 -5
  28. package/dist/types/pm-plugins/resizing-mark-view.d.ts +0 -11
  29. package/dist/types/pm-plugins/utils/single-player-expand.d.ts +9 -0
  30. package/dist/types/ui/LayoutButton.d.ts +3 -0
  31. package/dist/types-ts4.5/pm-plugins/pragmatic-resizer.d.ts +10 -0
  32. package/dist/types-ts4.5/pm-plugins/resizer-callbacks.d.ts +6 -5
  33. package/dist/types-ts4.5/pm-plugins/resizing-mark-view.d.ts +0 -11
  34. package/dist/types-ts4.5/pm-plugins/utils/single-player-expand.d.ts +9 -0
  35. package/dist/types-ts4.5/ui/LayoutButton.d.ts +3 -0
  36. package/package.json +4 -4
@@ -1,13 +1,7 @@
1
1
  import { BreakoutCssClassName } from '@atlaskit/editor-common/styles';
2
- import { draggable } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
3
- import { disableNativeDragPreview } from '@atlaskit/pragmatic-drag-and-drop/element/disable-native-drag-preview';
4
- import { preventUnhandled } from '@atlaskit/pragmatic-drag-and-drop/prevent-unhandled';
2
+ import { createPragmaticResizer } from './pragmatic-resizer';
5
3
  import { createResizerCallbacks } from './resizer-callbacks';
6
4
  export const LOCAL_RESIZE_PROPERTY = '--local-resizing-width';
7
-
8
- /**
9
- *
10
- */
11
5
  export class ResizingMarkView {
12
6
  /**
13
7
  * Wrap node view in a resizing mark view
@@ -65,71 +59,10 @@ export class ResizingMarkView {
65
59
  this.mark = mark;
66
60
  this.destroyFn = destroy;
67
61
  }
68
-
69
- /**
70
- *
71
- * @example
72
- */
73
62
  ignoreMutation() {
74
63
  return true;
75
64
  }
76
-
77
- /**
78
- *
79
- * @example
80
- */
81
65
  destroy() {
82
66
  this.destroyFn();
83
67
  }
84
- }
85
- const createPragmaticResizer = ({
86
- onDragStart,
87
- onDrag,
88
- onDrop
89
- }) => {
90
- const registerHandle = handleElement => {
91
- return draggable({
92
- element: handleElement,
93
- onGenerateDragPreview: ({
94
- nativeSetDragImage
95
- }) => {
96
- disableNativeDragPreview({
97
- nativeSetDragImage
98
- });
99
- preventUnhandled.start();
100
- },
101
- onDragStart,
102
- onDrag,
103
- onDrop(args) {
104
- preventUnhandled.stop();
105
- onDrop(args);
106
- }
107
- });
108
- };
109
- const createHandle = side => {
110
- const handle = document.createElement('div');
111
- handle.contentEditable = 'false';
112
- handle.classList.add('pm-breakout-resize-handle');
113
- if (side === 'left') {
114
- handle.classList.add('pm-breakout-resize-handle-left');
115
- } else {
116
- handle.classList.add('pm-breakout-resize-handle-right');
117
- }
118
- const handleInner = document.createElement('div');
119
- handleInner.classList.add('pm-breakout-resize-handle-inner');
120
- handle.appendChild(handleInner);
121
- return handle;
122
- };
123
- const rightHandle = createHandle('right');
124
- const leftHandle = createHandle('left');
125
- const rightHandleCleanup = registerHandle(rightHandle);
126
- const leftHandleCleanup = registerHandle(leftHandle);
127
- return {
128
- rightHandle,
129
- leftHandle,
130
- destroy: () => {
131
- rightHandleCleanup();
132
- leftHandleCleanup();
133
- }
134
- };
135
- };
68
+ }
@@ -1,11 +1,35 @@
1
1
  import { expandedState } from '@atlaskit/editor-common/expand';
2
2
  import { fg } from '@atlaskit/platform-feature-flags';
3
- export const updateExpandedState = (tr, node, isLivePage) => {
3
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
4
+ export const updateExpandedStateNew = ({
5
+ tr,
6
+ node,
7
+ pos,
8
+ isLivePage
9
+ }) => {
4
10
  if (isLivePage || fg('platform-editor-single-player-expand')) {
5
- const wasExpandExpanded = expandedState.get(node.node);
6
- const newExpand = tr.doc.nodeAt(node.pos);
11
+ const wasExpandExpanded = expandedState.get(node);
12
+ const newExpand = tr.doc.nodeAt(pos);
7
13
  if (wasExpandExpanded !== undefined && newExpand) {
8
14
  expandedState.set(newExpand, wasExpandExpanded);
9
15
  }
10
16
  }
17
+ };
18
+ export const updateExpandedState = (tr, node, isLivePage) => {
19
+ if (editorExperiment('platform_editor_breakout_resizing', true)) {
20
+ updateExpandedStateNew({
21
+ tr,
22
+ node: node.node,
23
+ pos: node.pos,
24
+ isLivePage
25
+ });
26
+ } else {
27
+ if (isLivePage || fg('platform-editor-single-player-expand')) {
28
+ const wasExpandExpanded = expandedState.get(node.node);
29
+ const newExpand = tr.doc.nodeAt(node.pos);
30
+ if (wasExpandExpanded !== undefined && newExpand) {
31
+ expandedState.set(newExpand, wasExpandExpanded);
32
+ }
33
+ }
34
+ }
11
35
  };
@@ -19,6 +19,7 @@ import CollapseIcon from '@atlaskit/icon/glyph/editor/collapse';
19
19
  import ExpandIcon from '@atlaskit/icon/glyph/editor/expand';
20
20
  import { B300, N20A, N300 } from '@atlaskit/theme/colors';
21
21
  import { layers } from '@atlaskit/theme/constants';
22
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
22
23
  import { removeBreakout } from '../editor-commands/remove-breakout';
23
24
  import { setBreakoutMode } from '../editor-commands/set-breakout-mode';
24
25
  import { getPluginState } from '../pm-plugins/plugin-key';
@@ -60,7 +61,9 @@ const LayoutButton = ({
60
61
  scrollableElement,
61
62
  editorView,
62
63
  node,
63
- isLivePage
64
+ isLivePage,
65
+ isBreakoutNodePresent,
66
+ breakoutMode: breakoutModeProp
64
67
  }) => {
65
68
  const handleClick = useCallback(breakoutMode => {
66
69
  const {
@@ -76,10 +79,11 @@ const LayoutButton = ({
76
79
  const {
77
80
  state
78
81
  } = editorView;
79
- if (!node || !isBreakoutMarkAllowed(state)) {
82
+ const exitCondition = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? !isBreakoutNodePresent : !node;
83
+ if (exitCondition || !isBreakoutMarkAllowed(state)) {
80
84
  return null;
81
85
  }
82
- const breakoutMode = getBreakoutMode(editorView.state);
86
+ const breakoutMode = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? breakoutModeProp : getBreakoutMode(editorView.state);
83
87
  const titleMessage = getTitle(breakoutMode);
84
88
  const title = formatMessage(titleMessage);
85
89
  const nextBreakoutMode = getNextBreakoutMode(breakoutMode);
@@ -1,13 +1,15 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
1
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
3
  import _createClass from "@babel/runtime/helpers/createClass";
3
4
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
4
5
  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; }
5
6
  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; }
6
- import React from 'react';
7
+ import React, { useState } from 'react';
7
8
  import { breakout } from '@atlaskit/adf-schema';
8
9
  import { useSharedPluginState, sharedPluginStateHookMigratorFactory } from '@atlaskit/editor-common/hooks';
9
10
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
10
11
  import { BreakoutCssClassName } from '@atlaskit/editor-common/styles';
12
+ import { usePluginStateEffect } from '@atlaskit/editor-common/use-plugin-state-effect';
11
13
  import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
12
14
  import { akEditorSwoopCubicBezier } from '@atlaskit/editor-shared-styles';
13
15
  import { fg } from '@atlaskit/platform-feature-flags';
@@ -15,6 +17,7 @@ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
15
17
  import { pluginKey } from './pm-plugins/plugin-key';
16
18
  import { createResizingPlugin } from './pm-plugins/resizing-plugin';
17
19
  import { findSupportedNodeForBreakout } from './pm-plugins/utils/find-breakout-node';
20
+ import { getBreakoutMode } from './pm-plugins/utils/get-breakout-mode';
18
21
  import LayoutButton from './ui/LayoutButton';
19
22
  var BreakoutView = /*#__PURE__*/_createClass(function BreakoutView(
20
23
  /**
@@ -119,13 +122,12 @@ var useOldHook = function useOldHook(api) {
119
122
  };
120
123
  };
121
124
  var useNewHook = function useNewHook(api) {
122
- var breakoutNode = useSharedPluginStateSelector(api, 'breakout.breakoutNode');
123
125
  var isDragging = useSharedPluginStateSelector(api, 'blockControls.isDragging');
124
126
  var isPMDragging = useSharedPluginStateSelector(api, 'blockControls.isPMDragging');
125
127
  var mode = useSharedPluginStateSelector(api, 'editorViewMode.mode');
126
128
  var editorDisabled = useSharedPluginStateSelector(api, 'editorDisabled.editorDisabled');
127
129
  return {
128
- breakoutNode: breakoutNode,
130
+ breakoutNode: undefined,
129
131
  isDragging: isDragging,
130
132
  isPMDragging: isPMDragging,
131
133
  mode: mode,
@@ -146,6 +148,27 @@ var LayoutButtonWrapper = function LayoutButtonWrapper(_ref2) {
146
148
  isPMDragging = _useSharedState.isPMDragging,
147
149
  mode = _useSharedState.mode,
148
150
  editorDisabled = _useSharedState.editorDisabled;
151
+ var _useState = useState(false),
152
+ _useState2 = _slicedToArray(_useState, 2),
153
+ breakoutNodePresent = _useState2[0],
154
+ setBreakoutNodePresent = _useState2[1];
155
+ var _useState3 = useState(getBreakoutMode(editorView.state)),
156
+ _useState4 = _slicedToArray(_useState3, 2),
157
+ breakoutMode = _useState4[0],
158
+ setBreakoutMode = _useState4[1];
159
+ usePluginStateEffect(api, ['breakout'], function (_ref3) {
160
+ var breakoutState = _ref3.breakoutState;
161
+ if (breakoutState !== null && breakoutState !== void 0 && breakoutState.breakoutNode && !breakoutNodePresent) {
162
+ setBreakoutNodePresent(true);
163
+ }
164
+ if (!(breakoutState !== null && breakoutState !== void 0 && breakoutState.breakoutNode) && breakoutNodePresent) {
165
+ setBreakoutNodePresent(false);
166
+ }
167
+ var nextBreakoutMode = getBreakoutMode(editorView.state);
168
+ if (nextBreakoutMode !== breakoutMode) {
169
+ setBreakoutMode(nextBreakoutMode);
170
+ }
171
+ });
149
172
  var interactionState = useSharedPluginStateSelector(api, 'interaction.interactionState');
150
173
  if (interactionState === 'hasNotHadInteraction' && fg('platform_editor_hide_expand_selection_states')) {
151
174
  return null;
@@ -163,12 +186,14 @@ var LayoutButtonWrapper = function LayoutButtonWrapper(_ref2) {
163
186
  boundariesElement: boundariesElement,
164
187
  scrollableElement: scrollableElement,
165
188
  node: (_breakoutNode$node = breakoutNode === null || breakoutNode === void 0 ? void 0 : breakoutNode.node) !== null && _breakoutNode$node !== void 0 ? _breakoutNode$node : null,
166
- isLivePage: isEditMode
189
+ isLivePage: isEditMode,
190
+ isBreakoutNodePresent: breakoutNodePresent,
191
+ breakoutMode: breakoutMode
167
192
  }) : null;
168
193
  };
169
- export var breakoutPlugin = function breakoutPlugin(_ref3) {
170
- var options = _ref3.config,
171
- api = _ref3.api;
194
+ export var breakoutPlugin = function breakoutPlugin(_ref4) {
195
+ var options = _ref4.config,
196
+ api = _ref4.api;
172
197
  return {
173
198
  name: 'breakout',
174
199
  pmPlugins: function pmPlugins() {
@@ -207,11 +232,11 @@ export var breakoutPlugin = function breakoutPlugin(_ref3) {
207
232
  }
208
233
  return pluginState;
209
234
  },
210
- contentComponent: function contentComponent(_ref4) {
211
- var editorView = _ref4.editorView,
212
- popupsMountPoint = _ref4.popupsMountPoint,
213
- popupsBoundariesElement = _ref4.popupsBoundariesElement,
214
- popupsScrollableElement = _ref4.popupsScrollableElement;
235
+ contentComponent: function contentComponent(_ref5) {
236
+ var editorView = _ref5.editorView,
237
+ popupsMountPoint = _ref5.popupsMountPoint,
238
+ popupsBoundariesElement = _ref5.popupsBoundariesElement,
239
+ popupsScrollableElement = _ref5.popupsScrollableElement;
215
240
  // This is a bit crappy, but should be resolved once we move to a static schema.
216
241
  if (options && !options.allowBreakoutButton) {
217
242
  return null;
@@ -1,4 +1,5 @@
1
- // TODO: ED-28029 - add fixes for expands and codeblocks
1
+ import { transferCodeBlockWrappedValue } from '@atlaskit/editor-common/code-block';
2
+ import { updateExpandedStateNew } from '../pm-plugins/utils/single-player-expand';
2
3
  export function setBreakoutWidth(width, mode, pos, isLivePage) {
3
4
  return function (state, dispatch) {
4
5
  var node = state.doc.nodeAt(pos);
@@ -9,6 +10,20 @@ export function setBreakoutWidth(width, mode, pos, isLivePage) {
9
10
  width: width,
10
11
  mode: mode
11
12
  })]);
13
+ if (node.type === state.schema.nodes.expand) {
14
+ updateExpandedStateNew({
15
+ tr: tr,
16
+ node: node,
17
+ pos: pos,
18
+ isLivePage: isLivePage
19
+ });
20
+ } else if (node.type === state.schema.nodes.codeBlock) {
21
+ var newNode = tr.doc.nodeAt(pos);
22
+ var oldNode = node;
23
+ if (newNode) {
24
+ transferCodeBlockWrappedValue(oldNode, newNode);
25
+ }
26
+ }
12
27
  if (dispatch) {
13
28
  dispatch(tr);
14
29
  }
@@ -1,6 +1,9 @@
1
1
  import { resizerHandleThumbWidth } from '@atlaskit/editor-common/styles';
2
- import { akEditorGutterPaddingDynamic, akEditorGutterPadding, akEditorCalculatedWideLayoutWidth } from '@atlaskit/editor-shared-styles';
3
- import { WIDTHS } from './resizer-callbacks';
2
+ import { akEditorGutterPaddingDynamic, akEditorGutterPadding, akEditorCalculatedWideLayoutWidth, akEditorFullWidthLayoutWidth, akEditorDefaultLayoutWidth } from '@atlaskit/editor-shared-styles';
3
+ var WIDTHS = {
4
+ MIN: akEditorDefaultLayoutWidth,
5
+ MAX: akEditorFullWidthLayoutWidth
6
+ };
4
7
  var GUIDELINE_KEYS = {
5
8
  lineLength: 'grid',
6
9
  wide: 'wide',
@@ -0,0 +1,54 @@
1
+ import { draggable } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
2
+ import { disableNativeDragPreview } from '@atlaskit/pragmatic-drag-and-drop/element/disable-native-drag-preview';
3
+ import { preventUnhandled } from '@atlaskit/pragmatic-drag-and-drop/prevent-unhandled';
4
+ export var createPragmaticResizer = function createPragmaticResizer(_ref) {
5
+ var onDragStart = _ref.onDragStart,
6
+ onDrag = _ref.onDrag,
7
+ _onDrop = _ref.onDrop;
8
+ var registerHandle = function registerHandle(handleElement) {
9
+ return draggable({
10
+ element: handleElement,
11
+ onGenerateDragPreview: function onGenerateDragPreview(_ref2) {
12
+ var nativeSetDragImage = _ref2.nativeSetDragImage;
13
+ disableNativeDragPreview({
14
+ nativeSetDragImage: nativeSetDragImage
15
+ });
16
+ preventUnhandled.start();
17
+ },
18
+ onDragStart: onDragStart,
19
+ onDrag: onDrag,
20
+ onDrop: function onDrop(args) {
21
+ preventUnhandled.stop();
22
+ _onDrop(args);
23
+ }
24
+ });
25
+ };
26
+ var createHandle = function createHandle(side) {
27
+ var handle = document.createElement('div');
28
+ handle.contentEditable = 'false';
29
+ handle.classList.add('pm-breakout-resize-handle');
30
+ if (side === 'left') {
31
+ handle.classList.add('pm-breakout-resize-handle-left');
32
+ handle.setAttribute('data-testid', 'pragmatic-resizer-handle-left');
33
+ } else {
34
+ handle.classList.add('pm-breakout-resize-handle-right');
35
+ handle.setAttribute('data-testid', 'pragmatic-resizer-handle-right');
36
+ }
37
+ var handleInner = document.createElement('div');
38
+ handleInner.classList.add('pm-breakout-resize-handle-inner');
39
+ handle.appendChild(handleInner);
40
+ return handle;
41
+ };
42
+ var rightHandle = createHandle('right');
43
+ var leftHandle = createHandle('left');
44
+ var rightHandleCleanup = registerHandle(rightHandle);
45
+ var leftHandleCleanup = registerHandle(leftHandle);
46
+ return {
47
+ rightHandle: rightHandle,
48
+ leftHandle: leftHandle,
49
+ destroy: function destroy() {
50
+ rightHandleCleanup();
51
+ leftHandleCleanup();
52
+ }
53
+ };
54
+ };
@@ -1,13 +1,13 @@
1
- import { akEditorGutterPaddingDynamic, akEditorGutterPadding } from '@atlaskit/editor-shared-styles';
1
+ import { akEditorGutterPaddingDynamic, akEditorGutterPadding, akEditorDefaultLayoutWidth, akEditorFullWidthLayoutWidth } from '@atlaskit/editor-shared-styles';
2
2
  import { setBreakoutWidth } from '../editor-commands/set-breakout-width';
3
3
  import { getGuidelines } from './get-guidelines';
4
4
  import { LOCAL_RESIZE_PROPERTY } from './resizing-mark-view';
5
5
  var RESIZE_RATIO = 2;
6
- export var WIDTHS = {
7
- MIN: 760,
8
- MAX: 1800
6
+ var WIDTHS = {
7
+ MIN: akEditorDefaultLayoutWidth,
8
+ MAX: akEditorFullWidthLayoutWidth
9
9
  };
10
- function getProposedWidth(_ref) {
10
+ export function getProposedWidth(_ref) {
11
11
  var _api$width$sharedStat;
12
12
  var initialWidth = _ref.initialWidth,
13
13
  location = _ref.location,
@@ -1,15 +1,9 @@
1
1
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
2
  import _createClass from "@babel/runtime/helpers/createClass";
3
3
  import { BreakoutCssClassName } from '@atlaskit/editor-common/styles';
4
- import { draggable } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
5
- import { disableNativeDragPreview } from '@atlaskit/pragmatic-drag-and-drop/element/disable-native-drag-preview';
6
- import { preventUnhandled } from '@atlaskit/pragmatic-drag-and-drop/prevent-unhandled';
4
+ import { createPragmaticResizer } from './pragmatic-resizer';
7
5
  import { createResizerCallbacks } from './resizer-callbacks';
8
6
  export var LOCAL_RESIZE_PROPERTY = '--local-resizing-width';
9
-
10
- /**
11
- *
12
- */
13
7
  export var ResizingMarkView = /*#__PURE__*/function () {
14
8
  /**
15
9
  * Wrap node view in a resizing mark view
@@ -67,74 +61,15 @@ export var ResizingMarkView = /*#__PURE__*/function () {
67
61
  this.mark = mark;
68
62
  this.destroyFn = destroy;
69
63
  }
70
-
71
- /**
72
- *
73
- * @example
74
- */
75
64
  return _createClass(ResizingMarkView, [{
76
65
  key: "ignoreMutation",
77
66
  value: function ignoreMutation() {
78
67
  return true;
79
68
  }
80
-
81
- /**
82
- *
83
- * @example
84
- */
85
69
  }, {
86
70
  key: "destroy",
87
71
  value: function destroy() {
88
72
  this.destroyFn();
89
73
  }
90
74
  }]);
91
- }();
92
- var createPragmaticResizer = function createPragmaticResizer(_ref) {
93
- var onDragStart = _ref.onDragStart,
94
- onDrag = _ref.onDrag,
95
- _onDrop = _ref.onDrop;
96
- var registerHandle = function registerHandle(handleElement) {
97
- return draggable({
98
- element: handleElement,
99
- onGenerateDragPreview: function onGenerateDragPreview(_ref2) {
100
- var nativeSetDragImage = _ref2.nativeSetDragImage;
101
- disableNativeDragPreview({
102
- nativeSetDragImage: nativeSetDragImage
103
- });
104
- preventUnhandled.start();
105
- },
106
- onDragStart: onDragStart,
107
- onDrag: onDrag,
108
- onDrop: function onDrop(args) {
109
- preventUnhandled.stop();
110
- _onDrop(args);
111
- }
112
- });
113
- };
114
- var createHandle = function createHandle(side) {
115
- var handle = document.createElement('div');
116
- handle.contentEditable = 'false';
117
- handle.classList.add('pm-breakout-resize-handle');
118
- if (side === 'left') {
119
- handle.classList.add('pm-breakout-resize-handle-left');
120
- } else {
121
- handle.classList.add('pm-breakout-resize-handle-right');
122
- }
123
- var handleInner = document.createElement('div');
124
- handleInner.classList.add('pm-breakout-resize-handle-inner');
125
- handle.appendChild(handleInner);
126
- return handle;
127
- };
128
- var rightHandle = createHandle('right');
129
- var leftHandle = createHandle('left');
130
- var rightHandleCleanup = registerHandle(rightHandle);
131
- var leftHandleCleanup = registerHandle(leftHandle);
132
- return {
133
- rightHandle: rightHandle,
134
- leftHandle: leftHandle,
135
- destroy: function destroy() {
136
- rightHandleCleanup();
137
- leftHandleCleanup();
138
- }
139
- };
140
- };
75
+ }();
@@ -1,11 +1,34 @@
1
1
  import { expandedState } from '@atlaskit/editor-common/expand';
2
2
  import { fg } from '@atlaskit/platform-feature-flags';
3
- export var updateExpandedState = function updateExpandedState(tr, node, isLivePage) {
3
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
4
+ export var updateExpandedStateNew = function updateExpandedStateNew(_ref) {
5
+ var tr = _ref.tr,
6
+ node = _ref.node,
7
+ pos = _ref.pos,
8
+ isLivePage = _ref.isLivePage;
4
9
  if (isLivePage || fg('platform-editor-single-player-expand')) {
5
- var wasExpandExpanded = expandedState.get(node.node);
6
- var newExpand = tr.doc.nodeAt(node.pos);
10
+ var wasExpandExpanded = expandedState.get(node);
11
+ var newExpand = tr.doc.nodeAt(pos);
7
12
  if (wasExpandExpanded !== undefined && newExpand) {
8
13
  expandedState.set(newExpand, wasExpandExpanded);
9
14
  }
10
15
  }
16
+ };
17
+ export var updateExpandedState = function updateExpandedState(tr, node, isLivePage) {
18
+ if (editorExperiment('platform_editor_breakout_resizing', true)) {
19
+ updateExpandedStateNew({
20
+ tr: tr,
21
+ node: node.node,
22
+ pos: node.pos,
23
+ isLivePage: isLivePage
24
+ });
25
+ } else {
26
+ if (isLivePage || fg('platform-editor-single-player-expand')) {
27
+ var wasExpandExpanded = expandedState.get(node.node);
28
+ var newExpand = tr.doc.nodeAt(node.pos);
29
+ if (wasExpandExpanded !== undefined && newExpand) {
30
+ expandedState.set(newExpand, wasExpandExpanded);
31
+ }
32
+ }
33
+ }
11
34
  };
@@ -19,6 +19,7 @@ import CollapseIcon from '@atlaskit/icon/glyph/editor/collapse';
19
19
  import ExpandIcon from '@atlaskit/icon/glyph/editor/expand';
20
20
  import { B300, N20A, N300 } from '@atlaskit/theme/colors';
21
21
  import { layers } from '@atlaskit/theme/constants';
22
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
22
23
  import { removeBreakout } from '../editor-commands/remove-breakout';
23
24
  import { setBreakoutMode } from '../editor-commands/set-breakout-mode';
24
25
  import { getPluginState } from '../pm-plugins/plugin-key';
@@ -58,7 +59,9 @@ var LayoutButton = function LayoutButton(_ref) {
58
59
  scrollableElement = _ref.scrollableElement,
59
60
  editorView = _ref.editorView,
60
61
  node = _ref.node,
61
- isLivePage = _ref.isLivePage;
62
+ isLivePage = _ref.isLivePage,
63
+ isBreakoutNodePresent = _ref.isBreakoutNodePresent,
64
+ breakoutModeProp = _ref.breakoutMode;
62
65
  var handleClick = useCallback(function (breakoutMode) {
63
66
  var state = editorView.state,
64
67
  dispatch = editorView.dispatch;
@@ -69,10 +72,11 @@ var LayoutButton = function LayoutButton(_ref) {
69
72
  }
70
73
  }, [editorView, isLivePage]);
71
74
  var state = editorView.state;
72
- if (!node || !isBreakoutMarkAllowed(state)) {
75
+ var exitCondition = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? !isBreakoutNodePresent : !node;
76
+ if (exitCondition || !isBreakoutMarkAllowed(state)) {
73
77
  return null;
74
78
  }
75
- var breakoutMode = getBreakoutMode(editorView.state);
79
+ var breakoutMode = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? breakoutModeProp : getBreakoutMode(editorView.state);
76
80
  var titleMessage = getTitle(breakoutMode);
77
81
  var title = formatMessage(titleMessage);
78
82
  var nextBreakoutMode = getNextBreakoutMode(breakoutMode);
@@ -0,0 +1,10 @@
1
+ import type { BaseEventPayload, ElementDragType } from '@atlaskit/pragmatic-drag-and-drop/types';
2
+ export declare const createPragmaticResizer: ({ onDragStart, onDrag, onDrop, }: {
3
+ onDragStart: () => void;
4
+ onDrag: (args: BaseEventPayload<ElementDragType>) => void;
5
+ onDrop: (args: BaseEventPayload<ElementDragType>) => void;
6
+ }) => {
7
+ rightHandle: HTMLDivElement;
8
+ leftHandle: HTMLDivElement;
9
+ destroy: () => void;
10
+ };
@@ -1,12 +1,13 @@
1
1
  import { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
2
2
  import { Mark } from '@atlaskit/editor-prosemirror/model';
3
3
  import { EditorView } from '@atlaskit/editor-prosemirror/view';
4
- import { BaseEventPayload, ElementDragType } from '@atlaskit/pragmatic-drag-and-drop/types';
4
+ import { BaseEventPayload, DragLocationHistory, ElementDragType } from '@atlaskit/pragmatic-drag-and-drop/types';
5
5
  import { BreakoutPlugin } from '../breakoutPluginType';
6
- export declare const WIDTHS: {
7
- MIN: number;
8
- MAX: number;
9
- };
6
+ export declare function getProposedWidth({ initialWidth, location, api, }: {
7
+ initialWidth: number;
8
+ location: DragLocationHistory;
9
+ api: ExtractInjectionAPI<BreakoutPlugin> | undefined;
10
+ }): number;
10
11
  export declare function createResizerCallbacks({ dom, contentDOM, view, mark, api, }: {
11
12
  dom: HTMLElement;
12
13
  contentDOM: HTMLElement;
@@ -3,9 +3,6 @@ import type { Mark } from '@atlaskit/editor-prosemirror/model';
3
3
  import type { EditorView, NodeView } from '@atlaskit/editor-prosemirror/view';
4
4
  import { BreakoutPlugin } from '../breakoutPluginType';
5
5
  export declare const LOCAL_RESIZE_PROPERTY = "--local-resizing-width";
6
- /**
7
- *
8
- */
9
6
  export declare class ResizingMarkView implements NodeView {
10
7
  dom: HTMLElement;
11
8
  contentDOM: HTMLElement;
@@ -22,14 +19,6 @@ export declare class ResizingMarkView implements NodeView {
22
19
  * ```
23
20
  */
24
21
  constructor(mark: Mark, view: EditorView, api: ExtractInjectionAPI<BreakoutPlugin> | undefined);
25
- /**
26
- *
27
- * @example
28
- */
29
22
  ignoreMutation(): boolean;
30
- /**
31
- *
32
- * @example
33
- */
34
23
  destroy(): void;
35
24
  }
@@ -1,3 +1,12 @@
1
+ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
1
2
  import type { Transaction } from '@atlaskit/editor-prosemirror/state';
2
3
  import type { ContentNodeWithPos } from '@atlaskit/editor-prosemirror/utils';
4
+ interface UpdateExpandedStateNew {
5
+ tr: Transaction;
6
+ node: PMNode;
7
+ pos: number;
8
+ isLivePage?: boolean;
9
+ }
10
+ export declare const updateExpandedStateNew: ({ tr, node, pos, isLivePage }: UpdateExpandedStateNew) => void;
3
11
  export declare const updateExpandedState: (tr: Transaction, node: ContentNodeWithPos, isLivePage?: boolean) => void;
12
+ export {};
@@ -1,5 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import type { WrappedComponentProps } from 'react-intl-next';
3
+ import type { BreakoutMode } from '@atlaskit/editor-common/types';
3
4
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
4
5
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
5
6
  export interface Props {
@@ -10,6 +11,8 @@ export interface Props {
10
11
  scrollableElement?: HTMLElement;
11
12
  handleClick?: Function;
12
13
  isLivePage?: boolean;
14
+ isBreakoutNodePresent: boolean;
15
+ breakoutMode: BreakoutMode | undefined;
13
16
  }
14
17
  declare const _default: import("react").FC<import("react-intl-next").WithIntlProps<Props & WrappedComponentProps>> & {
15
18
  WrappedComponent: import("react").ComponentType<Props & WrappedComponentProps>;
@@ -0,0 +1,10 @@
1
+ import type { BaseEventPayload, ElementDragType } from '@atlaskit/pragmatic-drag-and-drop/types';
2
+ export declare const createPragmaticResizer: ({ onDragStart, onDrag, onDrop, }: {
3
+ onDragStart: () => void;
4
+ onDrag: (args: BaseEventPayload<ElementDragType>) => void;
5
+ onDrop: (args: BaseEventPayload<ElementDragType>) => void;
6
+ }) => {
7
+ rightHandle: HTMLDivElement;
8
+ leftHandle: HTMLDivElement;
9
+ destroy: () => void;
10
+ };
@@ -1,12 +1,13 @@
1
1
  import { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
2
2
  import { Mark } from '@atlaskit/editor-prosemirror/model';
3
3
  import { EditorView } from '@atlaskit/editor-prosemirror/view';
4
- import { BaseEventPayload, ElementDragType } from '@atlaskit/pragmatic-drag-and-drop/types';
4
+ import { BaseEventPayload, DragLocationHistory, ElementDragType } from '@atlaskit/pragmatic-drag-and-drop/types';
5
5
  import { BreakoutPlugin } from '../breakoutPluginType';
6
- export declare const WIDTHS: {
7
- MIN: number;
8
- MAX: number;
9
- };
6
+ export declare function getProposedWidth({ initialWidth, location, api, }: {
7
+ initialWidth: number;
8
+ location: DragLocationHistory;
9
+ api: ExtractInjectionAPI<BreakoutPlugin> | undefined;
10
+ }): number;
10
11
  export declare function createResizerCallbacks({ dom, contentDOM, view, mark, api, }: {
11
12
  dom: HTMLElement;
12
13
  contentDOM: HTMLElement;