@atlaskit/editor-core 187.10.6 → 187.10.8
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 +6 -0
- package/dist/cjs/plugins/media/nodeviews/mediaNodeUpdater.js +5 -5
- package/dist/cjs/plugins/media/nodeviews/mediaNodeView/index.js +3 -3
- package/dist/cjs/plugins/media/nodeviews/mediaSingle.js +15 -6
- package/dist/cjs/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +18 -16
- package/dist/cjs/plugins/media/utils/media-single.js +5 -9
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/plugins/media/nodeviews/mediaNodeUpdater.js +1 -1
- package/dist/es2019/plugins/media/nodeviews/mediaNodeView/index.js +1 -1
- package/dist/es2019/plugins/media/nodeviews/mediaSingle.js +13 -4
- package/dist/es2019/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +11 -10
- package/dist/es2019/plugins/media/utils/media-single.js +6 -7
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/plugins/media/nodeviews/mediaNodeUpdater.js +1 -1
- package/dist/esm/plugins/media/nodeviews/mediaNodeView/index.js +1 -1
- package/dist/esm/plugins/media/nodeviews/mediaSingle.js +13 -4
- package/dist/esm/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +21 -19
- package/dist/esm/plugins/media/utils/media-single.js +6 -10
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/plugins/media/nodeviews/mediaNodeUpdater.d.ts +1 -2
- package/dist/types-ts4.5/plugins/media/nodeviews/mediaNodeUpdater.d.ts +1 -2
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @atlaskit/editor-core
|
|
2
2
|
|
|
3
|
+
## 187.10.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`7c8a9a4c0c1`](https://bitbucket.org/atlassian/atlassian-frontend/commits/7c8a9a4c0c1) - Update mediaSingleWidth props to render legacy media single with correct dimensions
|
|
8
|
+
|
|
3
9
|
## 187.10.6
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -11,7 +11,7 @@ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/cl
|
|
|
11
11
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
12
12
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
13
|
var _v = _interopRequireDefault(require("uuid/v4"));
|
|
14
|
-
var
|
|
14
|
+
var _mediaSingle = require("@atlaskit/editor-common/media-single");
|
|
15
15
|
var _mediaClient = require("@atlaskit/media-client");
|
|
16
16
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
17
17
|
var _helpers = require("../commands/helpers");
|
|
@@ -646,8 +646,8 @@ var MediaNodeUpdater = /*#__PURE__*/function () {
|
|
|
646
646
|
}
|
|
647
647
|
return _context14.abrupt("return", {
|
|
648
648
|
id: id,
|
|
649
|
-
height:
|
|
650
|
-
width:
|
|
649
|
+
height: _mediaSingle.DEFAULT_IMAGE_HEIGHT,
|
|
650
|
+
width: _mediaSingle.DEFAULT_IMAGE_WIDTH
|
|
651
651
|
});
|
|
652
652
|
case 15:
|
|
653
653
|
viewMediaClientConfig = mediaProvider.viewMediaClientConfig;
|
|
@@ -678,8 +678,8 @@ var MediaNodeUpdater = /*#__PURE__*/function () {
|
|
|
678
678
|
case 27:
|
|
679
679
|
return _context14.abrupt("return", {
|
|
680
680
|
id: id,
|
|
681
|
-
height: imageMetadata.original.height ||
|
|
682
|
-
width: imageMetadata.original.width ||
|
|
681
|
+
height: imageMetadata.original.height || _mediaSingle.DEFAULT_IMAGE_HEIGHT,
|
|
682
|
+
width: imageMetadata.original.width || _mediaSingle.DEFAULT_IMAGE_WIDTH
|
|
683
683
|
});
|
|
684
684
|
case 28:
|
|
685
685
|
case "end":
|
|
@@ -14,7 +14,7 @@ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime
|
|
|
14
14
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
15
15
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
16
16
|
var _providerFactory = require("@atlaskit/editor-common/provider-factory");
|
|
17
|
-
var
|
|
17
|
+
var _mediaSingle = require("@atlaskit/editor-common/media-single");
|
|
18
18
|
var _react = _interopRequireDefault(require("react"));
|
|
19
19
|
var _selectionBasedNodeView = require("@atlaskit/editor-common/selection-based-node-view");
|
|
20
20
|
var _media = _interopRequireDefault(require("./media"));
|
|
@@ -64,8 +64,8 @@ var MediaNodeView = /*#__PURE__*/function (_SelectionBasedNodeVi) {
|
|
|
64
64
|
height = height || urlHeight;
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
|
-
width = width ||
|
|
68
|
-
height = height ||
|
|
67
|
+
width = width || _mediaSingle.DEFAULT_IMAGE_WIDTH;
|
|
68
|
+
height = height || _mediaSingle.DEFAULT_IMAGE_HEIGHT;
|
|
69
69
|
var maxDimensions = {
|
|
70
70
|
width: "".concat(editorWidth.width, "px"),
|
|
71
71
|
height: "".concat(height / width * editorWidth.width, "px")
|
|
@@ -352,27 +352,36 @@ var MediaSingleNode = /*#__PURE__*/function (_Component) {
|
|
|
352
352
|
stateWidth = _this$state.width,
|
|
353
353
|
stateHeight = _this$state.height;
|
|
354
354
|
if (width === null) {
|
|
355
|
-
width = stateWidth ||
|
|
355
|
+
width = stateWidth || _mediaSingle.DEFAULT_IMAGE_WIDTH;
|
|
356
356
|
}
|
|
357
357
|
if (height === null) {
|
|
358
|
-
height = stateHeight ||
|
|
358
|
+
height = stateHeight || _mediaSingle.DEFAULT_IMAGE_HEIGHT;
|
|
359
359
|
}
|
|
360
360
|
}
|
|
361
361
|
if (!width || !height) {
|
|
362
|
-
width =
|
|
363
|
-
height =
|
|
362
|
+
width = _mediaSingle.DEFAULT_IMAGE_WIDTH;
|
|
363
|
+
height = _mediaSingle.DEFAULT_IMAGE_HEIGHT;
|
|
364
364
|
}
|
|
365
365
|
var isSelected = selected();
|
|
366
|
+
var contentWidth = this.getLineLength(view, getPos()) || lineLength;
|
|
366
367
|
var mediaSingleProps = {
|
|
367
368
|
layout: layout,
|
|
368
369
|
width: width,
|
|
369
370
|
height: height,
|
|
370
371
|
containerWidth: containerWidth,
|
|
371
|
-
lineLength:
|
|
372
|
+
lineLength: contentWidth,
|
|
372
373
|
pctWidth: mediaSingleWidthAttribute,
|
|
373
374
|
fullWidthMode: fullWidthMode,
|
|
374
375
|
hasFallbackContainer: false,
|
|
375
|
-
mediaSingleWidth:
|
|
376
|
+
mediaSingleWidth: (0, _mediaSingle.calcMediaSinglePixelWidth)({
|
|
377
|
+
width: mediaSingleWidthAttribute,
|
|
378
|
+
widthType: widthType,
|
|
379
|
+
origWidth: width,
|
|
380
|
+
layout: layout,
|
|
381
|
+
contentWidth: contentWidth,
|
|
382
|
+
containerWidth: containerWidth,
|
|
383
|
+
gutterOffset: _mediaSingle.MEDIA_SINGLE_GUTTER_SIZE
|
|
384
|
+
})
|
|
376
385
|
};
|
|
377
386
|
var ResizableMediaSingleProps = _objectSpread({
|
|
378
387
|
view: view,
|
|
@@ -137,7 +137,7 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
137
137
|
tr.setMeta('mediaSinglePlugin.isResizing', isResizing);
|
|
138
138
|
return dispatch(tr);
|
|
139
139
|
});
|
|
140
|
-
var initialWidth = props.mediaSingleWidth ||
|
|
140
|
+
var initialWidth = props.mediaSingleWidth || _mediaSingle.DEFAULT_IMAGE_WIDTH;
|
|
141
141
|
_this.state = {
|
|
142
142
|
offsetLeft: calcOffsetLeft(_this.insideInlineLike, _this.insideLayout, _this.props.view.dom, undefined),
|
|
143
143
|
// We default to true until we resolve the file type
|
|
@@ -164,7 +164,7 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
164
164
|
origWidth = _this$props3.width,
|
|
165
165
|
contentWidth = _this$props3.lineLength,
|
|
166
166
|
containerWidth = _this$props3.containerWidth;
|
|
167
|
-
return Math.max(Math.min(origWidth ||
|
|
167
|
+
return Math.max(Math.min(origWidth || _mediaSingle.DEFAULT_IMAGE_WIDTH, contentWidth || containerWidth || _editorSharedStyles.akEditorDefaultLayoutWidth), _mediaSingle.MEDIA_SINGLE_MIN_PIXEL_WIDTH);
|
|
168
168
|
}
|
|
169
169
|
}, {
|
|
170
170
|
key: "componentDidUpdate",
|
|
@@ -187,10 +187,10 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
187
187
|
var guidelines = this.getDefaultGuidelines();
|
|
188
188
|
this.displayGuideline(guidelines);
|
|
189
189
|
}
|
|
190
|
-
if (prevProps.
|
|
191
|
-
//
|
|
190
|
+
if (prevProps.mediaSingleWidth !== this.props.mediaSingleWidth && this.props.mediaSingleWidth) {
|
|
191
|
+
// update size when lineLength becomes defined later
|
|
192
192
|
// ensures extended experience renders legacy image with the same size as the legacy experience
|
|
193
|
-
var initialWidth = this.
|
|
193
|
+
var initialWidth = this.props.mediaSingleWidth;
|
|
194
194
|
this.setState({
|
|
195
195
|
size: {
|
|
196
196
|
width: initialWidth,
|
|
@@ -224,11 +224,13 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
224
224
|
}, {
|
|
225
225
|
key: "getSnaps",
|
|
226
226
|
value: function getSnaps() {
|
|
227
|
-
var
|
|
227
|
+
var _this$props5 = this.props,
|
|
228
|
+
view = _this$props5.view,
|
|
229
|
+
lineLength = _this$props5.lineLength;
|
|
228
230
|
var dom = view.dom;
|
|
229
231
|
var defaultGuidelines = this.getDefaultGuidelines();
|
|
230
232
|
// disable guidelines for nested media single node
|
|
231
|
-
var dynamicGuidelines = this.isNestedNode() ? [] : (0,
|
|
233
|
+
var dynamicGuidelines = this.isNestedNode() ? [] : (0, _guideline.generateDynamicGuidelines)(view.state, lineLength);
|
|
232
234
|
var guidelines = [].concat((0, _toConsumableArray2.default)(defaultGuidelines), (0, _toConsumableArray2.default)(dynamicGuidelines));
|
|
233
235
|
var mediaSingleSelector = 'div.mediaSingleView-content-wrap.ProseMirror-selectednode';
|
|
234
236
|
var _dom$getBoundingClien = dom.getBoundingClientRect(),
|
|
@@ -415,15 +417,15 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
415
417
|
key: "render",
|
|
416
418
|
value: function render() {
|
|
417
419
|
var _this2 = this;
|
|
418
|
-
var _this$
|
|
419
|
-
origWidth = _this$
|
|
420
|
-
layout = _this$
|
|
421
|
-
pctWidth = _this$
|
|
422
|
-
containerWidth = _this$
|
|
423
|
-
fullWidthMode = _this$
|
|
424
|
-
selected = _this$
|
|
425
|
-
children = _this$
|
|
426
|
-
intl = _this$
|
|
420
|
+
var _this$props6 = this.props,
|
|
421
|
+
origWidth = _this$props6.width,
|
|
422
|
+
layout = _this$props6.layout,
|
|
423
|
+
pctWidth = _this$props6.pctWidth,
|
|
424
|
+
containerWidth = _this$props6.containerWidth,
|
|
425
|
+
fullWidthMode = _this$props6.fullWidthMode,
|
|
426
|
+
selected = _this$props6.selected,
|
|
427
|
+
children = _this$props6.children,
|
|
428
|
+
intl = _this$props6.intl;
|
|
427
429
|
var _this$state = this.state,
|
|
428
430
|
isResizing = _this$state.isResizing,
|
|
429
431
|
size = _this$state.size;
|
|
@@ -17,14 +17,12 @@ var _mediaSingle = require("@atlaskit/editor-common/media-single");
|
|
|
17
17
|
var _mediaCommon = require("../utils/media-common");
|
|
18
18
|
var _slice = require("../../../utils/slice");
|
|
19
19
|
var _analytics = require("../../analytics");
|
|
20
|
-
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
21
20
|
var _analytics2 = require("@atlaskit/editor-common/analytics");
|
|
22
21
|
var _insert = require("@atlaskit/editor-common/insert");
|
|
23
22
|
var _isImage = require("./is-image");
|
|
24
23
|
var _position = require("../../../utils/prosemirror/position");
|
|
25
24
|
var _mediaCommon2 = require("@atlaskit/media-common");
|
|
26
25
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
27
|
-
var _ui = require("@atlaskit/editor-common/ui");
|
|
28
26
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
29
27
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
30
28
|
var getInsertMediaAnalytics = function getInsertMediaAnalytics(inputMethod, fileExtension) {
|
|
@@ -106,7 +104,9 @@ var insertMediaSingleNode = function insertMediaSingleNode(view, mediaState, inp
|
|
|
106
104
|
// add undefined as fallback as we don't want media single width to have upper limit as 0
|
|
107
105
|
// if widthPluginState.width is 0, default 760 will be used
|
|
108
106
|
var contentWidth = (widthPluginState === null || widthPluginState === void 0 ? void 0 : widthPluginState.lineLength) || (widthPluginState === null || widthPluginState === void 0 ? void 0 : widthPluginState.width) || undefined;
|
|
109
|
-
var node = createMediaSingleNode(state.schema, collection, contentWidth,
|
|
107
|
+
var node = createMediaSingleNode(state.schema, collection, contentWidth,
|
|
108
|
+
// pass undefined to use default min width
|
|
109
|
+
undefined, alignLeftOnInsert)(mediaState);
|
|
110
110
|
var fileExtension;
|
|
111
111
|
if (mediaState.fileName) {
|
|
112
112
|
var extensionIdx = mediaState.fileName.lastIndexOf('.');
|
|
@@ -140,10 +140,7 @@ var insertMediaSingleNode = function insertMediaSingleNode(view, mediaState, inp
|
|
|
140
140
|
return true;
|
|
141
141
|
};
|
|
142
142
|
exports.insertMediaSingleNode = insertMediaSingleNode;
|
|
143
|
-
var createMediaSingleNode = function createMediaSingleNode(schema, collection) {
|
|
144
|
-
var maxWidth = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _editorSharedStyles.akEditorDefaultLayoutWidth;
|
|
145
|
-
var minWidth = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _mediaSingle.MEDIA_SINGLE_MIN_PIXEL_WIDTH;
|
|
146
|
-
var alignLeftOnInsert = arguments.length > 4 ? arguments[4] : undefined;
|
|
143
|
+
var createMediaSingleNode = function createMediaSingleNode(schema, collection, maxWidth, minWidth, alignLeftOnInsert) {
|
|
147
144
|
return function (mediaState) {
|
|
148
145
|
var id = mediaState.id,
|
|
149
146
|
dimensions = mediaState.dimensions,
|
|
@@ -172,8 +169,7 @@ var createMediaSingleNode = function createMediaSingleNode(schema, collection) {
|
|
|
172
169
|
layout: 'align-start'
|
|
173
170
|
} : {};
|
|
174
171
|
var extendedMediaSingleAttrs = (0, _platformFeatureFlags.getBooleanFF)('platform.editor.media.extended-resize-experience') ? _objectSpread(_objectSpread({}, mediaSingleAttrs), {}, {
|
|
175
|
-
|
|
176
|
-
width: Math.max(Math.min(scaledWidth || _ui.DEFAULT_IMAGE_WIDTH, maxWidth), minWidth),
|
|
172
|
+
width: (0, _mediaSingle.getMediaSingleInitialWidth)(scaledWidth, maxWidth, minWidth),
|
|
177
173
|
// TODO: change to use enum
|
|
178
174
|
widthType: 'pixel'
|
|
179
175
|
}) : mediaSingleAttrs;
|
|
@@ -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.10.
|
|
9
|
+
var version = "187.10.8";
|
|
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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import uuidV4 from 'uuid/v4';
|
|
3
|
-
import { DEFAULT_IMAGE_HEIGHT, DEFAULT_IMAGE_WIDTH } from '@atlaskit/editor-common/
|
|
3
|
+
import { DEFAULT_IMAGE_HEIGHT, DEFAULT_IMAGE_WIDTH } from '@atlaskit/editor-common/media-single';
|
|
4
4
|
import { getMediaClient, isMediaBlobUrl, getAttrsFromUrl, isImageRepresentationReady } from '@atlaskit/media-client';
|
|
5
5
|
import { ACTION, ACTION_SUBJECT, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
6
6
|
import { replaceExternalMedia, updateAllMediaSingleNodesAttrs, updateCurrentMediaNodeAttrs, updateMediaSingleNodeAttrs } from '../commands/helpers';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import { WithProviders } from '@atlaskit/editor-common/provider-factory';
|
|
3
|
-
import { DEFAULT_IMAGE_HEIGHT, DEFAULT_IMAGE_WIDTH } from '@atlaskit/editor-common/
|
|
3
|
+
import { DEFAULT_IMAGE_HEIGHT, DEFAULT_IMAGE_WIDTH } from '@atlaskit/editor-common/media-single';
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import { SelectionBasedNodeView } from '@atlaskit/editor-common/selection-based-node-view';
|
|
6
6
|
import MediaNode from './media';
|
|
@@ -3,7 +3,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
3
3
|
import { jsx } from '@emotion/react';
|
|
4
4
|
import React, { Component } from 'react';
|
|
5
5
|
import { WithProviders } from '@atlaskit/editor-common/provider-factory';
|
|
6
|
-
import { MediaSingle
|
|
6
|
+
import { MediaSingle } from '@atlaskit/editor-common/ui';
|
|
7
7
|
import { browser, floatingLayouts, isRichMediaInsideOfBlockNode } from '@atlaskit/editor-common/utils';
|
|
8
8
|
import { isNodeSelectedOrInRange } from '../../../utils/nodes';
|
|
9
9
|
import { setNodeSelection, setTextSelection } from '../../../utils';
|
|
@@ -22,7 +22,7 @@ import CaptionPlaceholder from '../ui/CaptionPlaceholder';
|
|
|
22
22
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
23
23
|
import { insertAndSelectCaptionFromMediaSinglePos } from '../commands/captions';
|
|
24
24
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
25
|
-
import {
|
|
25
|
+
import { calcMediaSinglePixelWidth, MEDIA_SINGLE_GUTTER_SIZE, DEFAULT_IMAGE_HEIGHT, DEFAULT_IMAGE_WIDTH } from '@atlaskit/editor-common/media-single';
|
|
26
26
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
27
27
|
export default class MediaSingleNode extends Component {
|
|
28
28
|
constructor(...args) {
|
|
@@ -270,16 +270,25 @@ export default class MediaSingleNode extends Component {
|
|
|
270
270
|
height = DEFAULT_IMAGE_HEIGHT;
|
|
271
271
|
}
|
|
272
272
|
const isSelected = selected();
|
|
273
|
+
const contentWidth = this.getLineLength(view, getPos()) || lineLength;
|
|
273
274
|
const mediaSingleProps = {
|
|
274
275
|
layout,
|
|
275
276
|
width,
|
|
276
277
|
height,
|
|
277
278
|
containerWidth: containerWidth,
|
|
278
|
-
lineLength:
|
|
279
|
+
lineLength: contentWidth,
|
|
279
280
|
pctWidth: mediaSingleWidthAttribute,
|
|
280
281
|
fullWidthMode,
|
|
281
282
|
hasFallbackContainer: false,
|
|
282
|
-
mediaSingleWidth:
|
|
283
|
+
mediaSingleWidth: calcMediaSinglePixelWidth({
|
|
284
|
+
width: mediaSingleWidthAttribute,
|
|
285
|
+
widthType,
|
|
286
|
+
origWidth: width,
|
|
287
|
+
layout,
|
|
288
|
+
contentWidth,
|
|
289
|
+
containerWidth,
|
|
290
|
+
gutterOffset: MEDIA_SINGLE_GUTTER_SIZE
|
|
291
|
+
})
|
|
283
292
|
};
|
|
284
293
|
const ResizableMediaSingleProps = {
|
|
285
294
|
view: view,
|
|
@@ -4,7 +4,7 @@ import React from 'react';
|
|
|
4
4
|
import { jsx } from '@emotion/react';
|
|
5
5
|
import { findParentNodeOfTypeClosestToPos, hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
6
6
|
import { getMediaClient } from '@atlaskit/media-client';
|
|
7
|
-
import { calcPctFromPx, wrappedLayouts, handleSides, imageAlignmentMap, calcColumnsFromPx
|
|
7
|
+
import { calcPctFromPx, wrappedLayouts, handleSides, imageAlignmentMap, calcColumnsFromPx } from '@atlaskit/editor-common/ui';
|
|
8
8
|
import { nonWrappedLayouts, setNodeSelection } from '@atlaskit/editor-common/utils';
|
|
9
9
|
import { akEditorFullWidthLayoutWidth, akEditorGutterPadding, akEditorDefaultLayoutWidth } from '@atlaskit/editor-shared-styles';
|
|
10
10
|
import { wrapperStyle } from './styled';
|
|
@@ -15,9 +15,9 @@ import { messages } from './resizable-media-single-messages';
|
|
|
15
15
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
16
16
|
import classnames from 'classnames';
|
|
17
17
|
import { richMediaClassName, resizerStyles } from '@atlaskit/editor-common/styles';
|
|
18
|
-
import { MEDIA_SINGLE_MIN_PIXEL_WIDTH, MEDIA_SINGLE_SNAP_GAP, MEDIA_SINGLE_HIGHLIGHT_GAP } from '@atlaskit/editor-common/media-single';
|
|
19
|
-
import { findClosestSnap, getSnapWidth, getGuidelinesWithHighlights } from '@atlaskit/editor-common/guideline';
|
|
20
|
-
import { generateDefaultGuidelines
|
|
18
|
+
import { MEDIA_SINGLE_MIN_PIXEL_WIDTH, MEDIA_SINGLE_SNAP_GAP, MEDIA_SINGLE_HIGHLIGHT_GAP, DEFAULT_IMAGE_WIDTH } from '@atlaskit/editor-common/media-single';
|
|
19
|
+
import { findClosestSnap, getSnapWidth, getGuidelinesWithHighlights, generateDynamicGuidelines } from '@atlaskit/editor-common/guideline';
|
|
20
|
+
import { generateDefaultGuidelines } from './guidelines';
|
|
21
21
|
export const resizerNextTestId = 'mediaSingle.resizerNext.testid';
|
|
22
22
|
export function calcOffsetLeft(insideInlineLike, insideLayout, pmViewDom, wrapper) {
|
|
23
23
|
if (wrapper && insideInlineLike && !insideLayout) {
|
|
@@ -119,7 +119,7 @@ class ResizableMediaSingleNext extends React.Component {
|
|
|
119
119
|
tr.setMeta('mediaSinglePlugin.isResizing', isResizing);
|
|
120
120
|
return dispatch(tr);
|
|
121
121
|
});
|
|
122
|
-
const initialWidth = props.mediaSingleWidth ||
|
|
122
|
+
const initialWidth = props.mediaSingleWidth || DEFAULT_IMAGE_WIDTH;
|
|
123
123
|
this.state = {
|
|
124
124
|
offsetLeft: calcOffsetLeft(this.insideInlineLike, this.insideLayout, this.props.view.dom, undefined),
|
|
125
125
|
// We default to true until we resolve the file type
|
|
@@ -165,10 +165,10 @@ class ResizableMediaSingleNext extends React.Component {
|
|
|
165
165
|
const guidelines = this.getDefaultGuidelines();
|
|
166
166
|
this.displayGuideline(guidelines);
|
|
167
167
|
}
|
|
168
|
-
if (prevProps.
|
|
169
|
-
//
|
|
168
|
+
if (prevProps.mediaSingleWidth !== this.props.mediaSingleWidth && this.props.mediaSingleWidth) {
|
|
169
|
+
// update size when lineLength becomes defined later
|
|
170
170
|
// ensures extended experience renders legacy image with the same size as the legacy experience
|
|
171
|
-
const initialWidth = this.
|
|
171
|
+
const initialWidth = this.props.mediaSingleWidth;
|
|
172
172
|
this.setState({
|
|
173
173
|
size: {
|
|
174
174
|
width: initialWidth,
|
|
@@ -198,14 +198,15 @@ class ResizableMediaSingleNext extends React.Component {
|
|
|
198
198
|
// TODO: refactor this later, maybe use state to hold snaps array
|
|
199
199
|
getSnaps() {
|
|
200
200
|
const {
|
|
201
|
-
view
|
|
201
|
+
view,
|
|
202
|
+
lineLength
|
|
202
203
|
} = this.props;
|
|
203
204
|
const {
|
|
204
205
|
dom
|
|
205
206
|
} = view;
|
|
206
207
|
const defaultGuidelines = this.getDefaultGuidelines();
|
|
207
208
|
// disable guidelines for nested media single node
|
|
208
|
-
const dynamicGuidelines = this.isNestedNode() ? [] : generateDynamicGuidelines(view);
|
|
209
|
+
const dynamicGuidelines = this.isNestedNode() ? [] : generateDynamicGuidelines(view.state, lineLength);
|
|
209
210
|
const guidelines = [...defaultGuidelines, ...dynamicGuidelines];
|
|
210
211
|
const mediaSingleSelector = 'div.mediaSingleView-content-wrap.ProseMirror-selectednode';
|
|
211
212
|
const {
|
|
@@ -2,18 +2,16 @@ import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
|
|
|
2
2
|
import { safeInsert as pmSafeInsert, hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
3
3
|
import { checkNodeDown } from '../../../utils';
|
|
4
4
|
import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
|
|
5
|
-
import {
|
|
5
|
+
import { getMediaSingleInitialWidth } from '@atlaskit/editor-common/media-single';
|
|
6
6
|
import { copyOptionalAttrsFromMediaState } from '../utils/media-common';
|
|
7
7
|
import { mapSlice } from '../../../utils/slice';
|
|
8
8
|
import { addAnalytics } from '../../analytics';
|
|
9
|
-
import { akEditorDefaultLayoutWidth } from '@atlaskit/editor-shared-styles';
|
|
10
9
|
import { ACTION, ACTION_SUBJECT, EVENT_TYPE, ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
|
|
11
10
|
import { safeInsert, shouldSplitSelectedNodeOnNodeInsertion } from '@atlaskit/editor-common/insert';
|
|
12
11
|
import { isImage } from './is-image';
|
|
13
12
|
import { atTheBeginningOfBlock } from '../../../utils/prosemirror/position';
|
|
14
13
|
import { getRandomHex } from '@atlaskit/media-common';
|
|
15
14
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
16
|
-
import { DEFAULT_IMAGE_WIDTH } from '@atlaskit/editor-common/ui';
|
|
17
15
|
const getInsertMediaAnalytics = (inputMethod, fileExtension) => ({
|
|
18
16
|
action: ACTION.INSERTED,
|
|
19
17
|
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
@@ -97,7 +95,9 @@ export const insertMediaSingleNode = (view, mediaState, inputMethod, collection,
|
|
|
97
95
|
// add undefined as fallback as we don't want media single width to have upper limit as 0
|
|
98
96
|
// if widthPluginState.width is 0, default 760 will be used
|
|
99
97
|
const contentWidth = (widthPluginState === null || widthPluginState === void 0 ? void 0 : widthPluginState.lineLength) || (widthPluginState === null || widthPluginState === void 0 ? void 0 : widthPluginState.width) || undefined;
|
|
100
|
-
const node = createMediaSingleNode(state.schema, collection, contentWidth,
|
|
98
|
+
const node = createMediaSingleNode(state.schema, collection, contentWidth,
|
|
99
|
+
// pass undefined to use default min width
|
|
100
|
+
undefined, alignLeftOnInsert)(mediaState);
|
|
101
101
|
let fileExtension;
|
|
102
102
|
if (mediaState.fileName) {
|
|
103
103
|
const extensionIdx = mediaState.fileName.lastIndexOf('.');
|
|
@@ -130,7 +130,7 @@ export const insertMediaSingleNode = (view, mediaState, inputMethod, collection,
|
|
|
130
130
|
}
|
|
131
131
|
return true;
|
|
132
132
|
};
|
|
133
|
-
export const createMediaSingleNode = (schema, collection, maxWidth
|
|
133
|
+
export const createMediaSingleNode = (schema, collection, maxWidth, minWidth, alignLeftOnInsert) => mediaState => {
|
|
134
134
|
const {
|
|
135
135
|
id,
|
|
136
136
|
dimensions,
|
|
@@ -162,8 +162,7 @@ export const createMediaSingleNode = (schema, collection, maxWidth = akEditorDef
|
|
|
162
162
|
} : {};
|
|
163
163
|
const extendedMediaSingleAttrs = getBooleanFF('platform.editor.media.extended-resize-experience') ? {
|
|
164
164
|
...mediaSingleAttrs,
|
|
165
|
-
|
|
166
|
-
width: Math.max(Math.min(scaledWidth || DEFAULT_IMAGE_WIDTH, maxWidth), minWidth),
|
|
165
|
+
width: getMediaSingleInitialWidth(scaledWidth, maxWidth, minWidth),
|
|
167
166
|
// TODO: change to use enum
|
|
168
167
|
widthType: 'pixel'
|
|
169
168
|
} : mediaSingleAttrs;
|
package/dist/es2019/version.json
CHANGED
|
@@ -4,7 +4,7 @@ import _createClass from "@babel/runtime/helpers/createClass";
|
|
|
4
4
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
5
5
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
6
6
|
import uuidV4 from 'uuid/v4';
|
|
7
|
-
import { DEFAULT_IMAGE_HEIGHT, DEFAULT_IMAGE_WIDTH } from '@atlaskit/editor-common/
|
|
7
|
+
import { DEFAULT_IMAGE_HEIGHT, DEFAULT_IMAGE_WIDTH } from '@atlaskit/editor-common/media-single';
|
|
8
8
|
import { getMediaClient, isMediaBlobUrl as _isMediaBlobUrl, getAttrsFromUrl, isImageRepresentationReady } from '@atlaskit/media-client';
|
|
9
9
|
import { ACTION, ACTION_SUBJECT, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
10
10
|
import { replaceExternalMedia, updateAllMediaSingleNodesAttrs, updateCurrentMediaNodeAttrs, updateMediaSingleNodeAttrs } from '../commands/helpers';
|
|
@@ -9,7 +9,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
9
9
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
10
10
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
11
11
|
import { WithProviders } from '@atlaskit/editor-common/provider-factory';
|
|
12
|
-
import { DEFAULT_IMAGE_HEIGHT, DEFAULT_IMAGE_WIDTH } from '@atlaskit/editor-common/
|
|
12
|
+
import { DEFAULT_IMAGE_HEIGHT, DEFAULT_IMAGE_WIDTH } from '@atlaskit/editor-common/media-single';
|
|
13
13
|
import React from 'react';
|
|
14
14
|
import { SelectionBasedNodeView } from '@atlaskit/editor-common/selection-based-node-view';
|
|
15
15
|
import MediaNode from './media';
|
|
@@ -16,7 +16,7 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
16
16
|
import { jsx } from '@emotion/react';
|
|
17
17
|
import React, { Component } from 'react';
|
|
18
18
|
import { WithProviders } from '@atlaskit/editor-common/provider-factory';
|
|
19
|
-
import { MediaSingle
|
|
19
|
+
import { MediaSingle } from '@atlaskit/editor-common/ui';
|
|
20
20
|
import { browser, floatingLayouts, isRichMediaInsideOfBlockNode } from '@atlaskit/editor-common/utils';
|
|
21
21
|
import { isNodeSelectedOrInRange } from '../../../utils/nodes';
|
|
22
22
|
import { setNodeSelection, setTextSelection } from '../../../utils';
|
|
@@ -35,7 +35,7 @@ import CaptionPlaceholder from '../ui/CaptionPlaceholder';
|
|
|
35
35
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
36
36
|
import { insertAndSelectCaptionFromMediaSinglePos } from '../commands/captions';
|
|
37
37
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
38
|
-
import {
|
|
38
|
+
import { calcMediaSinglePixelWidth, MEDIA_SINGLE_GUTTER_SIZE, DEFAULT_IMAGE_HEIGHT, DEFAULT_IMAGE_WIDTH } from '@atlaskit/editor-common/media-single';
|
|
39
39
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
40
40
|
var MediaSingleNode = /*#__PURE__*/function (_Component) {
|
|
41
41
|
_inherits(MediaSingleNode, _Component);
|
|
@@ -354,16 +354,25 @@ var MediaSingleNode = /*#__PURE__*/function (_Component) {
|
|
|
354
354
|
height = DEFAULT_IMAGE_HEIGHT;
|
|
355
355
|
}
|
|
356
356
|
var isSelected = selected();
|
|
357
|
+
var contentWidth = this.getLineLength(view, getPos()) || lineLength;
|
|
357
358
|
var mediaSingleProps = {
|
|
358
359
|
layout: layout,
|
|
359
360
|
width: width,
|
|
360
361
|
height: height,
|
|
361
362
|
containerWidth: containerWidth,
|
|
362
|
-
lineLength:
|
|
363
|
+
lineLength: contentWidth,
|
|
363
364
|
pctWidth: mediaSingleWidthAttribute,
|
|
364
365
|
fullWidthMode: fullWidthMode,
|
|
365
366
|
hasFallbackContainer: false,
|
|
366
|
-
mediaSingleWidth:
|
|
367
|
+
mediaSingleWidth: calcMediaSinglePixelWidth({
|
|
368
|
+
width: mediaSingleWidthAttribute,
|
|
369
|
+
widthType: widthType,
|
|
370
|
+
origWidth: width,
|
|
371
|
+
layout: layout,
|
|
372
|
+
contentWidth: contentWidth,
|
|
373
|
+
containerWidth: containerWidth,
|
|
374
|
+
gutterOffset: MEDIA_SINGLE_GUTTER_SIZE
|
|
375
|
+
})
|
|
367
376
|
};
|
|
368
377
|
var ResizableMediaSingleProps = _objectSpread({
|
|
369
378
|
view: view,
|
|
@@ -15,7 +15,7 @@ import React from 'react';
|
|
|
15
15
|
import { jsx } from '@emotion/react';
|
|
16
16
|
import { findParentNodeOfTypeClosestToPos, hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
17
17
|
import { getMediaClient } from '@atlaskit/media-client';
|
|
18
|
-
import { calcPctFromPx, wrappedLayouts, handleSides, imageAlignmentMap, calcColumnsFromPx
|
|
18
|
+
import { calcPctFromPx, wrappedLayouts, handleSides, imageAlignmentMap, calcColumnsFromPx } from '@atlaskit/editor-common/ui';
|
|
19
19
|
import { nonWrappedLayouts, setNodeSelection } from '@atlaskit/editor-common/utils';
|
|
20
20
|
import { akEditorFullWidthLayoutWidth, akEditorGutterPadding, akEditorDefaultLayoutWidth } from '@atlaskit/editor-shared-styles';
|
|
21
21
|
import { wrapperStyle } from './styled';
|
|
@@ -26,9 +26,9 @@ import { messages } from './resizable-media-single-messages';
|
|
|
26
26
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
27
27
|
import classnames from 'classnames';
|
|
28
28
|
import { richMediaClassName, resizerStyles } from '@atlaskit/editor-common/styles';
|
|
29
|
-
import { MEDIA_SINGLE_MIN_PIXEL_WIDTH, MEDIA_SINGLE_SNAP_GAP, MEDIA_SINGLE_HIGHLIGHT_GAP } from '@atlaskit/editor-common/media-single';
|
|
30
|
-
import { findClosestSnap, getSnapWidth, getGuidelinesWithHighlights } from '@atlaskit/editor-common/guideline';
|
|
31
|
-
import { generateDefaultGuidelines
|
|
29
|
+
import { MEDIA_SINGLE_MIN_PIXEL_WIDTH, MEDIA_SINGLE_SNAP_GAP, MEDIA_SINGLE_HIGHLIGHT_GAP, DEFAULT_IMAGE_WIDTH } from '@atlaskit/editor-common/media-single';
|
|
30
|
+
import { findClosestSnap, getSnapWidth, getGuidelinesWithHighlights, generateDynamicGuidelines } from '@atlaskit/editor-common/guideline';
|
|
31
|
+
import { generateDefaultGuidelines } from './guidelines';
|
|
32
32
|
export var resizerNextTestId = 'mediaSingle.resizerNext.testid';
|
|
33
33
|
export function calcOffsetLeft(insideInlineLike, insideLayout, pmViewDom, wrapper) {
|
|
34
34
|
if (wrapper && insideInlineLike && !insideLayout) {
|
|
@@ -128,7 +128,7 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
128
128
|
tr.setMeta('mediaSinglePlugin.isResizing', isResizing);
|
|
129
129
|
return dispatch(tr);
|
|
130
130
|
});
|
|
131
|
-
var initialWidth = props.mediaSingleWidth ||
|
|
131
|
+
var initialWidth = props.mediaSingleWidth || DEFAULT_IMAGE_WIDTH;
|
|
132
132
|
_this.state = {
|
|
133
133
|
offsetLeft: calcOffsetLeft(_this.insideInlineLike, _this.insideLayout, _this.props.view.dom, undefined),
|
|
134
134
|
// We default to true until we resolve the file type
|
|
@@ -178,10 +178,10 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
178
178
|
var guidelines = this.getDefaultGuidelines();
|
|
179
179
|
this.displayGuideline(guidelines);
|
|
180
180
|
}
|
|
181
|
-
if (prevProps.
|
|
182
|
-
//
|
|
181
|
+
if (prevProps.mediaSingleWidth !== this.props.mediaSingleWidth && this.props.mediaSingleWidth) {
|
|
182
|
+
// update size when lineLength becomes defined later
|
|
183
183
|
// ensures extended experience renders legacy image with the same size as the legacy experience
|
|
184
|
-
var initialWidth = this.
|
|
184
|
+
var initialWidth = this.props.mediaSingleWidth;
|
|
185
185
|
this.setState({
|
|
186
186
|
size: {
|
|
187
187
|
width: initialWidth,
|
|
@@ -215,11 +215,13 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
215
215
|
}, {
|
|
216
216
|
key: "getSnaps",
|
|
217
217
|
value: function getSnaps() {
|
|
218
|
-
var
|
|
218
|
+
var _this$props5 = this.props,
|
|
219
|
+
view = _this$props5.view,
|
|
220
|
+
lineLength = _this$props5.lineLength;
|
|
219
221
|
var dom = view.dom;
|
|
220
222
|
var defaultGuidelines = this.getDefaultGuidelines();
|
|
221
223
|
// disable guidelines for nested media single node
|
|
222
|
-
var dynamicGuidelines = this.isNestedNode() ? [] : generateDynamicGuidelines(view);
|
|
224
|
+
var dynamicGuidelines = this.isNestedNode() ? [] : generateDynamicGuidelines(view.state, lineLength);
|
|
223
225
|
var guidelines = [].concat(_toConsumableArray(defaultGuidelines), _toConsumableArray(dynamicGuidelines));
|
|
224
226
|
var mediaSingleSelector = 'div.mediaSingleView-content-wrap.ProseMirror-selectednode';
|
|
225
227
|
var _dom$getBoundingClien = dom.getBoundingClientRect(),
|
|
@@ -406,15 +408,15 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
406
408
|
key: "render",
|
|
407
409
|
value: function render() {
|
|
408
410
|
var _this2 = this;
|
|
409
|
-
var _this$
|
|
410
|
-
origWidth = _this$
|
|
411
|
-
layout = _this$
|
|
412
|
-
pctWidth = _this$
|
|
413
|
-
containerWidth = _this$
|
|
414
|
-
fullWidthMode = _this$
|
|
415
|
-
selected = _this$
|
|
416
|
-
children = _this$
|
|
417
|
-
intl = _this$
|
|
411
|
+
var _this$props6 = this.props,
|
|
412
|
+
origWidth = _this$props6.width,
|
|
413
|
+
layout = _this$props6.layout,
|
|
414
|
+
pctWidth = _this$props6.pctWidth,
|
|
415
|
+
containerWidth = _this$props6.containerWidth,
|
|
416
|
+
fullWidthMode = _this$props6.fullWidthMode,
|
|
417
|
+
selected = _this$props6.selected,
|
|
418
|
+
children = _this$props6.children,
|
|
419
|
+
intl = _this$props6.intl;
|
|
418
420
|
var _this$state = this.state,
|
|
419
421
|
isResizing = _this$state.isResizing,
|
|
420
422
|
size = _this$state.size;
|
|
@@ -5,18 +5,16 @@ import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
|
|
|
5
5
|
import { safeInsert as pmSafeInsert, hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
6
6
|
import { checkNodeDown } from '../../../utils';
|
|
7
7
|
import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
|
|
8
|
-
import {
|
|
8
|
+
import { getMediaSingleInitialWidth } from '@atlaskit/editor-common/media-single';
|
|
9
9
|
import { copyOptionalAttrsFromMediaState } from '../utils/media-common';
|
|
10
10
|
import { mapSlice } from '../../../utils/slice';
|
|
11
11
|
import { addAnalytics } from '../../analytics';
|
|
12
|
-
import { akEditorDefaultLayoutWidth } from '@atlaskit/editor-shared-styles';
|
|
13
12
|
import { ACTION, ACTION_SUBJECT, EVENT_TYPE, ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
|
|
14
13
|
import { safeInsert, shouldSplitSelectedNodeOnNodeInsertion } from '@atlaskit/editor-common/insert';
|
|
15
14
|
import { isImage } from './is-image';
|
|
16
15
|
import { atTheBeginningOfBlock } from '../../../utils/prosemirror/position';
|
|
17
16
|
import { getRandomHex } from '@atlaskit/media-common';
|
|
18
17
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
19
|
-
import { DEFAULT_IMAGE_WIDTH } from '@atlaskit/editor-common/ui';
|
|
20
18
|
var getInsertMediaAnalytics = function getInsertMediaAnalytics(inputMethod, fileExtension) {
|
|
21
19
|
return {
|
|
22
20
|
action: ACTION.INSERTED,
|
|
@@ -94,7 +92,9 @@ export var insertMediaSingleNode = function insertMediaSingleNode(view, mediaSta
|
|
|
94
92
|
// add undefined as fallback as we don't want media single width to have upper limit as 0
|
|
95
93
|
// if widthPluginState.width is 0, default 760 will be used
|
|
96
94
|
var contentWidth = (widthPluginState === null || widthPluginState === void 0 ? void 0 : widthPluginState.lineLength) || (widthPluginState === null || widthPluginState === void 0 ? void 0 : widthPluginState.width) || undefined;
|
|
97
|
-
var node = createMediaSingleNode(state.schema, collection, contentWidth,
|
|
95
|
+
var node = createMediaSingleNode(state.schema, collection, contentWidth,
|
|
96
|
+
// pass undefined to use default min width
|
|
97
|
+
undefined, alignLeftOnInsert)(mediaState);
|
|
98
98
|
var fileExtension;
|
|
99
99
|
if (mediaState.fileName) {
|
|
100
100
|
var extensionIdx = mediaState.fileName.lastIndexOf('.');
|
|
@@ -127,10 +127,7 @@ export var insertMediaSingleNode = function insertMediaSingleNode(view, mediaSta
|
|
|
127
127
|
}
|
|
128
128
|
return true;
|
|
129
129
|
};
|
|
130
|
-
export var createMediaSingleNode = function createMediaSingleNode(schema, collection) {
|
|
131
|
-
var maxWidth = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : akEditorDefaultLayoutWidth;
|
|
132
|
-
var minWidth = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : MEDIA_SINGLE_MIN_PIXEL_WIDTH;
|
|
133
|
-
var alignLeftOnInsert = arguments.length > 4 ? arguments[4] : undefined;
|
|
130
|
+
export var createMediaSingleNode = function createMediaSingleNode(schema, collection, maxWidth, minWidth, alignLeftOnInsert) {
|
|
134
131
|
return function (mediaState) {
|
|
135
132
|
var id = mediaState.id,
|
|
136
133
|
dimensions = mediaState.dimensions,
|
|
@@ -159,8 +156,7 @@ export var createMediaSingleNode = function createMediaSingleNode(schema, collec
|
|
|
159
156
|
layout: 'align-start'
|
|
160
157
|
} : {};
|
|
161
158
|
var extendedMediaSingleAttrs = getBooleanFF('platform.editor.media.extended-resize-experience') ? _objectSpread(_objectSpread({}, mediaSingleAttrs), {}, {
|
|
162
|
-
|
|
163
|
-
width: Math.max(Math.min(scaledWidth || DEFAULT_IMAGE_WIDTH, maxWidth), minWidth),
|
|
159
|
+
width: getMediaSingleInitialWidth(scaledWidth, maxWidth, minWidth),
|
|
164
160
|
// TODO: change to use enum
|
|
165
161
|
widthType: 'pixel'
|
|
166
162
|
}) : mediaSingleAttrs;
|
package/dist/esm/version.json
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type { MediaADFAttrs } from '@atlaskit/adf-schema';
|
|
2
|
-
import type { MediaProvider } from '@atlaskit/editor-common/provider-factory';
|
|
2
|
+
import type { MediaProvider, ContextIdentifierProvider } from '@atlaskit/editor-common/provider-factory';
|
|
3
3
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
4
4
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
5
|
-
import type { ContextIdentifierProvider } from '@atlaskit/editor-common/provider-factory';
|
|
6
5
|
import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
|
|
7
6
|
import type { MediaOptions } from '../types';
|
|
8
7
|
import type { ProsemirrorGetPosHandler } from '../../../nodeviews';
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type { MediaADFAttrs } from '@atlaskit/adf-schema';
|
|
2
|
-
import type { MediaProvider } from '@atlaskit/editor-common/provider-factory';
|
|
2
|
+
import type { MediaProvider, ContextIdentifierProvider } from '@atlaskit/editor-common/provider-factory';
|
|
3
3
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
4
4
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
5
|
-
import type { ContextIdentifierProvider } from '@atlaskit/editor-common/provider-factory';
|
|
6
5
|
import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
|
|
7
6
|
import type { MediaOptions } from '../types';
|
|
8
7
|
import type { ProsemirrorGetPosHandler } from '../../../nodeviews';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-core",
|
|
3
|
-
"version": "187.10.
|
|
3
|
+
"version": "187.10.8",
|
|
4
4
|
"description": "A package contains Atlassian editor core functionality",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
"@atlaskit/media-common": "^8.0.0",
|
|
87
87
|
"@atlaskit/media-filmstrip": "^47.0.0",
|
|
88
88
|
"@atlaskit/media-picker": "^66.1.0",
|
|
89
|
-
"@atlaskit/media-ui": "^23.
|
|
89
|
+
"@atlaskit/media-ui": "^23.3.0",
|
|
90
90
|
"@atlaskit/media-viewer": "^48.0.0",
|
|
91
91
|
"@atlaskit/mention": "^22.1.0",
|
|
92
92
|
"@atlaskit/menu": "^1.9.0",
|