@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
|
@@ -2,7 +2,6 @@ import React from 'react';
|
|
|
2
2
|
import { pixelEntryMessages as messages } from '@atlaskit/editor-common/media';
|
|
3
3
|
import { hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
4
4
|
import GrowHorizontalIcon from '@atlaskit/icon/core/grow-horizontal';
|
|
5
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
5
|
import { openPixelEditor } from '../../pm-plugins/pixel-resizing/commands';
|
|
7
6
|
import { PixelEntry } from '../../pm-plugins/pixel-resizing/ui';
|
|
8
7
|
import { PIXEL_RESIZING_TOOLBAR_WIDTH } from '../../pm-plugins/pixel-resizing/ui/constants';
|
|
@@ -47,10 +46,11 @@ export const getResizeDropdownOption = (mediaOptions, state, formatMessage, sele
|
|
|
47
46
|
const {
|
|
48
47
|
allowResizing,
|
|
49
48
|
allowResizingInTables,
|
|
50
|
-
allowAdvancedToolBarOptions
|
|
49
|
+
allowAdvancedToolBarOptions,
|
|
50
|
+
allowPixelResizing
|
|
51
51
|
} = mediaOptions;
|
|
52
52
|
const isWithinTable = hasParentNodeOfType(state.schema.nodes.table)(state.selection);
|
|
53
|
-
if (allowAdvancedToolBarOptions && allowResizing && (!isWithinTable || allowResizingInTables === true) &&
|
|
53
|
+
if (allowAdvancedToolBarOptions && allowResizing && (!isWithinTable || allowResizingInTables === true) && allowPixelResizing) {
|
|
54
54
|
return [{
|
|
55
55
|
title: formatMessage(messages.resizeOption),
|
|
56
56
|
onClick: openPixelEditor(),
|
package/dist/esm/mediaPlugin.js
CHANGED
|
@@ -96,7 +96,7 @@ export var mediaPlugin = function mediaPlugin(_ref3) {
|
|
|
96
96
|
actions: {
|
|
97
97
|
insertMediaAsMediaSingle: function insertMediaAsMediaSingle(view, node, inputMethod, insertMediaVia) {
|
|
98
98
|
var _api$analytics;
|
|
99
|
-
return _insertMediaAsMediaSingle(view, node, inputMethod, api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, insertMediaVia);
|
|
99
|
+
return _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);
|
|
100
100
|
},
|
|
101
101
|
setProvider: function setProvider(provider) {
|
|
102
102
|
var _api$core$actions$exe;
|
|
@@ -124,16 +124,15 @@ export var mediaPlugin = function mediaPlugin(_ref3) {
|
|
|
124
124
|
allowMediaGroup = _ref5$allowMediaGroup === void 0 ? true : _ref5$allowMediaGroup,
|
|
125
125
|
_ref5$allowMediaSingl = _ref5.allowMediaSingle,
|
|
126
126
|
allowMediaSingle = _ref5$allowMediaSingl === void 0 ? false : _ref5$allowMediaSingl,
|
|
127
|
+
_ref5$allowPixelResiz = _ref5.allowPixelResizing,
|
|
128
|
+
allowPixelResizing = _ref5$allowPixelResiz === void 0 ? false : _ref5$allowPixelResiz,
|
|
127
129
|
allowCaptions = _ref5.allowCaptions,
|
|
128
130
|
allowMediaInlineImages = _ref5.allowMediaInlineImages,
|
|
129
131
|
mediaFeatureFlags = _ref5.featureFlags;
|
|
130
132
|
var allowMediaInline = fg('platform_editor_remove_media_inline_feature_flag') ? allowMediaInlineImages : getMediaFeatureFlag('mediaInline', mediaFeatureFlags);
|
|
131
|
-
var mediaSingleOption =
|
|
133
|
+
var mediaSingleOption = {
|
|
132
134
|
withCaption: allowCaptions,
|
|
133
|
-
withExtendedWidthTypes:
|
|
134
|
-
} : {
|
|
135
|
-
withCaption: allowCaptions,
|
|
136
|
-
withExtendedWidthTypes: false
|
|
135
|
+
withExtendedWidthTypes: allowPixelResizing
|
|
137
136
|
};
|
|
138
137
|
return [{
|
|
139
138
|
name: 'mediaGroup',
|
|
@@ -236,7 +235,7 @@ export var mediaPlugin = function mediaPlugin(_ref3) {
|
|
|
236
235
|
}
|
|
237
236
|
});
|
|
238
237
|
}
|
|
239
|
-
if (options && options.allowAdvancedToolBarOptions && options.allowResizing && editorExperiment('platform_editor_controls', 'variant1') &&
|
|
238
|
+
if (options && options.allowAdvancedToolBarOptions && options.allowResizing && editorExperiment('platform_editor_controls', 'variant1') && options.allowPixelResizing) {
|
|
240
239
|
pmPlugins.push({
|
|
241
240
|
name: 'mediaPixelResizing',
|
|
242
241
|
plugin: createMediaPixelResizingPlugin
|
|
@@ -341,7 +340,8 @@ export var mediaPlugin = function mediaPlugin(_ref3) {
|
|
|
341
340
|
altTextValidator: options && options.altTextValidator,
|
|
342
341
|
fullWidthEnabled: options && options.fullWidthEnabled,
|
|
343
342
|
allowMediaInlineImages: options && options.allowMediaInlineImages,
|
|
344
|
-
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'
|
|
343
|
+
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',
|
|
344
|
+
allowPixelResizing: options === null || options === void 0 ? void 0 : options.allowPixelResizing
|
|
345
345
|
}, api);
|
|
346
346
|
}
|
|
347
347
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { withLazyLoading } from '@atlaskit/editor-common/lazy-node-view';
|
|
2
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
3
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
3
4
|
import { ReactMediaSingleNode } from './mediaSingle';
|
|
4
5
|
export var lazyMediaSingleView = function lazyMediaSingleView(portalProviderAPI, eventDispatcher, providerFactory, api, dispatchAnalyticsEvent) {
|
|
5
6
|
var options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
|
|
6
|
-
if (editorExperiment('platform_editor_exp_lazy_node_views', false)) {
|
|
7
|
+
if (fg('platform_editor_ssr_media') || editorExperiment('platform_editor_exp_lazy_node_views', false)) {
|
|
7
8
|
return ReactMediaSingleNode(portalProviderAPI, eventDispatcher, providerFactory, api, dispatchAnalyticsEvent, options);
|
|
8
9
|
}
|
|
9
10
|
return withLazyLoading({
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { withLazyLoading } from '@atlaskit/editor-common/lazy-node-view';
|
|
2
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
3
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
3
4
|
import { ReactMediaNode } from './mediaNodeView';
|
|
4
5
|
export var lazyMediaView = function lazyMediaView(portalProviderAPI, eventDispatcher, providerFactory) {
|
|
5
6
|
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
6
7
|
var api = arguments.length > 4 ? arguments[4] : undefined;
|
|
7
|
-
if (editorExperiment('platform_editor_exp_lazy_node_views', false)) {
|
|
8
|
+
if (fg('platform_editor_ssr_media') || editorExperiment('platform_editor_exp_lazy_node_views', false)) {
|
|
8
9
|
return ReactMediaNode(portalProviderAPI, eventDispatcher, providerFactory, options, api);
|
|
9
10
|
}
|
|
10
11
|
return withLazyLoading({
|
|
@@ -15,6 +15,7 @@ import { AnalyticsContext } from '@atlaskit/analytics-next';
|
|
|
15
15
|
import { setNodeSelection, setTextSelection, withImageLoader } from '@atlaskit/editor-common/utils';
|
|
16
16
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
17
17
|
import { Card, CardLoading } from '@atlaskit/media-card';
|
|
18
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
18
19
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
19
20
|
import { stateKey as mediaStateKey } from '../../pm-plugins/plugin-key';
|
|
20
21
|
import { MediaCardWrapper } from '../styles';
|
|
@@ -276,6 +277,10 @@ export var MediaNode = /*#__PURE__*/function (_Component) {
|
|
|
276
277
|
return {};
|
|
277
278
|
}
|
|
278
279
|
};
|
|
280
|
+
var ssr;
|
|
281
|
+
if (fg('platform_editor_ssr_media')) {
|
|
282
|
+
ssr = process.env.REACT_SSR ? 'server' : 'client';
|
|
283
|
+
}
|
|
279
284
|
return /*#__PURE__*/React.createElement(MediaCardWrapper, {
|
|
280
285
|
dimensions: originalDimensions,
|
|
281
286
|
onContextMenu: this.selectMediaSingle,
|
|
@@ -301,7 +306,8 @@ export var MediaNode = /*#__PURE__*/function (_Component) {
|
|
|
301
306
|
featureFlags: mediaOptions && mediaOptions.featureFlags,
|
|
302
307
|
contextId: contextId,
|
|
303
308
|
alt: alt,
|
|
304
|
-
videoControlsWrapperRef: this.videoControlsWrapperRef
|
|
309
|
+
videoControlsWrapperRef: this.videoControlsWrapperRef,
|
|
310
|
+
ssr: ssr
|
|
305
311
|
})));
|
|
306
312
|
}
|
|
307
313
|
}]);
|
|
@@ -475,7 +475,7 @@ var MediaSingleNode = /*#__PURE__*/function (_Component) {
|
|
|
475
475
|
mediaElement: currentMediaElement(),
|
|
476
476
|
mediaHeight: height,
|
|
477
477
|
mediaWidth: width,
|
|
478
|
-
extendedResizeOffset:
|
|
478
|
+
extendedResizeOffset: mediaOptions.allowPixelResizing && !isInsideTable
|
|
479
479
|
}, function (_ref5) {
|
|
480
480
|
var visible = _ref5.visible;
|
|
481
481
|
return jsx(React.Fragment, null, visible && jsx(ExternalImageBadge, {
|
|
@@ -509,7 +509,7 @@ var MediaSingleNode = /*#__PURE__*/function (_Component) {
|
|
|
509
509
|
onClick: this.clickPlaceholder,
|
|
510
510
|
placeholderMessage: mediaOptions.allowImagePreview ? captionMessages.placeholderWithDoubleClickPrompt : captionMessages.placeholder
|
|
511
511
|
})));
|
|
512
|
-
return jsx(Fragment, null, canResize ?
|
|
512
|
+
return jsx(Fragment, null, canResize ? mediaOptions.allowPixelResizing ? jsx(ResizableMediaSingleNext
|
|
513
513
|
// Ignored via go/ees005
|
|
514
514
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
515
515
|
, _extends({}, resizableMediaSingleProps, {
|
|
@@ -651,14 +651,14 @@ var MediaSingleNodeView = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
651
651
|
return _createClass(MediaSingleNodeView, [{
|
|
652
652
|
key: "createDomRef",
|
|
653
653
|
value: function createDomRef() {
|
|
654
|
-
var _this$reactComponentP;
|
|
654
|
+
var _this$reactComponentP, _this$reactComponentP2;
|
|
655
655
|
var domRef = document.createElement('div');
|
|
656
656
|
|
|
657
657
|
// control the domRef contentEditable attribute based on the editor view mode
|
|
658
658
|
this.unsubscribeToViewModeChange = this.subscribeToViewModeChange(domRef);
|
|
659
659
|
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;
|
|
660
660
|
this.updateDomRefContentEditable(domRef, initialViewMode);
|
|
661
|
-
if (
|
|
661
|
+
if ((_this$reactComponentP2 = this.reactComponentProps.mediaOptions) !== null && _this$reactComponentP2 !== void 0 && _this$reactComponentP2.allowPixelResizing) {
|
|
662
662
|
domRef.classList.add('media-extended-resize-experience');
|
|
663
663
|
}
|
|
664
664
|
return domRef;
|
|
@@ -693,9 +693,9 @@ var MediaSingleNodeView = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
693
693
|
}, {
|
|
694
694
|
key: "subscribeToViewModeChange",
|
|
695
695
|
value: function subscribeToViewModeChange(domRef) {
|
|
696
|
-
var _this$
|
|
696
|
+
var _this$reactComponentP3,
|
|
697
697
|
_this3 = this;
|
|
698
|
-
return (_this$
|
|
698
|
+
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) {
|
|
699
699
|
var _viewModeState$nextSh;
|
|
700
700
|
_this3.updateDomRefContentEditable(domRef, (_viewModeState$nextSh = viewModeState.nextSharedState) === null || _viewModeState$nextSh === void 0 ? void 0 : _viewModeState$nextSh.mode);
|
|
701
701
|
});
|
|
@@ -703,7 +703,7 @@ var MediaSingleNodeView = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
703
703
|
}, {
|
|
704
704
|
key: "updateDomRefContentEditable",
|
|
705
705
|
value: function updateDomRefContentEditable(domRef, editorViewMode) {
|
|
706
|
-
var _this$
|
|
706
|
+
var _this$reactComponentP4;
|
|
707
707
|
// if the editor is in view mode, we should not allow editing
|
|
708
708
|
if (editorViewMode === 'view') {
|
|
709
709
|
domRef.contentEditable = 'false';
|
|
@@ -711,7 +711,7 @@ var MediaSingleNodeView = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
711
711
|
}
|
|
712
712
|
|
|
713
713
|
// if the editor is in edit mode, we should allow editing if the media options allow it
|
|
714
|
-
if ((_this$
|
|
714
|
+
if ((_this$reactComponentP4 = this.reactComponentProps.mediaOptions) !== null && _this$reactComponentP4 !== void 0 && _this$reactComponentP4.allowMediaSingleEditable) {
|
|
715
715
|
// workaround Chrome bug in https://product-fabric.atlassian.net/browse/ED-5379
|
|
716
716
|
// see also: https://github.com/ProseMirror/prosemirror/issues/884
|
|
717
717
|
domRef.contentEditable = 'true';
|
|
@@ -751,14 +751,14 @@ var MediaSingleNodeView = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
751
751
|
key: "render",
|
|
752
752
|
value: function render(props, forwardRef) {
|
|
753
753
|
var _this5 = this;
|
|
754
|
-
var _this$
|
|
755
|
-
eventDispatcher = _this$
|
|
756
|
-
fullWidthMode = _this$
|
|
757
|
-
providerFactory = _this$
|
|
758
|
-
mediaOptions = _this$
|
|
759
|
-
dispatchAnalyticsEvent = _this$
|
|
760
|
-
pluginInjectionApi = _this$
|
|
761
|
-
editorAppearance = _this$
|
|
754
|
+
var _this$reactComponentP5 = this.reactComponentProps,
|
|
755
|
+
eventDispatcher = _this$reactComponentP5.eventDispatcher,
|
|
756
|
+
fullWidthMode = _this$reactComponentP5.fullWidthMode,
|
|
757
|
+
providerFactory = _this$reactComponentP5.providerFactory,
|
|
758
|
+
mediaOptions = _this$reactComponentP5.mediaOptions,
|
|
759
|
+
dispatchAnalyticsEvent = _this$reactComponentP5.dispatchAnalyticsEvent,
|
|
760
|
+
pluginInjectionApi = _this$reactComponentP5.pluginInjectionApi,
|
|
761
|
+
editorAppearance = _this$reactComponentP5.editorAppearance;
|
|
762
762
|
|
|
763
763
|
// getPos is a boolean for marks, since this is a node we know it must be a function
|
|
764
764
|
var getPos = this.getPos;
|
|
@@ -471,7 +471,7 @@ export var MediaSingleNodeNext = function MediaSingleNodeNext(mediaSingleNodeNex
|
|
|
471
471
|
mediaElement: currentMediaElement(),
|
|
472
472
|
mediaHeight: height,
|
|
473
473
|
mediaWidth: width,
|
|
474
|
-
extendedResizeOffset:
|
|
474
|
+
extendedResizeOffset: mediaOptions.allowPixelResizing && !isInsideTable
|
|
475
475
|
}, function (_ref7) {
|
|
476
476
|
var visible = _ref7.visible;
|
|
477
477
|
return jsx(React.Fragment, null, visible && jsx(ExternalImageBadge, {
|
|
@@ -505,7 +505,7 @@ export var MediaSingleNodeNext = function MediaSingleNodeNext(mediaSingleNodeNex
|
|
|
505
505
|
onClick: clickPlaceholder,
|
|
506
506
|
placeholderMessage: mediaOptions.allowImagePreview ? captionMessages.placeholderWithDoubleClickPrompt : captionMessages.placeholder
|
|
507
507
|
})));
|
|
508
|
-
return jsx(Fragment, null, canResize ?
|
|
508
|
+
return jsx(Fragment, null, canResize ? mediaOptions.allowPixelResizing ? jsx(ResizableMediaSingleNext, {
|
|
509
509
|
view: view,
|
|
510
510
|
getPos: getPos,
|
|
511
511
|
updateSize: updateSize,
|
|
@@ -3,7 +3,6 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
|
|
|
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
4
|
import { mediaSingleSpec } from '@atlaskit/adf-schema';
|
|
5
5
|
import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
|
|
6
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
7
6
|
import { N20, N50 } from '@atlaskit/theme/colors';
|
|
8
7
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
9
8
|
import { getAttrsFromNodeMediaSingle } from './toDOMAttrs';
|
|
@@ -150,55 +149,57 @@ export var prepareWrapperContentDOM = function prepareWrapperContentDOM(_ref5) {
|
|
|
150
149
|
class: 'media-content-wrap'
|
|
151
150
|
}, 0]]]]];
|
|
152
151
|
};
|
|
153
|
-
export var
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
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
|
-
|
|
152
|
+
export var getToDom = function getToDom(allowPixelResizing) {
|
|
153
|
+
return function (node) {
|
|
154
|
+
var _mediaSingleAttrs$lay;
|
|
155
|
+
var mediaSingleAttrs = node.attrs;
|
|
156
|
+
var isPixelWidth = (mediaSingleAttrs === null || mediaSingleAttrs === void 0 ? void 0 : mediaSingleAttrs.widthType) === 'pixel';
|
|
157
|
+
var layout = (_mediaSingleAttrs$lay = mediaSingleAttrs === null || mediaSingleAttrs === void 0 ? void 0 : mediaSingleAttrs.layout) !== null && _mediaSingleAttrs$lay !== void 0 ? _mediaSingleAttrs$lay : 'center';
|
|
158
|
+
var childNode = node.firstChild;
|
|
159
|
+
var isExternalMedia = (childNode === null || childNode === void 0 ? void 0 : childNode.attrs.type) === 'external';
|
|
160
|
+
var childMediaWidth = (childNode === null || childNode === void 0 ? void 0 : childNode.attrs.width) || DEFAULT_IMAGE_WIDTH;
|
|
161
|
+
var childMediaHeight = (childNode === null || childNode === void 0 ? void 0 : childNode.attrs.height) || DEFAULT_IMAGE_HEIGHT;
|
|
162
|
+
var dataAttrs = getAttrsFromNodeMediaSingle(true, node);
|
|
163
|
+
var content = prepareWrapperContentDOM({
|
|
164
|
+
layout: layout,
|
|
165
|
+
dataAttrs: dataAttrs,
|
|
166
|
+
childMediaWidth: childMediaWidth,
|
|
167
|
+
childMediaHeight: childMediaHeight,
|
|
168
|
+
mediaSingleDimensionWidth: mediaSingleAttrs.width,
|
|
169
|
+
isPixelWidth: isPixelWidth,
|
|
170
|
+
isExtendedResizeExperience: allowPixelResizing
|
|
171
|
+
});
|
|
172
|
+
var isMediaWrapped = WRAPPED_LAYOUTS.includes(layout);
|
|
173
|
+
var proportionCalc = mediaProportionalWidthCSSCalc({
|
|
174
|
+
isPixelWidth: isPixelWidth,
|
|
175
|
+
isMediaWrapped: isMediaWrapped,
|
|
176
|
+
mediaSingleDimensionWidth: mediaSingleAttrs === null || mediaSingleAttrs === void 0 ? void 0 : mediaSingleAttrs.width,
|
|
177
|
+
isExtendedResizeExperience: allowPixelResizing
|
|
178
|
+
});
|
|
179
|
+
var contentWrapperWidth = mediaContentWrapperWidthCSSCalc({
|
|
180
|
+
isMediaWrapped: isMediaWrapped,
|
|
181
|
+
isExternalMedia: isExternalMedia,
|
|
182
|
+
isPixelWidth: isPixelWidth,
|
|
183
|
+
childMediaWidth: childMediaWidth,
|
|
184
|
+
mediaSingleDimensionWidth: mediaSingleAttrs === null || mediaSingleAttrs === void 0 ? void 0 : mediaSingleAttrs.width
|
|
185
|
+
});
|
|
186
|
+
return ['div', {
|
|
187
|
+
class: 'mediaSingleView-content-wrap',
|
|
188
|
+
layout: layout,
|
|
189
|
+
style: convertToInlineCss({
|
|
190
|
+
'--ak-editor-media-single--proportion': proportionCalc,
|
|
191
|
+
'--ak-editor-media-card-display': 'block',
|
|
192
|
+
'--ak-editor-media-single--gutter-size': GUTTER_SIZE,
|
|
193
|
+
'--ak-editor-media-margin-right': '0',
|
|
194
|
+
'--ak-editor-media-card-background-color': "var(--ds-background-neutral, ".concat(N20, ")"),
|
|
195
|
+
marginTop: isMediaWrapped ? HALF_GUTTER_SIZE : "var(--ds-space-300, 24px)",
|
|
196
|
+
marginBottom: isMediaWrapped ? HALF_GUTTER_SIZE : "var(--ds-space-300, 24px)",
|
|
197
|
+
marginRight: isMediaWrapped ? layout === 'wrap-right' ? 'auto' : HALF_GUTTER_SIZE : 0,
|
|
198
|
+
marginLeft: isMediaWrapped ? layout === 'wrap-left' ? 'auto' : HALF_GUTTER_SIZE : 0,
|
|
199
|
+
width: contentWrapperWidth
|
|
200
|
+
})
|
|
201
|
+
}, content];
|
|
202
|
+
};
|
|
202
203
|
};
|
|
203
204
|
|
|
204
205
|
// @nodeSpecException:toDOM patch
|
|
@@ -207,6 +208,7 @@ export var mediaSingleSpecWithFixedToDOM = function mediaSingleSpecWithFixedToDO
|
|
|
207
208
|
if (editorExperiment('platform_editor_exp_lazy_node_views', false)) {
|
|
208
209
|
return mediaSingleNode;
|
|
209
210
|
}
|
|
211
|
+
var toDOM = getToDom(mediaSingleOption.withExtendedWidthTypes);
|
|
210
212
|
return _objectSpread(_objectSpread({}, mediaSingleNode), {}, {
|
|
211
213
|
toDOM: toDOM
|
|
212
214
|
});
|
|
@@ -5,7 +5,6 @@ import { GapCursorSelection, Side } from '@atlaskit/editor-common/selection';
|
|
|
5
5
|
import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
6
6
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
7
7
|
import { akEditorDefaultLayoutWidth } from '@atlaskit/editor-shared-styles';
|
|
8
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
9
8
|
import { insertAndSelectCaptionFromMediaSinglePos, selectCaptionFromMediaSinglePos } from '../pm-plugins/commands/captions';
|
|
10
9
|
import { stateKey } from '../pm-plugins/plugin-key';
|
|
11
10
|
import { updateMediaSingleWidth } from '../ui/toolbar/commands';
|
|
@@ -38,7 +37,7 @@ function keymapPlugin(options, editorAnalyticsAPI, editorSelectionAPI, widthPlug
|
|
|
38
37
|
// Ignored via go/ees005
|
|
39
38
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
40
39
|
bindKeymapWithCommand(enter.common, splitMediaGroup, list);
|
|
41
|
-
if (
|
|
40
|
+
if (options !== null && options !== void 0 && options.allowPixelResizing) {
|
|
42
41
|
bindKeymapWithCommand(
|
|
43
42
|
// Ignored via go/ees005
|
|
44
43
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
@@ -149,7 +149,7 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
|
|
|
149
149
|
case 'block':
|
|
150
150
|
// read width state right before inserting to get up-to-date and define values
|
|
151
151
|
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();
|
|
152
|
-
insertMediaSingleNode(_this.view, mediaStateWithContext, _this.getInputMethod(pickerType), collection, _this.mediaOptions && _this.mediaOptions.alignLeftOnInsert, widthPluginState, editorAnalyticsAPI, _this.onNodeInserted, insertMediaVia);
|
|
152
|
+
insertMediaSingleNode(_this.view, mediaStateWithContext, _this.getInputMethod(pickerType), collection, _this.mediaOptions && _this.mediaOptions.alignLeftOnInsert, widthPluginState, editorAnalyticsAPI, _this.onNodeInserted, insertMediaVia, _this.mediaOptions && _this.mediaOptions.allowPixelResizing);
|
|
153
153
|
break;
|
|
154
154
|
case 'group':
|
|
155
155
|
insertMediaGroupNode(editorAnalyticsAPI)(_this.view, [mediaStateWithContext], collection, _this.getInputMethod(pickerType), insertMediaVia);
|
|
@@ -452,7 +452,9 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
|
|
|
452
452
|
this.waitForMediaUpload = options.waitForMediaUpload === undefined ? true : options.waitForMediaUpload;
|
|
453
453
|
var nodes = _state.schema.nodes;
|
|
454
454
|
assert(nodes.media && (nodes.mediaGroup || nodes.mediaSingle), 'Editor: unable to init media plugin - media or mediaGroup/mediaSingle node absent in schema');
|
|
455
|
-
if (mediaOptions !== null && mediaOptions !== void 0 && mediaOptions.
|
|
455
|
+
if (mediaOptions !== null && mediaOptions !== void 0 && mediaOptions.syncProvider) {
|
|
456
|
+
this.setMediaProvider(mediaOptions === null || mediaOptions === void 0 ? void 0 : mediaOptions.syncProvider);
|
|
457
|
+
} else if (mediaOptions !== null && mediaOptions !== void 0 && mediaOptions.provider) {
|
|
456
458
|
this.setMediaProvider(mediaOptions === null || mediaOptions === void 0 ? void 0 : mediaOptions.provider);
|
|
457
459
|
}
|
|
458
460
|
if (fg('platform_editor_remove_media_inline_feature_flag')) {
|
|
@@ -523,10 +525,19 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
|
|
|
523
525
|
return _context.abrupt("return");
|
|
524
526
|
case 8:
|
|
525
527
|
_context.prev = 8;
|
|
526
|
-
|
|
528
|
+
if (!(mediaProvider instanceof Promise)) {
|
|
529
|
+
_context.next = 15;
|
|
530
|
+
break;
|
|
531
|
+
}
|
|
532
|
+
_context.next = 12;
|
|
527
533
|
return mediaProvider;
|
|
528
|
-
case
|
|
534
|
+
case 12:
|
|
529
535
|
this.mediaProvider = _context.sent;
|
|
536
|
+
_context.next = 16;
|
|
537
|
+
break;
|
|
538
|
+
case 15:
|
|
539
|
+
this.mediaProvider = mediaProvider;
|
|
540
|
+
case 16:
|
|
530
541
|
// Ignored via go/ees007
|
|
531
542
|
// eslint-disable-next-line @atlaskit/editor/enforce-todo-comment-format
|
|
532
543
|
// TODO [MS-2038]: remove once context api is removed
|
|
@@ -539,10 +550,10 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
|
|
|
539
550
|
}
|
|
540
551
|
}
|
|
541
552
|
assert(this.mediaProvider.viewMediaClientConfig, "MediaProvider promise did not resolve to a valid instance of MediaProvider - ".concat(this.mediaProvider));
|
|
542
|
-
_context.next =
|
|
553
|
+
_context.next = 28;
|
|
543
554
|
break;
|
|
544
|
-
case
|
|
545
|
-
_context.prev =
|
|
555
|
+
case 20:
|
|
556
|
+
_context.prev = 20;
|
|
546
557
|
_context.t0 = _context["catch"](8);
|
|
547
558
|
wrappedError = new Error("Media functionality disabled due to rejected provider: ".concat(_context.t0 instanceof Error ? _context.t0.message : String(_context.t0)));
|
|
548
559
|
this.errorReporter.captureException(wrappedError);
|
|
@@ -554,7 +565,7 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
|
|
|
554
565
|
}));
|
|
555
566
|
}
|
|
556
567
|
return _context.abrupt("return");
|
|
557
|
-
case
|
|
568
|
+
case 28:
|
|
558
569
|
this.mediaClientConfig = this.mediaProvider.viewMediaClientConfig;
|
|
559
570
|
this.allowsUploads = !!this.mediaProvider.uploadMediaClientConfig;
|
|
560
571
|
view = this.view, allowsUploads = this.allowsUploads; // make sure editable DOM node is mounted
|
|
@@ -565,31 +576,31 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
|
|
|
565
576
|
}));
|
|
566
577
|
}
|
|
567
578
|
if (!this.allowsUploads) {
|
|
568
|
-
_context.next =
|
|
579
|
+
_context.next = 42;
|
|
569
580
|
break;
|
|
570
581
|
}
|
|
571
582
|
this.uploadMediaClientConfig = this.mediaProvider.uploadMediaClientConfig;
|
|
572
583
|
if (!(this.mediaProvider.uploadParams && this.uploadMediaClientConfig)) {
|
|
573
|
-
_context.next =
|
|
584
|
+
_context.next = 39;
|
|
574
585
|
break;
|
|
575
586
|
}
|
|
576
|
-
_context.next =
|
|
587
|
+
_context.next = 37;
|
|
577
588
|
return this.initPickers(this.mediaProvider.uploadParams, PickerFacade);
|
|
578
|
-
case
|
|
579
|
-
_context.next =
|
|
589
|
+
case 37:
|
|
590
|
+
_context.next = 40;
|
|
580
591
|
break;
|
|
581
|
-
case
|
|
592
|
+
case 39:
|
|
582
593
|
this.destroyPickers();
|
|
583
|
-
case
|
|
584
|
-
_context.next =
|
|
594
|
+
case 40:
|
|
595
|
+
_context.next = 43;
|
|
585
596
|
break;
|
|
586
|
-
case
|
|
597
|
+
case 42:
|
|
587
598
|
this.destroyPickers();
|
|
588
|
-
case
|
|
599
|
+
case 43:
|
|
589
600
|
case "end":
|
|
590
601
|
return _context.stop();
|
|
591
602
|
}
|
|
592
|
-
}, _callee, this, [[8,
|
|
603
|
+
}, _callee, this, [[8, 20]]);
|
|
593
604
|
}));
|
|
594
605
|
function setMediaProvider(_x) {
|
|
595
606
|
return _setMediaProvider.apply(this, arguments);
|
|
@@ -20,7 +20,9 @@ export var getMediaNodeInsertionType = function getMediaNodeInsertionType(state,
|
|
|
20
20
|
var canInsertInlineNode = getMediaFeatureFlag('mediaInline', mediaOptions === null || mediaOptions === void 0 ? void 0 : mediaOptions.featureFlags) && !isInEmptyLine(state) && (!isInsidePotentialEmptyParagraph(state) || isInSupportedInlineImageParent(state)) && canInsertMediaInline(state);
|
|
21
21
|
if (fg('platform_editor_remove_media_inline_feature_flag')) {
|
|
22
22
|
if (mediaOptions !== null && mediaOptions !== void 0 && mediaOptions.allowMediaInlineImages) {
|
|
23
|
-
|
|
23
|
+
if (canInsertInlineNode && !isVideo(fileMimeType)) {
|
|
24
|
+
return 'inline';
|
|
25
|
+
}
|
|
24
26
|
}
|
|
25
27
|
} else {
|
|
26
28
|
if (mediaInlineImagesEnabled(getMediaFeatureFlag('mediaInline', mediaOptions === null || mediaOptions === void 0 ? void 0 : mediaOptions.featureFlags), mediaOptions === null || mediaOptions === void 0 ? void 0 : mediaOptions.allowMediaInlineImages)) {
|
|
@@ -94,7 +94,7 @@ function insertNodesWithOptionalParagraph(_ref) {
|
|
|
94
94
|
export var isMediaSingle = function isMediaSingle(schema, fileMimeType) {
|
|
95
95
|
return !!schema.nodes.mediaSingle && isImage(fileMimeType);
|
|
96
96
|
};
|
|
97
|
-
export var insertMediaAsMediaSingle = function insertMediaAsMediaSingle(view, node, inputMethod, editorAnalyticsAPI, insertMediaVia) {
|
|
97
|
+
export var insertMediaAsMediaSingle = function insertMediaAsMediaSingle(view, node, inputMethod, editorAnalyticsAPI, insertMediaVia, allowPixelResizing) {
|
|
98
98
|
var _node$attrs$width;
|
|
99
99
|
var state = view.state,
|
|
100
100
|
dispatch = view.dispatch;
|
|
@@ -109,9 +109,8 @@ export var insertMediaAsMediaSingle = function insertMediaAsMediaSingle(view, no
|
|
|
109
109
|
if (node.type !== media || !isImage(node.attrs.__fileMimeType) && node.attrs.type !== 'external') {
|
|
110
110
|
return false;
|
|
111
111
|
}
|
|
112
|
-
var resizeExperience = fg('platform_editor_media_extended_resize_experience');
|
|
113
112
|
var insertMediaPopup = fg('platform_editor_add_media_from_url_rollout');
|
|
114
|
-
var mediaSingleAttrs =
|
|
113
|
+
var mediaSingleAttrs = allowPixelResizing && insertMediaPopup ? {
|
|
115
114
|
widthType: 'pixel',
|
|
116
115
|
width: getMediaSingleInitialWidth((_node$attrs$width = node.attrs.width) !== null && _node$attrs$width !== void 0 ? _node$attrs$width : DEFAULT_IMAGE_WIDTH),
|
|
117
116
|
layout: 'center'
|
|
@@ -136,7 +135,7 @@ var getFileExtension = function getFileExtension(fileName) {
|
|
|
136
135
|
}
|
|
137
136
|
return undefined;
|
|
138
137
|
};
|
|
139
|
-
export var insertMediaSingleNode = function insertMediaSingleNode(view, mediaState, inputMethod, collection, alignLeftOnInsert, widthPluginState, editorAnalyticsAPI, onNodeInserted, insertMediaVia) {
|
|
138
|
+
export var insertMediaSingleNode = function insertMediaSingleNode(view, mediaState, inputMethod, collection, alignLeftOnInsert, widthPluginState, editorAnalyticsAPI, onNodeInserted, insertMediaVia, allowPixelResizing) {
|
|
140
139
|
var _state$selection$$fro;
|
|
141
140
|
if (collection === undefined) {
|
|
142
141
|
return false;
|
|
@@ -149,7 +148,7 @@ export var insertMediaSingleNode = function insertMediaSingleNode(view, mediaSta
|
|
|
149
148
|
// add undefined as fallback as we don't want media single width to have upper limit as 0
|
|
150
149
|
// if widthPluginState.width is 0, default 760 will be used
|
|
151
150
|
var contentWidth = 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;
|
|
152
|
-
var node = createMediaSingleNode(state.schema, collection, contentWidth, mediaState.status !== 'error' && isVideo(mediaState.fileMimeType) ? MEDIA_SINGLE_VIDEO_MIN_PIXEL_WIDTH : MEDIA_SINGLE_DEFAULT_MIN_PIXEL_WIDTH, alignLeftOnInsert)(mediaState);
|
|
151
|
+
var node = createMediaSingleNode(state.schema, collection, contentWidth, mediaState.status !== 'error' && isVideo(mediaState.fileMimeType) ? MEDIA_SINGLE_VIDEO_MIN_PIXEL_WIDTH : MEDIA_SINGLE_DEFAULT_MIN_PIXEL_WIDTH, alignLeftOnInsert, allowPixelResizing)(mediaState);
|
|
153
152
|
var fileExtension;
|
|
154
153
|
if (mediaState.fileName) {
|
|
155
154
|
var extensionIdx = mediaState.fileName.lastIndexOf('.');
|
|
@@ -188,7 +187,7 @@ export var insertMediaSingleNode = function insertMediaSingleNode(view, mediaSta
|
|
|
188
187
|
}
|
|
189
188
|
return true;
|
|
190
189
|
};
|
|
191
|
-
export var changeFromMediaInlineToMediaSingleNode = function changeFromMediaInlineToMediaSingleNode(view, fromNode, widthPluginState, editorAnalyticsAPI) {
|
|
190
|
+
export var changeFromMediaInlineToMediaSingleNode = function changeFromMediaInlineToMediaSingleNode(view, fromNode, widthPluginState, editorAnalyticsAPI, allowPixelResizing) {
|
|
192
191
|
var _state$selection$$fro2;
|
|
193
192
|
var state = view.state,
|
|
194
193
|
dispatch = view.dispatch;
|
|
@@ -202,7 +201,7 @@ export var changeFromMediaInlineToMediaSingleNode = function changeFromMediaInli
|
|
|
202
201
|
// add undefined as fallback as we don't want media single width to have upper limit as 0
|
|
203
202
|
// if widthPluginState.width is 0, default 760 will be used
|
|
204
203
|
var contentWidth = 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;
|
|
205
|
-
var node = replaceWithMediaSingleNode(state.schema, contentWidth, MEDIA_SINGLE_DEFAULT_MIN_PIXEL_WIDTH)(fromNode);
|
|
204
|
+
var node = replaceWithMediaSingleNode(state.schema, contentWidth, MEDIA_SINGLE_DEFAULT_MIN_PIXEL_WIDTH, allowPixelResizing)(fromNode);
|
|
206
205
|
var fileExtension = getFileExtension(fromNode.attrs.__fileName);
|
|
207
206
|
// should split if media is valid content for the grandparent of the selected node
|
|
208
207
|
// and the parent node is a paragraph
|
|
@@ -234,7 +233,7 @@ export var changeFromMediaInlineToMediaSingleNode = function changeFromMediaInli
|
|
|
234
233
|
}
|
|
235
234
|
return true;
|
|
236
235
|
};
|
|
237
|
-
var createMediaSingleNode = function createMediaSingleNode(schema, collection, maxWidth, minWidth, alignLeftOnInsert) {
|
|
236
|
+
var createMediaSingleNode = function createMediaSingleNode(schema, collection, maxWidth, minWidth, alignLeftOnInsert, allowPixelResizing) {
|
|
238
237
|
return function (mediaState) {
|
|
239
238
|
var id = mediaState.id,
|
|
240
239
|
dimensions = mediaState.dimensions,
|
|
@@ -265,7 +264,7 @@ var createMediaSingleNode = function createMediaSingleNode(schema, collection, m
|
|
|
265
264
|
var mediaSingleAttrs = alignLeftOnInsert ? {
|
|
266
265
|
layout: 'align-start'
|
|
267
266
|
} : {};
|
|
268
|
-
var extendedMediaSingleAttrs =
|
|
267
|
+
var extendedMediaSingleAttrs = allowPixelResizing ? _objectSpread(_objectSpread({}, mediaSingleAttrs), {}, {
|
|
269
268
|
width: getMediaSingleInitialWidth(scaledWidth, maxWidth, minWidth),
|
|
270
269
|
// TODO: ED-26962 - change to use enum
|
|
271
270
|
widthType: 'pixel'
|
|
@@ -274,7 +273,7 @@ var createMediaSingleNode = function createMediaSingleNode(schema, collection, m
|
|
|
274
273
|
return mediaSingle.createChecked(extendedMediaSingleAttrs, mediaNode);
|
|
275
274
|
};
|
|
276
275
|
};
|
|
277
|
-
var replaceWithMediaSingleNode = function replaceWithMediaSingleNode(schema, maxWidth, minWidth) {
|
|
276
|
+
var replaceWithMediaSingleNode = function replaceWithMediaSingleNode(schema, maxWidth, minWidth, allowPixelResizing) {
|
|
278
277
|
return function (mediaNode) {
|
|
279
278
|
var width = mediaNode.attrs.width;
|
|
280
279
|
var _schema$nodes2 = schema.nodes,
|
|
@@ -283,7 +282,7 @@ var replaceWithMediaSingleNode = function replaceWithMediaSingleNode(schema, max
|
|
|
283
282
|
var copiedMediaNode = media.create(_objectSpread(_objectSpread({}, mediaNode.attrs), {}, {
|
|
284
283
|
type: 'file'
|
|
285
284
|
}), mediaNode.content, mediaNode.marks);
|
|
286
|
-
var extendedMediaSingleAttrs =
|
|
285
|
+
var extendedMediaSingleAttrs = allowPixelResizing ? {
|
|
287
286
|
width: getMediaSingleInitialWidth(width, maxWidth, minWidth),
|
|
288
287
|
widthType: 'pixel'
|
|
289
288
|
} : {};
|
|
@@ -727,7 +727,7 @@ export var ResizableMediaSingleNextFunctional = function ResizableMediaSingleNex
|
|
|
727
727
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
728
728
|
isResizing = _useState6[0],
|
|
729
729
|
setIsResizing = _useState6[1];
|
|
730
|
-
var _useState7 = useState(
|
|
730
|
+
var _useState7 = useState(!fg('platform_editor_ssr_media')),
|
|
731
731
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
732
732
|
isVideoFile = _useState8[0],
|
|
733
733
|
setIsVideoFile = _useState8[1];
|
|
@@ -123,7 +123,7 @@ export var changeMediaCardToInline = function changeMediaCardToInline(editorAnal
|
|
|
123
123
|
return true;
|
|
124
124
|
};
|
|
125
125
|
};
|
|
126
|
-
export var changeMediaInlineToMediaSingle = function changeMediaInlineToMediaSingle(editorAnalyticsAPI, widthPluginState) {
|
|
126
|
+
export var changeMediaInlineToMediaSingle = function changeMediaInlineToMediaSingle(editorAnalyticsAPI, widthPluginState, allowPixelResizing) {
|
|
127
127
|
return function (state, dispatch, view) {
|
|
128
128
|
var mediaInline = state.schema.nodes.mediaInline;
|
|
129
129
|
var selectedNode = state.selection instanceof NodeSelection && state.selection.node.type === mediaInline && state.selection.node;
|
|
@@ -131,7 +131,7 @@ export var changeMediaInlineToMediaSingle = function changeMediaInlineToMediaSin
|
|
|
131
131
|
return false;
|
|
132
132
|
}
|
|
133
133
|
if (view) {
|
|
134
|
-
return changeFromMediaInlineToMediaSingleNode(view, selectedNode, widthPluginState, editorAnalyticsAPI);
|
|
134
|
+
return changeFromMediaInlineToMediaSingleNode(view, selectedNode, widthPluginState, editorAnalyticsAPI, allowPixelResizing);
|
|
135
135
|
}
|
|
136
136
|
return true;
|
|
137
137
|
};
|