@atlaskit/editor-plugin-breakout 2.2.4 → 2.2.6

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 +19 -0
  2. package/dist/cjs/breakoutPlugin.js +10 -1
  3. package/dist/cjs/editor-commands/set-breakout-width.js +22 -0
  4. package/dist/cjs/pm-plugins/resizer-callbacks.js +76 -0
  5. package/dist/cjs/pm-plugins/resizing-mark-view.js +148 -0
  6. package/dist/cjs/pm-plugins/resizing-plugin.js +22 -0
  7. package/dist/es2019/breakoutPlugin.js +8 -1
  8. package/dist/es2019/editor-commands/set-breakout-width.js +16 -0
  9. package/dist/es2019/pm-plugins/resizer-callbacks.js +74 -0
  10. package/dist/es2019/pm-plugins/resizing-mark-view.js +136 -0
  11. package/dist/es2019/pm-plugins/resizing-plugin.js +16 -0
  12. package/dist/esm/breakoutPlugin.js +10 -1
  13. package/dist/esm/editor-commands/set-breakout-width.js +16 -0
  14. package/dist/esm/pm-plugins/resizer-callbacks.js +70 -0
  15. package/dist/esm/pm-plugins/resizing-mark-view.js +141 -0
  16. package/dist/esm/pm-plugins/resizing-plugin.js +16 -0
  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 +35 -0
  21. package/dist/types/pm-plugins/resizing-plugin.d.ts +6 -0
  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 +35 -0
  26. package/dist/types-ts4.5/pm-plugins/resizing-plugin.d.ts +6 -0
  27. package/package.json +8 -6
package/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # @atlaskit/editor-plugin-breakout
2
2
 
3
+ ## 2.2.6
4
+
5
+ ### Patch Changes
6
+
7
+ - [#157540](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/157540)
8
+ [`16b7448512972`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/16b7448512972) -
9
+ [ux] [ED-28038] this change adds the drag callbacks to the new resizing experience behind the
10
+ platform_editor_breakout_resizing experiment.
11
+ - Updated dependencies
12
+
13
+ ## 2.2.5
14
+
15
+ ### Patch Changes
16
+
17
+ - [#156743](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/156743)
18
+ [`170609348890d`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/170609348890d) -
19
+ Add new breakout resizing experience under experiment platform_editor_breakout_resizing
20
+ - Updated dependencies
21
+
3
22
  ## 2.2.4
4
23
 
5
24
  ### Patch Changes
@@ -17,6 +17,7 @@ var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-
17
17
  var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
18
18
  var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
19
19
  var _pluginKey = require("./pm-plugins/plugin-key");
20
+ var _resizingPlugin = require("./pm-plugins/resizing-plugin");
20
21
  var _findBreakoutNode = require("./pm-plugins/utils/find-breakout-node");
21
22
  var _LayoutButton = _interopRequireDefault(require("./ui/LayoutButton"));
22
23
  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; }
@@ -73,7 +74,7 @@ function shouldPluginStateUpdate(newBreakoutNode, currentBreakoutNode) {
73
74
  }
74
75
  return newBreakoutNode || currentBreakoutNode ? true : false;
75
76
  }
