@atlaskit/editor-plugin-media 0.3.6 → 0.3.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 +12 -0
- package/dist/cjs/nodeviews/mediaNodeView/index.js +23 -1
- package/dist/cjs/toolbar/index.js +3 -3
- package/dist/cjs/toolbar/utils.js +3 -2
- package/dist/cjs/utils/media-single.js +3 -2
- package/dist/es2019/nodeviews/mediaNodeView/index.js +21 -1
- package/dist/es2019/toolbar/index.js +3 -3
- package/dist/es2019/toolbar/utils.js +3 -2
- package/dist/es2019/utils/media-single.js +4 -1
- package/dist/esm/nodeviews/mediaNodeView/index.js +23 -1
- package/dist/esm/toolbar/index.js +3 -3
- package/dist/esm/toolbar/utils.js +3 -2
- package/dist/esm/utils/media-single.js +3 -2
- package/dist/types/nodeviews/mediaNodeView/index.d.ts +4 -0
- package/dist/types/toolbar/utils.d.ts +1 -1
- package/dist/types/utils/media-single.d.ts +1 -1
- package/dist/types-ts4.5/nodeviews/mediaNodeView/index.d.ts +4 -0
- package/dist/types-ts4.5/toolbar/utils.d.ts +1 -1
- package/dist/types-ts4.5/utils/media-single.d.ts +1 -1
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-media
|
|
2
2
|
|
|
3
|
+
## 0.3.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 0.3.7
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#40916](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/40916) [`0b80e2e68ea`](https://bitbucket.org/atlassian/atlassian-frontend/commits/0b80e2e68ea) - [ux] media single node with external type media should not show migration ui. Update external image with natural dimensions accordingly, and fixed whitespace issue in external image.
|
|
14
|
+
|
|
3
15
|
## 0.3.6
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.ReactMediaNode = void 0;
|
|
8
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
8
9
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
9
10
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
11
|
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
@@ -19,8 +20,12 @@ var _mediaSingle = require("@atlaskit/editor-common/media-single");
|
|
|
19
20
|
var _providerFactory = require("@atlaskit/editor-common/provider-factory");
|
|
20
21
|
var _selectionBasedNodeView = require("@atlaskit/editor-common/selection-based-node-view");
|
|
21
22
|
var _mediaClient = require("@atlaskit/media-client");
|
|
23
|
+
var _helpers = require("../../commands/helpers");
|
|
22
24
|
var _mediaCommon = require("../../utils/media-common");
|
|
23
25
|
var _media = _interopRequireDefault(require("./media"));
|
|
26
|
+
var _excluded = ["width", "height"];
|
|
27
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
28
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
24
29
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
25
30
|
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; } }
|
|
26
31
|
var MediaNodeWithProviders = function MediaNodeWithProviders(_ref) {
|
|
@@ -46,6 +51,22 @@ var MediaNodeView = /*#__PURE__*/function (_SelectionBasedNodeVi) {
|
|
|
46
51
|
}
|
|
47
52
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
48
53
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "isSelected", false);
|
|
54
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onExternalImageLoaded", function (dimensions) {
|
|
55
|
+
var getPos = _this.getPos;
|
|
56
|
+
var _this$getAttrs = _this.getAttrs(),
|
|
57
|
+
width = _this$getAttrs.width,
|
|
58
|
+
height = _this$getAttrs.height,
|
|
59
|
+
rest = (0, _objectWithoutProperties2.default)(_this$getAttrs, _excluded);
|
|
60
|
+
if (!width || !height) {
|
|
61
|
+
(0, _helpers.updateCurrentMediaNodeAttrs)(_objectSpread(_objectSpread({}, rest), {}, {
|
|
62
|
+
width: width || dimensions.width,
|
|
63
|
+
height: height || dimensions.height
|
|
64
|
+
}), {
|
|
65
|
+
node: _this.node,
|
|
66
|
+
getPos: getPos
|
|
67
|
+
})(_this.view.state, _this.view.dispatch);
|
|
68
|
+
}
|
|
69
|
+
});
|
|
49
70
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "renderMediaNodeWithState", function (mediaProvider, contextIdentifierProvider) {
|
|
50
71
|
return function (_ref2) {
|
|
51
72
|
var editorWidth = _ref2.width;
|
|
@@ -86,7 +107,8 @@ var MediaNodeView = /*#__PURE__*/function (_SelectionBasedNodeVi) {
|
|
|
86
107
|
url: url,
|
|
87
108
|
mediaProvider: mediaProvider,
|
|
88
109
|
contextIdentifierProvider: contextIdentifierProvider,
|
|
89
|
-
mediaOptions: mediaOptions
|
|
110
|
+
mediaOptions: mediaOptions,
|
|
111
|
+
onExternalImageLoaded: _this.onExternalImageLoaded
|
|
90
112
|
});
|
|
91
113
|
};
|
|
92
114
|
});
|
|
@@ -292,11 +292,11 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
292
292
|
var maxWidth = maxWidthForNestedNode || _editorSharedStyles.akEditorFullWidthLayoutWidth;
|
|
293
293
|
var isVideoFile = (0, _mediaSingle2.isVideo)(selectedMediaNode.attrs.__fileMimeType);
|
|
294
294
|
var minWidth = (0, _mediaSingle.calcMinWidth)(isVideoFile, maxWidthForNestedNode || contentWidth);
|
|
295
|
-
var
|
|
295
|
+
var hasPixelType = widthType === 'pixel';
|
|
296
296
|
var pixelWidthFromElement = (0, _utils2.getPixelWidthOfElement)(editorView, selectedMediaSingleNode.pos + 1,
|
|
297
297
|
// get pos of media node
|
|
298
298
|
mediaWidth || _mediaSingle.DEFAULT_IMAGE_WIDTH);
|
|
299
|
-
var pixelWidth =
|
|
299
|
+
var pixelWidth = hasPixelType ? mediaSingleWidth : pixelWidthFromElement;
|
|
300
300
|
|
|
301
301
|
//hasParentNode will return falsey value if selection depth === 0
|
|
302
302
|
var isNested = (0, _utils.hasParentNode)(function (n) {
|
|
@@ -305,7 +305,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
305
305
|
return /*#__PURE__*/_react.default.createElement(_PixelEntry.PixelEntry, {
|
|
306
306
|
intl: intl,
|
|
307
307
|
width: pluginState.isResizing ? pluginState.resizingWidth : pixelWidth,
|
|
308
|
-
showMigration: !pluginState.isResizing &&
|
|
308
|
+
showMigration: !pluginState.isResizing && !hasPixelType,
|
|
309
309
|
mediaWidth: mediaWidth || _mediaSingle.DEFAULT_IMAGE_WIDTH,
|
|
310
310
|
mediaHeight: mediaHeight || _mediaSingle.DEFAULT_IMAGE_HEIGHT,
|
|
311
311
|
minWidth: minWidth,
|
|
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.removeMediaGroupNode = exports.getSelectedMediaSingle = exports.getSelectedMediaContainerNodeAttrs = exports.getPixelWidthOfElement = exports.getMaxToolbarWidth = exports.downloadMedia = exports.calcNewLayout = void 0;
|
|
8
8
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
9
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
|
+
var _memoizeOne = _interopRequireDefault(require("memoize-one"));
|
|
10
11
|
var _mediaSingle = require("@atlaskit/editor-common/media-single");
|
|
11
12
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
12
13
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
@@ -72,13 +73,13 @@ var getSelectedMediaSingle = exports.getSelectedMediaSingle = function getSelect
|
|
|
72
73
|
var mediaSingle = state.schema.nodes.mediaSingle;
|
|
73
74
|
return (0, _utils.findSelectedNodeOfType)(mediaSingle)(state.selection) || (0, _utils.findParentNodeOfType)(mediaSingle)(state.selection);
|
|
74
75
|
};
|
|
75
|
-
var getPixelWidthOfElement = exports.getPixelWidthOfElement = function
|
|
76
|
+
var getPixelWidthOfElement = exports.getPixelWidthOfElement = (0, _memoizeOne.default)(function (editorView, pos, mediaWidth) {
|
|
76
77
|
var domNode = editorView.nodeDOM(pos);
|
|
77
78
|
if (domNode instanceof HTMLElement) {
|
|
78
79
|
return domNode.offsetWidth;
|
|
79
80
|
}
|
|
80
81
|
return mediaWidth;
|
|
81
|
-
};
|
|
82
|
+
});
|
|
82
83
|
var calcNewLayout = exports.calcNewLayout = function calcNewLayout(width, layout, contentWidth) {
|
|
83
84
|
var fullWidthMode = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
84
85
|
var isNested = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
@@ -8,6 +8,7 @@ exports.insertMediaSingleNode = exports.insertMediaAsMediaSingle = exports.creat
|
|
|
8
8
|
exports.isCaptionNode = isCaptionNode;
|
|
9
9
|
exports.isVideo = exports.isMediaSingle = void 0;
|
|
10
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
var _memoizeOne = _interopRequireDefault(require("memoize-one"));
|
|
11
12
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
12
13
|
var _insert = require("@atlaskit/editor-common/insert");
|
|
13
14
|
var _mediaSingle = require("@atlaskit/editor-common/media-single");
|
|
@@ -176,6 +177,6 @@ function isCaptionNode(editorView) {
|
|
|
176
177
|
}
|
|
177
178
|
return false;
|
|
178
179
|
}
|
|
179
|
-
var isVideo = exports.isVideo = function
|
|
180
|
+
var isVideo = exports.isVideo = (0, _memoizeOne.default)(function (fileType) {
|
|
180
181
|
return !!fileType && fileType.includes('video');
|
|
181
|
-
};
|
|
182
|
+
});
|
|
@@ -5,6 +5,7 @@ import { DEFAULT_IMAGE_HEIGHT, DEFAULT_IMAGE_WIDTH } from '@atlaskit/editor-comm
|
|
|
5
5
|
import { WithProviders } from '@atlaskit/editor-common/provider-factory';
|
|
6
6
|
import { SelectionBasedNodeView } from '@atlaskit/editor-common/selection-based-node-view';
|
|
7
7
|
import { getAttrsFromUrl } from '@atlaskit/media-client';
|
|
8
|
+
import { updateCurrentMediaNodeAttrs } from '../../commands/helpers';
|
|
8
9
|
import { isMediaBlobUrlFromAttrs } from '../../utils/media-common';
|
|
9
10
|
import MediaNode from './media';
|
|
10
11
|
const MediaNodeWithProviders = ({
|
|
@@ -25,6 +26,24 @@ class MediaNodeView extends SelectionBasedNodeView {
|
|
|
25
26
|
constructor(...args) {
|
|
26
27
|
super(...args);
|
|
27
28
|
_defineProperty(this, "isSelected", false);
|
|
29
|
+
_defineProperty(this, "onExternalImageLoaded", dimensions => {
|
|
30
|
+
const getPos = this.getPos;
|
|
31
|
+
const {
|
|
32
|
+
width,
|
|
33
|
+
height,
|
|
34
|
+
...rest
|
|
35
|
+
} = this.getAttrs();
|
|
36
|
+
if (!width || !height) {
|
|
37
|
+
updateCurrentMediaNodeAttrs({
|
|
38
|
+
...rest,
|
|
39
|
+
width: width || dimensions.width,
|
|
40
|
+
height: height || dimensions.height
|
|
41
|
+
}, {
|
|
42
|
+
node: this.node,
|
|
43
|
+
getPos
|
|
44
|
+
})(this.view.state, this.view.dispatch);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
28
47
|
_defineProperty(this, "renderMediaNodeWithState", (mediaProvider, contextIdentifierProvider) => {
|
|
29
48
|
return ({
|
|
30
49
|
width: editorWidth
|
|
@@ -72,7 +91,8 @@ class MediaNodeView extends SelectionBasedNodeView {
|
|
|
72
91
|
url: url,
|
|
73
92
|
mediaProvider: mediaProvider,
|
|
74
93
|
contextIdentifierProvider: contextIdentifierProvider,
|
|
75
|
-
mediaOptions: mediaOptions
|
|
94
|
+
mediaOptions: mediaOptions,
|
|
95
|
+
onExternalImageLoaded: this.onExternalImageLoaded
|
|
76
96
|
});
|
|
77
97
|
};
|
|
78
98
|
});
|
|
@@ -295,18 +295,18 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
|
|
|
295
295
|
const maxWidth = maxWidthForNestedNode || akEditorFullWidthLayoutWidth;
|
|
296
296
|
const isVideoFile = isVideo(selectedMediaNode.attrs.__fileMimeType);
|
|
297
297
|
const minWidth = calcMinWidth(isVideoFile, maxWidthForNestedNode || contentWidth);
|
|
298
|
-
const
|
|
298
|
+
const hasPixelType = widthType === 'pixel';
|
|
299
299
|
const pixelWidthFromElement = getPixelWidthOfElement(editorView, selectedMediaSingleNode.pos + 1,
|
|
300
300
|
// get pos of media node
|
|
301
301
|
mediaWidth || DEFAULT_IMAGE_WIDTH);
|
|
302
|
-
const pixelWidth =
|
|
302
|
+
const pixelWidth = hasPixelType ? mediaSingleWidth : pixelWidthFromElement;
|
|
303
303
|
|
|
304
304
|
//hasParentNode will return falsey value if selection depth === 0
|
|
305
305
|
const isNested = hasParentNode(n => n.type !== state.schema.nodes.doc)(state.selection);
|
|
306
306
|
return /*#__PURE__*/React.createElement(PixelEntry, {
|
|
307
307
|
intl: intl,
|
|
308
308
|
width: pluginState.isResizing ? pluginState.resizingWidth : pixelWidth,
|
|
309
|
-
showMigration: !pluginState.isResizing &&
|
|
309
|
+
showMigration: !pluginState.isResizing && !hasPixelType,
|
|
310
310
|
mediaWidth: mediaWidth || DEFAULT_IMAGE_WIDTH,
|
|
311
311
|
mediaHeight: mediaHeight || DEFAULT_IMAGE_HEIGHT,
|
|
312
312
|
minWidth: minWidth,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import memoizeOne from 'memoize-one';
|
|
1
2
|
import { wrappedLayouts } from '@atlaskit/editor-common/media-single';
|
|
2
3
|
import { findParentNodeOfType, findSelectedNodeOfType, removeParentNodeOfType, removeSelectedNode } from '@atlaskit/editor-prosemirror/utils';
|
|
3
4
|
import { akEditorFullWidthLayoutWidth } from '@atlaskit/editor-shared-styles';
|
|
@@ -49,13 +50,13 @@ export const getSelectedMediaSingle = state => {
|
|
|
49
50
|
} = state.schema.nodes;
|
|
50
51
|
return findSelectedNodeOfType(mediaSingle)(state.selection) || findParentNodeOfType(mediaSingle)(state.selection);
|
|
51
52
|
};
|
|
52
|
-
export const getPixelWidthOfElement = (editorView, pos, mediaWidth) => {
|
|
53
|
+
export const getPixelWidthOfElement = memoizeOne((editorView, pos, mediaWidth) => {
|
|
53
54
|
const domNode = editorView.nodeDOM(pos);
|
|
54
55
|
if (domNode instanceof HTMLElement) {
|
|
55
56
|
return domNode.offsetWidth;
|
|
56
57
|
}
|
|
57
58
|
return mediaWidth;
|
|
58
|
-
};
|
|
59
|
+
});
|
|
59
60
|
export const calcNewLayout = (width, layout, contentWidth, fullWidthMode = false, isNested = false) => {
|
|
60
61
|
const isWrappedLayout = wrappedLayouts.indexOf(layout) > -1;
|
|
61
62
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import memoizeOne from 'memoize-one';
|
|
1
2
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
2
3
|
import { safeInsert, shouldSplitSelectedNodeOnNodeInsertion } from '@atlaskit/editor-common/insert';
|
|
3
4
|
import { getMaxWidthForNestedNodeNext, getMediaSingleInitialWidth, MEDIA_SINGLE_DEFAULT_MIN_PIXEL_WIDTH, MEDIA_SINGLE_VIDEO_MIN_PIXEL_WIDTH } from '@atlaskit/editor-common/media-single';
|
|
@@ -173,4 +174,6 @@ export function isCaptionNode(editorView) {
|
|
|
173
174
|
}
|
|
174
175
|
return false;
|
|
175
176
|
}
|
|
176
|
-
export const isVideo = fileType =>
|
|
177
|
+
export const isVideo = memoizeOne(fileType => {
|
|
178
|
+
return !!fileType && fileType.includes('video');
|
|
179
|
+
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
1
2
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
3
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
4
|
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
@@ -6,6 +7,9 @@ import _inherits from "@babel/runtime/helpers/inherits";
|
|
|
6
7
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
7
8
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
8
9
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
10
|
+
var _excluded = ["width", "height"];
|
|
11
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
12
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
9
13
|
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
14
|
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
15
|
import React from 'react';
|
|
@@ -14,6 +18,7 @@ import { DEFAULT_IMAGE_HEIGHT, DEFAULT_IMAGE_WIDTH } from '@atlaskit/editor-comm
|
|
|
14
18
|
import { WithProviders } from '@atlaskit/editor-common/provider-factory';
|
|
15
19
|
import { SelectionBasedNodeView } from '@atlaskit/editor-common/selection-based-node-view';
|
|
16
20
|
import { getAttrsFromUrl } from '@atlaskit/media-client';
|
|
21
|
+
import { updateCurrentMediaNodeAttrs } from '../../commands/helpers';
|
|
17
22
|
import { isMediaBlobUrlFromAttrs } from '../../utils/media-common';
|
|
18
23
|
import MediaNode from './media';
|
|
19
24
|
var MediaNodeWithProviders = function MediaNodeWithProviders(_ref) {
|
|
@@ -39,6 +44,22 @@ var MediaNodeView = /*#__PURE__*/function (_SelectionBasedNodeVi) {
|
|
|
39
44
|
}
|
|
40
45
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
41
46
|
_defineProperty(_assertThisInitialized(_this), "isSelected", false);
|
|
47
|
+
_defineProperty(_assertThisInitialized(_this), "onExternalImageLoaded", function (dimensions) {
|
|
48
|
+
var getPos = _this.getPos;
|
|
49
|
+
var _this$getAttrs = _this.getAttrs(),
|
|
50
|
+
width = _this$getAttrs.width,
|
|
51
|
+
height = _this$getAttrs.height,
|
|
52
|
+
rest = _objectWithoutProperties(_this$getAttrs, _excluded);
|
|
53
|
+
if (!width || !height) {
|
|
54
|
+
updateCurrentMediaNodeAttrs(_objectSpread(_objectSpread({}, rest), {}, {
|
|
55
|
+
width: width || dimensions.width,
|
|
56
|
+
height: height || dimensions.height
|
|
57
|
+
}), {
|
|
58
|
+
node: _this.node,
|
|
59
|
+
getPos: getPos
|
|
60
|
+
})(_this.view.state, _this.view.dispatch);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
42
63
|
_defineProperty(_assertThisInitialized(_this), "renderMediaNodeWithState", function (mediaProvider, contextIdentifierProvider) {
|
|
43
64
|
return function (_ref2) {
|
|
44
65
|
var editorWidth = _ref2.width;
|
|
@@ -79,7 +100,8 @@ var MediaNodeView = /*#__PURE__*/function (_SelectionBasedNodeVi) {
|
|
|
79
100
|
url: url,
|
|
80
101
|
mediaProvider: mediaProvider,
|
|
81
102
|
contextIdentifierProvider: contextIdentifierProvider,
|
|
82
|
-
mediaOptions: mediaOptions
|
|
103
|
+
mediaOptions: mediaOptions,
|
|
104
|
+
onExternalImageLoaded: _this.onExternalImageLoaded
|
|
83
105
|
});
|
|
84
106
|
};
|
|
85
107
|
});
|
|
@@ -282,11 +282,11 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
282
282
|
var maxWidth = maxWidthForNestedNode || akEditorFullWidthLayoutWidth;
|
|
283
283
|
var isVideoFile = isVideo(selectedMediaNode.attrs.__fileMimeType);
|
|
284
284
|
var minWidth = calcMinWidth(isVideoFile, maxWidthForNestedNode || contentWidth);
|
|
285
|
-
var
|
|
285
|
+
var hasPixelType = widthType === 'pixel';
|
|
286
286
|
var pixelWidthFromElement = getPixelWidthOfElement(editorView, selectedMediaSingleNode.pos + 1,
|
|
287
287
|
// get pos of media node
|
|
288
288
|
mediaWidth || DEFAULT_IMAGE_WIDTH);
|
|
289
|
-
var pixelWidth =
|
|
289
|
+
var pixelWidth = hasPixelType ? mediaSingleWidth : pixelWidthFromElement;
|
|
290
290
|
|
|
291
291
|
//hasParentNode will return falsey value if selection depth === 0
|
|
292
292
|
var isNested = hasParentNode(function (n) {
|
|
@@ -295,7 +295,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
295
295
|
return /*#__PURE__*/React.createElement(PixelEntry, {
|
|
296
296
|
intl: intl,
|
|
297
297
|
width: pluginState.isResizing ? pluginState.resizingWidth : pixelWidth,
|
|
298
|
-
showMigration: !pluginState.isResizing &&
|
|
298
|
+
showMigration: !pluginState.isResizing && !hasPixelType,
|
|
299
299
|
mediaWidth: mediaWidth || DEFAULT_IMAGE_WIDTH,
|
|
300
300
|
mediaHeight: mediaHeight || DEFAULT_IMAGE_HEIGHT,
|
|
301
301
|
minWidth: minWidth,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
2
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
|
+
import memoizeOne from 'memoize-one';
|
|
3
4
|
import { wrappedLayouts } from '@atlaskit/editor-common/media-single';
|
|
4
5
|
import { findParentNodeOfType, findSelectedNodeOfType, removeParentNodeOfType, removeSelectedNode } from '@atlaskit/editor-prosemirror/utils';
|
|
5
6
|
import { akEditorFullWidthLayoutWidth } from '@atlaskit/editor-shared-styles';
|
|
@@ -65,13 +66,13 @@ export var getSelectedMediaSingle = function getSelectedMediaSingle(state) {
|
|
|
65
66
|
var mediaSingle = state.schema.nodes.mediaSingle;
|
|
66
67
|
return findSelectedNodeOfType(mediaSingle)(state.selection) || findParentNodeOfType(mediaSingle)(state.selection);
|
|
67
68
|
};
|
|
68
|
-
export var getPixelWidthOfElement = function
|
|
69
|
+
export var getPixelWidthOfElement = memoizeOne(function (editorView, pos, mediaWidth) {
|
|
69
70
|
var domNode = editorView.nodeDOM(pos);
|
|
70
71
|
if (domNode instanceof HTMLElement) {
|
|
71
72
|
return domNode.offsetWidth;
|
|
72
73
|
}
|
|
73
74
|
return mediaWidth;
|
|
74
|
-
};
|
|
75
|
+
});
|
|
75
76
|
export var calcNewLayout = function calcNewLayout(width, layout, contentWidth) {
|
|
76
77
|
var fullWidthMode = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
77
78
|
var isNested = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
3
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
import memoizeOne from 'memoize-one';
|
|
4
5
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
5
6
|
import { safeInsert, shouldSplitSelectedNodeOnNodeInsertion } from '@atlaskit/editor-common/insert';
|
|
6
7
|
import { getMaxWidthForNestedNodeNext, getMediaSingleInitialWidth, MEDIA_SINGLE_DEFAULT_MIN_PIXEL_WIDTH, MEDIA_SINGLE_VIDEO_MIN_PIXEL_WIDTH } from '@atlaskit/editor-common/media-single';
|
|
@@ -167,6 +168,6 @@ export function isCaptionNode(editorView) {
|
|
|
167
168
|
}
|
|
168
169
|
return false;
|
|
169
170
|
}
|
|
170
|
-
export var isVideo = function
|
|
171
|
+
export var isVideo = memoizeOne(function (fileType) {
|
|
171
172
|
return !!fileType && fileType.includes('video');
|
|
172
|
-
};
|
|
173
|
+
});
|
|
@@ -18,6 +18,10 @@ declare class MediaNodeView extends SelectionBasedNodeView<MediaNodeViewProps> {
|
|
|
18
18
|
stopEvent(event: Event): boolean;
|
|
19
19
|
getAttrs(): MediaADFAttrs;
|
|
20
20
|
isMediaBlobUrl(): boolean;
|
|
21
|
+
onExternalImageLoaded: (dimensions: {
|
|
22
|
+
width: number;
|
|
23
|
+
height: number;
|
|
24
|
+
}) => void;
|
|
21
25
|
renderMediaNodeWithState: (mediaProvider?: Promise<MediaProvider>, contextIdentifierProvider?: Promise<ContextIdentifierProvider>) => ({ width: editorWidth }: {
|
|
22
26
|
width?: import("@atlaskit/editor-common/types").EditorContainerWidth | undefined;
|
|
23
27
|
}) => JSX.Element;
|
|
@@ -6,6 +6,6 @@ export declare const getSelectedMediaContainerNodeAttrs: (mediaPluginState: Medi
|
|
|
6
6
|
export declare const downloadMedia: (mediaPluginState: MediaPluginState) => Promise<boolean>;
|
|
7
7
|
export declare const removeMediaGroupNode: (state: EditorState) => import("prosemirror-state").Transaction;
|
|
8
8
|
export declare const getSelectedMediaSingle: (state: EditorState) => import("prosemirror-utils/dist/types").FindResult;
|
|
9
|
-
export declare const getPixelWidthOfElement: (editorView: EditorView, pos: number, mediaWidth: number) => number
|
|
9
|
+
export declare const getPixelWidthOfElement: import("memoize-one").MemoizedFn<(editorView: EditorView, pos: number, mediaWidth: number) => number>;
|
|
10
10
|
export declare const calcNewLayout: (width: number, layout: RichMediaLayout, contentWidth: number, fullWidthMode?: boolean, isNested?: boolean) => RichMediaLayout;
|
|
11
11
|
export declare const getMaxToolbarWidth: () => number;
|
|
@@ -17,4 +17,4 @@ export declare const insertMediaAsMediaSingle: (view: EditorView, node: PMNode,
|
|
|
17
17
|
export declare const insertMediaSingleNode: (view: EditorView, mediaState: MediaState, inputMethod?: InputMethodInsertMedia, collection?: string, alignLeftOnInsert?: boolean, newInsertionBehaviour?: boolean, widthPluginState?: WidthPluginState | undefined, editorAnalyticsAPI?: EditorAnalyticsAPI | undefined) => boolean;
|
|
18
18
|
export declare const createMediaSingleNode: (schema: Schema, collection: string, maxWidth?: number, minWidth?: number, alignLeftOnInsert?: boolean) => (mediaState: MediaSingleState) => PMNode;
|
|
19
19
|
export declare function isCaptionNode(editorView: EditorView): boolean;
|
|
20
|
-
export declare const isVideo: (fileType?: string) => boolean
|
|
20
|
+
export declare const isVideo: import("memoize-one").MemoizedFn<(fileType?: string) => boolean>;
|
|
@@ -18,6 +18,10 @@ declare class MediaNodeView extends SelectionBasedNodeView<MediaNodeViewProps> {
|
|
|
18
18
|
stopEvent(event: Event): boolean;
|
|
19
19
|
getAttrs(): MediaADFAttrs;
|
|
20
20
|
isMediaBlobUrl(): boolean;
|
|
21
|
+
onExternalImageLoaded: (dimensions: {
|
|
22
|
+
width: number;
|
|
23
|
+
height: number;
|
|
24
|
+
}) => void;
|
|
21
25
|
renderMediaNodeWithState: (mediaProvider?: Promise<MediaProvider>, contextIdentifierProvider?: Promise<ContextIdentifierProvider>) => ({ width: editorWidth }: {
|
|
22
26
|
width?: import("@atlaskit/editor-common/types").EditorContainerWidth | undefined;
|
|
23
27
|
}) => JSX.Element;
|
|
@@ -6,6 +6,6 @@ export declare const getSelectedMediaContainerNodeAttrs: (mediaPluginState: Medi
|
|
|
6
6
|
export declare const downloadMedia: (mediaPluginState: MediaPluginState) => Promise<boolean>;
|
|
7
7
|
export declare const removeMediaGroupNode: (state: EditorState) => import("prosemirror-state").Transaction;
|
|
8
8
|
export declare const getSelectedMediaSingle: (state: EditorState) => import("prosemirror-utils/dist/types").FindResult;
|
|
9
|
-
export declare const getPixelWidthOfElement: (editorView: EditorView, pos: number, mediaWidth: number) => number
|
|
9
|
+
export declare const getPixelWidthOfElement: import("memoize-one").MemoizedFn<(editorView: EditorView, pos: number, mediaWidth: number) => number>;
|
|
10
10
|
export declare const calcNewLayout: (width: number, layout: RichMediaLayout, contentWidth: number, fullWidthMode?: boolean, isNested?: boolean) => RichMediaLayout;
|
|
11
11
|
export declare const getMaxToolbarWidth: () => number;
|
|
@@ -17,4 +17,4 @@ export declare const insertMediaAsMediaSingle: (view: EditorView, node: PMNode,
|
|
|
17
17
|
export declare const insertMediaSingleNode: (view: EditorView, mediaState: MediaState, inputMethod?: InputMethodInsertMedia, collection?: string, alignLeftOnInsert?: boolean, newInsertionBehaviour?: boolean, widthPluginState?: WidthPluginState | undefined, editorAnalyticsAPI?: EditorAnalyticsAPI | undefined) => boolean;
|
|
18
18
|
export declare const createMediaSingleNode: (schema: Schema, collection: string, maxWidth?: number, minWidth?: number, alignLeftOnInsert?: boolean) => (mediaState: MediaSingleState) => PMNode;
|
|
19
19
|
export declare function isCaptionNode(editorView: EditorView): boolean;
|
|
20
|
-
export declare const isVideo: (fileType?: string) => boolean
|
|
20
|
+
export declare const isVideo: import("memoize-one").MemoizedFn<(fileType?: string) => boolean>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-media",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.8",
|
|
4
4
|
"description": "Media plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -35,14 +35,14 @@
|
|
|
35
35
|
"@atlaskit/adf-schema": "^32.0.0",
|
|
36
36
|
"@atlaskit/analytics-namespaced-context": "^6.7.0",
|
|
37
37
|
"@atlaskit/analytics-next": "^9.1.0",
|
|
38
|
-
"@atlaskit/button": "^16.
|
|
39
|
-
"@atlaskit/editor-common": "^76.
|
|
38
|
+
"@atlaskit/button": "^16.11.0",
|
|
39
|
+
"@atlaskit/editor-common": "^76.14.0",
|
|
40
40
|
"@atlaskit/editor-palette": "1.5.1",
|
|
41
41
|
"@atlaskit/editor-plugin-analytics": "^0.2.0",
|
|
42
42
|
"@atlaskit/editor-plugin-decorations": "^0.2.0",
|
|
43
43
|
"@atlaskit/editor-plugin-editor-disabled": "^0.2.0",
|
|
44
44
|
"@atlaskit/editor-plugin-feature-flags": "^1.0.0",
|
|
45
|
-
"@atlaskit/editor-plugin-floating-toolbar": "^0.
|
|
45
|
+
"@atlaskit/editor-plugin-floating-toolbar": "^0.7.0",
|
|
46
46
|
"@atlaskit/editor-plugin-focus": "^0.2.0",
|
|
47
47
|
"@atlaskit/editor-plugin-grid": "^0.3.0",
|
|
48
48
|
"@atlaskit/editor-plugin-guideline": "^0.5.0",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"@atlaskit/editor-tables": "^2.3.0",
|
|
53
53
|
"@atlaskit/form": "^8.11.0",
|
|
54
54
|
"@atlaskit/icon": "^21.12.0",
|
|
55
|
-
"@atlaskit/media-card": "^77.
|
|
55
|
+
"@atlaskit/media-card": "^77.2.0",
|
|
56
56
|
"@atlaskit/media-client": "^24.0.0",
|
|
57
57
|
"@atlaskit/media-common": "^9.0.0",
|
|
58
58
|
"@atlaskit/media-filmstrip": "^47.0.0",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"@atlaskit/platform-feature-flags": "^0.2.0",
|
|
63
63
|
"@atlaskit/textfield": "^5.6.0",
|
|
64
64
|
"@atlaskit/theme": "^12.6.0",
|
|
65
|
-
"@atlaskit/tokens": "^1.
|
|
65
|
+
"@atlaskit/tokens": "^1.28.0",
|
|
66
66
|
"@atlaskit/tooltip": "^17.8.0",
|
|
67
67
|
"@babel/runtime": "^7.0.0",
|
|
68
68
|
"@emotion/react": "^11.7.1",
|