@atlaskit/editor-core 187.29.2 → 187.29.4
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 +16 -0
- package/dist/cjs/plugins/media/nodeviews/mediaSingle.js +9 -46
- package/dist/cjs/plugins/media/toolbar/index.js +14 -1
- package/dist/cjs/plugins/media/ui/PixelEntry/constants.js +8 -0
- package/dist/cjs/plugins/media/ui/PixelEntry/index.js +14 -1
- package/dist/cjs/plugins/media/ui/PixelEntry/messages.js +10 -0
- package/dist/cjs/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +23 -21
- package/dist/cjs/plugins/type-ahead/index.js +1 -0
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/plugins/media/nodeviews/mediaSingle.js +4 -41
- package/dist/es2019/plugins/media/toolbar/index.js +16 -2
- package/dist/es2019/plugins/media/ui/PixelEntry/constants.js +1 -0
- package/dist/es2019/plugins/media/ui/PixelEntry/index.js +14 -1
- package/dist/es2019/plugins/media/ui/PixelEntry/messages.js +10 -0
- package/dist/es2019/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +9 -7
- package/dist/es2019/plugins/type-ahead/index.js +1 -0
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/plugins/media/nodeviews/mediaSingle.js +4 -41
- package/dist/esm/plugins/media/toolbar/index.js +15 -2
- package/dist/esm/plugins/media/ui/PixelEntry/constants.js +1 -0
- package/dist/esm/plugins/media/ui/PixelEntry/index.js +14 -1
- package/dist/esm/plugins/media/ui/PixelEntry/messages.js +10 -0
- package/dist/esm/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +23 -21
- package/dist/esm/plugins/type-ahead/index.js +1 -0
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/labs/next/presets/default.d.ts +8 -8
- package/dist/types/plugins/emoji/index.d.ts +1 -1
- package/dist/types/plugins/media/nodeviews/mediaSingle.d.ts +0 -12
- package/dist/types/plugins/media/ui/PixelEntry/constants.d.ts +1 -0
- package/dist/types/plugins/media/ui/PixelEntry/index.d.ts +1 -1
- package/dist/types/plugins/media/ui/PixelEntry/messages.d.ts +10 -0
- package/dist/types/plugins/media/ui/PixelEntry/types.d.ts +8 -0
- package/dist/types/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.d.ts +1 -1
- package/dist/types/plugins/type-ahead/api.d.ts +2 -1
- package/dist/types/plugins/type-ahead/index.d.ts +2 -13
- package/dist/types/plugins/type-ahead/types.d.ts +2 -3
- package/dist/types-ts4.5/labs/next/presets/default.d.ts +8 -8
- package/dist/types-ts4.5/plugins/emoji/index.d.ts +1 -1
- package/dist/types-ts4.5/plugins/media/nodeviews/mediaSingle.d.ts +0 -12
- package/dist/types-ts4.5/plugins/media/ui/PixelEntry/constants.d.ts +1 -0
- package/dist/types-ts4.5/plugins/media/ui/PixelEntry/index.d.ts +1 -1
- package/dist/types-ts4.5/plugins/media/ui/PixelEntry/messages.d.ts +10 -0
- package/dist/types-ts4.5/plugins/media/ui/PixelEntry/types.d.ts +8 -0
- package/dist/types-ts4.5/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.d.ts +1 -1
- package/dist/types-ts4.5/plugins/type-ahead/api.d.ts +2 -1
- package/dist/types-ts4.5/plugins/type-ahead/index.d.ts +2 -13
- package/dist/types-ts4.5/plugins/type-ahead/types.d.ts +2 -3
- package/package.json +2 -1
- package/report.api.md +2 -14
- package/tmp/api-report-tmp.d.ts +2 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/editor-core
|
|
2
2
|
|
|
3
|
+
## 187.29.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`8595f0ddc4b`](https://bitbucket.org/atlassian/atlassian-frontend/commits/8595f0ddc4b) - Always show resizer handles when mediaSingle node is selected
|
|
8
|
+
- [`1af653a9630`](https://bitbucket.org/atlassian/atlassian-frontend/commits/1af653a9630) - ED-19433 Initial scaffold for editor-plugin-type-ahead
|
|
9
|
+
- [`2f7d7be2983`](https://bitbucket.org/atlassian/atlassian-frontend/commits/2f7d7be2983) - [ux] ED-19438 Added dark mode icons for headings 1 to 6
|
|
10
|
+
- [`1b917526a9f`](https://bitbucket.org/atlassian/atlassian-frontend/commits/1b917526a9f) - [ux] add convert to pixels cta in pixel entry for legacy experience
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
|
|
13
|
+
## 187.29.3
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- [`9650cf173e5`](https://bitbucket.org/atlassian/atlassian-frontend/commits/9650cf173e5) - Fix bug where if mediaSingle node is first item in document it is treated as video
|
|
18
|
+
|
|
3
19
|
## 187.29.2
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
@@ -24,7 +24,6 @@ var _ui = require("@atlaskit/editor-common/ui");
|
|
|
24
24
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
25
25
|
var _nodes = require("../../../utils/nodes");
|
|
26
26
|
var _utils2 = require("../../../utils");
|
|
27
|
-
var _mediaSingle = require("../utils/media-single");
|
|
28
27
|
var _ResizableMediaSingleNext = _interopRequireDefault(require("../ui/ResizableMediaSingle/ResizableMediaSingleNext"));
|
|
29
28
|
var _ResizableMediaSingle = _interopRequireDefault(require("../ui/ResizableMediaSingle"));
|
|
30
29
|
var _main = require("../pm-plugins/main");
|
|
@@ -40,7 +39,7 @@ var _CaptionPlaceholder = _interopRequireDefault(require("../ui/CaptionPlacehold
|
|
|
40
39
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
41
40
|
var _captions = require("../commands/captions");
|
|
42
41
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
43
|
-
var
|
|
42
|
+
var _mediaSingle = require("@atlaskit/editor-common/media-single");
|
|
44
43
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
45
44
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
46
45
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -251,42 +250,6 @@ var MediaSingleNode = /*#__PURE__*/function (_Component) {
|
|
|
251
250
|
}
|
|
252
251
|
(0, _captions.insertAndSelectCaptionFromMediaSinglePos)(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d = pluginInjectionApi.dependencies) === null || _pluginInjectionApi$d === void 0 ? void 0 : (_pluginInjectionApi$d2 = _pluginInjectionApi$d.analytics) === null || _pluginInjectionApi$d2 === void 0 ? void 0 : _pluginInjectionApi$d2.actions)(getPos(), node)(view.state, view.dispatch);
|
|
253
252
|
});
|
|
254
|
-
/**
|
|
255
|
-
* Get parent width for a nested media single node
|
|
256
|
-
* @param view Editor view
|
|
257
|
-
* @param pos node position
|
|
258
|
-
*/
|
|
259
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getLineLength", function (view, pos, includeMoreParentNodeTypes) {
|
|
260
|
-
if (typeof pos !== 'number') {
|
|
261
|
-
return null;
|
|
262
|
-
}
|
|
263
|
-
if ((0, _utils.isRichMediaInsideOfBlockNode)(view, pos)) {
|
|
264
|
-
var $pos = view.state.doc.resolve(pos);
|
|
265
|
-
var domNode = view.nodeDOM($pos.pos);
|
|
266
|
-
if ($pos.nodeAfter && _utils.floatingLayouts.indexOf($pos.nodeAfter.attrs.layout) > -1 && domNode && domNode.parentElement) {
|
|
267
|
-
return domNode.parentElement.offsetWidth;
|
|
268
|
-
}
|
|
269
|
-
if (domNode instanceof HTMLElement) {
|
|
270
|
-
return domNode.offsetWidth;
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
return null;
|
|
274
|
-
});
|
|
275
|
-
/**
|
|
276
|
-
* Get parent width for a nested media single node for new experience
|
|
277
|
-
* @param view Editor view
|
|
278
|
-
* @param pos node position
|
|
279
|
-
*/
|
|
280
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getLineLengthNext", function (view, pos) {
|
|
281
|
-
if (typeof pos !== 'number') {
|
|
282
|
-
return null;
|
|
283
|
-
}
|
|
284
|
-
var $pos = view.state.doc.resolve(pos);
|
|
285
|
-
if ($pos && $pos.parent.type.name !== 'doc') {
|
|
286
|
-
return (0, _mediaSingle.getParentWidthForNestedMediaSingleNode)($pos, view);
|
|
287
|
-
}
|
|
288
|
-
return null;
|
|
289
|
-
});
|
|
290
253
|
return _this;
|
|
291
254
|
}
|
|
292
255
|
(0, _createClass2.default)(MediaSingleNode, [{
|
|
@@ -376,19 +339,19 @@ var MediaSingleNode = /*#__PURE__*/function (_Component) {
|
|
|
376
339
|
stateWidth = _this$state.width,
|
|
377
340
|
stateHeight = _this$state.height;
|
|
378
341
|
if (width === null) {
|
|
379
|
-
width = stateWidth ||
|
|
342
|
+
width = stateWidth || _mediaSingle.DEFAULT_IMAGE_WIDTH;
|
|
380
343
|
}
|
|
381
344
|
if (height === null) {
|
|
382
|
-
height = stateHeight ||
|
|
345
|
+
height = stateHeight || _mediaSingle.DEFAULT_IMAGE_HEIGHT;
|
|
383
346
|
}
|
|
384
347
|
}
|
|
385
348
|
if (!width || !height) {
|
|
386
|
-
width =
|
|
387
|
-
height =
|
|
349
|
+
width = _mediaSingle.DEFAULT_IMAGE_WIDTH;
|
|
350
|
+
height = _mediaSingle.DEFAULT_IMAGE_HEIGHT;
|
|
388
351
|
}
|
|
389
352
|
var isSelected = selected();
|
|
390
|
-
var contentWidthForLegacyExperience =
|
|
391
|
-
var contentWidth =
|
|
353
|
+
var contentWidthForLegacyExperience = (0, _mediaSingle.getMaxWidthForNestedNode)(view, getPos()) || lineLength;
|
|
354
|
+
var contentWidth = (0, _mediaSingle.getMaxWidthForNestedNodeNext)(view, getPos()) || lineLength;
|
|
392
355
|
var mediaSingleProps = {
|
|
393
356
|
layout: layout,
|
|
394
357
|
width: width,
|
|
@@ -398,7 +361,7 @@ var MediaSingleNode = /*#__PURE__*/function (_Component) {
|
|
|
398
361
|
pctWidth: mediaSingleWidthAttribute,
|
|
399
362
|
fullWidthMode: fullWidthMode,
|
|
400
363
|
hasFallbackContainer: false,
|
|
401
|
-
mediaSingleWidth: (0,
|
|
364
|
+
mediaSingleWidth: (0, _mediaSingle.calcMediaSinglePixelWidth)({
|
|
402
365
|
width: mediaSingleWidthAttribute,
|
|
403
366
|
widthType: widthType,
|
|
404
367
|
origWidth: width,
|
|
@@ -407,7 +370,7 @@ var MediaSingleNode = /*#__PURE__*/function (_Component) {
|
|
|
407
370
|
// thus we use the legecy value (exclude table as container node)
|
|
408
371
|
contentWidth: contentWidthForLegacyExperience,
|
|
409
372
|
containerWidth: containerWidth,
|
|
410
|
-
gutterOffset:
|
|
373
|
+
gutterOffset: _mediaSingle.MEDIA_SINGLE_GUTTER_SIZE
|
|
411
374
|
})
|
|
412
375
|
};
|
|
413
376
|
var resizableMediaSingleProps = _objectSpread({
|
|
@@ -288,18 +288,20 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
288
288
|
var _selectedMediaNode$at = selectedMediaNode.attrs,
|
|
289
289
|
mediaWidth = _selectedMediaNode$at.width,
|
|
290
290
|
mediaHeight = _selectedMediaNode$at.height;
|
|
291
|
+
var isLegacy = widthType !== 'pixel';
|
|
291
292
|
var pixelWidth = (0, _mediaSingle.calcMediaSinglePixelWidth)({
|
|
292
293
|
width: singleMediaWidth,
|
|
293
294
|
widthType: widthType,
|
|
294
295
|
origWidth: mediaWidth || _mediaSingle.DEFAULT_IMAGE_WIDTH,
|
|
295
296
|
layout: layout,
|
|
296
|
-
contentWidth: contentWidth,
|
|
297
|
+
contentWidth: (0, _mediaSingle.getMaxWidthForNestedNode)(editorView, selectedMediaSingleNode.pos) || contentWidth,
|
|
297
298
|
containerWidth: containerWidth,
|
|
298
299
|
gutterOffset: _mediaSingle.MEDIA_SINGLE_GUTTER_SIZE
|
|
299
300
|
});
|
|
300
301
|
return /*#__PURE__*/_react.default.createElement(_PixelEntry.PixelEntry, {
|
|
301
302
|
intl: intl,
|
|
302
303
|
width: pluginState.isResizing ? pluginState.resizingWidth : pixelWidth,
|
|
304
|
+
showMigration: !pluginState.isResizing && isLegacy,
|
|
303
305
|
mediaWidth: mediaWidth || _mediaSingle.DEFAULT_IMAGE_WIDTH,
|
|
304
306
|
mediaHeight: mediaHeight || _mediaSingle.DEFAULT_IMAGE_HEIGHT,
|
|
305
307
|
validate: function validate(value) {
|
|
@@ -314,6 +316,17 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
314
316
|
width: width,
|
|
315
317
|
widthType: 'pixel'
|
|
316
318
|
}));
|
|
319
|
+
tr.setMeta('scrollIntoView', false);
|
|
320
|
+
tr.setSelection(_state2.NodeSelection.create(tr.doc, selectedMediaSingleNode.pos));
|
|
321
|
+
dispatch(tr);
|
|
322
|
+
},
|
|
323
|
+
onMigrate: function onMigrate() {
|
|
324
|
+
var tr = state.tr.setNodeMarkup(selectedMediaSingleNode.pos, undefined, _objectSpread(_objectSpread({}, selectedMediaSingleNode.node.attrs), {}, {
|
|
325
|
+
width: pixelWidth,
|
|
326
|
+
widthType: 'pixel'
|
|
327
|
+
}));
|
|
328
|
+
tr.setMeta('scrollIntoView', false);
|
|
329
|
+
tr.setSelection(_state2.NodeSelection.create(tr.doc, selectedMediaSingleNode.pos));
|
|
317
330
|
dispatch(tr);
|
|
318
331
|
}
|
|
319
332
|
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.PIXELENTRY_MIGRATION_BUTTON_TESTID = void 0;
|
|
7
|
+
var PIXELENTRY_MIGRATION_BUTTON_TESTID = 'pixel-entry-convert-pixels-btn';
|
|
8
|
+
exports.PIXELENTRY_MIGRATION_BUTTON_TESTID = PIXELENTRY_MIGRATION_BUTTON_TESTID;
|
|
@@ -16,6 +16,7 @@ var _button = _interopRequireDefault(require("@atlaskit/button"));
|
|
|
16
16
|
var _form = _interopRequireWildcard(require("@atlaskit/form"));
|
|
17
17
|
var _styles = require("./styles");
|
|
18
18
|
var _messages = require("./messages");
|
|
19
|
+
var _constants = require("./constants");
|
|
19
20
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
20
21
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
21
22
|
/** @jsx jsx */
|
|
@@ -26,7 +27,9 @@ var PixelEntry = function PixelEntry(_ref) {
|
|
|
26
27
|
mediaHeight = _ref.mediaHeight,
|
|
27
28
|
onSubmit = _ref.onSubmit,
|
|
28
29
|
validate = _ref.validate,
|
|
29
|
-
formatMessage = _ref.intl.formatMessage
|
|
30
|
+
formatMessage = _ref.intl.formatMessage,
|
|
31
|
+
showMigration = _ref.showMigration,
|
|
32
|
+
onMigrate = _ref.onMigrate;
|
|
30
33
|
var ratioWidth = (0, _react2.useMemo)(function () {
|
|
31
34
|
return mediaHeight / mediaWidth;
|
|
32
35
|
}, [mediaHeight, mediaWidth]);
|
|
@@ -96,6 +99,16 @@ var PixelEntry = function PixelEntry(_ref) {
|
|
|
96
99
|
}
|
|
97
100
|
};
|
|
98
101
|
}, [ratioHeight, ratioWidth]);
|
|
102
|
+
if (showMigration) {
|
|
103
|
+
return (0, _react.jsx)(_tooltip.default, {
|
|
104
|
+
content: formatMessage(_messages.messages.migrationButtonTooltip)
|
|
105
|
+
}, (0, _react.jsx)(_button.default, {
|
|
106
|
+
appearance: "warning",
|
|
107
|
+
spacing: "compact",
|
|
108
|
+
onClick: onMigrate,
|
|
109
|
+
testId: _constants.PIXELENTRY_MIGRATION_BUTTON_TESTID
|
|
110
|
+
}, formatMessage(_messages.messages.migrationButtonText)));
|
|
111
|
+
}
|
|
99
112
|
return (0, _react.jsx)("div", {
|
|
100
113
|
css: _styles.pixelEntryForm
|
|
101
114
|
}, (0, _react.jsx)(_form.default, {
|
|
@@ -35,6 +35,16 @@ var messages = (0, _reactIntlNext.defineMessages)({
|
|
|
35
35
|
id: 'fabric.editor.media.pixelEntry.submitButtonText',
|
|
36
36
|
defaultMessage: 'Submit',
|
|
37
37
|
description: 'The text give to the hidden submit button'
|
|
38
|
+
},
|
|
39
|
+
migrationButtonText: {
|
|
40
|
+
id: 'fabric.editor.media.pixelEntry.migrationButtonText',
|
|
41
|
+
defaultMessage: 'Convert to pixels',
|
|
42
|
+
description: 'The text give to the button used to covert to pixels for legacy experience'
|
|
43
|
+
},
|
|
44
|
+
migrationButtonTooltip: {
|
|
45
|
+
id: 'fabric.editor.media.pixelEntry.migrationButtonTooltip',
|
|
46
|
+
defaultMessage: 'Migrate from percentage to fixed pixel sizing',
|
|
47
|
+
description: 'The tooltip displayed on the migration button'
|
|
38
48
|
}
|
|
39
49
|
});
|
|
40
50
|
exports.messages = messages;
|
|
@@ -185,8 +185,10 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
185
185
|
});
|
|
186
186
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "selectCurrentMediaNode", function () {
|
|
187
187
|
// TODO: if adding !this.props.selected, it doesn't work if media single node is at top postion
|
|
188
|
-
|
|
189
|
-
|
|
188
|
+
if (_this.pos === null) {
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
(0, _utils2.setNodeSelection)(_this.props.view, _this.pos);
|
|
190
192
|
});
|
|
191
193
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleResizeStart", function () {
|
|
192
194
|
_this.setState({
|
|
@@ -372,7 +374,7 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
372
374
|
get: function get() {
|
|
373
375
|
var pos = this.pos;
|
|
374
376
|
// need to pass view because we may not get updated props in time
|
|
375
|
-
return pos
|
|
377
|
+
return pos === null ? pos : this.props.view.state.doc.resolve(pos);
|
|
376
378
|
}
|
|
377
379
|
}, {
|
|
378
380
|
key: "aspectRatio",
|
|
@@ -430,50 +432,49 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
430
432
|
key: "checkVideoFile",
|
|
431
433
|
value: function () {
|
|
432
434
|
var _checkVideoFile = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(viewMediaClientConfig) {
|
|
433
|
-
var
|
|
435
|
+
var mediaNode, mediaClient, state;
|
|
434
436
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
435
437
|
while (1) switch (_context2.prev = _context2.next) {
|
|
436
438
|
case 0:
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
_context2.next = 3;
|
|
439
|
+
if (!(this.pos === null || !viewMediaClientConfig)) {
|
|
440
|
+
_context2.next = 2;
|
|
440
441
|
break;
|
|
441
442
|
}
|
|
442
443
|
return _context2.abrupt("return");
|
|
443
|
-
case
|
|
444
|
-
mediaNode = this.props.view.state.doc.nodeAt(
|
|
444
|
+
case 2:
|
|
445
|
+
mediaNode = this.props.view.state.doc.nodeAt(this.pos + 1);
|
|
445
446
|
if (!(!mediaNode || !mediaNode.attrs.id)) {
|
|
446
|
-
_context2.next =
|
|
447
|
+
_context2.next = 5;
|
|
447
448
|
break;
|
|
448
449
|
}
|
|
449
450
|
return _context2.abrupt("return");
|
|
450
|
-
case
|
|
451
|
+
case 5:
|
|
451
452
|
mediaClient = (0, _mediaClient.getMediaClient)(viewMediaClientConfig);
|
|
452
|
-
_context2.prev =
|
|
453
|
-
_context2.next =
|
|
453
|
+
_context2.prev = 6;
|
|
454
|
+
_context2.next = 9;
|
|
454
455
|
return mediaClient.file.getCurrentState(mediaNode.attrs.id, {
|
|
455
456
|
collectionName: mediaNode.attrs.collection
|
|
456
457
|
});
|
|
457
|
-
case
|
|
458
|
+
case 9:
|
|
458
459
|
state = _context2.sent;
|
|
459
460
|
if (state && state.status !== 'error' && state.mediaType === 'image') {
|
|
460
461
|
this.setState({
|
|
461
462
|
isVideoFile: false
|
|
462
463
|
});
|
|
463
464
|
}
|
|
464
|
-
_context2.next =
|
|
465
|
+
_context2.next = 16;
|
|
465
466
|
break;
|
|
466
|
-
case
|
|
467
|
-
_context2.prev =
|
|
468
|
-
_context2.t0 = _context2["catch"](
|
|
467
|
+
case 13:
|
|
468
|
+
_context2.prev = 13;
|
|
469
|
+
_context2.t0 = _context2["catch"](6);
|
|
469
470
|
this.setState({
|
|
470
471
|
isVideoFile: false
|
|
471
472
|
});
|
|
472
|
-
case
|
|
473
|
+
case 16:
|
|
473
474
|
case "end":
|
|
474
475
|
return _context2.stop();
|
|
475
476
|
}
|
|
476
|
-
}, _callee2, this, [[
|
|
477
|
+
}, _callee2, this, [[6, 13]]);
|
|
477
478
|
}));
|
|
478
479
|
function checkVideoFile(_x) {
|
|
479
480
|
return _checkVideoFile.apply(this, arguments);
|
|
@@ -538,7 +539,8 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
538
539
|
handleResizeStop: this.handleResizeStop,
|
|
539
540
|
snap: this.state.snaps,
|
|
540
541
|
resizeRatio: _utils2.nonWrappedLayouts.includes(layout) ? 2 : 1,
|
|
541
|
-
"data-testid": resizerNextTestId
|
|
542
|
+
"data-testid": resizerNextTestId,
|
|
543
|
+
isHandleVisible: selected
|
|
542
544
|
}, children));
|
|
543
545
|
}
|
|
544
546
|
}]);
|
|
@@ -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.29.
|
|
9
|
+
var version = "187.29.4";
|
|
10
10
|
exports.version = version;
|
|
11
11
|
var nextMajorVersion = function nextMajorVersion() {
|
|
12
12
|
return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
|
|
@@ -5,10 +5,9 @@ import { jsx } from '@emotion/react';
|
|
|
5
5
|
import React, { Component } from 'react';
|
|
6
6
|
import { WithProviders } from '@atlaskit/editor-common/provider-factory';
|
|
7
7
|
import { MediaSingle } from '@atlaskit/editor-common/ui';
|
|
8
|
-
import { browser
|
|
8
|
+
import { browser } from '@atlaskit/editor-common/utils';
|
|
9
9
|
import { isNodeSelectedOrInRange } from '../../../utils/nodes';
|
|
10
10
|
import { setNodeSelection, setTextSelection } from '../../../utils';
|
|
11
|
-
import { getParentWidthForNestedMediaSingleNode } from '../utils/media-single';
|
|
12
11
|
import ResizableMediaSingleNext from '../ui/ResizableMediaSingle/ResizableMediaSingleNext';
|
|
13
12
|
import ResizableMediaSingle from '../ui/ResizableMediaSingle';
|
|
14
13
|
import { MEDIA_CONTENT_WRAP_CLASS_NAME } from '../pm-plugins/main';
|
|
@@ -24,7 +23,7 @@ import CaptionPlaceholder from '../ui/CaptionPlaceholder';
|
|
|
24
23
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
25
24
|
import { insertAndSelectCaptionFromMediaSinglePos } from '../commands/captions';
|
|
26
25
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
27
|
-
import { calcMediaSinglePixelWidth, MEDIA_SINGLE_GUTTER_SIZE, DEFAULT_IMAGE_HEIGHT, DEFAULT_IMAGE_WIDTH } from '@atlaskit/editor-common/media-single';
|
|
26
|
+
import { calcMediaSinglePixelWidth, MEDIA_SINGLE_GUTTER_SIZE, DEFAULT_IMAGE_HEIGHT, DEFAULT_IMAGE_WIDTH, getMaxWidthForNestedNode, getMaxWidthForNestedNodeNext } from '@atlaskit/editor-common/media-single';
|
|
28
27
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
29
28
|
export default class MediaSingleNode extends Component {
|
|
30
29
|
constructor(...args) {
|
|
@@ -177,42 +176,6 @@ export default class MediaSingleNode extends Component {
|
|
|
177
176
|
}
|
|
178
177
|
insertAndSelectCaptionFromMediaSinglePos(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d = pluginInjectionApi.dependencies) === null || _pluginInjectionApi$d === void 0 ? void 0 : (_pluginInjectionApi$d2 = _pluginInjectionApi$d.analytics) === null || _pluginInjectionApi$d2 === void 0 ? void 0 : _pluginInjectionApi$d2.actions)(getPos(), node)(view.state, view.dispatch);
|
|
179
178
|
});
|
|
180
|
-
/**
|
|
181
|
-
* Get parent width for a nested media single node
|
|
182
|
-
* @param view Editor view
|
|
183
|
-
* @param pos node position
|
|
184
|
-
*/
|
|
185
|
-
_defineProperty(this, "getLineLength", (view, pos, includeMoreParentNodeTypes) => {
|
|
186
|
-
if (typeof pos !== 'number') {
|
|
187
|
-
return null;
|
|
188
|
-
}
|
|
189
|
-
if (isRichMediaInsideOfBlockNode(view, pos)) {
|
|
190
|
-
const $pos = view.state.doc.resolve(pos);
|
|
191
|
-
const domNode = view.nodeDOM($pos.pos);
|
|
192
|
-
if ($pos.nodeAfter && floatingLayouts.indexOf($pos.nodeAfter.attrs.layout) > -1 && domNode && domNode.parentElement) {
|
|
193
|
-
return domNode.parentElement.offsetWidth;
|
|
194
|
-
}
|
|
195
|
-
if (domNode instanceof HTMLElement) {
|
|
196
|
-
return domNode.offsetWidth;
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
return null;
|
|
200
|
-
});
|
|
201
|
-
/**
|
|
202
|
-
* Get parent width for a nested media single node for new experience
|
|
203
|
-
* @param view Editor view
|
|
204
|
-
* @param pos node position
|
|
205
|
-
*/
|
|
206
|
-
_defineProperty(this, "getLineLengthNext", (view, pos) => {
|
|
207
|
-
if (typeof pos !== 'number') {
|
|
208
|
-
return null;
|
|
209
|
-
}
|
|
210
|
-
const $pos = view.state.doc.resolve(pos);
|
|
211
|
-
if ($pos && $pos.parent.type.name !== 'doc') {
|
|
212
|
-
return getParentWidthForNestedMediaSingleNode($pos, view);
|
|
213
|
-
}
|
|
214
|
-
return null;
|
|
215
|
-
});
|
|
216
179
|
}
|
|
217
180
|
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
218
181
|
if (nextProps.mediaProvider !== this.props.mediaProvider) {
|
|
@@ -294,8 +257,8 @@ export default class MediaSingleNode extends Component {
|
|
|
294
257
|
height = DEFAULT_IMAGE_HEIGHT;
|
|
295
258
|
}
|
|
296
259
|
const isSelected = selected();
|
|
297
|
-
const contentWidthForLegacyExperience =
|
|
298
|
-
const contentWidth =
|
|
260
|
+
const contentWidthForLegacyExperience = getMaxWidthForNestedNode(view, getPos()) || lineLength;
|
|
261
|
+
const contentWidth = getMaxWidthForNestedNodeNext(view, getPos()) || lineLength;
|
|
299
262
|
const mediaSingleProps = {
|
|
300
263
|
layout,
|
|
301
264
|
width,
|
|
@@ -25,7 +25,7 @@ import ImageBorderItem from '../ui/ImageBorder';
|
|
|
25
25
|
import { currentMediaNodeBorderMark } from '../utils/current-media-node';
|
|
26
26
|
import { shouldShowImageBorder } from './imageBorder';
|
|
27
27
|
import { PixelEntry } from '../ui/PixelEntry';
|
|
28
|
-
import { DEFAULT_IMAGE_WIDTH, DEFAULT_IMAGE_HEIGHT, MEDIA_SINGLE_DEFAULT_MIN_PIXEL_WIDTH, MEDIA_SINGLE_GUTTER_SIZE, calcMediaSinglePixelWidth } from '@atlaskit/editor-common/media-single';
|
|
28
|
+
import { DEFAULT_IMAGE_WIDTH, DEFAULT_IMAGE_HEIGHT, MEDIA_SINGLE_DEFAULT_MIN_PIXEL_WIDTH, MEDIA_SINGLE_GUTTER_SIZE, calcMediaSinglePixelWidth, getMaxWidthForNestedNode } from '@atlaskit/editor-common/media-single';
|
|
29
29
|
import { akEditorDefaultLayoutWidth, akEditorFullWidthLayoutWidth } from '@atlaskit/editor-shared-styles';
|
|
30
30
|
const remove = (state, dispatch) => {
|
|
31
31
|
if (dispatch) {
|
|
@@ -293,18 +293,20 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
|
|
|
293
293
|
width: mediaWidth,
|
|
294
294
|
height: mediaHeight
|
|
295
295
|
} = selectedMediaNode.attrs;
|
|
296
|
+
const isLegacy = widthType !== 'pixel';
|
|
296
297
|
const pixelWidth = calcMediaSinglePixelWidth({
|
|
297
298
|
width: singleMediaWidth,
|
|
298
299
|
widthType,
|
|
299
300
|
origWidth: mediaWidth || DEFAULT_IMAGE_WIDTH,
|
|
300
301
|
layout,
|
|
301
|
-
contentWidth,
|
|
302
|
+
contentWidth: getMaxWidthForNestedNode(editorView, selectedMediaSingleNode.pos) || contentWidth,
|
|
302
303
|
containerWidth,
|
|
303
304
|
gutterOffset: MEDIA_SINGLE_GUTTER_SIZE
|
|
304
305
|
});
|
|
305
306
|
return /*#__PURE__*/React.createElement(PixelEntry, {
|
|
306
307
|
intl: intl,
|
|
307
308
|
width: pluginState.isResizing ? pluginState.resizingWidth : pixelWidth,
|
|
309
|
+
showMigration: !pluginState.isResizing && isLegacy,
|
|
308
310
|
mediaWidth: mediaWidth || DEFAULT_IMAGE_WIDTH,
|
|
309
311
|
mediaHeight: mediaHeight || DEFAULT_IMAGE_HEIGHT,
|
|
310
312
|
validate: value => {
|
|
@@ -321,6 +323,18 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
|
|
|
321
323
|
width,
|
|
322
324
|
widthType: 'pixel'
|
|
323
325
|
});
|
|
326
|
+
tr.setMeta('scrollIntoView', false);
|
|
327
|
+
tr.setSelection(NodeSelection.create(tr.doc, selectedMediaSingleNode.pos));
|
|
328
|
+
dispatch(tr);
|
|
329
|
+
},
|
|
330
|
+
onMigrate: () => {
|
|
331
|
+
const tr = state.tr.setNodeMarkup(selectedMediaSingleNode.pos, undefined, {
|
|
332
|
+
...selectedMediaSingleNode.node.attrs,
|
|
333
|
+
width: pixelWidth,
|
|
334
|
+
widthType: 'pixel'
|
|
335
|
+
});
|
|
336
|
+
tr.setMeta('scrollIntoView', false);
|
|
337
|
+
tr.setSelection(NodeSelection.create(tr.doc, selectedMediaSingleNode.pos));
|
|
324
338
|
dispatch(tr);
|
|
325
339
|
}
|
|
326
340
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const PIXELENTRY_MIGRATION_BUTTON_TESTID = 'pixel-entry-convert-pixels-btn';
|
|
@@ -8,6 +8,7 @@ import Button from '@atlaskit/button';
|
|
|
8
8
|
import Form, { Field } from '@atlaskit/form';
|
|
9
9
|
import { pixelSizingInput, pixelSizingLabel, pixelSizingWidthInput, pixelSizingHeightInput, pixelSizingWrapper, pixelEntryForm, pixelEntryHiddenSubmit } from './styles';
|
|
10
10
|
import { messages } from './messages';
|
|
11
|
+
import { PIXELENTRY_MIGRATION_BUTTON_TESTID } from './constants';
|
|
11
12
|
export const PixelEntry = ({
|
|
12
13
|
width,
|
|
13
14
|
mediaWidth,
|
|
@@ -16,7 +17,9 @@ export const PixelEntry = ({
|
|
|
16
17
|
validate,
|
|
17
18
|
intl: {
|
|
18
19
|
formatMessage
|
|
19
|
-
}
|
|
20
|
+
},
|
|
21
|
+
showMigration,
|
|
22
|
+
onMigrate
|
|
20
23
|
}) => {
|
|
21
24
|
const ratioWidth = useMemo(() => {
|
|
22
25
|
return mediaHeight / mediaWidth;
|
|
@@ -79,6 +82,16 @@ export const PixelEntry = ({
|
|
|
79
82
|
}
|
|
80
83
|
}
|
|
81
84
|
}, [ratioHeight, ratioWidth]);
|
|
85
|
+
if (showMigration) {
|
|
86
|
+
return jsx(Tooltip, {
|
|
87
|
+
content: formatMessage(messages.migrationButtonTooltip)
|
|
88
|
+
}, jsx(Button, {
|
|
89
|
+
appearance: "warning",
|
|
90
|
+
spacing: "compact",
|
|
91
|
+
onClick: onMigrate,
|
|
92
|
+
testId: PIXELENTRY_MIGRATION_BUTTON_TESTID
|
|
93
|
+
}, formatMessage(messages.migrationButtonText)));
|
|
94
|
+
}
|
|
82
95
|
return jsx("div", {
|
|
83
96
|
css: pixelEntryForm
|
|
84
97
|
}, jsx(Form, {
|
|
@@ -29,5 +29,15 @@ export const messages = defineMessages({
|
|
|
29
29
|
id: 'fabric.editor.media.pixelEntry.submitButtonText',
|
|
30
30
|
defaultMessage: 'Submit',
|
|
31
31
|
description: 'The text give to the hidden submit button'
|
|
32
|
+
},
|
|
33
|
+
migrationButtonText: {
|
|
34
|
+
id: 'fabric.editor.media.pixelEntry.migrationButtonText',
|
|
35
|
+
defaultMessage: 'Convert to pixels',
|
|
36
|
+
description: 'The text give to the button used to covert to pixels for legacy experience'
|
|
37
|
+
},
|
|
38
|
+
migrationButtonTooltip: {
|
|
39
|
+
id: 'fabric.editor.media.pixelEntry.migrationButtonTooltip',
|
|
40
|
+
defaultMessage: 'Migrate from percentage to fixed pixel sizing',
|
|
41
|
+
description: 'The tooltip displayed on the migration button'
|
|
32
42
|
}
|
|
33
43
|
});
|
|
@@ -165,8 +165,10 @@ class ResizableMediaSingleNext extends React.Component {
|
|
|
165
165
|
});
|
|
166
166
|
_defineProperty(this, "selectCurrentMediaNode", () => {
|
|
167
167
|
// TODO: if adding !this.props.selected, it doesn't work if media single node is at top postion
|
|
168
|
-
|
|
169
|
-
|
|
168
|
+
if (this.pos === null) {
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
setNodeSelection(this.props.view, this.pos);
|
|
170
172
|
});
|
|
171
173
|
_defineProperty(this, "handleResizeStart", () => {
|
|
172
174
|
this.setState({
|
|
@@ -326,7 +328,7 @@ class ResizableMediaSingleNext extends React.Component {
|
|
|
326
328
|
get $pos() {
|
|
327
329
|
const pos = this.pos;
|
|
328
330
|
// need to pass view because we may not get updated props in time
|
|
329
|
-
return pos
|
|
331
|
+
return pos === null ? pos : this.props.view.state.doc.resolve(pos);
|
|
330
332
|
}
|
|
331
333
|
get aspectRatio() {
|
|
332
334
|
const {
|
|
@@ -377,11 +379,10 @@ class ResizableMediaSingleNext extends React.Component {
|
|
|
377
379
|
return this.isNestedNode() ? [] : generateDefaultGuidelines(lineLength, containerWidth, fullWidthMode);
|
|
378
380
|
}
|
|
379
381
|
async checkVideoFile(viewMediaClientConfig) {
|
|
380
|
-
|
|
381
|
-
if (!$pos || !viewMediaClientConfig) {
|
|
382
|
+
if (this.pos === null || !viewMediaClientConfig) {
|
|
382
383
|
return;
|
|
383
384
|
}
|
|
384
|
-
const mediaNode = this.props.view.state.doc.nodeAt(
|
|
385
|
+
const mediaNode = this.props.view.state.doc.nodeAt(this.pos + 1);
|
|
385
386
|
if (!mediaNode || !mediaNode.attrs.id) {
|
|
386
387
|
return;
|
|
387
388
|
}
|
|
@@ -458,7 +459,8 @@ class ResizableMediaSingleNext extends React.Component {
|
|
|
458
459
|
handleResizeStop: this.handleResizeStop,
|
|
459
460
|
snap: this.state.snaps,
|
|
460
461
|
resizeRatio: nonWrappedLayouts.includes(layout) ? 2 : 1,
|
|
461
|
-
"data-testid": resizerNextTestId
|
|
462
|
+
"data-testid": resizerNextTestId,
|
|
463
|
+
isHandleVisible: selected
|
|
462
464
|
}, children));
|
|
463
465
|
}
|
|
464
466
|
}
|