@atlaskit/editor-core 187.14.4 → 187.14.7
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/plugins/insert-block/ui/ToolbarInsertBlock/index.js +4 -1
- package/dist/cjs/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +153 -192
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/index.js +4 -1
- package/dist/es2019/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +126 -167
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/index.js +4 -1
- package/dist/esm/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +155 -194
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/labs/next/presets/default.d.ts +12 -4
- package/dist/types/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.d.ts +21 -3
- package/dist/types-ts4.5/labs/next/presets/default.d.ts +12 -4
- package/dist/types-ts4.5/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.d.ts +21 -3
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @atlaskit/editor-core
|
|
2
2
|
|
|
3
|
+
## 187.14.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`3bbe8f91f34`](https://bitbucket.org/atlassian/atlassian-frontend/commits/3bbe8f91f34) - refactor ResizableMediaSingleNext around guidelines and snapping
|
|
8
|
+
- [`a675f834911`](https://bitbucket.org/atlassian/atlassian-frontend/commits/a675f834911) - Introduce `commands` optional parameter to `NextEditorPlugin`. It can be used similarly to `actions` in `NextEditorPlugin` but `commands` must adhere to the type of `PluginCommand`:
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
type PluginCommand = ({ tr }: { tr: Transaction }) => Transaction | null;
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
`PluginCommand`s are specifically used for code that is executed to modify a Transaction. They should be used in preference to the existing prosemirror `Command` type.
|
|
15
|
+
|
|
16
|
+
- Updated dependencies
|
|
17
|
+
|
|
3
18
|
## 187.14.4
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
|
@@ -19,6 +19,7 @@ var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
|
19
19
|
var _reactIntlNext = require("react-intl-next");
|
|
20
20
|
var _picker = require("@atlaskit/emoji/picker");
|
|
21
21
|
var _ui = require("@atlaskit/editor-common/ui");
|
|
22
|
+
var _preset = require("@atlaskit/editor-common/preset");
|
|
22
23
|
var _ToolbarButton = _interopRequireDefault(require("../../../../ui/ToolbarButton"));
|
|
23
24
|
var _styles = require("@atlaskit/editor-common/styles");
|
|
24
25
|
var _actions = require("../../../date/actions");
|
|
@@ -177,7 +178,9 @@ var ToolbarInsertBlock = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
177
178
|
pluginInjectionApi = _this$props.pluginInjectionApi;
|
|
178
179
|
var state = editorView.state,
|
|
179
180
|
dispatch = editorView.dispatch;
|
|
180
|
-
|
|
181
|
+
|
|
182
|
+
// We should update this to use `pluginInjectionApi.executeCommand` once available
|
|
183
|
+
(0, _preset.pluginCommandToPMCommand)(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d = pluginInjectionApi.dependencies) === null || _pluginInjectionApi$d === void 0 ? void 0 : (_pluginInjectionApi$d2 = _pluginInjectionApi$d.hyperlink) === null || _pluginInjectionApi$d2 === void 0 ? void 0 : _pluginInjectionApi$d2.commands.showLinkToolbar(inputMethod))(state, dispatch);
|
|
181
184
|
return true;
|
|
182
185
|
});
|
|
183
186
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "insertMention", function (inputMethod) {
|
|
@@ -58,12 +58,28 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
58
58
|
var _this;
|
|
59
59
|
(0, _classCallCheck2.default)(this, ResizableMediaSingleNext);
|
|
60
60
|
_this = _super.call(this, props);
|
|
61
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "
|
|
61
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "guidelines", []);
|
|
62
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getAllGuidelines", function () {
|
|
62
63
|
var _this$props = _this.props,
|
|
63
|
-
|
|
64
|
-
state = _this$props.view.state,
|
|
65
|
-
containerWidth = _this$props.containerWidth,
|
|
64
|
+
view = _this$props.view,
|
|
66
65
|
lineLength = _this$props.lineLength;
|
|
66
|
+
var defaultGuidelines = _this.getDefaultGuidelines();
|
|
67
|
+
// disable guidelines for nested media single node
|
|
68
|
+
var dynamicGuidelines = _this.isNestedNode() ? [] : (0, _guideline.generateDynamicGuidelines)(view.state, lineLength, {
|
|
69
|
+
styles: {
|
|
70
|
+
lineStyle: 'dashed'
|
|
71
|
+
},
|
|
72
|
+
show: false
|
|
73
|
+
});
|
|
74
|
+
var guidelines = [].concat((0, _toConsumableArray2.default)(defaultGuidelines), (0, _toConsumableArray2.default)(dynamicGuidelines));
|
|
75
|
+
return guidelines;
|
|
76
|
+
});
|
|
77
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "calcNewSize", function (newWidth, stop) {
|
|
78
|
+
var _this$props2 = _this.props,
|
|
79
|
+
layout = _this$props2.layout,
|
|
80
|
+
state = _this$props2.view.state,
|
|
81
|
+
containerWidth = _this$props2.containerWidth,
|
|
82
|
+
lineLength = _this$props2.lineLength;
|
|
67
83
|
var newPct = (0, _ui.calcPctFromPx)(newWidth, _this.props.lineLength) * 100;
|
|
68
84
|
_this.setState({
|
|
69
85
|
resizedPctWidth: newPct
|
|
@@ -102,10 +118,10 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
102
118
|
return _this.insideInlineLike ? (0, _ui.calcColumnsFromPx)(offsetLeft, _this.props.lineLength, _this.props.gridSize) : 0;
|
|
103
119
|
});
|
|
104
120
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "calcPxHeight", function (newWidth) {
|
|
105
|
-
var _this$
|
|
106
|
-
_this$
|
|
107
|
-
width = _this$
|
|
108
|
-
height = _this$
|
|
121
|
+
var _this$props3 = _this.props,
|
|
122
|
+
_this$props3$width = _this$props3.width,
|
|
123
|
+
width = _this$props3$width === void 0 ? newWidth : _this$props3$width,
|
|
124
|
+
height = _this$props3.height;
|
|
109
125
|
return Math.round(height / width * newWidth);
|
|
110
126
|
});
|
|
111
127
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "saveWrapper", function (wrapper) {
|
|
@@ -126,6 +142,111 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
126
142
|
tr.setMeta('mediaSinglePlugin.isResizing', isResizing);
|
|
127
143
|
return dispatch(tr);
|
|
128
144
|
});
|
|
145
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "updateActiveGuidelines", function () {
|
|
146
|
+
var width = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
147
|
+
var guidelines = arguments.length > 1 ? arguments[1] : undefined;
|
|
148
|
+
var guidelineSnapsReference = arguments.length > 2 ? arguments[2] : undefined;
|
|
149
|
+
if (guidelineSnapsReference.snaps.x) {
|
|
150
|
+
var _findClosestSnap = (0, _guideline.findClosestSnap)(width, guidelineSnapsReference.snaps.x, guidelineSnapsReference.guidelineReference, _mediaSingle.MEDIA_SINGLE_SNAP_GAP),
|
|
151
|
+
gap = _findClosestSnap.gap,
|
|
152
|
+
activeGuidelineKeys = _findClosestSnap.keys;
|
|
153
|
+
_this.displayGuideline((0, _guideline.getGuidelinesWithHighlights)(gap, _mediaSingle.MEDIA_SINGLE_SNAP_GAP, activeGuidelineKeys, guidelines));
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "roundPixelValue", function (value) {
|
|
157
|
+
return Math.round(value);
|
|
158
|
+
});
|
|
159
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getHeightFromNewWidth", function (originalWidth, originalHeight, newWidth) {
|
|
160
|
+
return _this.roundPixelValue(originalHeight / originalWidth * newWidth);
|
|
161
|
+
});
|
|
162
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "calculateSizeState", function (size, delta) {
|
|
163
|
+
var originalWidth = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
164
|
+
var originalHeight = arguments.length > 3 ? arguments[3] : undefined;
|
|
165
|
+
var onResizeStop = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
166
|
+
var calculatedWidth = _this.roundPixelValue(size.width + delta.width);
|
|
167
|
+
var calculatedWidthWithLayout = _this.calcNewSize(calculatedWidth, onResizeStop);
|
|
168
|
+
var calculatedHeightWithLayout = _this.getHeightFromNewWidth(originalWidth, originalHeight, calculatedWidth);
|
|
169
|
+
return {
|
|
170
|
+
width: calculatedWidth,
|
|
171
|
+
height: calculatedHeightWithLayout,
|
|
172
|
+
calculatedWidthWithLayout: calculatedWidthWithLayout
|
|
173
|
+
};
|
|
174
|
+
});
|
|
175
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "selectCurrentMediaNode", function () {
|
|
176
|
+
// TODO: if adding !this.props.selected, it doesn't work if media single node is at top postion
|
|
177
|
+
if (typeof _this.props.getPos === 'function') {
|
|
178
|
+
var propPos = _this.props.getPos();
|
|
179
|
+
if (propPos !== undefined) {
|
|
180
|
+
(0, _utils2.setNodeSelection)(_this.props.view, propPos);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleResizeStart", function () {
|
|
185
|
+
_this.setState({
|
|
186
|
+
isResizing: true
|
|
187
|
+
});
|
|
188
|
+
_this.selectCurrentMediaNode();
|
|
189
|
+
_this.setIsResizing(true);
|
|
190
|
+
// re-calucate guidelines
|
|
191
|
+
_this.guidelines = _this.getAllGuidelines();
|
|
192
|
+
return 0;
|
|
193
|
+
});
|
|
194
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleResize", function (size, delta) {
|
|
195
|
+
var _this$props4 = _this.props,
|
|
196
|
+
originalWidth = _this$props4.width,
|
|
197
|
+
originalHeight = _this$props4.height,
|
|
198
|
+
layout = _this$props4.layout,
|
|
199
|
+
updateSize = _this$props4.updateSize,
|
|
200
|
+
lineLength = _this$props4.lineLength;
|
|
201
|
+
var _this$calculateSizeSt = _this.calculateSizeState(size, delta, originalWidth, originalHeight),
|
|
202
|
+
width = _this$calculateSizeSt.width,
|
|
203
|
+
height = _this$calculateSizeSt.height,
|
|
204
|
+
calculatedWidthWithLayout = _this$calculateSizeSt.calculatedWidthWithLayout;
|
|
205
|
+
var guidelineSnaps = (0, _guideline.getGuidelineSnaps)(_this.guidelines, lineLength, layout);
|
|
206
|
+
_this.updateActiveGuidelines(width, _this.guidelines, guidelineSnaps);
|
|
207
|
+
_this.setState({
|
|
208
|
+
size: {
|
|
209
|
+
width: width,
|
|
210
|
+
height: height
|
|
211
|
+
},
|
|
212
|
+
snaps: guidelineSnaps.snaps
|
|
213
|
+
});
|
|
214
|
+
if (calculatedWidthWithLayout.layout !== layout) {
|
|
215
|
+
updateSize(width, calculatedWidthWithLayout.layout);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// TODO: Update once type updated from editor common resizer
|
|
219
|
+
return 0;
|
|
220
|
+
});
|
|
221
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleResizeStop", function (size, delta) {
|
|
222
|
+
var _this$props5 = _this.props,
|
|
223
|
+
originalWidth = _this$props5.width,
|
|
224
|
+
originalHeight = _this$props5.height,
|
|
225
|
+
updateSize = _this$props5.updateSize,
|
|
226
|
+
dispatchAnalyticsEvent = _this$props5.dispatchAnalyticsEvent,
|
|
227
|
+
nodeType = _this$props5.nodeType;
|
|
228
|
+
var _this$calculateSizeSt2 = _this.calculateSizeState(size, delta, originalWidth, originalHeight, true),
|
|
229
|
+
width = _this$calculateSizeSt2.width,
|
|
230
|
+
height = _this$calculateSizeSt2.height,
|
|
231
|
+
calculatedWidthWithLayout = _this$calculateSizeSt2.calculatedWidthWithLayout;
|
|
232
|
+
_this.setIsResizing(false);
|
|
233
|
+
_this.displayGuideline([]);
|
|
234
|
+
if (dispatchAnalyticsEvent) {
|
|
235
|
+
dispatchAnalyticsEvent(getResizeAnalyticsEvent(nodeType, calculatedWidthWithLayout.width, calculatedWidthWithLayout.layout));
|
|
236
|
+
}
|
|
237
|
+
_this.setState({
|
|
238
|
+
isResizing: false,
|
|
239
|
+
size: {
|
|
240
|
+
width: width,
|
|
241
|
+
height: height
|
|
242
|
+
}
|
|
243
|
+
}, function () {
|
|
244
|
+
updateSize(width, calculatedWidthWithLayout.layout);
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
// TODO: Update once type updated from editor common resizer
|
|
248
|
+
return 0;
|
|
249
|
+
});
|
|
129
250
|
var initialWidth = props.mediaSingleWidth || _mediaSingle.DEFAULT_IMAGE_WIDTH;
|
|
130
251
|
_this.state = {
|
|
131
252
|
offsetLeft: (0, _mediaSingle.calculateOffsetLeft)(_this.insideInlineLike, _this.insideLayout, _this.props.view.dom, undefined),
|
|
@@ -135,7 +256,8 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
135
256
|
size: {
|
|
136
257
|
width: initialWidth,
|
|
137
258
|
height: _this.calcPxHeight(initialWidth)
|
|
138
|
-
}
|
|
259
|
+
},
|
|
260
|
+
snaps: {}
|
|
139
261
|
};
|
|
140
262
|
return _this;
|
|
141
263
|
}
|
|
@@ -149,15 +271,15 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
149
271
|
(0, _createClass2.default)(ResizableMediaSingleNext, [{
|
|
150
272
|
key: "calcInitialWidth",
|
|
151
273
|
value: function calcInitialWidth() {
|
|
152
|
-
var _this$
|
|
153
|
-
origWidth = _this$
|
|
154
|
-
contentWidth = _this$
|
|
155
|
-
containerWidth = _this$
|
|
274
|
+
var _this$props6 = this.props,
|
|
275
|
+
origWidth = _this$props6.width,
|
|
276
|
+
contentWidth = _this$props6.lineLength,
|
|
277
|
+
containerWidth = _this$props6.containerWidth;
|
|
156
278
|
return Math.max(Math.min(origWidth || _mediaSingle.DEFAULT_IMAGE_WIDTH, contentWidth || containerWidth || _editorSharedStyles.akEditorDefaultLayoutWidth), _mediaSingle.MEDIA_SINGLE_MIN_PIXEL_WIDTH);
|
|
157
279
|
}
|
|
158
280
|
}, {
|
|
159
281
|
key: "componentDidUpdate",
|
|
160
|
-
value: function componentDidUpdate(prevProps
|
|
282
|
+
value: function componentDidUpdate(prevProps) {
|
|
161
283
|
var offsetLeft = (0, _mediaSingle.calculateOffsetLeft)(this.insideInlineLike, this.insideLayout, this.props.view.dom, this.wrapper);
|
|
162
284
|
if (offsetLeft !== this.state.offsetLeft && offsetLeft >= 0) {
|
|
163
285
|
this.setState({
|
|
@@ -172,10 +294,6 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
172
294
|
resizedPctWidth: this.props.pctWidth
|
|
173
295
|
});
|
|
174
296
|
}
|
|
175
|
-
if (prevState.isResizing !== this.state.isResizing && this.state.isResizing) {
|
|
176
|
-
var guidelines = this.getDefaultGuidelines();
|
|
177
|
-
this.displayGuideline(guidelines);
|
|
178
|
-
}
|
|
179
297
|
if (prevProps.mediaSingleWidth !== this.props.mediaSingleWidth && this.props.mediaSingleWidth) {
|
|
180
298
|
// update size when lineLength becomes defined later
|
|
181
299
|
// ensures extended experience renders legacy image with the same size as the legacy experience
|
|
@@ -199,78 +317,14 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
199
317
|
}, {
|
|
200
318
|
key: "getDefaultGuidelines",
|
|
201
319
|
value: function getDefaultGuidelines() {
|
|
202
|
-
var _this$
|
|
203
|
-
lineLength = _this$
|
|
204
|
-
containerWidth = _this$
|
|
205
|
-
fullWidthMode = _this$
|
|
320
|
+
var _this$props7 = this.props,
|
|
321
|
+
lineLength = _this$props7.lineLength,
|
|
322
|
+
containerWidth = _this$props7.containerWidth,
|
|
323
|
+
fullWidthMode = _this$props7.fullWidthMode;
|
|
206
324
|
|
|
207
325
|
// disable guidelines for nested media single node
|
|
208
326
|
return this.isNestedNode() ? [] : (0, _guideline.generateDefaultGuidelines)(lineLength, containerWidth, fullWidthMode);
|
|
209
327
|
}
|
|
210
|
-
|
|
211
|
-
// Calculate width of media nodes for snaps based on dynamic guidelines
|
|
212
|
-
// TODO: refactor this later, maybe use state to hold snaps array
|
|
213
|
-
}, {
|
|
214
|
-
key: "getSnaps",
|
|
215
|
-
value: function getSnaps() {
|
|
216
|
-
var _this$props5 = this.props,
|
|
217
|
-
view = _this$props5.view,
|
|
218
|
-
lineLength = _this$props5.lineLength;
|
|
219
|
-
var dom = view.dom;
|
|
220
|
-
var defaultGuidelines = this.getDefaultGuidelines();
|
|
221
|
-
// disable guidelines for nested media single node
|
|
222
|
-
var dynamicGuidelines = this.isNestedNode() ? [] : (0, _guideline.generateDynamicGuidelines)(view.state, lineLength, {
|
|
223
|
-
styles: {
|
|
224
|
-
lineStyle: 'dashed'
|
|
225
|
-
},
|
|
226
|
-
show: false
|
|
227
|
-
});
|
|
228
|
-
var guidelines = [].concat((0, _toConsumableArray2.default)(defaultGuidelines), (0, _toConsumableArray2.default)(dynamicGuidelines));
|
|
229
|
-
var mediaSingleSelector = 'div.mediaSingleView-content-wrap.ProseMirror-selectednode';
|
|
230
|
-
var _dom$getBoundingClien = dom.getBoundingClientRect(),
|
|
231
|
-
width = _dom$getBoundingClien.width;
|
|
232
|
-
var halfWidth = width / 2;
|
|
233
|
-
var selectedMedia = dom.querySelector(mediaSingleSelector);
|
|
234
|
-
if (selectedMedia) {
|
|
235
|
-
var pixelWidth = parseFloat(selectedMedia.getAttribute('width') || '') || 0;
|
|
236
|
-
var layout = selectedMedia.getAttribute('layout');
|
|
237
|
-
var snap = 0;
|
|
238
|
-
switch (layout) {
|
|
239
|
-
case 'align-start':
|
|
240
|
-
case 'wrap-left':
|
|
241
|
-
snap = pixelWidth - halfWidth;
|
|
242
|
-
break;
|
|
243
|
-
case 'align-end':
|
|
244
|
-
case 'wrap-right':
|
|
245
|
-
snap = width - pixelWidth - halfWidth;
|
|
246
|
-
break;
|
|
247
|
-
case 'center':
|
|
248
|
-
case 'wide':
|
|
249
|
-
case 'full-width':
|
|
250
|
-
snap = -pixelWidth / 2;
|
|
251
|
-
break;
|
|
252
|
-
// we ingnore full-width and wide
|
|
253
|
-
default:
|
|
254
|
-
snap = 0;
|
|
255
|
-
}
|
|
256
|
-
var snapWidths = (0, _guideline.getSnapWidth)(guidelines, pixelWidth, snap, layout);
|
|
257
|
-
var snapToWidths = snapWidths.map(function (s) {
|
|
258
|
-
return s && s.width;
|
|
259
|
-
});
|
|
260
|
-
|
|
261
|
-
// update guidelines
|
|
262
|
-
if (this.state.isResizing) {
|
|
263
|
-
var _findClosestSnap = (0, _guideline.findClosestSnap)(this.state.size.width, snapToWidths, snapWidths, _mediaSingle.MEDIA_SINGLE_HIGHLIGHT_GAP),
|
|
264
|
-
gap = _findClosestSnap.gap,
|
|
265
|
-
activeGuidelineKeys = _findClosestSnap.keys;
|
|
266
|
-
this.displayGuideline((0, _guideline.getGuidelinesWithHighlights)(gap, _mediaSingle.MEDIA_SINGLE_HIGHLIGHT_GAP, activeGuidelineKeys, guidelines));
|
|
267
|
-
}
|
|
268
|
-
return snapToWidths.length > 0 ? {
|
|
269
|
-
x: snapToWidths
|
|
270
|
-
} : {};
|
|
271
|
-
}
|
|
272
|
-
return {};
|
|
273
|
-
}
|
|
274
328
|
}, {
|
|
275
329
|
key: "wrappedLayout",
|
|
276
330
|
get: function get() {
|
|
@@ -411,15 +465,15 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
411
465
|
key: "render",
|
|
412
466
|
value: function render() {
|
|
413
467
|
var _this2 = this;
|
|
414
|
-
var _this$
|
|
415
|
-
origWidth = _this$
|
|
416
|
-
layout = _this$
|
|
417
|
-
pctWidth = _this$
|
|
418
|
-
containerWidth = _this$
|
|
419
|
-
fullWidthMode = _this$
|
|
420
|
-
selected = _this$
|
|
421
|
-
children = _this$
|
|
422
|
-
intl = _this$
|
|
468
|
+
var _this$props8 = this.props,
|
|
469
|
+
origWidth = _this$props8.width,
|
|
470
|
+
layout = _this$props8.layout,
|
|
471
|
+
pctWidth = _this$props8.pctWidth,
|
|
472
|
+
containerWidth = _this$props8.containerWidth,
|
|
473
|
+
fullWidthMode = _this$props8.fullWidthMode,
|
|
474
|
+
selected = _this$props8.selected,
|
|
475
|
+
children = _this$props8.children,
|
|
476
|
+
intl = _this$props8.intl;
|
|
423
477
|
var _this$state = this.state,
|
|
424
478
|
isResizing = _this$state.isResizing,
|
|
425
479
|
size = _this$state.size;
|
|
@@ -432,99 +486,6 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
432
486
|
}
|
|
433
487
|
});
|
|
434
488
|
|
|
435
|
-
/**
|
|
436
|
-
* NEW REFACTOR
|
|
437
|
-
*/
|
|
438
|
-
var roundPixelValue = function roundPixelValue(value) {
|
|
439
|
-
return Math.round(value);
|
|
440
|
-
};
|
|
441
|
-
var getHeightFromNewWidth = function getHeightFromNewWidth(originalWidth, originalHeight, newWidth) {
|
|
442
|
-
return roundPixelValue(originalHeight / originalWidth * newWidth);
|
|
443
|
-
};
|
|
444
|
-
var calculateSizeState = function calculateSizeState(size, delta) {
|
|
445
|
-
var originalWidth = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
446
|
-
var originalHeight = arguments.length > 3 ? arguments[3] : undefined;
|
|
447
|
-
var onResizeStop = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
448
|
-
var calculatedWidth = roundPixelValue(size.width + delta.width);
|
|
449
|
-
var calculatedWidthWithLayout = _this2.calcNewSize(calculatedWidth, onResizeStop);
|
|
450
|
-
var calculatedHeightWithLayout = getHeightFromNewWidth(originalWidth, originalHeight, calculatedWidth);
|
|
451
|
-
return {
|
|
452
|
-
width: calculatedWidth,
|
|
453
|
-
height: calculatedHeightWithLayout,
|
|
454
|
-
calculatedWidthWithLayout: calculatedWidthWithLayout
|
|
455
|
-
};
|
|
456
|
-
};
|
|
457
|
-
var selectCurrentMediaNode = function selectCurrentMediaNode() {
|
|
458
|
-
if (!_this2.props.selected && typeof _this2.props.getPos === 'function') {
|
|
459
|
-
var propPos = _this2.props.getPos();
|
|
460
|
-
if (propPos !== undefined) {
|
|
461
|
-
(0, _utils2.setNodeSelection)(_this2.props.view, propPos);
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
};
|
|
465
|
-
var handleResizeStart = function handleResizeStart() {
|
|
466
|
-
_this2.setState({
|
|
467
|
-
isResizing: true
|
|
468
|
-
});
|
|
469
|
-
selectCurrentMediaNode();
|
|
470
|
-
_this2.setIsResizing(true);
|
|
471
|
-
|
|
472
|
-
// TODO: Update once type updated from editor common resizer
|
|
473
|
-
return 0;
|
|
474
|
-
};
|
|
475
|
-
var handleResize = function handleResize(size, delta) {
|
|
476
|
-
var _this2$props = _this2.props,
|
|
477
|
-
originalWidth = _this2$props.width,
|
|
478
|
-
originalHeight = _this2$props.height,
|
|
479
|
-
layout = _this2$props.layout,
|
|
480
|
-
updateSize = _this2$props.updateSize;
|
|
481
|
-
var _calculateSizeState = calculateSizeState(size, delta, originalWidth, originalHeight),
|
|
482
|
-
width = _calculateSizeState.width,
|
|
483
|
-
height = _calculateSizeState.height,
|
|
484
|
-
calculatedWidthWithLayout = _calculateSizeState.calculatedWidthWithLayout;
|
|
485
|
-
_this2.setState({
|
|
486
|
-
size: {
|
|
487
|
-
width: width,
|
|
488
|
-
height: height
|
|
489
|
-
}
|
|
490
|
-
});
|
|
491
|
-
if (calculatedWidthWithLayout.layout !== layout) {
|
|
492
|
-
updateSize(width, calculatedWidthWithLayout.layout);
|
|
493
|
-
}
|
|
494
|
-
|
|
495
|
-
// TODO: Update once type updated from editor common resizer
|
|
496
|
-
return 0;
|
|
497
|
-
};
|
|
498
|
-
var handleResizeStop = function handleResizeStop(size, delta) {
|
|
499
|
-
var _this2$props2 = _this2.props,
|
|
500
|
-
originalWidth = _this2$props2.width,
|
|
501
|
-
originalHeight = _this2$props2.height,
|
|
502
|
-
updateSize = _this2$props2.updateSize,
|
|
503
|
-
dispatchAnalyticsEvent = _this2$props2.dispatchAnalyticsEvent,
|
|
504
|
-
nodeType = _this2$props2.nodeType;
|
|
505
|
-
var _calculateSizeState2 = calculateSizeState(size, delta, originalWidth, originalHeight, true),
|
|
506
|
-
width = _calculateSizeState2.width,
|
|
507
|
-
height = _calculateSizeState2.height,
|
|
508
|
-
calculatedWidthWithLayout = _calculateSizeState2.calculatedWidthWithLayout;
|
|
509
|
-
_this2.setIsResizing(false);
|
|
510
|
-
_this2.displayGuideline([]);
|
|
511
|
-
if (dispatchAnalyticsEvent) {
|
|
512
|
-
dispatchAnalyticsEvent(getResizeAnalyticsEvent(nodeType, calculatedWidthWithLayout.width, calculatedWidthWithLayout.layout));
|
|
513
|
-
}
|
|
514
|
-
_this2.setState({
|
|
515
|
-
isResizing: false,
|
|
516
|
-
size: {
|
|
517
|
-
width: width,
|
|
518
|
-
height: height
|
|
519
|
-
}
|
|
520
|
-
}, function () {
|
|
521
|
-
updateSize(width, calculatedWidthWithLayout.layout);
|
|
522
|
-
});
|
|
523
|
-
|
|
524
|
-
// TODO: Update once type updated from editor common resizer
|
|
525
|
-
return 0;
|
|
526
|
-
};
|
|
527
|
-
|
|
528
489
|
// TODO: Clean up where this lives and how it gets generated
|
|
529
490
|
var className = (0, _classnames.default)(_styles.richMediaClassName, "image-".concat(layout), isResizing ? 'is-resizing' : 'not-resizing', this.props.className, {
|
|
530
491
|
'not-resized': !pctWidth,
|
|
@@ -551,10 +512,10 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
551
512
|
snapGap: _mediaSingle.MEDIA_SINGLE_SNAP_GAP,
|
|
552
513
|
enable: enable,
|
|
553
514
|
width: size.width,
|
|
554
|
-
handleResizeStart: handleResizeStart,
|
|
555
|
-
handleResize: handleResize,
|
|
556
|
-
handleResizeStop: handleResizeStop,
|
|
557
|
-
snap: this.
|
|
515
|
+
handleResizeStart: this.handleResizeStart,
|
|
516
|
+
handleResize: this.handleResize,
|
|
517
|
+
handleResizeStop: this.handleResizeStop,
|
|
518
|
+
snap: this.state.snaps,
|
|
558
519
|
resizeRatio: _utils2.nonWrappedLayouts.includes(layout) ? 2 : 1,
|
|
559
520
|
"data-testid": resizerNextTestId
|
|
560
521
|
}, showSizeGuide && (0, _react2.jsx)(_ResizeLabel.default, {
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.version = exports.nextMajorVersion = exports.name = void 0;
|
|
7
7
|
var name = "@atlaskit/editor-core";
|
|
8
8
|
exports.name = name;
|
|
9
|
-
var version = "187.14.
|
|
9
|
+
var version = "187.14.7";
|
|
10
10
|
exports.version = version;
|
|
11
11
|
var nextMajorVersion = function nextMajorVersion() {
|
|
12
12
|
return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
|
package/dist/cjs/version.json
CHANGED
|
@@ -6,6 +6,7 @@ import ReactDOM from 'react-dom';
|
|
|
6
6
|
import { injectIntl } from 'react-intl-next';
|
|
7
7
|
import { EmojiPicker as AkEmojiPicker } from '@atlaskit/emoji/picker';
|
|
8
8
|
import { Popup } from '@atlaskit/editor-common/ui';
|
|
9
|
+
import { pluginCommandToPMCommand } from '@atlaskit/editor-common/preset';
|
|
9
10
|
import ToolbarButton from '../../../../ui/ToolbarButton';
|
|
10
11
|
import { separatorStyles, buttonGroupStyle, wrapperStyle } from '@atlaskit/editor-common/styles';
|
|
11
12
|
import { insertDate } from '../../../date/actions';
|
|
@@ -161,7 +162,9 @@ export class ToolbarInsertBlock extends React.PureComponent {
|
|
|
161
162
|
state,
|
|
162
163
|
dispatch
|
|
163
164
|
} = editorView;
|
|
164
|
-
|
|
165
|
+
|
|
166
|
+
// We should update this to use `pluginInjectionApi.executeCommand` once available
|
|
167
|
+
pluginCommandToPMCommand(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d = pluginInjectionApi.dependencies) === null || _pluginInjectionApi$d === void 0 ? void 0 : (_pluginInjectionApi$d2 = _pluginInjectionApi$d.hyperlink) === null || _pluginInjectionApi$d2 === void 0 ? void 0 : _pluginInjectionApi$d2.commands.showLinkToolbar(inputMethod))(state, dispatch);
|
|
165
168
|
return true;
|
|
166
169
|
});
|
|
167
170
|
_defineProperty(this, "insertMention", inputMethod => {
|