@atlaskit/editor-plugin-media 2.4.1 → 2.6.0
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 +28 -0
- package/dist/cjs/mediaPlugin.js +8 -8
- package/dist/cjs/nodeviews/lazy-media-single.js +2 -1
- package/dist/cjs/nodeviews/lazy-media.js +2 -1
- package/dist/cjs/nodeviews/mediaNodeView/media.js +7 -1
- package/dist/cjs/nodeviews/mediaSingle.js +16 -16
- package/dist/cjs/nodeviews/mediaSingleNext.js +2 -2
- package/dist/cjs/nodeviews/toDOM-fixes/mediaSingle.js +53 -51
- package/dist/cjs/pm-plugins/keymap.js +1 -2
- package/dist/cjs/pm-plugins/main.js +30 -19
- package/dist/cjs/pm-plugins/utils/media-inline.js +3 -1
- package/dist/cjs/pm-plugins/utils/media-single.js +10 -11
- package/dist/cjs/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +1 -1
- package/dist/cjs/ui/toolbar/commands.js +2 -2
- package/dist/cjs/ui/toolbar/index.js +9 -7
- package/dist/cjs/ui/toolbar/mediaInline.js +1 -1
- package/dist/cjs/ui/toolbar/pixel-resizing.js +3 -3
- package/dist/es2019/mediaPlugin.js +7 -8
- package/dist/es2019/nodeviews/lazy-media-single.js +2 -1
- package/dist/es2019/nodeviews/lazy-media.js +2 -1
- package/dist/es2019/nodeviews/mediaNodeView/media.js +7 -1
- package/dist/es2019/nodeviews/mediaSingle.js +8 -8
- package/dist/es2019/nodeviews/mediaSingleNext.js +2 -2
- package/dist/es2019/nodeviews/toDOM-fixes/mediaSingle.js +5 -5
- package/dist/es2019/pm-plugins/keymap.js +1 -2
- package/dist/es2019/pm-plugins/main.js +9 -3
- package/dist/es2019/pm-plugins/utils/media-inline.js +3 -1
- package/dist/es2019/pm-plugins/utils/media-single.js +10 -11
- package/dist/es2019/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +1 -1
- package/dist/es2019/ui/toolbar/commands.js +2 -2
- package/dist/es2019/ui/toolbar/index.js +9 -7
- package/dist/es2019/ui/toolbar/mediaInline.js +1 -1
- package/dist/es2019/ui/toolbar/pixel-resizing.js +3 -3
- package/dist/esm/mediaPlugin.js +8 -8
- package/dist/esm/nodeviews/lazy-media-single.js +2 -1
- package/dist/esm/nodeviews/lazy-media.js +2 -1
- package/dist/esm/nodeviews/mediaNodeView/media.js +7 -1
- package/dist/esm/nodeviews/mediaSingle.js +16 -16
- package/dist/esm/nodeviews/mediaSingleNext.js +2 -2
- package/dist/esm/nodeviews/toDOM-fixes/mediaSingle.js +52 -50
- package/dist/esm/pm-plugins/keymap.js +1 -2
- package/dist/esm/pm-plugins/main.js +30 -19
- package/dist/esm/pm-plugins/utils/media-inline.js +3 -1
- package/dist/esm/pm-plugins/utils/media-single.js +10 -11
- package/dist/esm/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +1 -1
- package/dist/esm/ui/toolbar/commands.js +2 -2
- package/dist/esm/ui/toolbar/index.js +9 -7
- package/dist/esm/ui/toolbar/mediaInline.js +1 -1
- package/dist/esm/ui/toolbar/pixel-resizing.js +3 -3
- package/dist/types/nodeviews/toDOM-fixes/mediaSingle.d.ts +1 -1
- package/dist/types/pm-plugins/main.d.ts +1 -1
- package/dist/types/pm-plugins/utils/media-single.d.ts +4 -4
- package/dist/types/types/index.d.ts +4 -1
- package/dist/types/ui/toolbar/commands.d.ts +1 -1
- package/dist/types-ts4.5/nodeviews/toDOM-fixes/mediaSingle.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/main.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/utils/media-single.d.ts +4 -4
- package/dist/types-ts4.5/types/index.d.ts +4 -1
- package/dist/types-ts4.5/ui/toolbar/commands.d.ts +1 -1
- package/package.json +9 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-media
|
|
2
2
|
|
|
3
|
+
## 2.6.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#123268](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/123268)
|
|
8
|
+
[`f47a830143188`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/f47a830143188) -
|
|
9
|
+
Allow for passing in a resolved media provider to enable SSR'ing media in the editor
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#140448](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/140448)
|
|
14
|
+
[`1bbf6b1e2ade5`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/1bbf6b1e2ade5) -
|
|
15
|
+
[HOT-116646] Fix inline media check
|
|
16
|
+
- Updated dependencies
|
|
17
|
+
|
|
18
|
+
## 2.5.0
|
|
19
|
+
|
|
20
|
+
### Minor Changes
|
|
21
|
+
|
|
22
|
+
- [#134613](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/134613)
|
|
23
|
+
[`be20cc186939b`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/be20cc186939b) -
|
|
24
|
+
ED-26247 Remove feature flag platform_media_extended_resize_experience and replace it with a new
|
|
25
|
+
media prop which defaults to false allowPixelResizing
|
|
26
|
+
|
|
27
|
+
### Patch Changes
|
|
28
|
+
|
|
29
|
+
- Updated dependencies
|
|
30
|
+
|
|
3
31
|
## 2.4.1
|
|
4
32
|
|
|
5
33
|
### Patch Changes
|
package/dist/cjs/mediaPlugin.js
CHANGED
|
@@ -106,7 +106,7 @@ var mediaPlugin = exports.mediaPlugin = function mediaPlugin(_ref3) {
|
|
|
106
106
|
actions: {
|
|
107
107
|
insertMediaAsMediaSingle: function insertMediaAsMediaSingle(view, node, inputMethod, insertMediaVia) {
|
|
108
108
|
var _api$analytics;
|
|
109
|
-
return (0, _mediaSingle2.insertMediaAsMediaSingle)(view, node, inputMethod, api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, insertMediaVia);
|
|
109
|
+
return (0, _mediaSingle2.insertMediaAsMediaSingle)(view, node, inputMethod, api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, insertMediaVia, options === null || options === void 0 ? void 0 : options.allowPixelResizing);
|
|
110
110
|
},
|
|
111
111
|
setProvider: function setProvider(provider) {
|
|
112
112
|
var _api$core$actions$exe;
|
|
@@ -134,16 +134,15 @@ var mediaPlugin = exports.mediaPlugin = function mediaPlugin(_ref3) {
|
|
|
134
134
|
allowMediaGroup = _ref5$allowMediaGroup === void 0 ? true : _ref5$allowMediaGroup,
|
|
135
135
|
_ref5$allowMediaSingl = _ref5.allowMediaSingle,
|
|
136
136
|
allowMediaSingle = _ref5$allowMediaSingl === void 0 ? false : _ref5$allowMediaSingl,
|
|
137
|
+
_ref5$allowPixelResiz = _ref5.allowPixelResizing,
|
|
138
|
+
allowPixelResizing = _ref5$allowPixelResiz === void 0 ? false : _ref5$allowPixelResiz,
|
|
137
139
|
allowCaptions = _ref5.allowCaptions,
|
|
138
140
|
allowMediaInlineImages = _ref5.allowMediaInlineImages,
|
|
139
141
|
mediaFeatureFlags = _ref5.featureFlags;
|
|
140
142
|
var allowMediaInline = (0, _platformFeatureFlags.fg)('platform_editor_remove_media_inline_feature_flag') ? allowMediaInlineImages : (0, _mediaCommon.getMediaFeatureFlag)('mediaInline', mediaFeatureFlags);
|
|
141
|
-
var mediaSingleOption =
|
|
143
|
+
var mediaSingleOption = {
|
|
142
144
|
withCaption: allowCaptions,
|
|
143
|
-
withExtendedWidthTypes:
|
|
144
|
-
} : {
|
|
145
|
-
withCaption: allowCaptions,
|
|
146
|
-
withExtendedWidthTypes: false
|
|
145
|
+
withExtendedWidthTypes: allowPixelResizing
|
|
147
146
|
};
|
|
148
147
|
return [{
|
|
149
148
|
name: 'mediaGroup',
|
|
@@ -246,7 +245,7 @@ var mediaPlugin = exports.mediaPlugin = function mediaPlugin(_ref3) {
|
|
|
246
245
|
}
|
|
247
246
|
});
|
|
248
247
|
}
|
|
249
|
-
if (options && options.allowAdvancedToolBarOptions && options.allowResizing && (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') &&
|
|
248
|
+
if (options && options.allowAdvancedToolBarOptions && options.allowResizing && (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && options.allowPixelResizing) {
|
|
250
249
|
pmPlugins.push({
|
|
251
250
|
name: 'mediaPixelResizing',
|
|
252
251
|
plugin: _pixelResizing.createPlugin
|
|
@@ -351,7 +350,8 @@ var mediaPlugin = exports.mediaPlugin = function mediaPlugin(_ref3) {
|
|
|
351
350
|
altTextValidator: options && options.altTextValidator,
|
|
352
351
|
fullWidthEnabled: options && options.fullWidthEnabled,
|
|
353
352
|
allowMediaInlineImages: options && options.allowMediaInlineImages,
|
|
354
|
-
isViewOnly: (api === null || api === void 0 || (_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 || (_api$editorViewMode = _api$editorViewMode.sharedState.currentState()) === null || _api$editorViewMode === void 0 ? void 0 : _api$editorViewMode.mode) === 'view'
|
|
353
|
+
isViewOnly: (api === null || api === void 0 || (_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 || (_api$editorViewMode = _api$editorViewMode.sharedState.currentState()) === null || _api$editorViewMode === void 0 ? void 0 : _api$editorViewMode.mode) === 'view',
|
|
354
|
+
allowPixelResizing: options === null || options === void 0 ? void 0 : options.allowPixelResizing
|
|
355
355
|
}, api);
|
|
356
356
|
}
|
|
357
357
|
}
|
|
@@ -7,13 +7,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.lazyMediaSingleView = void 0;
|
|
8
8
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
9
9
|
var _lazyNodeView = require("@atlaskit/editor-common/lazy-node-view");
|
|
10
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
10
11
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
11
12
|
var _mediaSingle = require("./mediaSingle");
|
|
12
13
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
13
14
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != (0, _typeof2.default)(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
14
15
|
var lazyMediaSingleView = exports.lazyMediaSingleView = function lazyMediaSingleView(portalProviderAPI, eventDispatcher, providerFactory, api, dispatchAnalyticsEvent) {
|
|
15
16
|
var options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
|
|
16
|
-
if ((0, _experiments.editorExperiment)('platform_editor_exp_lazy_node_views', false)) {
|
|
17
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_ssr_media') || (0, _experiments.editorExperiment)('platform_editor_exp_lazy_node_views', false)) {
|
|
17
18
|
return (0, _mediaSingle.ReactMediaSingleNode)(portalProviderAPI, eventDispatcher, providerFactory, api, dispatchAnalyticsEvent, options);
|
|
18
19
|
}
|
|
19
20
|
return (0, _lazyNodeView.withLazyLoading)({
|
|
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.lazyMediaView = void 0;
|
|
8
8
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
9
9
|
var _lazyNodeView = require("@atlaskit/editor-common/lazy-node-view");
|
|
10
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
10
11
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
11
12
|
var _mediaNodeView = require("./mediaNodeView");
|
|
12
13
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
@@ -14,7 +15,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
14
15
|
var lazyMediaView = exports.lazyMediaView = function lazyMediaView(portalProviderAPI, eventDispatcher, providerFactory) {
|
|
15
16
|
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
16
17
|
var api = arguments.length > 4 ? arguments[4] : undefined;
|
|
17
|
-
if ((0, _experiments.editorExperiment)('platform_editor_exp_lazy_node_views', false)) {
|
|
18
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_ssr_media') || (0, _experiments.editorExperiment)('platform_editor_exp_lazy_node_views', false)) {
|
|
18
19
|
return (0, _mediaNodeView.ReactMediaNode)(portalProviderAPI, eventDispatcher, providerFactory, options, api);
|
|
19
20
|
}
|
|
20
21
|
return (0, _lazyNodeView.withLazyLoading)({
|
|
@@ -21,6 +21,7 @@ var _analyticsNext = require("@atlaskit/analytics-next");
|
|
|
21
21
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
22
22
|
var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
|
|
23
23
|
var _mediaCard = require("@atlaskit/media-card");
|
|
24
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
24
25
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
25
26
|
var _pluginKey = require("../../pm-plugins/plugin-key");
|
|
26
27
|
var _styles = require("../styles");
|
|
@@ -285,6 +286,10 @@ var MediaNode = exports.MediaNode = /*#__PURE__*/function (_Component) {
|
|
|
285
286
|
return {};
|
|
286
287
|
}
|
|
287
288
|
};
|
|
289
|
+
var ssr;
|
|
290
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_ssr_media')) {
|
|
291
|
+
ssr = process.env.REACT_SSR ? 'server' : 'client';
|
|
292
|
+
}
|
|
288
293
|
return /*#__PURE__*/_react.default.createElement(_styles.MediaCardWrapper, {
|
|
289
294
|
dimensions: originalDimensions,
|
|
290
295
|
onContextMenu: this.selectMediaSingle,
|
|
@@ -310,7 +315,8 @@ var MediaNode = exports.MediaNode = /*#__PURE__*/function (_Component) {
|
|
|
310
315
|
featureFlags: mediaOptions && mediaOptions.featureFlags,
|
|
311
316
|
contextId: contextId,
|
|
312
317
|
alt: alt,
|
|
313
|
-
videoControlsWrapperRef: this.videoControlsWrapperRef
|
|
318
|
+
videoControlsWrapperRef: this.videoControlsWrapperRef,
|
|
319
|
+
ssr: ssr
|
|
314
320
|
})));
|
|
315
321
|
}
|
|
316
322
|
}]);
|
|
@@ -481,7 +481,7 @@ var MediaSingleNode = exports.default = /*#__PURE__*/function (_Component) {
|
|
|
481
481
|
mediaElement: currentMediaElement(),
|
|
482
482
|
mediaHeight: height,
|
|
483
483
|
mediaWidth: width,
|
|
484
|
-
extendedResizeOffset:
|
|
484
|
+
extendedResizeOffset: mediaOptions.allowPixelResizing && !isInsideTable
|
|
485
485
|
}, function (_ref5) {
|
|
486
486
|
var visible = _ref5.visible;
|
|
487
487
|
return (0, _react2.jsx)(_react.default.Fragment, null, visible && (0, _react2.jsx)(_mediaSingle.ExternalImageBadge, {
|
|
@@ -515,7 +515,7 @@ var MediaSingleNode = exports.default = /*#__PURE__*/function (_Component) {
|
|
|
515
515
|
onClick: this.clickPlaceholder,
|
|
516
516
|
placeholderMessage: mediaOptions.allowImagePreview ? _media.captionMessages.placeholderWithDoubleClickPrompt : _media.captionMessages.placeholder
|
|
517
517
|
})));
|
|
518
|
-
return (0, _react2.jsx)(_react.Fragment, null, canResize ?
|
|
518
|
+
return (0, _react2.jsx)(_react.Fragment, null, canResize ? mediaOptions.allowPixelResizing ? (0, _react2.jsx)(_ResizableMediaSingleNext.default
|
|
519
519
|
// Ignored via go/ees005
|
|
520
520
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
521
521
|
, (0, _extends2.default)({}, resizableMediaSingleProps, {
|
|
@@ -656,14 +656,14 @@ var MediaSingleNodeView = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
656
656
|
return (0, _createClass2.default)(MediaSingleNodeView, [{
|
|
657
657
|
key: "createDomRef",
|
|
658
658
|
value: function createDomRef() {
|
|
659
|
-
var _this$reactComponentP;
|
|
659
|
+
var _this$reactComponentP, _this$reactComponentP2;
|
|
660
660
|
var domRef = document.createElement('div');
|
|
661
661
|
|
|
662
662
|
// control the domRef contentEditable attribute based on the editor view mode
|
|
663
663
|
this.unsubscribeToViewModeChange = this.subscribeToViewModeChange(domRef);
|
|
664
664
|
var initialViewMode = (_this$reactComponentP = this.reactComponentProps.pluginInjectionApi) === null || _this$reactComponentP === void 0 || (_this$reactComponentP = _this$reactComponentP.editorViewMode) === null || _this$reactComponentP === void 0 || (_this$reactComponentP = _this$reactComponentP.sharedState.currentState()) === null || _this$reactComponentP === void 0 ? void 0 : _this$reactComponentP.mode;
|
|
665
665
|
this.updateDomRefContentEditable(domRef, initialViewMode);
|
|
666
|
-
if ((0
|
|
666
|
+
if ((_this$reactComponentP2 = this.reactComponentProps.mediaOptions) !== null && _this$reactComponentP2 !== void 0 && _this$reactComponentP2.allowPixelResizing) {
|
|
667
667
|
domRef.classList.add('media-extended-resize-experience');
|
|
668
668
|
}
|
|
669
669
|
return domRef;
|
|
@@ -698,9 +698,9 @@ var MediaSingleNodeView = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
698
698
|
}, {
|
|
699
699
|
key: "subscribeToViewModeChange",
|
|
700
700
|
value: function subscribeToViewModeChange(domRef) {
|
|
701
|
-
var _this$
|
|
701
|
+
var _this$reactComponentP3,
|
|
702
702
|
_this3 = this;
|
|
703
|
-
return (_this$
|
|
703
|
+
return (_this$reactComponentP3 = this.reactComponentProps.pluginInjectionApi) === null || _this$reactComponentP3 === void 0 || (_this$reactComponentP3 = _this$reactComponentP3.editorViewMode) === null || _this$reactComponentP3 === void 0 ? void 0 : _this$reactComponentP3.sharedState.onChange(function (viewModeState) {
|
|
704
704
|
var _viewModeState$nextSh;
|
|
705
705
|
_this3.updateDomRefContentEditable(domRef, (_viewModeState$nextSh = viewModeState.nextSharedState) === null || _viewModeState$nextSh === void 0 ? void 0 : _viewModeState$nextSh.mode);
|
|
706
706
|
});
|
|
@@ -708,7 +708,7 @@ var MediaSingleNodeView = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
708
708
|
}, {
|
|
709
709
|
key: "updateDomRefContentEditable",
|
|
710
710
|
value: function updateDomRefContentEditable(domRef, editorViewMode) {
|
|
711
|
-
var _this$
|
|
711
|
+
var _this$reactComponentP4;
|
|
712
712
|
// if the editor is in view mode, we should not allow editing
|
|
713
713
|
if (editorViewMode === 'view') {
|
|
714
714
|
domRef.contentEditable = 'false';
|
|
@@ -716,7 +716,7 @@ var MediaSingleNodeView = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
716
716
|
}
|
|
717
717
|
|
|
718
718
|
// if the editor is in edit mode, we should allow editing if the media options allow it
|
|
719
|
-
if ((_this$
|
|
719
|
+
if ((_this$reactComponentP4 = this.reactComponentProps.mediaOptions) !== null && _this$reactComponentP4 !== void 0 && _this$reactComponentP4.allowMediaSingleEditable) {
|
|
720
720
|
// workaround Chrome bug in https://product-fabric.atlassian.net/browse/ED-5379
|
|
721
721
|
// see also: https://github.com/ProseMirror/prosemirror/issues/884
|
|
722
722
|
domRef.contentEditable = 'true';
|
|
@@ -756,14 +756,14 @@ var MediaSingleNodeView = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
756
756
|
key: "render",
|
|
757
757
|
value: function render(props, forwardRef) {
|
|
758
758
|
var _this5 = this;
|
|
759
|
-
var _this$
|
|
760
|
-
eventDispatcher = _this$
|
|
761
|
-
fullWidthMode = _this$
|
|
762
|
-
providerFactory = _this$
|
|
763
|
-
mediaOptions = _this$
|
|
764
|
-
dispatchAnalyticsEvent = _this$
|
|
765
|
-
pluginInjectionApi = _this$
|
|
766
|
-
editorAppearance = _this$
|
|
759
|
+
var _this$reactComponentP5 = this.reactComponentProps,
|
|
760
|
+
eventDispatcher = _this$reactComponentP5.eventDispatcher,
|
|
761
|
+
fullWidthMode = _this$reactComponentP5.fullWidthMode,
|
|
762
|
+
providerFactory = _this$reactComponentP5.providerFactory,
|
|
763
|
+
mediaOptions = _this$reactComponentP5.mediaOptions,
|
|
764
|
+
dispatchAnalyticsEvent = _this$reactComponentP5.dispatchAnalyticsEvent,
|
|
765
|
+
pluginInjectionApi = _this$reactComponentP5.pluginInjectionApi,
|
|
766
|
+
editorAppearance = _this$reactComponentP5.editorAppearance;
|
|
767
767
|
|
|
768
768
|
// getPos is a boolean for marks, since this is a node we know it must be a function
|
|
769
769
|
var getPos = this.getPos;
|
|
@@ -478,7 +478,7 @@ var MediaSingleNodeNext = exports.MediaSingleNodeNext = function MediaSingleNode
|
|
|
478
478
|
mediaElement: currentMediaElement(),
|
|
479
479
|
mediaHeight: height,
|
|
480
480
|
mediaWidth: width,
|
|
481
|
-
extendedResizeOffset:
|
|
481
|
+
extendedResizeOffset: mediaOptions.allowPixelResizing && !isInsideTable
|
|
482
482
|
}, function (_ref7) {
|
|
483
483
|
var visible = _ref7.visible;
|
|
484
484
|
return (0, _react2.jsx)(_react.default.Fragment, null, visible && (0, _react2.jsx)(_mediaSingle.ExternalImageBadge, {
|
|
@@ -512,7 +512,7 @@ var MediaSingleNodeNext = exports.MediaSingleNodeNext = function MediaSingleNode
|
|
|
512
512
|
onClick: clickPlaceholder,
|
|
513
513
|
placeholderMessage: mediaOptions.allowImagePreview ? _media.captionMessages.placeholderWithDoubleClickPrompt : _media.captionMessages.placeholder
|
|
514
514
|
})));
|
|
515
|
-
return (0, _react2.jsx)(_react.Fragment, null, canResize ?
|
|
515
|
+
return (0, _react2.jsx)(_react.Fragment, null, canResize ? mediaOptions.allowPixelResizing ? (0, _react2.jsx)(_ResizableMediaSingleNext.default, {
|
|
516
516
|
view: view,
|
|
517
517
|
getPos: getPos,
|
|
518
518
|
updateSize: updateSize,
|
|
@@ -4,11 +4,10 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.
|
|
7
|
+
exports.prepareWrapperContentDOM = exports.mediaWidthCSSCalc = exports.mediaSingleSpecWithFixedToDOM = exports.mediaProportionalWidthCSSCalc = exports.mediaJustifyContentCSS = exports.mediaContentWrapperWidthCSSCalc = exports.getToDom = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _adfSchema = require("@atlaskit/adf-schema");
|
|
10
10
|
var _lazyNodeView = require("@atlaskit/editor-common/lazy-node-view");
|
|
11
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
12
11
|
var _colors = require("@atlaskit/theme/colors");
|
|
13
12
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
14
13
|
var _toDOMAttrs = require("./toDOMAttrs");
|
|
@@ -157,55 +156,57 @@ var prepareWrapperContentDOM = exports.prepareWrapperContentDOM = function prepa
|
|
|
157
156
|
class: 'media-content-wrap'
|
|
158
157
|
}, 0]]]]];
|
|
159
158
|
};
|
|
160
|
-
var
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
159
|
+
var getToDom = exports.getToDom = function getToDom(allowPixelResizing) {
|
|
160
|
+
return function (node) {
|
|
161
|
+
var _mediaSingleAttrs$lay;
|
|
162
|
+
var mediaSingleAttrs = node.attrs;
|
|
163
|
+
var isPixelWidth = (mediaSingleAttrs === null || mediaSingleAttrs === void 0 ? void 0 : mediaSingleAttrs.widthType) === 'pixel';
|
|
164
|
+
var layout = (_mediaSingleAttrs$lay = mediaSingleAttrs === null || mediaSingleAttrs === void 0 ? void 0 : mediaSingleAttrs.layout) !== null && _mediaSingleAttrs$lay !== void 0 ? _mediaSingleAttrs$lay : 'center';
|
|
165
|
+
var childNode = node.firstChild;
|
|
166
|
+
var isExternalMedia = (childNode === null || childNode === void 0 ? void 0 : childNode.attrs.type) === 'external';
|
|
167
|
+
var childMediaWidth = (childNode === null || childNode === void 0 ? void 0 : childNode.attrs.width) || DEFAULT_IMAGE_WIDTH;
|
|
168
|
+
var childMediaHeight = (childNode === null || childNode === void 0 ? void 0 : childNode.attrs.height) || DEFAULT_IMAGE_HEIGHT;
|
|
169
|
+
var dataAttrs = (0, _toDOMAttrs.getAttrsFromNodeMediaSingle)(true, node);
|
|
170
|
+
var content = prepareWrapperContentDOM({
|
|
171
|
+
layout: layout,
|
|
172
|
+
dataAttrs: dataAttrs,
|
|
173
|
+
childMediaWidth: childMediaWidth,
|
|
174
|
+
childMediaHeight: childMediaHeight,
|
|
175
|
+
mediaSingleDimensionWidth: mediaSingleAttrs.width,
|
|
176
|
+
isPixelWidth: isPixelWidth,
|
|
177
|
+
isExtendedResizeExperience: allowPixelResizing
|
|
178
|
+
});
|
|
179
|
+
var isMediaWrapped = WRAPPED_LAYOUTS.includes(layout);
|
|
180
|
+
var proportionCalc = mediaProportionalWidthCSSCalc({
|
|
181
|
+
isPixelWidth: isPixelWidth,
|
|
182
|
+
isMediaWrapped: isMediaWrapped,
|
|
183
|
+
mediaSingleDimensionWidth: mediaSingleAttrs === null || mediaSingleAttrs === void 0 ? void 0 : mediaSingleAttrs.width,
|
|
184
|
+
isExtendedResizeExperience: allowPixelResizing
|
|
185
|
+
});
|
|
186
|
+
var contentWrapperWidth = mediaContentWrapperWidthCSSCalc({
|
|
187
|
+
isMediaWrapped: isMediaWrapped,
|
|
188
|
+
isExternalMedia: isExternalMedia,
|
|
189
|
+
isPixelWidth: isPixelWidth,
|
|
190
|
+
childMediaWidth: childMediaWidth,
|
|
191
|
+
mediaSingleDimensionWidth: mediaSingleAttrs === null || mediaSingleAttrs === void 0 ? void 0 : mediaSingleAttrs.width
|
|
192
|
+
});
|
|
193
|
+
return ['div', {
|
|
194
|
+
class: 'mediaSingleView-content-wrap',
|
|
195
|
+
layout: layout,
|
|
196
|
+
style: (0, _lazyNodeView.convertToInlineCss)({
|
|
197
|
+
'--ak-editor-media-single--proportion': proportionCalc,
|
|
198
|
+
'--ak-editor-media-card-display': 'block',
|
|
199
|
+
'--ak-editor-media-single--gutter-size': GUTTER_SIZE,
|
|
200
|
+
'--ak-editor-media-margin-right': '0',
|
|
201
|
+
'--ak-editor-media-card-background-color': "var(--ds-background-neutral, ".concat(_colors.N20, ")"),
|
|
202
|
+
marginTop: isMediaWrapped ? HALF_GUTTER_SIZE : "var(--ds-space-300, 24px)",
|
|
203
|
+
marginBottom: isMediaWrapped ? HALF_GUTTER_SIZE : "var(--ds-space-300, 24px)",
|
|
204
|
+
marginRight: isMediaWrapped ? layout === 'wrap-right' ? 'auto' : HALF_GUTTER_SIZE : 0,
|
|
205
|
+
marginLeft: isMediaWrapped ? layout === 'wrap-left' ? 'auto' : HALF_GUTTER_SIZE : 0,
|
|
206
|
+
width: contentWrapperWidth
|
|
207
|
+
})
|
|
208
|
+
}, content];
|
|
209
|
+
};
|
|
209
210
|
};
|
|
210
211
|
|
|
211
212
|
// @nodeSpecException:toDOM patch
|
|
@@ -214,6 +215,7 @@ var mediaSingleSpecWithFixedToDOM = exports.mediaSingleSpecWithFixedToDOM = func
|
|
|
214
215
|
if ((0, _experiments.editorExperiment)('platform_editor_exp_lazy_node_views', false)) {
|
|
215
216
|
return mediaSingleNode;
|
|
216
217
|
}
|
|
218
|
+
var toDOM = getToDom(mediaSingleOption.withExtendedWidthTypes);
|
|
217
219
|
return _objectSpread(_objectSpread({}, mediaSingleNode), {}, {
|
|
218
220
|
toDOM: toDOM
|
|
219
221
|
});
|
|
@@ -11,7 +11,6 @@ var _selection = require("@atlaskit/editor-common/selection");
|
|
|
11
11
|
var _keymap = require("@atlaskit/editor-prosemirror/keymap");
|
|
12
12
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
13
13
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
14
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
15
14
|
var _captions = require("../pm-plugins/commands/captions");
|
|
16
15
|
var _pluginKey = require("../pm-plugins/plugin-key");
|
|
17
16
|
var _commands = require("../ui/toolbar/commands");
|
|
@@ -44,7 +43,7 @@ function keymapPlugin(options, editorAnalyticsAPI, editorSelectionAPI, widthPlug
|
|
|
44
43
|
// Ignored via go/ees005
|
|
45
44
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
46
45
|
(0, _keymaps.bindKeymapWithCommand)(_keymaps.enter.common, splitMediaGroup, list);
|
|
47
|
-
if (
|
|
46
|
+
if (options !== null && options !== void 0 && options.allowPixelResizing) {
|
|
48
47
|
(0, _keymaps.bindKeymapWithCommand)(
|
|
49
48
|
// Ignored via go/ees005
|
|
50
49
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
@@ -158,7 +158,7 @@ var MediaPluginStateImplementation = exports.MediaPluginStateImplementation = /*
|
|
|
158
158
|
case 'block':
|
|
159
159
|
// read width state right before inserting to get up-to-date and define values
|
|
160
160
|
var widthPluginState = (_this$pluginInjection2 = _this.pluginInjectionApi) === null || _this$pluginInjection2 === void 0 || (_this$pluginInjection2 = _this$pluginInjection2.width) === null || _this$pluginInjection2 === void 0 ? void 0 : _this$pluginInjection2.sharedState.currentState();
|
|
161
|
-
(0, _mediaSingle2.insertMediaSingleNode)(_this.view, mediaStateWithContext, _this.getInputMethod(pickerType), collection, _this.mediaOptions && _this.mediaOptions.alignLeftOnInsert, widthPluginState, editorAnalyticsAPI, _this.onNodeInserted, insertMediaVia);
|
|
161
|
+
(0, _mediaSingle2.insertMediaSingleNode)(_this.view, mediaStateWithContext, _this.getInputMethod(pickerType), collection, _this.mediaOptions && _this.mediaOptions.alignLeftOnInsert, widthPluginState, editorAnalyticsAPI, _this.onNodeInserted, insertMediaVia, _this.mediaOptions && _this.mediaOptions.allowPixelResizing);
|
|
162
162
|
break;
|
|
163
163
|
case 'group':
|
|
164
164
|
(0, _mediaFiles.insertMediaGroupNode)(editorAnalyticsAPI)(_this.view, [mediaStateWithContext], collection, _this.getInputMethod(pickerType), insertMediaVia);
|
|
@@ -461,7 +461,9 @@ var MediaPluginStateImplementation = exports.MediaPluginStateImplementation = /*
|
|
|
461
461
|
this.waitForMediaUpload = options.waitForMediaUpload === undefined ? true : options.waitForMediaUpload;
|
|
462
462
|
var nodes = _state.schema.nodes;
|
|
463
463
|
(0, _assert.default)(nodes.media && (nodes.mediaGroup || nodes.mediaSingle), 'Editor: unable to init media plugin - media or mediaGroup/mediaSingle node absent in schema');
|
|
464
|
-
if (mediaOptions !== null && mediaOptions !== void 0 && mediaOptions.
|
|
464
|
+
if (mediaOptions !== null && mediaOptions !== void 0 && mediaOptions.syncProvider) {
|
|
465
|
+
this.setMediaProvider(mediaOptions === null || mediaOptions === void 0 ? void 0 : mediaOptions.syncProvider);
|
|
466
|
+
} else if (mediaOptions !== null && mediaOptions !== void 0 && mediaOptions.provider) {
|
|
465
467
|
this.setMediaProvider(mediaOptions === null || mediaOptions === void 0 ? void 0 : mediaOptions.provider);
|
|
466
468
|
}
|
|
467
469
|
if ((0, _platformFeatureFlags.fg)('platform_editor_remove_media_inline_feature_flag')) {
|
|
@@ -532,10 +534,19 @@ var MediaPluginStateImplementation = exports.MediaPluginStateImplementation = /*
|
|
|
532
534
|
return _context.abrupt("return");
|
|
533
535
|
case 8:
|
|
534
536
|
_context.prev = 8;
|
|
535
|
-
|
|
537
|
+
if (!(mediaProvider instanceof Promise)) {
|
|
538
|
+
_context.next = 15;
|
|
539
|
+
break;
|
|
540
|
+
}
|
|
541
|
+
_context.next = 12;
|
|
536
542
|
return mediaProvider;
|
|
537
|
-
case
|
|
543
|
+
case 12:
|
|
538
544
|
this.mediaProvider = _context.sent;
|
|
545
|
+
_context.next = 16;
|
|
546
|
+
break;
|
|
547
|
+
case 15:
|
|
548
|
+
this.mediaProvider = mediaProvider;
|
|
549
|
+
case 16:
|
|
539
550
|
// Ignored via go/ees007
|
|
540
551
|
// eslint-disable-next-line @atlaskit/editor/enforce-todo-comment-format
|
|
541
552
|
// TODO [MS-2038]: remove once context api is removed
|
|
@@ -548,10 +559,10 @@ var MediaPluginStateImplementation = exports.MediaPluginStateImplementation = /*
|
|
|
548
559
|
}
|
|
549
560
|
}
|
|
550
561
|
(0, _assert.default)(this.mediaProvider.viewMediaClientConfig, "MediaProvider promise did not resolve to a valid instance of MediaProvider - ".concat(this.mediaProvider));
|
|
551
|
-
_context.next =
|
|
562
|
+
_context.next = 28;
|
|
552
563
|
break;
|
|
553
|
-
case
|
|
554
|
-
_context.prev =
|
|
564
|
+
case 20:
|
|
565
|
+
_context.prev = 20;
|
|
555
566
|
_context.t0 = _context["catch"](8);
|
|
556
567
|
wrappedError = new Error("Media functionality disabled due to rejected provider: ".concat(_context.t0 instanceof Error ? _context.t0.message : String(_context.t0)));
|
|
557
568
|
this.errorReporter.captureException(wrappedError);
|
|
@@ -563,7 +574,7 @@ var MediaPluginStateImplementation = exports.MediaPluginStateImplementation = /*
|
|
|
563
574
|
}));
|
|
564
575
|
}
|
|
565
576
|
return _context.abrupt("return");
|
|
566
|
-
case
|
|
577
|
+
case 28:
|
|
567
578
|
this.mediaClientConfig = this.mediaProvider.viewMediaClientConfig;
|
|
568
579
|
this.allowsUploads = !!this.mediaProvider.uploadMediaClientConfig;
|
|
569
580
|
view = this.view, allowsUploads = this.allowsUploads; // make sure editable DOM node is mounted
|
|
@@ -574,31 +585,31 @@ var MediaPluginStateImplementation = exports.MediaPluginStateImplementation = /*
|
|
|
574
585
|
}));
|
|
575
586
|
}
|
|
576
587
|
if (!this.allowsUploads) {
|
|
577
|
-
_context.next =
|
|
588
|
+
_context.next = 42;
|
|
578
589
|
break;
|
|
579
590
|
}
|
|
580
591
|
this.uploadMediaClientConfig = this.mediaProvider.uploadMediaClientConfig;
|
|
581
592
|
if (!(this.mediaProvider.uploadParams && this.uploadMediaClientConfig)) {
|
|
582
|
-
_context.next =
|
|
593
|
+
_context.next = 39;
|
|
583
594
|
break;
|
|
584
595
|
}
|
|
585
|
-
_context.next =
|
|
596
|
+
_context.next = 37;
|
|
586
597
|
return this.initPickers(this.mediaProvider.uploadParams, _pickerFacade.default);
|
|
587
|
-
case
|
|
588
|
-
_context.next =
|
|
598
|
+
case 37:
|
|
599
|
+
_context.next = 40;
|
|
589
600
|
break;
|
|
590
|
-
case
|
|
601
|
+
case 39:
|
|
591
602
|
this.destroyPickers();
|
|
592
|
-
case
|
|
593
|
-
_context.next =
|
|
603
|
+
case 40:
|
|
604
|
+
_context.next = 43;
|
|
594
605
|
break;
|
|
595
|
-
case
|
|
606
|
+
case 42:
|
|
596
607
|
this.destroyPickers();
|
|
597
|
-
case
|
|
608
|
+
case 43:
|
|
598
609
|
case "end":
|
|
599
610
|
return _context.stop();
|
|
600
611
|
}
|
|
601
|
-
}, _callee, this, [[8,
|
|
612
|
+
}, _callee, this, [[8, 20]]);
|
|
602
613
|
}));
|
|
603
614
|
function setMediaProvider(_x) {
|
|
604
615
|
return _setMediaProvider.apply(this, arguments);
|
|
@@ -26,7 +26,9 @@ var getMediaNodeInsertionType = exports.getMediaNodeInsertionType = function get
|
|
|
26
26
|
var canInsertInlineNode = (0, _mediaCommon.getMediaFeatureFlag)('mediaInline', mediaOptions === null || mediaOptions === void 0 ? void 0 : mediaOptions.featureFlags) && !(0, _utils.isInEmptyLine)(state) && (!(0, _mediaCommon2.isInsidePotentialEmptyParagraph)(state) || isInSupportedInlineImageParent(state)) && (0, _mediaFiles.canInsertMediaInline)(state);
|
|
27
27
|
if ((0, _platformFeatureFlags.fg)('platform_editor_remove_media_inline_feature_flag')) {
|
|
28
28
|
if (mediaOptions !== null && mediaOptions !== void 0 && mediaOptions.allowMediaInlineImages) {
|
|
29
|
-
|
|
29
|
+
if (canInsertInlineNode && !(0, _isType.isVideo)(fileMimeType)) {
|
|
30
|
+
return 'inline';
|
|
31
|
+
}
|
|
30
32
|
}
|
|
31
33
|
} else {
|
|
32
34
|
if ((0, _mediaInline.mediaInlineImagesEnabled)((0, _mediaCommon.getMediaFeatureFlag)('mediaInline', mediaOptions === null || mediaOptions === void 0 ? void 0 : mediaOptions.featureFlags), mediaOptions === null || mediaOptions === void 0 ? void 0 : mediaOptions.allowMediaInlineImages)) {
|
|
@@ -101,7 +101,7 @@ function insertNodesWithOptionalParagraph(_ref) {
|
|
|
101
101
|
var isMediaSingle = exports.isMediaSingle = function isMediaSingle(schema, fileMimeType) {
|
|
102
102
|
return !!schema.nodes.mediaSingle && (0, _isType.isImage)(fileMimeType);
|
|
103
103
|
};
|
|
104
|
-
var insertMediaAsMediaSingle = exports.insertMediaAsMediaSingle = function insertMediaAsMediaSingle(view, node, inputMethod, editorAnalyticsAPI, insertMediaVia) {
|
|
104
|
+
var insertMediaAsMediaSingle = exports.insertMediaAsMediaSingle = function insertMediaAsMediaSingle(view, node, inputMethod, editorAnalyticsAPI, insertMediaVia, allowPixelResizing) {
|
|
105
105
|
var _node$attrs$width;
|
|
106
106
|
var state = view.state,
|
|
107
107
|
dispatch = view.dispatch;
|
|
@@ -116,9 +116,8 @@ var insertMediaAsMediaSingle = exports.insertMediaAsMediaSingle = function inser
|
|
|
116
116
|
if (node.type !== media || !(0, _isType.isImage)(node.attrs.__fileMimeType) && node.attrs.type !== 'external') {
|
|
117
117
|
return false;
|
|
118
118
|
}
|
|
119
|
-
var resizeExperience = (0, _platformFeatureFlags.fg)('platform_editor_media_extended_resize_experience');
|
|
120
119
|
var insertMediaPopup = (0, _platformFeatureFlags.fg)('platform_editor_add_media_from_url_rollout');
|
|
121
|
-
var mediaSingleAttrs =
|
|
120
|
+
var mediaSingleAttrs = allowPixelResizing && insertMediaPopup ? {
|
|
122
121
|
widthType: 'pixel',
|
|
123
122
|
width: (0, _mediaSingle.getMediaSingleInitialWidth)((_node$attrs$width = node.attrs.width) !== null && _node$attrs$width !== void 0 ? _node$attrs$width : _mediaSingle.DEFAULT_IMAGE_WIDTH),
|
|
124
123
|
layout: 'center'
|
|
@@ -143,7 +142,7 @@ var getFileExtension = function getFileExtension(fileName) {
|
|
|
143
142
|
}
|
|
144
143
|
return undefined;
|
|
145
144
|
};
|
|
146
|
-
var insertMediaSingleNode = exports.insertMediaSingleNode = function insertMediaSingleNode(view, mediaState, inputMethod, collection, alignLeftOnInsert, widthPluginState, editorAnalyticsAPI, onNodeInserted, insertMediaVia) {
|
|
145
|
+
var insertMediaSingleNode = exports.insertMediaSingleNode = function insertMediaSingleNode(view, mediaState, inputMethod, collection, alignLeftOnInsert, widthPluginState, editorAnalyticsAPI, onNodeInserted, insertMediaVia, allowPixelResizing) {
|
|
147
146
|
var _state$selection$$fro;
|
|
148
147
|
if (collection === undefined) {
|
|
149
148
|
return false;
|
|
@@ -156,7 +155,7 @@ var insertMediaSingleNode = exports.insertMediaSingleNode = function insertMedia
|
|
|
156
155
|
// add undefined as fallback as we don't want media single width to have upper limit as 0
|
|
157
156
|
// if widthPluginState.width is 0, default 760 will be used
|
|
158
157
|
var contentWidth = (0, _mediaSingle.getMaxWidthForNestedNodeNext)(view, state.selection.$from.pos, true) || (widthPluginState === null || widthPluginState === void 0 ? void 0 : widthPluginState.lineLength) || (widthPluginState === null || widthPluginState === void 0 ? void 0 : widthPluginState.width) || undefined;
|
|
159
|
-
var node = createMediaSingleNode(state.schema, collection, contentWidth, mediaState.status !== 'error' && isVideo(mediaState.fileMimeType) ? _mediaSingle.MEDIA_SINGLE_VIDEO_MIN_PIXEL_WIDTH : _mediaSingle.MEDIA_SINGLE_DEFAULT_MIN_PIXEL_WIDTH, alignLeftOnInsert)(mediaState);
|
|
158
|
+
var node = createMediaSingleNode(state.schema, collection, contentWidth, mediaState.status !== 'error' && isVideo(mediaState.fileMimeType) ? _mediaSingle.MEDIA_SINGLE_VIDEO_MIN_PIXEL_WIDTH : _mediaSingle.MEDIA_SINGLE_DEFAULT_MIN_PIXEL_WIDTH, alignLeftOnInsert, allowPixelResizing)(mediaState);
|
|
160
159
|
var fileExtension;
|
|
161
160
|
if (mediaState.fileName) {
|
|
162
161
|
var extensionIdx = mediaState.fileName.lastIndexOf('.');
|
|
@@ -195,7 +194,7 @@ var insertMediaSingleNode = exports.insertMediaSingleNode = function insertMedia
|
|
|
195
194
|
}
|
|
196
195
|
return true;
|
|
197
196
|
};
|
|
198
|
-
var changeFromMediaInlineToMediaSingleNode = exports.changeFromMediaInlineToMediaSingleNode = function changeFromMediaInlineToMediaSingleNode(view, fromNode, widthPluginState, editorAnalyticsAPI) {
|
|
197
|
+
var changeFromMediaInlineToMediaSingleNode = exports.changeFromMediaInlineToMediaSingleNode = function changeFromMediaInlineToMediaSingleNode(view, fromNode, widthPluginState, editorAnalyticsAPI, allowPixelResizing) {
|
|
199
198
|
var _state$selection$$fro2;
|
|
200
199
|
var state = view.state,
|
|
201
200
|
dispatch = view.dispatch;
|
|
@@ -209,7 +208,7 @@ var changeFromMediaInlineToMediaSingleNode = exports.changeFromMediaInlineToMedi
|
|
|
209
208
|
// add undefined as fallback as we don't want media single width to have upper limit as 0
|
|
210
209
|
// if widthPluginState.width is 0, default 760 will be used
|
|
211
210
|
var contentWidth = (0, _mediaSingle.getMaxWidthForNestedNodeNext)(view, state.selection.$from.pos, true) || (widthPluginState === null || widthPluginState === void 0 ? void 0 : widthPluginState.lineLength) || (widthPluginState === null || widthPluginState === void 0 ? void 0 : widthPluginState.width) || undefined;
|
|
212
|
-
var node = replaceWithMediaSingleNode(state.schema, contentWidth, _mediaSingle.MEDIA_SINGLE_DEFAULT_MIN_PIXEL_WIDTH)(fromNode);
|
|
211
|
+
var node = replaceWithMediaSingleNode(state.schema, contentWidth, _mediaSingle.MEDIA_SINGLE_DEFAULT_MIN_PIXEL_WIDTH, allowPixelResizing)(fromNode);
|
|
213
212
|
var fileExtension = getFileExtension(fromNode.attrs.__fileName);
|
|
214
213
|
// should split if media is valid content for the grandparent of the selected node
|
|
215
214
|
// and the parent node is a paragraph
|
|
@@ -241,7 +240,7 @@ var changeFromMediaInlineToMediaSingleNode = exports.changeFromMediaInlineToMedi
|
|
|
241
240
|
}
|
|
242
241
|
return true;
|
|
243
242
|
};
|
|
244
|
-
var createMediaSingleNode = function createMediaSingleNode(schema, collection, maxWidth, minWidth, alignLeftOnInsert) {
|
|
243
|
+
var createMediaSingleNode = function createMediaSingleNode(schema, collection, maxWidth, minWidth, alignLeftOnInsert, allowPixelResizing) {
|
|
245
244
|
return function (mediaState) {
|
|
246
245
|
var id = mediaState.id,
|
|
247
246
|
dimensions = mediaState.dimensions,
|
|
@@ -272,7 +271,7 @@ var createMediaSingleNode = function createMediaSingleNode(schema, collection, m
|
|
|
272
271
|
var mediaSingleAttrs = alignLeftOnInsert ? {
|
|
273
272
|
layout: 'align-start'
|
|
274
273
|
} : {};
|
|
275
|
-
var extendedMediaSingleAttrs =
|
|
274
|
+
var extendedMediaSingleAttrs = allowPixelResizing ? _objectSpread(_objectSpread({}, mediaSingleAttrs), {}, {
|
|
276
275
|
width: (0, _mediaSingle.getMediaSingleInitialWidth)(scaledWidth, maxWidth, minWidth),
|
|
277
276
|
// TODO: ED-26962 - change to use enum
|
|
278
277
|
widthType: 'pixel'
|
|
@@ -281,7 +280,7 @@ var createMediaSingleNode = function createMediaSingleNode(schema, collection, m
|
|
|
281
280
|
return mediaSingle.createChecked(extendedMediaSingleAttrs, mediaNode);
|
|
282
281
|
};
|
|
283
282
|
};
|
|
284
|
-
var replaceWithMediaSingleNode = function replaceWithMediaSingleNode(schema, maxWidth, minWidth) {
|
|
283
|
+
var replaceWithMediaSingleNode = function replaceWithMediaSingleNode(schema, maxWidth, minWidth, allowPixelResizing) {
|
|
285
284
|
return function (mediaNode) {
|
|
286
285
|
var width = mediaNode.attrs.width;
|
|
287
286
|
var _schema$nodes2 = schema.nodes,
|
|
@@ -290,7 +289,7 @@ var replaceWithMediaSingleNode = function replaceWithMediaSingleNode(schema, max
|
|
|
290
289
|
var copiedMediaNode = media.create(_objectSpread(_objectSpread({}, mediaNode.attrs), {}, {
|
|
291
290
|
type: 'file'
|
|
292
291
|
}), mediaNode.content, mediaNode.marks);
|
|
293
|
-
var extendedMediaSingleAttrs =
|
|
292
|
+
var extendedMediaSingleAttrs = allowPixelResizing ? {
|
|
294
293
|
width: (0, _mediaSingle.getMediaSingleInitialWidth)(width, maxWidth, minWidth),
|
|
295
294
|
widthType: 'pixel'
|
|
296
295
|
} : {};
|