76
- function createPlugin(pluginInjectionApi, _ref) {
77
+ function createPlugin(api, _ref) {
77
78
  var dispatch = _ref.dispatch;
78
79
  return new _safePlugin.SafePlugin({
79
80
  state: {
@@ -173,6 +174,14 @@ var breakoutPlugin = exports.breakoutPlugin = function breakoutPlugin(_ref3) {
173
174
  return {
174
175
  name: 'breakout',
175
176
  pmPlugins: function pmPlugins() {
177
+ if ((0, _experiments.editorExperiment)('platform_editor_breakout_resizing', true)) {
178
+ return [{
179
+ name: 'breakout-resizing',
180
+ plugin: function plugin() {
181
+ return (0, _resizingPlugin.createResizingPlugin)(api);
182
+ }
183
+ }];
184
+ }
176
185
  return [{
177
186
  name: 'breakout',
178
187
  plugin: function plugin(props) {
@@ -0,0 +1,22 @@
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, 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
+ })]);
17
+ if (dispatch) {
18
+ dispatch(tr);
19
+ }
20
+ return true;
21
+ };
22
+ }
@@ -0,0 +1,76 @@
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 initialWidth = mark.attrs.width;
65
+ var newWidth = getProposedWidth({
66
+ initialWidth: initialWidth,
67
+ location: location,
68
+ api: api
69
+ });
70
+ (0, _setBreakoutWidth.setBreakoutWidth)(newWidth, pos)(view.state, view.dispatch);
71
+ contentDOM.style.removeProperty(_resizingMarkView.LOCAL_RESIZE_PROPERTY);
72
+ view.dispatch(view.state.tr.setMeta('is-resizer-resizing', false).setMeta('scrollIntoView', false));
73
+ 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'));
74
+ }
75
+ };
76
+ }
@@ -0,0 +1,148 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.ResizingMarkView = exports.LOCAL_RESIZE_PROPERTY = void 0;
8
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
9
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
+ var _styles = require("@atlaskit/editor-common/styles");
11
+ var _adapter = require("@atlaskit/pragmatic-drag-and-drop/element/adapter");
12
+ var _disableNativeDragPreview = require("@atlaskit/pragmatic-drag-and-drop/element/disable-native-drag-preview");
13
+ var _preventUnhandled = require("@atlaskit/pragmatic-drag-and-drop/prevent-unhandled");
14
+ var _resizerCallbacks = require("./resizer-callbacks");
15
+ var LOCAL_RESIZE_PROPERTY = exports.LOCAL_RESIZE_PROPERTY = '--local-resizing-width';
16
+
17
+ /**
18
+ *
19
+ */
20
+ var ResizingMarkView = exports.ResizingMarkView = /*#__PURE__*/function () {
21
+ /**
22
+ * Wrap node view in a resizing mark view
23
+ * @param {Mark} mark - The breakout mark to resize
24
+ * @param {EditorView} view - The editor view
25
+ * @param {ExtractInjectionAPI<BreakoutPlugin> | undefined} api - the pluginInjectionAPI
26
+ * @example
27
+ * ```ts
28
+ * ```
29
+ */
30
+ function ResizingMarkView(mark, view, api) {
31
+ (0, _classCallCheck2.default)(this, ResizingMarkView);
32
+ var dom = document.createElement('div');
33
+ var contentDOM = document.createElement('div');
34
+ contentDOM.className = _styles.BreakoutCssClassName.BREAKOUT_MARK_DOM;
35
+ contentDOM.setAttribute('data-testid', 'ak-editor-breakout-mark-dom');
36
+ dom.className = _styles.BreakoutCssClassName.BREAKOUT_MARK;
37
+ dom.setAttribute('data-layout', mark.attrs.mode);
38
+ dom.setAttribute('data-testid', 'ak-editor-breakout-mark');
39
+ // dom - styles
40
+ dom.style.transform = 'none';
41
+ dom.style.display = 'grid';
42
+ dom.style.justifyContent = 'center';
43
+ dom.style.position = 'relative';
44
+
45
+ // contentDOM - styles
46
+ contentDOM.style.gridRow = '1';
47
+ contentDOM.style.gridColumn = '1';
48
+ if (mark.attrs.width) {
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)))");
50
+ } else {
51
+ if (mark.attrs.mode === 'wide') {
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))))");
53
+ }
54
+ if (mark.attrs.mode === 'full-width') {
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))))");
56
+ }
57
+ }
58
+ dom.appendChild(contentDOM);
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),
67
+ leftHandle = _createPragmaticResiz.leftHandle,
68
+ rightHandle = _createPragmaticResiz.rightHandle,
69
+ destroy = _createPragmaticResiz.destroy;
70
+ dom.prepend(leftHandle);
71
+ dom.appendChild(rightHandle);
72
+ this.dom = dom;
73
+ this.contentDOM = contentDOM;
74
+ this.view = view;
75
+ this.mark = mark;
76
+ this.destroyFn = destroy;
77
+ }
78
+
79
+ /**
80
+ *
81
+ * @example
82
+ */
83
+ return (0, _createClass2.default)(ResizingMarkView, [{
84
+ key: "ignoreMutation",
85
+ value: function ignoreMutation() {
86
+ return true;
87
+ }
88
+
89
+ /**
90
+ *
91
+ * @example
92
+ */
93
+ }, {
94
+ key: "destroy",
95
+ value: function destroy() {
96
+ this.destroyFn();
97
+ }
98
+ }]);
99
+ }();
100
+ var createPragmaticResizer = function createPragmaticResizer(_ref) {
101
+ var onDragStart = _ref.onDragStart,
102
+ onDrag = _ref.onDrag,
103
+ _onDrop = _ref.onDrop;
104
+ var registerHandle = function registerHandle(handleElement) {
105
+ return (0, _adapter.draggable)({
106
+ element: handleElement,
107
+ onGenerateDragPreview: function onGenerateDragPreview(_ref2) {
108
+ var nativeSetDragImage = _ref2.nativeSetDragImage;
109
+ (0, _disableNativeDragPreview.disableNativeDragPreview)({
110
+ nativeSetDragImage: nativeSetDragImage
111
+ });
112
+ _preventUnhandled.preventUnhandled.start();
113
+ },
114
+ onDragStart: onDragStart,
115
+ onDrag: onDrag,
116
+ onDrop: function onDrop(args) {
117
+ _preventUnhandled.preventUnhandled.stop();
118
+ _onDrop(args);
119
+ }
120
+ });
121
+ };
122
+ var createHandle = function createHandle(side) {
123
+ var handle = document.createElement('div');
124
+ handle.contentEditable = 'false';
125
+ handle.classList.add('pm-breakout-resize-handle');
126
+ if (side === 'left') {
127
+ handle.classList.add('pm-breakout-resize-handle-left');
128
+ } else {
129
+ handle.classList.add('pm-breakout-resize-handle-right');
130
+ }
131
+ var handleInner = document.createElement('div');
132
+ handleInner.classList.add('pm-breakout-resize-handle-inner');
133
+ handle.appendChild(handleInner);
134
+ return handle;
135
+ };
136
+ var rightHandle = createHandle('right');
137
+ var leftHandle = createHandle('left');
138
+ var rightHandleCleanup = registerHandle(rightHandle);
139
+ var leftHandleCleanup = registerHandle(leftHandle);
140
+ return {
141
+ rightHandle: rightHandle,
142
+ leftHandle: leftHandle,
143
+ destroy: function destroy() {
144
+ rightHandleCleanup();
145
+ leftHandleCleanup();
146
+ }
147
+ };
148
+ };
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.resizingPluginKey = exports.createResizingPlugin = void 0;
7
+ var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
8
+ var _state = require("@atlaskit/editor-prosemirror/state");
9
+ var _resizingMarkView = require("./resizing-mark-view");
10
+ var resizingPluginKey = exports.resizingPluginKey = new _state.PluginKey('breakout-resizing');
11
+ var createResizingPlugin = exports.createResizingPlugin = function createResizingPlugin(api) {
12
+ return new _safePlugin.SafePlugin({
13
+ key: resizingPluginKey,
14
+ props: {
15
+ markViews: {
16
+ breakout: function breakout(mark, view) {
17
+ return new _resizingMarkView.ResizingMarkView(mark, view, api);
18
+ }
19
+ }
20
+ }
21
+ });
22
+ };
@@ -7,6 +7,7 @@ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared
7
7
  import { akEditorSwoopCubicBezier } from '@atlaskit/editor-shared-styles';
