@atlaskit/editor-plugin-breakout 2.2.5 → 2.3.0

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 (27) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/cjs/breakoutPlugin.js +2 -2
  3. package/dist/cjs/editor-commands/set-breakout-width.js +23 -0
  4. package/dist/cjs/pm-plugins/resizer-callbacks.js +77 -0
  5. package/dist/cjs/pm-plugins/resizing-mark-view.js +16 -11
  6. package/dist/cjs/pm-plugins/resizing-plugin.js +94 -2
  7. package/dist/es2019/breakoutPlugin.js +2 -2
  8. package/dist/es2019/editor-commands/set-breakout-width.js +17 -0
  9. package/dist/es2019/pm-plugins/resizer-callbacks.js +75 -0
  10. package/dist/es2019/pm-plugins/resizing-mark-view.js +15 -10
  11. package/dist/es2019/pm-plugins/resizing-plugin.js +97 -2
  12. package/dist/esm/breakoutPlugin.js +2 -2
  13. package/dist/esm/editor-commands/set-breakout-width.js +17 -0
  14. package/dist/esm/pm-plugins/resizer-callbacks.js +71 -0
  15. package/dist/esm/pm-plugins/resizing-mark-view.js +15 -10
  16. package/dist/esm/pm-plugins/resizing-plugin.js +94 -2
  17. package/dist/types/breakoutPluginType.d.ts +3 -1
  18. package/dist/types/editor-commands/set-breakout-width.d.ts +2 -0
  19. package/dist/types/pm-plugins/resizer-callbacks.d.ts +16 -0
  20. package/dist/types/pm-plugins/resizing-mark-view.d.ts +5 -1
  21. package/dist/types/pm-plugins/resizing-plugin.d.ts +4 -1
  22. package/dist/types-ts4.5/breakoutPluginType.d.ts +3 -1
  23. package/dist/types-ts4.5/editor-commands/set-breakout-width.d.ts +2 -0
  24. package/dist/types-ts4.5/pm-plugins/resizer-callbacks.d.ts +16 -0
  25. package/dist/types-ts4.5/pm-plugins/resizing-mark-view.d.ts +5 -1
  26. package/dist/types-ts4.5/pm-plugins/resizing-plugin.d.ts +4 -1
  27. package/package.json +3 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,32 @@
1
1
  # @atlaskit/editor-plugin-breakout
2
2
 
