@atlaskit/editor-plugin-breakout 2.2.3 → 2.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/dist/cjs/breakoutPlugin.js +9 -0
- package/dist/cjs/pm-plugins/resizing-mark-view.js +143 -0
- package/dist/cjs/pm-plugins/resizing-plugin.js +22 -0
- package/dist/es2019/breakoutPlugin.js +7 -0
- package/dist/es2019/pm-plugins/resizing-mark-view.js +131 -0
- package/dist/es2019/pm-plugins/resizing-plugin.js +16 -0
- package/dist/esm/breakoutPlugin.js +9 -0
- package/dist/esm/pm-plugins/resizing-mark-view.js +136 -0
- package/dist/esm/pm-plugins/resizing-plugin.js +16 -0
- package/dist/types/pm-plugins/resizing-mark-view.d.ts +31 -0
- package/dist/types/pm-plugins/resizing-plugin.d.ts +4 -0
- package/dist/types-ts4.5/pm-plugins/resizing-mark-view.d.ts +31 -0
- package/dist/types-ts4.5/pm-plugins/resizing-plugin.d.ts +4 -0
- package/package.json +7 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-breakout
|
|
2
2
|
|
|
3
|
+
## 2.2.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#156743](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/156743)
|
|
8
|
+
[`170609348890d`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/170609348890d) -
|
|
9
|
+
Add new breakout resizing experience under experiment platform_editor_breakout_resizing
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
12
|
+
## 2.2.4
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Updated dependencies
|
|
17
|
+
|
|
3
18
|
## 2.2.3
|
|
4
19
|
|
|
5
20
|
### 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; }
|
|
@@ -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)();
|
|
182
|
+
}
|
|
183
|
+
}];
|
|
184
|
+
}
|
|
176
185
|
return [{
|
|
177
186
|
name: 'breakout',
|
|
178
187
|
plugin: function plugin(props) {
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.ResizingMarkView = 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 localResizeProperty = '--local-resizing-width';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
*
|
|
18
|
+
*/
|
|
19
|
+
var ResizingMarkView = exports.ResizingMarkView = /*#__PURE__*/function () {
|
|
20
|
+
/**
|
|
21
|
+
* Wrap node view in a resizing mark view
|
|
22
|
+
* @param {Mark} mark - The breakout mark to resize
|
|
23
|
+
* @param {EditorView} view - The editor view
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
function ResizingMarkView(mark, view) {
|
|
29
|
+
(0, _classCallCheck2.default)(this, ResizingMarkView);
|
|
30
|
+
var dom = document.createElement('div');
|
|
31
|
+
var contentDOM = document.createElement('div');
|
|
32
|
+
contentDOM.className = _styles.BreakoutCssClassName.BREAKOUT_MARK_DOM;
|
|
33
|
+
contentDOM.setAttribute('data-testid', 'ak-editor-breakout-mark-dom');
|
|
34
|
+
dom.className = _styles.BreakoutCssClassName.BREAKOUT_MARK;
|
|
35
|
+
dom.setAttribute('data-layout', mark.attrs.mode);
|
|
36
|
+
dom.setAttribute('data-testid', 'ak-editor-breakout-mark');
|
|
37
|
+
// dom - styles
|
|
38
|
+
dom.style.transform = 'none';
|
|
39
|
+
dom.style.display = 'grid';
|
|
40
|
+
dom.style.justifyContent = 'center';
|
|
41
|
+
dom.style.position = 'relative';
|
|
42
|
+
|
|
43
|
+
// contentDOM - styles
|
|
44
|
+
contentDOM.style.gridRow = '1';
|
|
45
|
+
contentDOM.style.gridColumn = '1';
|
|
46
|
+
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)))");
|
|
48
|
+
} else {
|
|
49
|
+
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))))");
|
|
51
|
+
}
|
|
52
|
+
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))))");
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
dom.appendChild(contentDOM);
|
|
57
|
+
var _createPragmaticResiz = createPragmaticResizer({
|
|
58
|
+
onDragStart: function onDragStart() {},
|
|
59
|
+
onDrag: function onDrag() {},
|
|
60
|
+
onDrop: function onDrop() {}
|
|
61
|
+
}),
|
|
62
|
+
leftHandle = _createPragmaticResiz.leftHandle,
|
|
63
|
+
rightHandle = _createPragmaticResiz.rightHandle,
|
|
64
|
+
destroy = _createPragmaticResiz.destroy;
|
|
65
|
+
dom.prepend(leftHandle);
|
|
66
|
+
dom.appendChild(rightHandle);
|
|
67
|
+
this.dom = dom;
|
|
68
|
+
this.contentDOM = contentDOM;
|
|
69
|
+
this.view = view;
|
|
70
|
+
this.mark = mark;
|
|
71
|
+
this.destroyFn = destroy;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
*/
|
|
78
|
+
return (0, _createClass2.default)(ResizingMarkView, [{
|
|
79
|
+
key: "ignoreMutation",
|
|
80
|
+
value: function ignoreMutation() {
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
*/
|
|
88
|
+
}, {
|
|
89
|
+
key: "destroy",
|
|
90
|
+
value: function destroy() {
|
|
91
|
+
this.destroyFn();
|
|
92
|
+
}
|
|
93
|
+
}]);
|
|
94
|
+
}();
|
|
95
|
+
var createPragmaticResizer = function createPragmaticResizer(_ref) {
|
|
96
|
+
var onDragStart = _ref.onDragStart,
|
|
97
|
+
onDrag = _ref.onDrag,
|
|
98
|
+
_onDrop = _ref.onDrop;
|
|
99
|
+
var registerHandle = function registerHandle(handleElement) {
|
|
100
|
+
return (0, _adapter.draggable)({
|
|
101
|
+
element: handleElement,
|
|
102
|
+
onGenerateDragPreview: function onGenerateDragPreview(_ref2) {
|
|
103
|
+
var nativeSetDragImage = _ref2.nativeSetDragImage;
|
|
104
|
+
(0, _disableNativeDragPreview.disableNativeDragPreview)({
|
|
105
|
+
nativeSetDragImage: nativeSetDragImage
|
|
106
|
+
});
|
|
107
|
+
_preventUnhandled.preventUnhandled.start();
|
|
108
|
+
},
|
|
109
|
+
onDragStart: onDragStart,
|
|
110
|
+
onDrag: onDrag,
|
|
111
|
+
onDrop: function onDrop(args) {
|
|
112
|
+
_preventUnhandled.preventUnhandled.stop();
|
|
113
|
+
_onDrop(args);
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
};
|
|
117
|
+
var createHandle = function createHandle(side) {
|
|
118
|
+
var handle = document.createElement('div');
|
|
119
|
+
handle.contentEditable = 'false';
|
|
120
|
+
handle.classList.add('pm-breakout-resize-handle');
|
|
121
|
+
if (side === 'left') {
|
|
122
|
+
handle.classList.add('pm-breakout-resize-handle-left');
|
|
123
|
+
} else {
|
|
124
|
+
handle.classList.add('pm-breakout-resize-handle-right');
|
|
125
|
+
}
|
|
126
|
+
var handleInner = document.createElement('div');
|
|
127
|
+
handleInner.classList.add('pm-breakout-resize-handle-inner');
|
|
128
|
+
handle.appendChild(handleInner);
|
|
129
|
+
return handle;
|
|
130
|
+
};
|
|
131
|
+
var rightHandle = createHandle('right');
|
|
132
|
+
var leftHandle = createHandle('left');
|
|
133
|
+
var rightHandleCleanup = registerHandle(rightHandle);
|
|
134
|
+
var leftHandleCleanup = registerHandle(leftHandle);
|
|
135
|
+
return {
|
|
136
|
+
rightHandle: rightHandle,
|
|
137
|
+
leftHandle: leftHandle,
|
|
138
|
+
destroy: function destroy() {
|
|
139
|
+
rightHandleCleanup();
|
|
140
|
+
leftHandleCleanup();
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
};
|
|
@@ -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() {
|
|
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);
|
|
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 {
|
|
@@ -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()
|
|
175
|
+
}];
|
|
176
|
+
}
|
|
170
177
|
return [{
|
|
171
178
|
name: 'breakout',
|
|
172
179
|
plugin: props => createPlugin(api, props)
|
|
@@ -0,0 +1,131 @@
|
|
|
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
|
+
const localResizeProperty = '--local-resizing-width';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
*/
|
|
10
|
+
export class ResizingMarkView {
|
|
11
|
+
/**
|
|
12
|
+
* Wrap node view in a resizing mark view
|
|
13
|
+
* @param {Mark} mark - The breakout mark to resize
|
|
14
|
+
* @param {EditorView} view - The editor view
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
constructor(mark, view) {
|
|
20
|
+
const dom = document.createElement('div');
|
|
21
|
+
const contentDOM = document.createElement('div');
|
|
22
|
+
contentDOM.className = BreakoutCssClassName.BREAKOUT_MARK_DOM;
|
|
23
|
+
contentDOM.setAttribute('data-testid', 'ak-editor-breakout-mark-dom');
|
|
24
|
+
dom.className = BreakoutCssClassName.BREAKOUT_MARK;
|
|
25
|
+
dom.setAttribute('data-layout', mark.attrs.mode);
|
|
26
|
+
dom.setAttribute('data-testid', 'ak-editor-breakout-mark');
|
|
27
|
+
// dom - styles
|
|
28
|
+
dom.style.transform = 'none';
|
|
29
|
+
dom.style.display = 'grid';
|
|
30
|
+
dom.style.justifyContent = 'center';
|
|
31
|
+
dom.style.position = 'relative';
|
|
32
|
+
|
|
33
|
+
// contentDOM - styles
|
|
34
|
+
contentDOM.style.gridRow = '1';
|
|
35
|
+
contentDOM.style.gridColumn = '1';
|
|
36
|
+
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)))`;
|
|
38
|
+
} else {
|
|
39
|
+
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))))`;
|
|
41
|
+
}
|
|
42
|
+
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))))`;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
dom.appendChild(contentDOM);
|
|
47
|
+
const {
|
|
48
|
+
leftHandle,
|
|
49
|
+
rightHandle,
|
|
50
|
+
destroy
|
|
51
|
+
} = createPragmaticResizer({
|
|
52
|
+
onDragStart: () => {},
|
|
53
|
+
onDrag: () => {},
|
|
54
|
+
onDrop: () => {}
|
|
55
|
+
});
|
|
56
|
+
dom.prepend(leftHandle);
|
|
57
|
+
dom.appendChild(rightHandle);
|
|
58
|
+
this.dom = dom;
|
|
59
|
+
this.contentDOM = contentDOM;
|
|
60
|
+
this.view = view;
|
|
61
|
+
this.mark = mark;
|
|
62
|
+
this.destroyFn = destroy;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
*/
|
|
69
|
+
ignoreMutation() {
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
*/
|
|
77
|
+
destroy() {
|
|
78
|
+
this.destroyFn();
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
const createPragmaticResizer = ({
|
|
82
|
+
onDragStart,
|
|
83
|
+
onDrag,
|
|
84
|
+
onDrop
|
|
85
|
+
}) => {
|
|
86
|
+
const registerHandle = handleElement => {
|
|
87
|
+
return draggable({
|
|
88
|
+
element: handleElement,
|
|
89
|
+
onGenerateDragPreview: ({
|
|
90
|
+
nativeSetDragImage
|
|
91
|
+
}) => {
|
|
92
|
+
disableNativeDragPreview({
|
|
93
|
+
nativeSetDragImage
|
|
94
|
+
});
|
|
95
|
+
preventUnhandled.start();
|
|
96
|
+
},
|
|
97
|
+
onDragStart,
|
|
98
|
+
onDrag,
|
|
99
|
+
onDrop(args) {
|
|
100
|
+
preventUnhandled.stop();
|
|
101
|
+
onDrop(args);
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
};
|
|
105
|
+
const createHandle = side => {
|
|
106
|
+
const handle = document.createElement('div');
|
|
107
|
+
handle.contentEditable = 'false';
|
|
108
|
+
handle.classList.add('pm-breakout-resize-handle');
|
|
109
|
+
if (side === 'left') {
|
|
110
|
+
handle.classList.add('pm-breakout-resize-handle-left');
|
|
111
|
+
} else {
|
|
112
|
+
handle.classList.add('pm-breakout-resize-handle-right');
|
|
113
|
+
}
|
|
114
|
+
const handleInner = document.createElement('div');
|
|
115
|
+
handleInner.classList.add('pm-breakout-resize-handle-inner');
|
|
116
|
+
handle.appendChild(handleInner);
|
|
117
|
+
return handle;
|
|
118
|
+
};
|
|
119
|
+
const rightHandle = createHandle('right');
|
|
120
|
+
const leftHandle = createHandle('left');
|
|
121
|
+
const rightHandleCleanup = registerHandle(rightHandle);
|
|
122
|
+
const leftHandleCleanup = registerHandle(leftHandle);
|
|
123
|
+
return {
|
|
124
|
+
rightHandle,
|
|
125
|
+
leftHandle,
|
|
126
|
+
destroy: () => {
|
|
127
|
+
rightHandleCleanup();
|
|
128
|
+
leftHandleCleanup();
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
};
|
|
@@ -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 = () => {
|
|
6
|
+
return new SafePlugin({
|
|
7
|
+
key: resizingPluginKey,
|
|
8
|
+
props: {
|
|
9
|
+
markViews: {
|
|
10
|
+
breakout: (mark, view) => {
|
|
11
|
+
return new ResizingMarkView(mark, view);
|
|
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(
|
|
@@ -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();
|
|
175
|
+
}
|
|
176
|
+
}];
|
|
177
|
+
}
|
|
169
178
|
return [{
|
|
170
179
|
name: 'breakout',
|
|
171
180
|
plugin: function plugin(props) {
|
|
@@ -0,0 +1,136 @@
|
|
|
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
|
+
var localResizeProperty = '--local-resizing-width';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
export var ResizingMarkView = /*#__PURE__*/function () {
|
|
13
|
+
/**
|
|
14
|
+
* Wrap node view in a resizing mark view
|
|
15
|
+
* @param {Mark} mark - The breakout mark to resize
|
|
16
|
+
* @param {EditorView} view - The editor view
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
function ResizingMarkView(mark, view) {
|
|
22
|
+
_classCallCheck(this, ResizingMarkView);
|
|
23
|
+
var dom = document.createElement('div');
|
|
24
|
+
var contentDOM = document.createElement('div');
|
|
25
|
+
contentDOM.className = BreakoutCssClassName.BREAKOUT_MARK_DOM;
|
|
26
|
+
contentDOM.setAttribute('data-testid', 'ak-editor-breakout-mark-dom');
|
|
27
|
+
dom.className = BreakoutCssClassName.BREAKOUT_MARK;
|
|
28
|
+
dom.setAttribute('data-layout', mark.attrs.mode);
|
|
29
|
+
dom.setAttribute('data-testid', 'ak-editor-breakout-mark');
|
|
30
|
+
// dom - styles
|
|
31
|
+
dom.style.transform = 'none';
|
|
32
|
+
dom.style.display = 'grid';
|
|
33
|
+
dom.style.justifyContent = 'center';
|
|
34
|
+
dom.style.position = 'relative';
|
|
35
|
+
|
|
36
|
+
// contentDOM - styles
|
|
37
|
+
contentDOM.style.gridRow = '1';
|
|
38
|
+
contentDOM.style.gridColumn = '1';
|
|
39
|
+
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)))");
|
|
41
|
+
} else {
|
|
42
|
+
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))))");
|
|
44
|
+
}
|
|
45
|
+
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))))");
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
dom.appendChild(contentDOM);
|
|
50
|
+
var _createPragmaticResiz = createPragmaticResizer({
|
|
51
|
+
onDragStart: function onDragStart() {},
|
|
52
|
+
onDrag: function onDrag() {},
|
|
53
|
+
onDrop: function onDrop() {}
|
|
54
|
+
}),
|
|
55
|
+
leftHandle = _createPragmaticResiz.leftHandle,
|
|
56
|
+
rightHandle = _createPragmaticResiz.rightHandle,
|
|
57
|
+
destroy = _createPragmaticResiz.destroy;
|
|
58
|
+
dom.prepend(leftHandle);
|
|
59
|
+
dom.appendChild(rightHandle);
|
|
60
|
+
this.dom = dom;
|
|
61
|
+
this.contentDOM = contentDOM;
|
|
62
|
+
this.view = view;
|
|
63
|
+
this.mark = mark;
|
|
64
|
+
this.destroyFn = destroy;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
*/
|
|
71
|
+
return _createClass(ResizingMarkView, [{
|
|
72
|
+
key: "ignoreMutation",
|
|
73
|
+
value: function ignoreMutation() {
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
*/
|
|
81
|
+
}, {
|
|
82
|
+
key: "destroy",
|
|
83
|
+
value: function destroy() {
|
|
84
|
+
this.destroyFn();
|
|
85
|
+
}
|
|
86
|
+
}]);
|
|
87
|
+
}();
|
|
88
|
+
var createPragmaticResizer = function createPragmaticResizer(_ref) {
|
|
89
|
+
var onDragStart = _ref.onDragStart,
|
|
90
|
+
onDrag = _ref.onDrag,
|
|
91
|
+
_onDrop = _ref.onDrop;
|
|
92
|
+
var registerHandle = function registerHandle(handleElement) {
|
|
93
|
+
return draggable({
|
|
94
|
+
element: handleElement,
|
|
95
|
+
onGenerateDragPreview: function onGenerateDragPreview(_ref2) {
|
|
96
|
+
var nativeSetDragImage = _ref2.nativeSetDragImage;
|
|
97
|
+
disableNativeDragPreview({
|
|
98
|
+
nativeSetDragImage: nativeSetDragImage
|
|
99
|
+
});
|
|
100
|
+
preventUnhandled.start();
|
|
101
|
+
},
|
|
102
|
+
onDragStart: onDragStart,
|
|
103
|
+
onDrag: onDrag,
|
|
104
|
+
onDrop: function onDrop(args) {
|
|
105
|
+
preventUnhandled.stop();
|
|
106
|
+
_onDrop(args);
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
};
|
|
110
|
+
var createHandle = function createHandle(side) {
|
|
111
|
+
var 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
|
+
var handleInner = document.createElement('div');
|
|
120
|
+
handleInner.classList.add('pm-breakout-resize-handle-inner');
|
|
121
|
+
handle.appendChild(handleInner);
|
|
122
|
+
return handle;
|
|
123
|
+
};
|
|
124
|
+
var rightHandle = createHandle('right');
|
|
125
|
+
var leftHandle = createHandle('left');
|
|
126
|
+
var rightHandleCleanup = registerHandle(rightHandle);
|
|
127
|
+
var leftHandleCleanup = registerHandle(leftHandle);
|
|
128
|
+
return {
|
|
129
|
+
rightHandle: rightHandle,
|
|
130
|
+
leftHandle: leftHandle,
|
|
131
|
+
destroy: function 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 var resizingPluginKey = new PluginKey('breakout-resizing');
|
|
5
|
+
export var createResizingPlugin = function createResizingPlugin() {
|
|
6
|
+
return new SafePlugin({
|
|
7
|
+
key: resizingPluginKey,
|
|
8
|
+
props: {
|
|
9
|
+
markViews: {
|
|
10
|
+
breakout: function breakout(mark, view) {
|
|
11
|
+
return new ResizingMarkView(mark, view);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Mark } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
import type { EditorView, NodeView } from '@atlaskit/editor-prosemirror/view';
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
export declare class ResizingMarkView implements NodeView {
|
|
7
|
+
dom: HTMLElement;
|
|
8
|
+
contentDOM: HTMLElement;
|
|
9
|
+
view: EditorView;
|
|
10
|
+
mark: Mark;
|
|
11
|
+
destroyFn: () => void;
|
|
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
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
constructor(mark: Mark, view: EditorView);
|
|
21
|
+
/**
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
*/
|
|
25
|
+
ignoreMutation(): boolean;
|
|
26
|
+
/**
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
*/
|
|
30
|
+
destroy(): void;
|
|
31
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Mark } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
import type { EditorView, NodeView } from '@atlaskit/editor-prosemirror/view';
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
export declare class ResizingMarkView implements NodeView {
|
|
7
|
+
dom: HTMLElement;
|
|
8
|
+
contentDOM: HTMLElement;
|
|
9
|
+
view: EditorView;
|
|
10
|
+
mark: Mark;
|
|
11
|
+
destroyFn: () => void;
|
|
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
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
constructor(mark: Mark, view: EditorView);
|
|
21
|
+
/**
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
*/
|
|
25
|
+
ignoreMutation(): boolean;
|
|
26
|
+
/**
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
*/
|
|
30
|
+
destroy(): void;
|
|
31
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-breakout",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.5",
|
|
4
4
|
"description": "Breakout plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -34,18 +34,19 @@
|
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@atlaskit/adf-schema": "^47.6.0",
|
|
37
|
-
"@atlaskit/editor-common": "^
|
|
38
|
-
"@atlaskit/editor-plugin-block-controls": "^3.
|
|
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
41
|
"@atlaskit/editor-plugin-width": "^3.0.0",
|
|
42
42
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
43
43
|
"@atlaskit/editor-shared-styles": "^3.4.0",
|
|
44
|
-
"@atlaskit/icon": "^26.
|
|
44
|
+
"@atlaskit/icon": "^26.1.0",
|
|
45
45
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
46
|
+
"@atlaskit/pragmatic-drag-and-drop": "^1.7.0",
|
|
46
47
|
"@atlaskit/theme": "^18.0.0",
|
|
47
|
-
"@atlaskit/tmp-editor-statsig": "^4.
|
|
48
|
-
"@atlaskit/tokens": "^4.
|
|
48
|
+
"@atlaskit/tmp-editor-statsig": "^4.23.0",
|
|
49
|
+
"@atlaskit/tokens": "^4.9.0",
|
|
49
50
|
"@babel/runtime": "^7.0.0",
|
|
50
51
|
"@emotion/react": "^11.7.1"
|
|
51
52
|
},
|