8
8
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
9
9
  import { pluginKey } from './pm-plugins/plugin-key';
10
+ import { createResizingPlugin } from './pm-plugins/resizing-plugin';
10
11
  import { findSupportedNodeForBreakout } from './pm-plugins/utils/find-breakout-node';
11
12
  import LayoutButton from './ui/LayoutButton';
12
13
  class BreakoutView {
@@ -62,7 +63,7 @@ function shouldPluginStateUpdate(newBreakoutNode, currentBreakoutNode) {
62
63
  }
63
64
  return newBreakoutNode || currentBreakoutNode ? true : false;
64
65
  }
65
- function createPlugin(pluginInjectionApi, {
66
+ function createPlugin(api, {
66
67
  dispatch
67
68
  }) {
68
69
  return new SafePlugin({
@@ -167,6 +168,12 @@ export const breakoutPlugin = ({
167
168
  }) => ({
168
169
  name: 'breakout',
169
170
  pmPlugins() {
171
+ if (editorExperiment('platform_editor_breakout_resizing', true)) {
172
+ return [{
173
+ name: 'breakout-resizing',
174
+ plugin: () => createResizingPlugin(api)
175
+ }];
176
+ }
170
177
  return [{
171
178
  name: 'breakout',
172
179
  plugin: props => createPlugin(api, props)
@@ -0,0 +1,16 @@
1
+ // TODO: ED-28029 - add fixes for expands and codeblocks
2
+ export function setBreakoutWidth(width, 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
+ })]);
11
+ if (dispatch) {
12
+ dispatch(tr);
13
+ }
14
+ return true;
15
+ };
16
+ }
@@ -0,0 +1,74 @@
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 initialWidth = mark.attrs.width;
63
+ const newWidth = getProposedWidth({
64
+ initialWidth,
65
+ location,
66
+ api
67
+ });
68
+ setBreakoutWidth(newWidth, pos)(view.state, view.dispatch);
69
+ contentDOM.style.removeProperty(LOCAL_RESIZE_PROPERTY);
70
+ view.dispatch(view.state.tr.setMeta('is-resizer-resizing', false).setMeta('scrollIntoView', false));
71
+ 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'));
72
+ }
73
+ };
74
+ }
@@ -0,0 +1,136 @@
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';
5
+ import { createResizerCallbacks } from './resizer-callbacks';
6
+ export const LOCAL_RESIZE_PROPERTY = '--local-resizing-width';
7
+
8
+ /**
9
+ *
10
+ */
11
+ export class ResizingMarkView {
12
+ /**
13
+ * Wrap node view in a resizing mark view
14
+ * @param {Mark} mark - The breakout mark to resize
15
+ * @param {EditorView} view - The editor view
16
+ * @param {ExtractInjectionAPI<BreakoutPlugin> | undefined} api - the pluginInjectionAPI
17
+ * @example
18
+ * ```ts
19
+ * ```
20
+ */
21
+ constructor(mark, view, api) {
22
+ const dom = document.createElement('div');
23
+ const contentDOM = document.createElement('div');
24
+ contentDOM.className = BreakoutCssClassName.BREAKOUT_MARK_DOM;
25
+ contentDOM.setAttribute('data-testid', 'ak-editor-breakout-mark-dom');
26
+ dom.className = BreakoutCssClassName.BREAKOUT_MARK;
27
+ dom.setAttribute('data-layout', mark.attrs.mode);
28
+ dom.setAttribute('data-testid', 'ak-editor-breakout-mark');
29
+ // dom - styles
30
+ dom.style.transform = 'none';
31
+ dom.style.display = 'grid';
32
+ dom.style.justifyContent = 'center';
33
+ dom.style.position = 'relative';
34
+
35
+ // contentDOM - styles
36
+ contentDOM.style.gridRow = '1';
37
+ contentDOM.style.gridColumn = '1';
38
+ if (mark.attrs.width) {
39
+ contentDOM.style.minWidth = `min(var(${LOCAL_RESIZE_PROPERTY}, ${mark.attrs.width}px), calc(100cqw - var(--ak-editor--breakout-full-page-guttering-padding)))`;
40
+ } else {
41
+ if (mark.attrs.mode === 'wide') {
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))))`;
43
+ }
44
+ if (mark.attrs.mode === 'full-width') {
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))))`;
46
+ }
47
+ }
48
+ dom.appendChild(contentDOM);
49
+ const callbacks = createResizerCallbacks({
50
+ dom,
51
+ contentDOM,
52
+ view,
53
+ mark,
54
+ api
55
+ });
56
+ const {
57
+ leftHandle,
58
+ rightHandle,
59
+ destroy
60
+ } = createPragmaticResizer(callbacks);
61
+ dom.prepend(leftHandle);
62
+ dom.appendChild(rightHandle);
63
+ this.dom = dom;
64
+ this.contentDOM = contentDOM;
65
+ this.view = view;
66
+ this.mark = mark;
67
+ this.destroyFn = destroy;
68
+ }
69
+
70
+ /**
71
+ *
72
+ * @example
73
+ */
74
+ ignoreMutation() {
75
+ return true;
76
+ }
77
+
78
+ /**
79
+ *
80
+ * @example
81
+ */
82
+ destroy() {
83
+ this.destroyFn();
84
+ }
85
+ }
86
+ const createPragmaticResizer = ({
87
+ onDragStart,
88
+ onDrag,
89
+ onDrop
90
+ }) => {
91
+ const registerHandle = handleElement => {
92
+ return draggable({
93
+ element: handleElement,
94
+ onGenerateDragPreview: ({
95
+ nativeSetDragImage
96
+ }) => {
97
+ disableNativeDragPreview({
98
+ nativeSetDragImage
99
+ });
100
+ preventUnhandled.start();
101
+ },
102
+ onDragStart,
103
+ onDrag,
104
+ onDrop(args) {
105
+ preventUnhandled.stop();
106
+ onDrop(args);
107
+ }
108
+ });
109
+ };
110
+ const createHandle = side => {
111
+ const handle = document.createElement('div');
112
+ handle.contentEditable = 'false';
113
+ handle.classList.add('pm-breakout-resize-handle');
114
+ if (side === 'left') {
115
+ handle.classList.add('pm-breakout-resize-handle-left');
116
+ } else {
117
+ handle.classList.add('pm-breakout-resize-handle-right');
118
+ }
119
+ const handleInner = document.createElement('div');
120
+ handleInner.classList.add('pm-breakout-resize-handle-inner');
121
+ handle.appendChild(handleInner);
122
+ return handle;
123
+ };
124
+ const rightHandle = createHandle('right');
125
+ const leftHandle = createHandle('left');
126
+ const rightHandleCleanup = registerHandle(rightHandle);
127
+ const leftHandleCleanup = registerHandle(leftHandle);
128
+ return {
129
+ rightHandle,
130
+ leftHandle,
131
+ destroy: () => {
132
+ rightHandleCleanup();
133
+ leftHandleCleanup();
134
+ }
135
+ };
136
+ };
@@ -0,0 +1,16 @@
1
+ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
+ import { PluginKey } from '@atlaskit/editor-prosemirror/state';
3
+ import { ResizingMarkView } from './resizing-mark-view';
4
+ export const resizingPluginKey = new PluginKey('breakout-resizing');
5
+ export const createResizingPlugin = api => {
6
+ return new SafePlugin({
7
+ key: resizingPluginKey,
8
+ props: {
9
+ markViews: {
10
+ breakout: (mark, view) => {
11
+ return new ResizingMarkView(mark, view, api);
12
+ }
13
+ }
14
+ }
15
+ });
16
+ };
@@ -12,6 +12,7 @@ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared
12
12
  import { akEditorSwoopCubicBezier } from '@atlaskit/editor-shared-styles';