3
+ ## 2.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#158239](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/158239)
8
+ [`c2caa0af876e0`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/c2caa0af876e0) -
9
+ [ux] ED-28028 add breakout mark to expands, codeblocks and layouts for new resizing experience
10
+ behind the platform_editor_breakout_resizing experiment
11
+
12
+ ### Patch Changes
13
+
14
+ - [#159213](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/159213)
15
+ [`75e3b93e94f8c`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/75e3b93e94f8c) -
16
+ [ED-28069] this change is retaining the breakout mode when setting the breakout width when using
17
+ the new resizing experience behind the platform_editor_breakout_resizing experiment.
18
+ - Updated dependencies
19
+
20
+ ## 2.2.6
21
+
22
+ ### Patch Changes
23
+
24
+ - [#157540](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/157540)
25
+ [`16b7448512972`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/16b7448512972) -
26
+ [ux] [ED-28038] this change adds the drag callbacks to the new resizing experience behind the
27
+ platform_editor_breakout_resizing experiment.
28
+ - Updated dependencies
29
+
3
30
  ## 2.2.5
4
31
 
5
32
  ### Patch Changes
@@ -74,7 +74,7 @@ function shouldPluginStateUpdate(newBreakoutNode, currentBreakoutNode) {
74
74
  }
75
75
  return newBreakoutNode || currentBreakoutNode ? true : false;
76
76
  }
77
- function createPlugin(pluginInjectionApi, _ref) {
77
+ function createPlugin(api, _ref) {
78
78
  var dispatch = _ref.dispatch;
79
79
  return new _safePlugin.SafePlugin({
80
80
  state: {
@@ -178,7 +178,7 @@ var breakoutPlugin = exports.breakoutPlugin = function breakoutPlugin(_ref3) {
178
178
  return [{
179
179
  name: 'breakout-resizing',
180
180
  plugin: function plugin() {
181
- return (0, _resizingPlugin.createResizingPlugin)();
181
+ return (0, _resizingPlugin.createResizingPlugin)(api, options);
182
182
  }
183
183
  }];
184
184
  }
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.setBreakoutWidth = setBreakoutWidth;
7
+ // TODO: ED-28029 - add fixes for expands and codeblocks
8
+ function setBreakoutWidth(width, mode, pos, isLivePage) {
9
+ return function (state, dispatch) {
10
+ var node = state.doc.nodeAt(pos);
11
+ if (!node) {
12
+ return false;
13
+ }
14
+ var tr = state.tr.setNodeMarkup(pos, node.type, node.attrs, [state.schema.marks.breakout.create({
15
+ width: width,
16
+ mode: mode
17
+ })]);
18
+ if (dispatch) {
19
+ dispatch(tr);
20
+ }
21
+ return true;
22
+ };
23
+ }
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createResizerCallbacks = createResizerCallbacks;
7
+ var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
8
+ var _preventUnhandled = require("@atlaskit/pragmatic-drag-and-drop/prevent-unhandled");
9
+ var _setBreakoutWidth = require("../editor-commands/set-breakout-width");
10
+ var _resizingMarkView = require("./resizing-mark-view");
11
+ var RESIZE_RATIO = 2;
12
+ var WIDTHS = {
13
+ MIN: 760,
14
+ MAX: 1800
15
+ };
16
+ function getProposedWidth(_ref) {
17
+ var _api$width$sharedStat;
18
+ var initialWidth = _ref.initialWidth,
19
+ location = _ref.location,
20
+ api = _ref.api;
21
+ var diffX = (location.current.input.clientX - location.initial.input.clientX) * RESIZE_RATIO;
22
+ var proposedWidth = initialWidth + diffX;
23
+
24
+ // TODO: ED-28024 - add snapping logic
25
+
26
+ var containerWidth = ((api === null || api === void 0 || (_api$width$sharedStat = api.width.sharedState) === null || _api$width$sharedStat === void 0 || (_api$width$sharedStat = _api$width$sharedStat.currentState()) === null || _api$width$sharedStat === void 0 ? void 0 : _api$width$sharedStat.width) || 0) - 2 * (0, _editorSharedStyles.akEditorGutterPaddingDynamic)() - _editorSharedStyles.akEditorGutterPadding;
27
+ return Math.min(Math.max(WIDTHS.MIN, Math.min(proposedWidth, containerWidth)), WIDTHS.MAX);
28
+ }
29
+ ;
30
+ function createResizerCallbacks(_ref2) {
31
+ var dom = _ref2.dom,
32
+ contentDOM = _ref2.contentDOM,
33
+ view = _ref2.view,
34
+ mark = _ref2.mark,
35
+ api = _ref2.api;
36
+ return {
37
+ onDragStart: function onDragStart() {
38
+ requestAnimationFrame(function () {
39
+ var _api$userIntent;
40
+ // TODO: ED-28027 - add guidelines
41
+ api === null || api === void 0 || api.core.actions.execute((_api$userIntent = api.userIntent) === null || _api$userIntent === void 0 ? void 0 : _api$userIntent.commands.setCurrentUserIntent('dragging'));
42
+ });
43
+ view.dispatch(view.state.tr.setMeta('is-resizer-resizing', true));
44
+ },
45
+ onDrag: function onDrag(_ref3) {
46
+ var location = _ref3.location;
47
+ var initialWidth = mark.attrs.width;
48
+ var newWidth = getProposedWidth({
49
+ initialWidth: initialWidth,
50
+ location: location,
51
+ api: api
52
+ });
53
+ contentDOM.style.setProperty(_resizingMarkView.LOCAL_RESIZE_PROPERTY, "".concat(newWidth, "px"));
54
+ },
55
+ onDrop: function onDrop(_ref4) {
56
+ var _api$userIntent2;
57
+ var location = _ref4.location;
58
+ // TODO: ED-28027 - remove guidelines
59
+ _preventUnhandled.preventUnhandled.stop();
60
+ var pos = view.posAtDOM(dom, 0);
61
+ if (pos === undefined) {
62
+ return;
63
+ }
64
+ var mode = mark.attrs.mode;
65
+ var initialWidth = mark.attrs.width;
66
+ var newWidth = getProposedWidth({
67
+ initialWidth: initialWidth,
68
+ location: location,
69
+ api: api
70
+ });
71
+ (0, _setBreakoutWidth.setBreakoutWidth)(newWidth, mode, pos)(view.state, view.dispatch);
72
+ contentDOM.style.removeProperty(_resizingMarkView.LOCAL_RESIZE_PROPERTY);
73
+ view.dispatch(view.state.tr.setMeta('is-resizer-resizing', false).setMeta('scrollIntoView', false));
74
+ api === null || api === void 0 || api.core.actions.execute((_api$userIntent2 = api.userIntent) === null || _api$userIntent2 === void 0 ? void 0 : _api$userIntent2.commands.setCurrentUserIntent('default'));
75
+ }
76
+ };
77
+ }
@@ -4,14 +4,15 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.ResizingMarkView = void 0;
7
+ exports.ResizingMarkView = exports.LOCAL_RESIZE_PROPERTY = void 0;
8
8
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
9
9
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
10
  var _styles = require("@atlaskit/editor-common/styles");
11
11
  var _adapter = require("@atlaskit/pragmatic-drag-and-drop/element/adapter");
12
12
  var _disableNativeDragPreview = require("@atlaskit/pragmatic-drag-and-drop/element/disable-native-drag-preview");
13
13
  var _preventUnhandled = require("@atlaskit/pragmatic-drag-and-drop/prevent-unhandled");
14
- var localResizeProperty = '--local-resizing-width';
14
+ var _resizerCallbacks = require("./resizer-callbacks");
15
+ var LOCAL_RESIZE_PROPERTY = exports.LOCAL_RESIZE_PROPERTY = '--local-resizing-width';
15
16
 
16
17
  /**
17
18
  *
@@ -21,11 +22,12 @@ var ResizingMarkView = exports.ResizingMarkView = /*#__PURE__*/function () {
21
22
  * Wrap node view in a resizing mark view
22
23
  * @param {Mark} mark - The breakout mark to resize
23
24
  * @param {EditorView} view - The editor view
25
+ * @param {ExtractInjectionAPI<BreakoutPlugin> | undefined} api - the pluginInjectionAPI
24
26
  * @example
25
27
  * ```ts
26
28
  * ```
27
29
  */
28
- function ResizingMarkView(mark, view) {
30
+ function ResizingMarkView(mark, view, api) {
29
31
  (0, _classCallCheck2.default)(this, ResizingMarkView);
30
32
  var dom = document.createElement('div');
31
33
  var contentDOM = document.createElement('div');
@@ -44,21 +46,24 @@ var ResizingMarkView = exports.ResizingMarkView = /*#__PURE__*/function () {
44
46
  contentDOM.style.gridRow = '1';
45
47
  contentDOM.style.gridColumn = '1';
46
48
  if (mark.attrs.width) {
47
- contentDOM.style.minWidth = "min(var(".concat(localResizeProperty, ", ").concat(mark.attrs.width, "px), calc(100cqw - var(--ak-editor--breakout-full-page-guttering-padding)))");
49
+ contentDOM.style.minWidth = "min(var(".concat(LOCAL_RESIZE_PROPERTY, ", ").concat(mark.attrs.width, "px), calc(100cqw - var(--ak-editor--breakout-full-page-guttering-padding)))");
48
50
  } else {
49
51
  if (mark.attrs.mode === 'wide') {
50
- contentDOM.style.minWidth = "max(var(--ak-editor--line-length), min(var(".concat(localResizeProperty, ", var(--ak-editor--breakout-wide-layout-width)), calc(100cqw - var(--ak-editor--breakout-full-page-guttering-padding))))");
52
+ contentDOM.style.minWidth = "max(var(--ak-editor--line-length), min(var(".concat(LOCAL_RESIZE_PROPERTY, ", var(--ak-editor--breakout-wide-layout-width)), calc(100cqw - var(--ak-editor--breakout-full-page-guttering-padding))))");
51
53
  }
52
54
  if (mark.attrs.mode === 'full-width') {
53
- contentDOM.style.minWidth = "max(var(--ak-editor--line-length), min(var(".concat(localResizeProperty, ", var(--ak-editor--full-width-layout-width)), calc(100cqw - var(--ak-editor--breakout-full-page-guttering-padding))))");
55
+ contentDOM.style.minWidth = "max(var(--ak-editor--line-length), min(var(".concat(LOCAL_RESIZE_PROPERTY, ", var(--ak-editor--full-width-layout-width)), calc(100cqw - var(--ak-editor--breakout-full-page-guttering-padding))))");
54
56
  }
55
57
  }
56
58
  dom.appendChild(contentDOM);
57
- var _createPragmaticResiz = createPragmaticResizer({
58
- onDragStart: function onDragStart() {},
59
- onDrag: function onDrag() {},
60
- onDrop: function onDrop() {}
61
- }),
59
+ var callbacks = (0, _resizerCallbacks.createResizerCallbacks)({
60
+ dom: dom,
61
+ contentDOM: contentDOM,
62
+ view: view,
63
+ mark: mark,
64
+ api: api
65
+ });
66
+ var _createPragmaticResiz = createPragmaticResizer(callbacks),
62
67
  leftHandle = _createPragmaticResiz.leftHandle,
63
68
  rightHandle = _createPragmaticResiz.rightHandle,
64
69
  destroy = _createPragmaticResiz.destroy;
@@ -5,18 +5,110 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.resizingPluginKey = exports.createResizingPlugin = void 0;
7
7
  var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
8
+ var _utils = require("@atlaskit/editor-common/utils");
9
+ var _document = require("@atlaskit/editor-common/utils/document");
8
10
  var _state = require("@atlaskit/editor-prosemirror/state");
11
+ var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
9
12
  var _resizingMarkView = require("./resizing-mark-view");
13
+ var addBreakoutToResizableNode = function addBreakoutToResizableNode(_ref) {
14
+ var node = _ref.node,
15
+ pos = _ref.pos,
16
+ newState = _ref.newState,
17
+ newTr = _ref.newTr,
18
+ breakoutResizableNodes = _ref.breakoutResizableNodes,
19
+ isFullWidthEnabled = _ref.isFullWidthEnabled;
20
+ var updatedDocChanged = false;
21
+ var updatedTr = newTr;
22
+ if (breakoutResizableNodes.has(node.type)) {
23
+ var breakout = newState.schema.marks.breakout;
24
+ var breakoutMark = node.marks.find(function (mark) {
25
+ return mark.type === breakout;
26
+ });
27
+ if (!breakoutMark) {
28
+ var width = isFullWidthEnabled ? _editorSharedStyles.akEditorFullWidthLayoutWidth : _editorSharedStyles.akEditorDefaultLayoutWidth;
29
+ updatedTr = newTr.setNodeMarkup(pos, node.type, node.attrs, [breakout.create({
30
+ width: width
31
+ })]);
32
+ updatedDocChanged = true;
33
+ } else if ((breakoutMark === null || breakoutMark === void 0 ? void 0 : breakoutMark.attrs.width) === null || (breakoutMark === null || breakoutMark === void 0 ? void 0 : breakoutMark.attrs.width) === undefined) {
34
+ var mode = breakoutMark.attrs.mode;
35
+ var newWidth = mode === 'wide' ? _editorSharedStyles.akEditorCalculatedWideLayoutWidth : _editorSharedStyles.akEditorFullWidthLayoutWidth;
36
+ updatedTr = newTr.setNodeMarkup(pos, node.type, node.attrs, [breakout.create({
37
+ width: newWidth,
38
+ mode: mode
39
+ })]);
40
+ updatedDocChanged = true;
41
+ }
42
+ }
43
+ return {
44
+ updatedTr: updatedTr,
45
+ updatedDocChanged: updatedDocChanged
46
+ };
47
+ };
10
48
  var resizingPluginKey = exports.resizingPluginKey = new _state.PluginKey('breakout-resizing');
11
- var createResizingPlugin = exports.createResizingPlugin = function createResizingPlugin() {
49
+ var createResizingPlugin = exports.createResizingPlugin = function createResizingPlugin(api, options) {
12
50
  return new _safePlugin.SafePlugin({
13
51
  key: resizingPluginKey,
14
52
  props: {
15
53
  markViews: {
16
54
  breakout: function breakout(mark, view) {
17
- return new _resizingMarkView.ResizingMarkView(mark, view);
55
+ return new _resizingMarkView.ResizingMarkView(mark, view, api);
18
56
  }
19
57
  }
58
+ },
59
+ appendTransaction: function appendTransaction(transactions, oldState, newState) {
60
+ var newTr = newState.tr;
61
+ var hasDocChanged = false;
62
+ var _newState$schema$node = newState.schema.nodes,
63
+ expand = _newState$schema$node.expand,
64
+ codeBlock = _newState$schema$node.codeBlock,
65
+ layoutSection = _newState$schema$node.layoutSection;
66
+ var breakoutResizableNodes = new Set([expand, codeBlock, layoutSection]);
67
+ var isFullWidthEnabled = !((options === null || options === void 0 ? void 0 : options.allowBreakoutButton) === true);
68
+ if ((0, _document.isReplaceDocOperation)(transactions, oldState)) {
69
+ newState.doc.forEach(function (node, pos) {
70
+ var _addBreakoutToResizab = addBreakoutToResizableNode({
71
+ node: node,
72
+ pos: pos,
73
+ newState: newState,
74
+ newTr: newTr,
75
+ breakoutResizableNodes: breakoutResizableNodes,
76
+ isFullWidthEnabled: isFullWidthEnabled
77
+ }),
78
+ updatedTr = _addBreakoutToResizab.updatedTr,
79
+ updatedDocChanged = _addBreakoutToResizab.updatedDocChanged;
80
+ newTr = updatedTr;
81
+ hasDocChanged = hasDocChanged || updatedDocChanged;
82
+ });
83
+ } else {
84
+ transactions.forEach(function (tr) {
85
+ var isAddingResizableNodes = tr.steps.some(function (step) {
86
+ return (0, _utils.stepAddsOneOf)(step, breakoutResizableNodes);
87
+ });
88
+ if (isAddingResizableNodes) {
89
+ var changedNodes = (0, _document.getChangedNodes)(tr);
90
+ changedNodes.forEach(function (_ref2) {
91
+ var node = _ref2.node,
92
+ pos = _ref2.pos;
93
+ var _addBreakoutToResizab2 = addBreakoutToResizableNode({
94
+ node: node,
95
+ pos: pos,
96
+ newState: newState,
97
+ newTr: newTr,
98
+ breakoutResizableNodes: breakoutResizableNodes,
99
+ isFullWidthEnabled: isFullWidthEnabled
100
+ }),
101
+ updatedTr = _addBreakoutToResizab2.updatedTr,
102
+ updatedDocChanged = _addBreakoutToResizab2.updatedDocChanged;
103
+ newTr = updatedTr;
104
+ hasDocChanged = hasDocChanged || updatedDocChanged;
105
+ });
106
+ }
107
+ });
108
+ }
109
+ if (hasDocChanged) {
110
+ return newTr;
111
+ }
20
112
  }
21
113
  });
22
114
  };
@@ -63,7 +63,7 @@ function shouldPluginStateUpdate(newBreakoutNode, currentBreakoutNode) {
63
63
  }
64
64
  return newBreakoutNode || currentBreakoutNode ? true : false;
65
65
  }
66
- function createPlugin(pluginInjectionApi, {
66
+ function createPlugin(api, {
67
67
  dispatch
68
68
  }) {
69
69
  return new SafePlugin({
@@ -171,7 +171,7 @@ export const breakoutPlugin = ({
171
171
  if (editorExperiment('platform_editor_breakout_resizing', true)) {
172
172
  return [{
173
173
  name: 'breakout-resizing',
174
- plugin: () => createResizingPlugin()
174
+ plugin: () => createResizingPlugin(api, options)
175
175
  }];
176
176
  }
177
177
  return [{
@@ -0,0 +1,17 @@
1
+ // TODO: ED-28029 - add fixes for expands and codeblocks
2
+ export function setBreakoutWidth(width, mode, pos, isLivePage) {
3
+ return (state, dispatch) => {
4
+ const node = state.doc.nodeAt(pos);
5
+ if (!node) {
6
+ return false;
7
+ }
8
+ const tr = state.tr.setNodeMarkup(pos, node.type, node.attrs, [state.schema.marks.breakout.create({
9
+ width,
10
+ mode
11
+ })]);
12
+ if (dispatch) {
13
+ dispatch(tr);
14
+ }
15
+ return true;
16
+ };
17
+ }
@@ -0,0 +1,75 @@
1
+ import { akEditorGutterPaddingDynamic, akEditorGutterPadding } from "@atlaskit/editor-shared-styles";
2
+ import { preventUnhandled } from "@atlaskit/pragmatic-drag-and-drop/prevent-unhandled";
3
+ import { setBreakoutWidth } from "../editor-commands/set-breakout-width";
4
+ import { LOCAL_RESIZE_PROPERTY } from "./resizing-mark-view";
5
+ const RESIZE_RATIO = 2;
6
+ const WIDTHS = {
7
+ MIN: 760,
8
+ MAX: 1800
9
+ };
10
+ function getProposedWidth({
11
+ initialWidth,
12
+ location,
13
+ api
14
+ }) {
15
+ var _api$width$sharedStat, _api$width$sharedStat2;
16
+ const diffX = (location.current.input.clientX - location.initial.input.clientX) * RESIZE_RATIO;
17
+ const proposedWidth = initialWidth + diffX;
18
+
19
+ // TODO: ED-28024 - add snapping logic
20
+
21
+ const containerWidth = ((api === null || api === void 0 ? void 0 : (_api$width$sharedStat = api.width.sharedState) === null || _api$width$sharedStat === void 0 ? void 0 : (_api$width$sharedStat2 = _api$width$sharedStat.currentState()) === null || _api$width$sharedStat2 === void 0 ? void 0 : _api$width$sharedStat2.width) || 0) - 2 * akEditorGutterPaddingDynamic() - akEditorGutterPadding;
22
+ return Math.min(Math.max(WIDTHS.MIN, Math.min(proposedWidth, containerWidth)), WIDTHS.MAX);
23
+ }
24
+ ;
25
+ export function createResizerCallbacks({
26
+ dom,
27
+ contentDOM,
28
+ view,
29
+ mark,
30
+ api
31
+ }) {
32
+ return {
33
+ onDragStart: () => {
34
+ requestAnimationFrame(() => {
35
+ var _api$userIntent;
36
+ // TODO: ED-28027 - add guidelines
37
+ api === null || api === void 0 ? void 0 : api.core.actions.execute((_api$userIntent = api.userIntent) === null || _api$userIntent === void 0 ? void 0 : _api$userIntent.commands.setCurrentUserIntent('dragging'));
38
+ });
39
+ view.dispatch(view.state.tr.setMeta('is-resizer-resizing', true));
40
+ },
41
+ onDrag: ({
42
+ location
43
+ }) => {
44
+ const initialWidth = mark.attrs.width;
45
+ const newWidth = getProposedWidth({
46
+ initialWidth,
47
+ location,
48
+ api
49
+ });
50
+ contentDOM.style.setProperty(LOCAL_RESIZE_PROPERTY, `${newWidth}px`);
51
+ },
52
+ onDrop({
53
+ location
54
+ }) {
55
+ var _api$userIntent2;
56
+ // TODO: ED-28027 - remove guidelines
57
+ preventUnhandled.stop();
58
+ const pos = view.posAtDOM(dom, 0);
59
+ if (pos === undefined) {
60
+ return;
61
+ }
62
+ const mode = mark.attrs.mode;
63
+ const initialWidth = mark.attrs.width;
64
+ const newWidth = getProposedWidth({
65
+ initialWidth,
66
+ location,
67
+ api
68
+ });
69
+ setBreakoutWidth(newWidth, mode, pos)(view.state, view.dispatch);
70
+ contentDOM.style.removeProperty(LOCAL_RESIZE_PROPERTY);
71
+ view.dispatch(view.state.tr.setMeta('is-resizer-resizing', false).setMeta('scrollIntoView', false));
72
+ api === null || api === void 0 ? void 0 : api.core.actions.execute((_api$userIntent2 = api.userIntent) === null || _api$userIntent2 === void 0 ? void 0 : _api$userIntent2.commands.setCurrentUserIntent('default'));
73
+ }
74
+ };
75
+ }
@@ -2,7 +2,8 @@ import { BreakoutCssClassName } from '@atlaskit/editor-common/styles';
2
2
  import { draggable } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
3
3
  import { disableNativeDragPreview } from '@atlaskit/pragmatic-drag-and-drop/element/disable-native-drag-preview';
4
4
  import { preventUnhandled } from '@atlaskit/pragmatic-drag-and-drop/prevent-unhandled';
5
- const localResizeProperty = '--local-resizing-width';
5
+ import { createResizerCallbacks } from './resizer-callbacks';
6
+ export const LOCAL_RESIZE_PROPERTY = '--local-resizing-width';
6
7
 
7
8
  /**
8
9
  *
@@ -12,11 +13,12 @@ export class ResizingMarkView {
12
13
  * Wrap node view in a resizing mark view
13
14
  * @param {Mark} mark - The breakout mark to resize
14
15
  * @param {EditorView} view - The editor view
16
+ * @param {ExtractInjectionAPI<BreakoutPlugin> | undefined} api - the pluginInjectionAPI
15
17
  * @example
16
18
  * ```ts
17
19
  * ```
18
20
  */
19
- constructor(mark, view) {
21
+ constructor(mark, view, api) {
20
22
  const dom = document.createElement('div');
21
23
  const contentDOM = document.createElement('div');
22
24
  contentDOM.className = BreakoutCssClassName.BREAKOUT_MARK_DOM;
@@ -34,25 +36,28 @@ export class ResizingMarkView {
34
36
  contentDOM.style.gridRow = '1';
35
37
  contentDOM.style.gridColumn = '1';
36
38
  if (mark.attrs.width) {
37
- contentDOM.style.minWidth = `min(var(${localResizeProperty}, ${mark.attrs.width}px), calc(100cqw - var(--ak-editor--breakout-full-page-guttering-padding)))`;
39
+ contentDOM.style.minWidth = `min(var(${LOCAL_RESIZE_PROPERTY}, ${mark.attrs.width}px), calc(100cqw - var(--ak-editor--breakout-full-page-guttering-padding)))`;
38
40
  } else {
39
41
  if (mark.attrs.mode === 'wide') {
40
- contentDOM.style.minWidth = `max(var(--ak-editor--line-length), min(var(${localResizeProperty}, var(--ak-editor--breakout-wide-layout-width)), calc(100cqw - var(--ak-editor--breakout-full-page-guttering-padding))))`;
42
+ contentDOM.style.minWidth = `max(var(--ak-editor--line-length), min(var(${LOCAL_RESIZE_PROPERTY}, var(--ak-editor--breakout-wide-layout-width)), calc(100cqw - var(--ak-editor--breakout-full-page-guttering-padding))))`;
41
43
  }
42
44
  if (mark.attrs.mode === 'full-width') {
43
- contentDOM.style.minWidth = `max(var(--ak-editor--line-length), min(var(${localResizeProperty}, var(--ak-editor--full-width-layout-width)), calc(100cqw - var(--ak-editor--breakout-full-page-guttering-padding))))`;
45
+ contentDOM.style.minWidth = `max(var(--ak-editor--line-length), min(var(${LOCAL_RESIZE_PROPERTY}, var(--ak-editor--full-width-layout-width)), calc(100cqw - var(--ak-editor--breakout-full-page-guttering-padding))))`;
44
46
  }
45
47
  }
46
48
  dom.appendChild(contentDOM);
49
+ const callbacks = createResizerCallbacks({
50
+ dom,
51
+ contentDOM,
52
+ view,
53
+ mark,
54
+ api
55
+ });
47
56
  const {
48
57
  leftHandle,
49
58
  rightHandle,
50
59
  destroy
51
- } = createPragmaticResizer({
52
- onDragStart: () => {},
53
- onDrag: () => {},
54
- onDrop: () => {}
55
- });
60
+ } = createPragmaticResizer(callbacks);
56
61
  dom.prepend(leftHandle);
57
62
  dom.appendChild(rightHandle);
58
63
  this.dom = dom;
@@ -1,16 +1,111 @@
1
1
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
+ import { stepAddsOneOf } from '@atlaskit/editor-common/utils';
3
+ import { getChangedNodes, isReplaceDocOperation } from '@atlaskit/editor-common/utils/document';
2
4
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
5
+ import { akEditorDefaultLayoutWidth, akEditorFullWidthLayoutWidth, akEditorCalculatedWideLayoutWidth } from '@atlaskit/editor-shared-styles';
3
6
  import { ResizingMarkView } from './resizing-mark-view';
7
+ const addBreakoutToResizableNode = ({
8
+ node,
9
+ pos,
10
+ newState,
11
+ newTr,
12
+ breakoutResizableNodes,
13
+ isFullWidthEnabled
14
+ }) => {
15
+ let updatedDocChanged = false;
16
+ let updatedTr = newTr;
17
+ if (breakoutResizableNodes.has(node.type)) {
18
+ const {
19
+ breakout
20
+ } = newState.schema.marks;
21
+ const breakoutMark = node.marks.find(mark => mark.type === breakout);
22
+ if (!breakoutMark) {
23
+ const width = isFullWidthEnabled ? akEditorFullWidthLayoutWidth : akEditorDefaultLayoutWidth;
24
+ updatedTr = newTr.setNodeMarkup(pos, node.type, node.attrs, [breakout.create({
25
+ width: width
26
+ })]);
27
+ updatedDocChanged = true;
28
+ } else if ((breakoutMark === null || breakoutMark === void 0 ? void 0 : breakoutMark.attrs.width) === null || (breakoutMark === null || breakoutMark === void 0 ? void 0 : breakoutMark.attrs.width) === undefined) {
29
+ const mode = breakoutMark.attrs.mode;
30
+ const newWidth = mode === 'wide' ? akEditorCalculatedWideLayoutWidth : akEditorFullWidthLayoutWidth;
31
+ updatedTr = newTr.setNodeMarkup(pos, node.type, node.attrs, [breakout.create({
32
+ width: newWidth,
33
+ mode: mode
34
+ })]);
35
+ updatedDocChanged = true;
36
+ }
37
+ }
38
+ return {
39
+ updatedTr,
40
+ updatedDocChanged
41
+ };
42
+ };
4
43
  export const resizingPluginKey = new PluginKey('breakout-resizing');
5
- export const createResizingPlugin = () => {
44
+ export const createResizingPlugin = (api, options) => {
6
45
  return new SafePlugin({
7
46
  key: resizingPluginKey,
8
47
  props: {
9
48
  markViews: {
10
49
  breakout: (mark, view) => {
11
- return new ResizingMarkView(mark, view);
50
+ return new ResizingMarkView(mark, view, api);
12
51
  }
13
52
  }
53
+ },
54
+ appendTransaction(transactions, oldState, newState) {
55
+ let newTr = newState.tr;
56
+ let hasDocChanged = false;
57
+ const {
58
+ expand,
59
+ codeBlock,
60
+ layoutSection
61
+ } = newState.schema.nodes;
62
+ const breakoutResizableNodes = new Set([expand, codeBlock, layoutSection]);
63
+ const isFullWidthEnabled = !((options === null || options === void 0 ? void 0 : options.allowBreakoutButton) === true);
64
+ if (isReplaceDocOperation(transactions, oldState)) {
65
+ newState.doc.forEach((node, pos) => {
66
+ const {
67
+ updatedTr,
68
+ updatedDocChanged
69
+ } = addBreakoutToResizableNode({
70
+ node,
71
+ pos,
72
+ newState,
73
+ newTr,
74
+ breakoutResizableNodes,
75
+ isFullWidthEnabled
76
+ });
77
+ newTr = updatedTr;
78
+ hasDocChanged = hasDocChanged || updatedDocChanged;
79
+ });
80
+ } else {
81
+ transactions.forEach(tr => {
82
+ const isAddingResizableNodes = tr.steps.some(step => stepAddsOneOf(step, breakoutResizableNodes));
83
+ if (isAddingResizableNodes) {
84
+ const changedNodes = getChangedNodes(tr);
85
+ changedNodes.forEach(({
86
+ node,
87
+ pos
88
+ }) => {
89
+ const {
90
+ updatedTr,
91
+ updatedDocChanged
92
+ } = addBreakoutToResizableNode({
93
+ node,
94
+ pos,
95
+ newState,
96
+ newTr,
97
+ breakoutResizableNodes,
98
+ isFullWidthEnabled
99
+ });
100
+ newTr = updatedTr;
101
+ hasDocChanged = hasDocChanged || updatedDocChanged;
102
+ });
103
+ }
104
+ });
105
+ }
106
+ if (hasDocChanged) {
107
+ return newTr;
108
+ }
14
109
  }
15
110
  });
16
111
  };
@@ -67,7 +67,7 @@ function shouldPluginStateUpdate(newBreakoutNode, currentBreakoutNode) {
67
67
  }
68
68
  return newBreakoutNode || currentBreakoutNode ? true : false;
69
69
  }
70
- function createPlugin(pluginInjectionApi, _ref) {
70
+ function createPlugin(api, _ref) {
71
71
  var dispatch = _ref.dispatch;
72
72
  return new SafePlugin({
73
73
  state: {
@@ -171,7 +171,7 @@ export var breakoutPlugin = function breakoutPlugin(_ref3) {
171
171
  return [{
172
172
  name: 'breakout-resizing',
173
173
  plugin: function plugin() {
174
- return createResizingPlugin();
174
+ return createResizingPlugin(api, options);
175
175
  }
176
176
  }];
177
177
  }
@@ -0,0 +1,17 @@
1
+ // TODO: ED-28029 - add fixes for expands and codeblocks
2
+ export function setBreakoutWidth(width, mode, pos, isLivePage) {
3
+ return function (state, dispatch) {
4
+ var node = state.doc.nodeAt(pos);
5
+ if (!node) {
6
+ return false;
7
+ }
8
+ var tr = state.tr.setNodeMarkup(pos, node.type, node.attrs, [state.schema.marks.breakout.create({
9
+ width: width,
10
+ mode: mode
11
+ })]);
12
+ if (dispatch) {
13
+ dispatch(tr);
14
+ }
15
+ return true;
16
+ };
17
+ }
@@ -0,0 +1,71 @@
1
+ import { akEditorGutterPaddingDynamic, akEditorGutterPadding } from "@atlaskit/editor-shared-styles";
2
+ import { preventUnhandled } from "@atlaskit/pragmatic-drag-and-drop/prevent-unhandled";
3
+ import { setBreakoutWidth } from "../editor-commands/set-breakout-width";
4
+ import { LOCAL_RESIZE_PROPERTY } from "./resizing-mark-view";
5
+ var RESIZE_RATIO = 2;
6
+ var WIDTHS = {
7
+ MIN: 760,
8
+ MAX: 1800
9
+ };
10
+ function getProposedWidth(_ref) {
11
+ var _api$width$sharedStat;
12
+ var initialWidth = _ref.initialWidth,
13
+ location = _ref.location,
14
+ api = _ref.api;
15
+ var diffX = (location.current.input.clientX - location.initial.input.clientX) * RESIZE_RATIO;
16
+ var proposedWidth = initialWidth + diffX;
17
+
18
+ // TODO: ED-28024 - add snapping logic
19
+
20
+ var containerWidth = ((api === null || api === void 0 || (_api$width$sharedStat = api.width.sharedState) === null || _api$width$sharedStat === void 0 || (_api$width$sharedStat = _api$width$sharedStat.currentState()) === null || _api$width$sharedStat === void 0 ? void 0 : _api$width$sharedStat.width) || 0) - 2 * akEditorGutterPaddingDynamic() - akEditorGutterPadding;
21
+ return Math.min(Math.max(WIDTHS.MIN, Math.min(proposedWidth, containerWidth)), WIDTHS.MAX);
22
+ }
23
+ ;
24
+ export function createResizerCallbacks(_ref2) {
25
+ var dom = _ref2.dom,
26
+ contentDOM = _ref2.contentDOM,
27
+ view = _ref2.view,
28
+ mark = _ref2.mark,
29
+ api = _ref2.api;
30
+ return {
31
+ onDragStart: function onDragStart() {
32
+ requestAnimationFrame(function () {
33
+ var _api$userIntent;
34
+ // TODO: ED-28027 - add guidelines
35
+ api === null || api === void 0 || api.core.actions.execute((_api$userIntent = api.userIntent) === null || _api$userIntent === void 0 ? void 0 : _api$userIntent.commands.setCurrentUserIntent('dragging'));
36
+ });
37
+ view.dispatch(view.state.tr.setMeta('is-resizer-resizing', true));
38
+ },
39
+ onDrag: function onDrag(_ref3) {
40
+ var location = _ref3.location;
41
+ var initialWidth = mark.attrs.width;
42
+ var newWidth = getProposedWidth({
43
+ initialWidth: initialWidth,
44
+ location: location,
45
+ api: api
46
+ });
47
+ contentDOM.style.setProperty(LOCAL_RESIZE_PROPERTY, "".concat(newWidth, "px"));
48
+ },
49
+ onDrop: function onDrop(_ref4) {
50
+ var _api$userIntent2;
51
+ var location = _ref4.location;
52
+ // TODO: ED-28027 - remove guidelines
53
+ preventUnhandled.stop();
54
+ var pos = view.posAtDOM(dom, 0);
55
+ if (pos === undefined) {
56
+ return;
57
+ }
58
+ var mode = mark.attrs.mode;
59
+ var initialWidth = mark.attrs.width;
60
+ var newWidth = getProposedWidth({
61
+ initialWidth: initialWidth,
62
+ location: location,
63
+ api: api
64
+ });
65
+ setBreakoutWidth(newWidth, mode, pos)(view.state, view.dispatch);
66
+ contentDOM.style.removeProperty(LOCAL_RESIZE_PROPERTY);
67
+ view.dispatch(view.state.tr.setMeta('is-resizer-resizing', false).setMeta('scrollIntoView', false));
68
+ api === null || api === void 0 || api.core.actions.execute((_api$userIntent2 = api.userIntent) === null || _api$userIntent2 === void 0 ? void 0 : _api$userIntent2.commands.setCurrentUserIntent('default'));
69
+ }
70
+ };
71
+ }
@@ -4,7 +4,8 @@ import { BreakoutCssClassName } from '@atlaskit/editor-common/styles';
4
4
  import { draggable } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
5
5
  import { disableNativeDragPreview } from '@atlaskit/pragmatic-drag-and-drop/element/disable-native-drag-preview';
6
6
  import { preventUnhandled } from '@atlaskit/pragmatic-drag-and-drop/prevent-unhandled';
7
- var localResizeProperty = '--local-resizing-width';
7
+ import { createResizerCallbacks } from './resizer-callbacks';
8
+ export var LOCAL_RESIZE_PROPERTY = '--local-resizing-width';
8
9
 
9
10
  /**
10
11
  *
@@ -14,11 +15,12 @@ export var ResizingMarkView = /*#__PURE__*/function () {
14
15
  * Wrap node view in a resizing mark view
15
16
  * @param {Mark} mark - The breakout mark to resize
16
17
  * @param {EditorView} view - The editor view
18
+ * @param {ExtractInjectionAPI<BreakoutPlugin> | undefined} api - the pluginInjectionAPI
17
19
  * @example
18
20
  * ```ts
19
21
  * ```
20
22
  */
21
- function ResizingMarkView(mark, view) {
23
+ function ResizingMarkView(mark, view, api) {
22
24
  _classCallCheck(this, ResizingMarkView);
23
25
  var dom = document.createElement('div');
24
26
  var contentDOM = document.createElement('div');
@@ -37,21 +39,24 @@ export var ResizingMarkView = /*#__PURE__*/function () {
37
39
  contentDOM.style.gridRow = '1';
38
40
  contentDOM.style.gridColumn = '1';
39
41
  if (mark.attrs.width) {
40
- contentDOM.style.minWidth = "min(var(".concat(localResizeProperty, ", ").concat(mark.attrs.width, "px), calc(100cqw - var(--ak-editor--breakout-full-page-guttering-padding)))");
42
+ contentDOM.style.minWidth = "min(var(".concat(LOCAL_RESIZE_PROPERTY, ", ").concat(mark.attrs.width, "px), calc(100cqw - var(--ak-editor--breakout-full-page-guttering-padding)))");
41
43
  } else {
42
44
  if (mark.attrs.mode === 'wide') {
43
- contentDOM.style.minWidth = "max(var(--ak-editor--line-length), min(var(".concat(localResizeProperty, ", var(--ak-editor--breakout-wide-layout-width)), calc(100cqw - var(--ak-editor--breakout-full-page-guttering-padding))))");
45
+ contentDOM.style.minWidth = "max(var(--ak-editor--line-length), min(var(".concat(LOCAL_RESIZE_PROPERTY, ", var(--ak-editor--breakout-wide-layout-width)), calc(100cqw - var(--ak-editor--breakout-full-page-guttering-padding))))");
44
46
  }
45
47
  if (mark.attrs.mode === 'full-width') {
46
- contentDOM.style.minWidth = "max(var(--ak-editor--line-length), min(var(".concat(localResizeProperty, ", var(--ak-editor--full-width-layout-width)), calc(100cqw - var(--ak-editor--breakout-full-page-guttering-padding))))");
48
+ contentDOM.style.minWidth = "max(var(--ak-editor--line-length), min(var(".concat(LOCAL_RESIZE_PROPERTY, ", var(--ak-editor--full-width-layout-width)), calc(100cqw - var(--ak-editor--breakout-full-page-guttering-padding))))");
47
49
  }
48
50
  }
49
51
  dom.appendChild(contentDOM);
50
- var _createPragmaticResiz = createPragmaticResizer({
51
- onDragStart: function onDragStart() {},
52
- onDrag: function onDrag() {},
53
- onDrop: function onDrop() {}
54
- }),
52
+ var callbacks = createResizerCallbacks({
53
+ dom: dom,
54
+ contentDOM: contentDOM,
55
+ view: view,
56
+ mark: mark,
57
+ api: api
58
+ });
59
+ var _createPragmaticResiz = createPragmaticResizer(callbacks),
55
60
  leftHandle = _createPragmaticResiz.leftHandle,
56
61
  rightHandle = _createPragmaticResiz.rightHandle,
57
62
  destroy = _createPragmaticResiz.destroy;
@@ -1,16 +1,108 @@
1
1
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
+ import { stepAddsOneOf } from '@atlaskit/editor-common/utils';
3
+ import { getChangedNodes, isReplaceDocOperation } from '@atlaskit/editor-common/utils/document';
2
4
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
5
+ import { akEditorDefaultLayoutWidth, akEditorFullWidthLayoutWidth, akEditorCalculatedWideLayoutWidth } from '@atlaskit/editor-shared-styles';
3
6
  import { ResizingMarkView } from './resizing-mark-view';
7
+ var addBreakoutToResizableNode = function addBreakoutToResizableNode(_ref) {
8
+ var node = _ref.node,
9
+ pos = _ref.pos,
10
+ newState = _ref.newState,
11
+ newTr = _ref.newTr,
12
+ breakoutResizableNodes = _ref.breakoutResizableNodes,
13
+ isFullWidthEnabled = _ref.isFullWidthEnabled;
14
+ var updatedDocChanged = false;
15
+ var updatedTr = newTr;
16
+ if (breakoutResizableNodes.has(node.type)) {
17
+ var breakout = newState.schema.marks.breakout;
18
+ var breakoutMark = node.marks.find(function (mark) {
19
+ return mark.type === breakout;
20
+ });
21
+ if (!breakoutMark) {
22
+ var width = isFullWidthEnabled ? akEditorFullWidthLayoutWidth : akEditorDefaultLayoutWidth;
23
+ updatedTr = newTr.setNodeMarkup(pos, node.type, node.attrs, [breakout.create({
24
+ width: width
25
+ })]);
26
+ updatedDocChanged = true;
27
+ } else if ((breakoutMark === null || breakoutMark === void 0 ? void 0 : breakoutMark.attrs.width) === null || (breakoutMark === null || breakoutMark === void 0 ? void 0 : breakoutMark.attrs.width) === undefined) {
28
+ var mode = breakoutMark.attrs.mode;
29
+ var newWidth = mode === 'wide' ? akEditorCalculatedWideLayoutWidth : akEditorFullWidthLayoutWidth;
30
+ updatedTr = newTr.setNodeMarkup(pos, node.type, node.attrs, [breakout.create({
31
+ width: newWidth,
32
+ mode: mode
33
+ })]);
34
+ updatedDocChanged = true;
35
+ }
36
+ }
37
+ return {
38
+ updatedTr: updatedTr,
39
+ updatedDocChanged: updatedDocChanged
40
+ };
41
+ };
4
42
  export var resizingPluginKey = new PluginKey('breakout-resizing');
5
- export var createResizingPlugin = function createResizingPlugin() {
43
+ export var createResizingPlugin = function createResizingPlugin(api, options) {
6
44
  return new SafePlugin({
7
45
  key: resizingPluginKey,
8
46
  props: {
9
47
  markViews: {
10
48
  breakout: function breakout(mark, view) {
11
- return new ResizingMarkView(mark, view);
49
+ return new ResizingMarkView(mark, view, api);
12
50
  }
13
51
  }
52
+ },
53
+ appendTransaction: function appendTransaction(transactions, oldState, newState) {
54
+ var newTr = newState.tr;
55
+ var hasDocChanged = false;
56
+ var _newState$schema$node = newState.schema.nodes,
57
+ expand = _newState$schema$node.expand,
58
+ codeBlock = _newState$schema$node.codeBlock,
59
+ layoutSection = _newState$schema$node.layoutSection;
60
+ var breakoutResizableNodes = new Set([expand, codeBlock, layoutSection]);
61
+ var isFullWidthEnabled = !((options === null || options === void 0 ? void 0 : options.allowBreakoutButton) === true);
62
+ if (isReplaceDocOperation(transactions, oldState)) {
63
+ newState.doc.forEach(function (node, pos) {
64
+ var _addBreakoutToResizab = addBreakoutToResizableNode({
65
+ node: node,
66
+ pos: pos,
67
+ newState: newState,
68
+ newTr: newTr,
69
+ breakoutResizableNodes: breakoutResizableNodes,
70
+ isFullWidthEnabled: isFullWidthEnabled
71
+ }),
72
+ updatedTr = _addBreakoutToResizab.updatedTr,
73
+ updatedDocChanged = _addBreakoutToResizab.updatedDocChanged;
74
+ newTr = updatedTr;
75
+ hasDocChanged = hasDocChanged || updatedDocChanged;
76
+ });
77
+ } else {
78
+ transactions.forEach(function (tr) {
79
+ var isAddingResizableNodes = tr.steps.some(function (step) {
80
+ return stepAddsOneOf(step, breakoutResizableNodes);
81
+ });
82
+ if (isAddingResizableNodes) {
83
+ var changedNodes = getChangedNodes(tr);
84
+ changedNodes.forEach(function (_ref2) {
85
+ var node = _ref2.node,
86
+ pos = _ref2.pos;
87
+ var _addBreakoutToResizab2 = addBreakoutToResizableNode({
88
+ node: node,
89
+ pos: pos,
90
+ newState: newState,
91
+ newTr: newTr,
92
+ breakoutResizableNodes: breakoutResizableNodes,
93
+ isFullWidthEnabled: isFullWidthEnabled
94
+ }),
95
+ updatedTr = _addBreakoutToResizab2.updatedTr,
96
+ updatedDocChanged = _addBreakoutToResizab2.updatedDocChanged;
97
+ newTr = updatedTr;
98
+ hasDocChanged = hasDocChanged || updatedDocChanged;
99
+ });
100
+ }
101
+ });
102
+ }
103
+ if (hasDocChanged) {
104
+ return newTr;
105
+ }
14
106
  }
15
107
  });
16
108
  };
@@ -2,6 +2,7 @@ import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/t
2
2
  import { type BlockControlsPlugin } from '@atlaskit/editor-plugin-block-controls';
3
3
  import { type EditorDisabledPlugin } from '@atlaskit/editor-plugin-editor-disabled';
4
4
  import type { EditorViewModePlugin } from '@atlaskit/editor-plugin-editor-viewmode';
5
+ import { UserIntentPlugin } from '@atlaskit/editor-plugin-user-intent';
5
6
  import type { WidthPlugin } from '@atlaskit/editor-plugin-width';
6
7
  import type { ContentNodeWithPos } from '@atlaskit/editor-prosemirror/utils';
7
8
  export interface BreakoutPluginState {
@@ -14,7 +15,8 @@ export type BreakoutPluginDependencies = [
14
15
  WidthPlugin,
15
16
  OptionalPlugin<EditorViewModePlugin>,
16
17
  OptionalPlugin<EditorDisabledPlugin>,
17
- OptionalPlugin<BlockControlsPlugin>
18
+ OptionalPlugin<BlockControlsPlugin>,
19
+ OptionalPlugin<UserIntentPlugin>
18
20
  ];
19
21
  export type BreakoutPlugin = NextEditorPlugin<'breakout', {
20
22
  pluginConfiguration: BreakoutPluginOptions | undefined;
@@ -0,0 +1,2 @@
1
+ import type { BreakoutMode, Command } from '@atlaskit/editor-common/types';
2
+ export declare function setBreakoutWidth(width: number, mode: BreakoutMode, pos: number, isLivePage?: boolean): Command;
@@ -0,0 +1,16 @@
1
+ import { ExtractInjectionAPI } from "@atlaskit/editor-common/types";
2
+ import { Mark } from '@atlaskit/editor-prosemirror/model';
3
+ import { EditorView } from "@atlaskit/editor-prosemirror/view";
4
+ import { BaseEventPayload, ElementDragType } from "@atlaskit/pragmatic-drag-and-drop/types";
5
+ import { BreakoutPlugin } from "../breakoutPluginType";
6
+ export declare function createResizerCallbacks({ dom, contentDOM, view, mark, api }: {
7
+ dom: HTMLElement;
8
+ contentDOM: HTMLElement;
9
+ view: EditorView;
10
+ mark: Mark;
11
+ api: ExtractInjectionAPI<BreakoutPlugin> | undefined;
12
+ }): {
13
+ onDragStart: () => void;
14
+ onDrag: (args: BaseEventPayload<ElementDragType>) => void;
15
+ onDrop: (args: BaseEventPayload<ElementDragType>) => void;
16
+ };
@@ -1,5 +1,8 @@
1
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
1
2
  import type { Mark } from '@atlaskit/editor-prosemirror/model';
2
3
  import type { EditorView, NodeView } from '@atlaskit/editor-prosemirror/view';
4
+ import { BreakoutPlugin } from '../breakoutPluginType';
5
+ export declare const LOCAL_RESIZE_PROPERTY = "--local-resizing-width";
3
6
  /**
4
7
  *
5
8
  */
@@ -13,11 +16,12 @@ export declare class ResizingMarkView implements NodeView {
13
16
  * Wrap node view in a resizing mark view
14
17
  * @param {Mark} mark - The breakout mark to resize
15
18
  * @param {EditorView} view - The editor view
19
+ * @param {ExtractInjectionAPI<BreakoutPlugin> | undefined} api - the pluginInjectionAPI
16
20
  * @example
17
21
  * ```ts
18
22
  * ```
19
23
  */
20
- constructor(mark: Mark, view: EditorView);
24
+ constructor(mark: Mark, view: EditorView, api: ExtractInjectionAPI<BreakoutPlugin> | undefined);
21
25
  /**
22
26
  *
23
27
  * @example
@@ -1,4 +1,7 @@
1
1
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
+ import { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
2
3
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
4
+ import { BreakoutPlugin } from '../breakoutPluginType';
5
+ import type { BreakoutPluginOptions } from '../breakoutPluginType';
3
6
  export declare const resizingPluginKey: PluginKey<any>;
4
- export declare const createResizingPlugin: () => SafePlugin<any>;
7
+ export declare const createResizingPlugin: (api: ExtractInjectionAPI<BreakoutPlugin> | undefined, options?: BreakoutPluginOptions) => SafePlugin<any>;
@@ -2,6 +2,7 @@ import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/t
2
2
  import { type BlockControlsPlugin } from '@atlaskit/editor-plugin-block-controls';
3
3
  import { type EditorDisabledPlugin } from '@atlaskit/editor-plugin-editor-disabled';
4
4
  import type { EditorViewModePlugin } from '@atlaskit/editor-plugin-editor-viewmode';
5
+ import { UserIntentPlugin } from '@atlaskit/editor-plugin-user-intent';
5
6
  import type { WidthPlugin } from '@atlaskit/editor-plugin-width';
6
7
  import type { ContentNodeWithPos } from '@atlaskit/editor-prosemirror/utils';
7
8
  export interface BreakoutPluginState {
@@ -14,7 +15,8 @@ export type BreakoutPluginDependencies = [
14
15
  WidthPlugin,
15
16
  OptionalPlugin<EditorViewModePlugin>,
16
17
  OptionalPlugin<EditorDisabledPlugin>,
17
- OptionalPlugin<BlockControlsPlugin>
18
+ OptionalPlugin<BlockControlsPlugin>,
19
+ OptionalPlugin<UserIntentPlugin>
18
20
  ];
19
21
  export type BreakoutPlugin = NextEditorPlugin<'breakout', {
20
22
  pluginConfiguration: BreakoutPluginOptions | undefined;
@@ -0,0 +1,2 @@
1
+ import type { BreakoutMode, Command } from '@atlaskit/editor-common/types';
2
+ export declare function setBreakoutWidth(width: number, mode: BreakoutMode, pos: number, isLivePage?: boolean): Command;
@@ -0,0 +1,16 @@
1
+ import { ExtractInjectionAPI } from "@atlaskit/editor-common/types";
2
+ import { Mark } from '@atlaskit/editor-prosemirror/model';
3
+ import { EditorView } from "@atlaskit/editor-prosemirror/view";
4
+ import { BaseEventPayload, ElementDragType } from "@atlaskit/pragmatic-drag-and-drop/types";
5
+ import { BreakoutPlugin } from "../breakoutPluginType";
6
+ export declare function createResizerCallbacks({ dom, contentDOM, view, mark, api }: {
7
+ dom: HTMLElement;
8
+ contentDOM: HTMLElement;
9
+ view: EditorView;
10
+ mark: Mark;
11
+ api: ExtractInjectionAPI<BreakoutPlugin> | undefined;
12
+ }): {
13
+ onDragStart: () => void;
14
+ onDrag: (args: BaseEventPayload<ElementDragType>) => void;
15
+ onDrop: (args: BaseEventPayload<ElementDragType>) => void;
16
+ };
@@ -1,5 +1,8 @@
1
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
1
2
  import type { Mark } from '@atlaskit/editor-prosemirror/model';
2
3
  import type { EditorView, NodeView } from '@atlaskit/editor-prosemirror/view';
4
+ import { BreakoutPlugin } from '../breakoutPluginType';
5
+ export declare const LOCAL_RESIZE_PROPERTY = "--local-resizing-width";
3
6
  /**
4
7
  *
5
8
  */
@@ -13,11 +16,12 @@ export declare class ResizingMarkView implements NodeView {
13
16
  * Wrap node view in a resizing mark view
14
17
  * @param {Mark} mark - The breakout mark to resize
15
18
  * @param {EditorView} view - The editor view
19
+ * @param {ExtractInjectionAPI<BreakoutPlugin> | undefined} api - the pluginInjectionAPI
16
20
  * @example
17
21
  * ```ts
18
22
  * ```
19
23
  */
20
- constructor(mark: Mark, view: EditorView);
24
+ constructor(mark: Mark, view: EditorView, api: ExtractInjectionAPI<BreakoutPlugin> | undefined);
21
25
  /**
22
26
  *
23
27
  * @example
@@ -1,4 +1,7 @@
1
1
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
+ import { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
2
3
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
4
+ import { BreakoutPlugin } from '../breakoutPluginType';
5
+ import type { BreakoutPluginOptions } from '../breakoutPluginType';
3
6
  export declare const resizingPluginKey: PluginKey<any>;
4
- export declare const createResizingPlugin: () => SafePlugin<any>;
7
+ export declare const createResizingPlugin: (api: ExtractInjectionAPI<BreakoutPlugin> | undefined, options?: BreakoutPluginOptions) => SafePlugin<any>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-breakout",
3
- "version": "2.2.5",
3
+ "version": "2.3.0",
4
4
  "description": "Breakout plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -38,6 +38,7 @@
38
38
  "@atlaskit/editor-plugin-block-controls": "^3.14.0",
39
39
  "@atlaskit/editor-plugin-editor-disabled": "^2.0.0",
40
40
  "@atlaskit/editor-plugin-editor-viewmode": "^3.1.0",
41
+ "@atlaskit/editor-plugin-user-intent": "^0.1.0",
41
42
  "@atlaskit/editor-plugin-width": "^3.0.0",
42
43
  "@atlaskit/editor-prosemirror": "7.0.0",
43
44
  "@atlaskit/editor-shared-styles": "^3.4.0",
@@ -45,7 +46,7 @@
45
46
  "@atlaskit/platform-feature-flags": "^1.1.0",
46
47
  "@atlaskit/pragmatic-drag-and-drop": "^1.7.0",
47
48
  "@atlaskit/theme": "^18.0.0",
48
- "@atlaskit/tmp-editor-statsig": "^4.23.0",
49
+ "@atlaskit/tmp-editor-statsig": "^4.24.0",
49
50
  "@atlaskit/tokens": "^4.9.0",
50
51
  "@babel/runtime": "^7.0.0",
51
52
  "@emotion/react": "^11.7.1"