13
13
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
14
14
  import { pluginKey } from './pm-plugins/plugin-key';
15
+ import { createResizingPlugin } from './pm-plugins/resizing-plugin';
15
16
  import { findSupportedNodeForBreakout } from './pm-plugins/utils/find-breakout-node';
16
17
  import LayoutButton from './ui/LayoutButton';
17
18
  var BreakoutView = /*#__PURE__*/_createClass(function BreakoutView(
@@ -66,7 +67,7 @@ function shouldPluginStateUpdate(newBreakoutNode, currentBreakoutNode) {
66
67
  }
67
68
  return newBreakoutNode || currentBreakoutNode ? true : false;
68
69
  }
69
- function createPlugin(pluginInjectionApi, _ref) {
70
+ function createPlugin(api, _ref) {
70
71
  var dispatch = _ref.dispatch;
71
72
  return new SafePlugin({
72
73
  state: {
@@ -166,6 +167,14 @@ export var breakoutPlugin = function breakoutPlugin(_ref3) {
166
167
  return {
167
168
  name: 'breakout',
168
169
  pmPlugins: function pmPlugins() {
170
+ if (editorExperiment('platform_editor_breakout_resizing', true)) {
171
+ return [{
172
+ name: 'breakout-resizing',
173
+ plugin: function plugin() {
174
+ return createResizingPlugin(api);
175
+ }
176
+ }];
177
+ }
169
178
  return [{
170
179
  name: 'breakout',
171
180
  plugin: function plugin(props) {
@@ -0,0 +1,16 @@
1
+ // TODO: ED-28029 - add fixes for expands and codeblocks
2
+ export function setBreakoutWidth(width, 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
+ })]);
11
+ if (dispatch) {
12
+ dispatch(tr);
13
+ }
14
+ return true;
15
+ };
16
+ }
@@ -0,0 +1,70 @@
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 initialWidth = mark.attrs.width;
59
+ var newWidth = getProposedWidth({
60
+ initialWidth: initialWidth,
61
+ location: location,
62
+ api: api
63
+ });
64
+ setBreakoutWidth(newWidth, pos)(view.state, view.dispatch);
65
+ contentDOM.style.removeProperty(LOCAL_RESIZE_PROPERTY);
66
+ view.dispatch(view.state.tr.setMeta('is-resizer-resizing', false).setMeta('scrollIntoView', false));
67
+ 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'));
68
+ }
69
+ };
70
+ }
@@ -0,0 +1,141 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/createClass";
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';
7
+ import { createResizerCallbacks } from './resizer-callbacks';
8
+ export var LOCAL_RESIZE_PROPERTY = '--local-resizing-width';
9
+
10
+ /**
11
+ *
12
+ */
13
+ export var ResizingMarkView = /*#__PURE__*/function () {
14
+ /**
15
+ * Wrap node view in a resizing mark view
16
+ * @param {Mark} mark - The breakout mark to resize
17
+ * @param {EditorView} view - The editor view
18
+ * @param {ExtractInjectionAPI<BreakoutPlugin> | undefined} api - the pluginInjectionAPI
19
+ * @example
20
+ * ```ts
21
+ * ```
22
+ */
23
+ function ResizingMarkView(mark, view, api) {
24
+ _classCallCheck(this, ResizingMarkView);
25
+ var dom = document.createElement('div');
26
+ var contentDOM = document.createElement('div');
27
+ contentDOM.className = BreakoutCssClassName.BREAKOUT_MARK_DOM;
28
+ contentDOM.setAttribute('data-testid', 'ak-editor-breakout-mark-dom');
29
+ dom.className = BreakoutCssClassName.BREAKOUT_MARK;
30
+ dom.setAttribute('data-layout', mark.attrs.mode);
31
+ dom.setAttribute('data-testid', 'ak-editor-breakout-mark');
32
+ // dom - styles
33
+ dom.style.transform = 'none';
34
+ dom.style.display = 'grid';
35
+ dom.style.justifyContent = 'center';
36
+ dom.style.position = 'relative';
37
+
38
+ // contentDOM - styles
39
+ contentDOM.style.gridRow = '1';
40
+ contentDOM.style.gridColumn = '1';
41
+ if (mark.attrs.width) {
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)))");
43
+ } else {
44
+ if (mark.attrs.mode === 'wide') {
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))))");
46
+ }
47
+ if (mark.attrs.mode === 'full-width') {
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))))");
49
+ }
50
+ }
51
+ dom.appendChild(contentDOM);
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),
60
+ leftHandle = _createPragmaticResiz.leftHandle,
61
+ rightHandle = _createPragmaticResiz.rightHandle,
62
+ destroy = _createPragmaticResiz.destroy;
63
+ dom.prepend(leftHandle);
64
+ dom.appendChild(rightHandle);
65
+ this.dom = dom;
66
+ this.contentDOM = contentDOM;
67
+ this.view = view;
68
+ this.mark = mark;
69
+ this.destroyFn = destroy;
70
+ }
71
+
72
+ /**
73
+ *
74
+ * @example
75
+ */
76
+ return _createClass(ResizingMarkView, [{
77
+ key: "ignoreMutation",
78
+ value: function ignoreMutation() {
79
+ return true;
80
+ }
81
+
82
+ /**
83
+ *
84
+ * @example
85
+ */
86
+ }, {
87
+ key: "destroy",
88
+ value: function destroy() {
89
+ this.destroyFn();
90
+ }
91
+ }]);
92
+ }();
93
+ var createPragmaticResizer = function createPragmaticResizer(_ref) {
94
+ var onDragStart = _ref.onDragStart,
95
+ onDrag = _ref.onDrag,
96
+ _onDrop = _ref.onDrop;
97
+ var registerHandle = function registerHandle(handleElement) {
98
+ return draggable({
99
+ element: handleElement,
100
+ onGenerateDragPreview: function onGenerateDragPreview(_ref2) {
101
+ var nativeSetDragImage = _ref2.nativeSetDragImage;
102
+ disableNativeDragPreview({
103
+ nativeSetDragImage: nativeSetDragImage
104
+ });
105
+ preventUnhandled.start();
106
+ },
107
+ onDragStart: onDragStart,
108
+ onDrag: onDrag,
109
+ onDrop: function onDrop(args) {
110
+ preventUnhandled.stop();
111
+ _onDrop(args);
112
+ }
113
+ });
114
+ };
115
+ var createHandle = function createHandle(side) {
116
+ var handle = document.createElement('div');
117
+ handle.contentEditable = 'false';
118
+ handle.classList.add('pm-breakout-resize-handle');
119
+ if (side === 'left') {
120
+ handle.classList.add('pm-breakout-resize-handle-left');
121
+ } else {
122
+ handle.classList.add('pm-breakout-resize-handle-right');
123
+ }
124
+ var handleInner = document.createElement('div');
125
+ handleInner.classList.add('pm-breakout-resize-handle-inner');
126
+ handle.appendChild(handleInner);
127
+ return handle;
128
+ };
129
+ var rightHandle = createHandle('right');
130
+ var leftHandle = createHandle('left');
131
+ var rightHandleCleanup = registerHandle(rightHandle);
132
+ var leftHandleCleanup = registerHandle(leftHandle);
133
+ return {
134
+ rightHandle: rightHandle,
135
+ leftHandle: leftHandle,
136
+ destroy: function destroy() {
137
+ rightHandleCleanup();
138
+ leftHandleCleanup();
139
+ }
140
+ };
141
+ };
@@ -0,0 +1,16 @@
1
+ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
+ import { PluginKey } from '@atlaskit/editor-prosemirror/state';
3
+ import { ResizingMarkView } from './resizing-mark-view';
4
+ export var resizingPluginKey = new PluginKey('breakout-resizing');
5
+ export var createResizingPlugin = function createResizingPlugin(api) {
6
+ return new SafePlugin({
7
+ key: resizingPluginKey,
8
+ props: {
9
+ markViews: {
10
+ breakout: function breakout(mark, view) {
11
+ return new ResizingMarkView(mark, view, api);
12
+ }
13
+ }
14
+ }
15
+ });
16
+ };
@@ -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 { Command } from '@atlaskit/editor-common/types';
2
+ export declare function setBreakoutWidth(width: number, 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
+ };
@@ -0,0 +1,35 @@
1
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
2
+ import type { Mark } from '@atlaskit/editor-prosemirror/model';
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";
6
+ /**
7
+ *
8
+ */
9
+ export declare class ResizingMarkView implements NodeView {
10
+ dom: HTMLElement;
11
+ contentDOM: HTMLElement;
12
+ view: EditorView;
13
+ mark: Mark;
14
+ destroyFn: () => void;
15
+ /**
16
+ * Wrap node view in a resizing mark view
17
+ * @param {Mark} mark - The breakout mark to resize
18
+ * @param {EditorView} view - The editor view
19
+ * @param {ExtractInjectionAPI<BreakoutPlugin> | undefined} api - the pluginInjectionAPI
20
+ * @example
21
+ * ```ts
22
+ * ```
23
+ */
24
+ constructor(mark: Mark, view: EditorView, api: ExtractInjectionAPI<BreakoutPlugin> | undefined);
25
+ /**
26
+ *
27
+ * @example
28
+ */
29
+ ignoreMutation(): boolean;
30
+ /**
31
+ *
32
+ * @example
33
+ */
34
+ destroy(): void;
35
+ }
@@ -0,0 +1,6 @@
1
+ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
+ import { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
+ import { PluginKey } from '@atlaskit/editor-prosemirror/state';
4
+ import { BreakoutPlugin } from '../breakoutPluginType';
5
+ export declare const resizingPluginKey: PluginKey<any>;
6
+ export declare const createResizingPlugin: (api: ExtractInjectionAPI<BreakoutPlugin> | undefined) => 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 { Command } from '@atlaskit/editor-common/types';
2
+ export declare function setBreakoutWidth(width: number, 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
+ };
@@ -0,0 +1,35 @@
1
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
2
+ import type { Mark } from '@atlaskit/editor-prosemirror/model';
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";
6
+ /**
7
+ *
8
+ */
9
+ export declare class ResizingMarkView implements NodeView {
10
+ dom: HTMLElement;
11
+ contentDOM: HTMLElement;
12
+ view: EditorView;
13
+ mark: Mark;
14
+ destroyFn: () => void;
15
+ /**
16
+ * Wrap node view in a resizing mark view
17
+ * @param {Mark} mark - The breakout mark to resize
18
+ * @param {EditorView} view - The editor view
19
+ * @param {ExtractInjectionAPI<BreakoutPlugin> | undefined} api - the pluginInjectionAPI
20
+ * @example
21
+ * ```ts
22
+ * ```
23
+ */
24
+ constructor(mark: Mark, view: EditorView, api: ExtractInjectionAPI<BreakoutPlugin> | undefined);
25
+ /**
26
+ *
27
+ * @example
28
+ */
29
+ ignoreMutation(): boolean;
30
+ /**
31
+ *
32
+ * @example
33
+ */
34
+ destroy(): void;
35
+ }
@@ -0,0 +1,6 @@
1
+ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
+ import { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
+ import { PluginKey } from '@atlaskit/editor-prosemirror/state';
4
+ import { BreakoutPlugin } from '../breakoutPluginType';
5
+ export declare const resizingPluginKey: PluginKey<any>;
6
+ export declare const createResizingPlugin: (api: ExtractInjectionAPI<BreakoutPlugin> | undefined) => SafePlugin<any>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-breakout",
3
- "version": "2.2.4",
3
+ "version": "2.2.6",
4
4
  "description": "Breakout plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -34,18 +34,20 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "@atlaskit/adf-schema": "^47.6.0",
37
- "@atlaskit/editor-common": "^105.0.0",
38
- "@atlaskit/editor-plugin-block-controls": "^3.13.0",
37
+ "@atlaskit/editor-common": "^105.8.0",
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",
44
- "@atlaskit/icon": "^26.0.0",
45
+ "@atlaskit/icon": "^26.1.0",
45
46
  "@atlaskit/platform-feature-flags": "^1.1.0",
47
+ "@atlaskit/pragmatic-drag-and-drop": "^1.7.0",
46
48
  "@atlaskit/theme": "^18.0.0",
47
- "@atlaskit/tmp-editor-statsig": "^4.19.0",
48
- "@atlaskit/tokens": "^4.8.0",
49
+ "@atlaskit/tmp-editor-statsig": "^4.24.0",
50
+ "@atlaskit/tokens": "^4.9.0",
49
51
  "@babel/runtime": "^7.0.0",
50
52
  "@emotion/react": "^11.7.1"
51
53
  },