@atlaskit/editor-plugin-media 2.4.1 → 2.5.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 +13 -0
- package/dist/cjs/mediaPlugin.js +8 -8
- 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 +1 -1
- package/dist/cjs/pm-plugins/utils/media-single.js +10 -11
- 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/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 +1 -1
- package/dist/es2019/pm-plugins/utils/media-single.js +10 -11
- 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/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 +1 -1
- package/dist/esm/pm-plugins/utils/media-single.js +10 -11
- 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/utils/media-single.d.ts +4 -4
- package/dist/types/types/index.d.ts +2 -0
- 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/utils/media-single.d.ts +4 -4
- package/dist/types-ts4.5/types/index.d.ts +2 -0
- package/dist/types-ts4.5/ui/toolbar/commands.d.ts +1 -1
- package/package.json +2 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-media
|
|
2
2
|
|
|
3
|
+
## 2.5.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#134613](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/134613)
|
|
8
|
+
[`be20cc186939b`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/be20cc186939b) -
|
|
9
|
+
ED-26247 Remove feature flag platform_media_extended_resize_experience and replace it with a new
|
|
10
|
+
media prop which defaults to false allowPixelResizing
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies
|
|
15
|
+
|
|
3
16
|
## 2.4.1
|
|
4
17
|
|
|
5
18
|
### 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
|
}
|
|
@@ -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);
|
|
@@ -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
|
} : {};
|
|
@@ -130,7 +130,7 @@ var changeMediaCardToInline = exports.changeMediaCardToInline = function changeM
|
|
|
130
130
|
return true;
|
|
131
131
|
};
|
|
132
132
|
};
|
|
133
|
-
var changeMediaInlineToMediaSingle = exports.changeMediaInlineToMediaSingle = function changeMediaInlineToMediaSingle(editorAnalyticsAPI, widthPluginState) {
|
|
133
|
+
var changeMediaInlineToMediaSingle = exports.changeMediaInlineToMediaSingle = function changeMediaInlineToMediaSingle(editorAnalyticsAPI, widthPluginState, allowPixelResizing) {
|
|
134
134
|
return function (state, dispatch, view) {
|
|
135
135
|
var mediaInline = state.schema.nodes.mediaInline;
|
|
136
136
|
var selectedNode = state.selection instanceof _state.NodeSelection && state.selection.node.type === mediaInline && state.selection.node;
|
|
@@ -138,7 +138,7 @@ var changeMediaInlineToMediaSingle = exports.changeMediaInlineToMediaSingle = fu
|
|
|
138
138
|
return false;
|
|
139
139
|
}
|
|
140
140
|
if (view) {
|
|
141
|
-
return (0, _mediaSingle2.changeFromMediaInlineToMediaSingleNode)(view, selectedNode, widthPluginState, editorAnalyticsAPI);
|
|
141
|
+
return (0, _mediaSingle2.changeFromMediaInlineToMediaSingleNode)(view, selectedNode, widthPluginState, editorAnalyticsAPI, allowPixelResizing);
|
|
142
142
|
}
|
|
143
143
|
return true;
|
|
144
144
|
};
|
|
@@ -241,7 +241,8 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
241
241
|
allowMediaInline = options.allowMediaInline,
|
|
242
242
|
allowMediaInlineImages = options.allowMediaInlineImages,
|
|
243
243
|
allowImagePreview = options.allowImagePreview,
|
|
244
|
-
isViewOnly = options.isViewOnly
|
|
244
|
+
isViewOnly = options.isViewOnly,
|
|
245
|
+
allowPixelResizing = options.allowPixelResizing;
|
|
245
246
|
var toolbarButtons = [];
|
|
246
247
|
var _ref2 = (_pluginInjectionApi$d = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$d2 = pluginInjectionApi.decorations) === null || _pluginInjectionApi$d2 === void 0 ? void 0 : _pluginInjectionApi$d2.actions) !== null && _pluginInjectionApi$d !== void 0 ? _pluginInjectionApi$d : {},
|
|
247
248
|
hoverDecoration = _ref2.hoverDecoration;
|
|
@@ -280,7 +281,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
280
281
|
var widthPlugin = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.width;
|
|
281
282
|
var isChangingLayoutDisabled = false;
|
|
282
283
|
var selectedNode = (0, _utils2.getSelectedMediaSingle)(state);
|
|
283
|
-
if (
|
|
284
|
+
if (allowPixelResizing) {
|
|
284
285
|
var _widthPlugin$sharedSt;
|
|
285
286
|
var contentWidth = widthPlugin === null || widthPlugin === void 0 || (_widthPlugin$sharedSt = widthPlugin.sharedState.currentState()) === null || _widthPlugin$sharedSt === void 0 ? void 0 : _widthPlugin$sharedSt.lineLength;
|
|
286
287
|
var selectedNodeMaxWidth = pluginState.currentMaxWidth || contentWidth;
|
|
@@ -288,7 +289,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
288
289
|
isChangingLayoutDisabled = true;
|
|
289
290
|
}
|
|
290
291
|
}
|
|
291
|
-
var layoutButtons = (0, _card.buildLayoutButtons)(state, intl, state.schema.nodes.mediaSingle, widthPlugin, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a3 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a3 === void 0 ? void 0 : _pluginInjectionApi$a3.actions, allowResizing, allowResizingInTables, true, true, isChangingLayoutDisabled);
|
|
292
|
+
var layoutButtons = (0, _card.buildLayoutButtons)(state, intl, state.schema.nodes.mediaSingle, widthPlugin, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a3 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a3 === void 0 ? void 0 : _pluginInjectionApi$a3.actions, allowResizing, allowResizingInTables, true, true, isChangingLayoutDisabled, allowPixelResizing);
|
|
292
293
|
var addLayoutDropdownToToolbar = function addLayoutDropdownToToolbar() {
|
|
293
294
|
var selectedLayoutIcon = (0, _utils2.getSelectedLayoutIcon)([].concat((0, _toConsumableArray2.default)(_card.alignmentIcons), (0, _toConsumableArray2.default)(_card.wrappingIcons)),
|
|
294
295
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
@@ -445,7 +446,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
445
446
|
// Pixel Entry Toolbar Support
|
|
446
447
|
var selection = state.selection;
|
|
447
448
|
var isWithinTable = (0, _utils.hasParentNodeOfType)([state.schema.nodes.table])(selection);
|
|
448
|
-
if (allowResizing && (!isWithinTable || allowResizingInTables === true) &&
|
|
449
|
+
if (allowResizing && (!isWithinTable || allowResizingInTables === true) && allowPixelResizing) {
|
|
449
450
|
var selectedMediaSingleNode = (0, _utils2.getSelectedMediaSingle)(state);
|
|
450
451
|
var sizeInput = {
|
|
451
452
|
type: 'custom',
|
|
@@ -709,7 +710,8 @@ var floatingToolbar = exports.floatingToolbar = function floatingToolbar(state,
|
|
|
709
710
|
allowResizing = options.allowResizing,
|
|
710
711
|
isViewOnly = options.isViewOnly,
|
|
711
712
|
allowResizingInTables = options.allowResizingInTables,
|
|
712
|
-
allowAdvancedToolBarOptions = options.allowAdvancedToolBarOptions
|
|
713
|
+
allowAdvancedToolBarOptions = options.allowAdvancedToolBarOptions,
|
|
714
|
+
allowPixelResizing = options.allowPixelResizing;
|
|
713
715
|
var allowMediaInline = options.allowMediaInline;
|
|
714
716
|
allowMediaInline = (0, _platformFeatureFlags.fg)('platform_editor_remove_media_inline_feature_flag') ? allowMediaInlineImages : allowMediaInline;
|
|
715
717
|
var mediaPluginState = _pluginKey.stateKey.getState(state);
|
|
@@ -748,7 +750,7 @@ var floatingToolbar = exports.floatingToolbar = function floatingToolbar(state,
|
|
|
748
750
|
}
|
|
749
751
|
var selection = state.selection;
|
|
750
752
|
var isWithinTable = (0, _utils.hasParentNodeOfType)([state.schema.nodes.table])(selection);
|
|
751
|
-
if (allowAdvancedToolBarOptions && allowResizing && (!isWithinTable || allowResizingInTables === true) && (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1')
|
|
753
|
+
if (allowAdvancedToolBarOptions && allowResizing && (!isWithinTable || allowResizingInTables === true) && allowPixelResizing && (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1')) {
|
|
752
754
|
var mediaPixelResizingPluginState = (0, _pixelResizing.getPluginState)(state);
|
|
753
755
|
if (mediaPixelResizingPluginState !== null && mediaPixelResizingPluginState !== void 0 && mediaPixelResizingPluginState.isPixelEditorOpen) {
|
|
754
756
|
return (0, _pixelResizing2.getPixelResizingToolbar)(baseToolbar, {
|
|
@@ -850,7 +852,7 @@ var floatingToolbar = exports.floatingToolbar = function floatingToolbar(state,
|
|
|
850
852
|
scrollable: true,
|
|
851
853
|
mediaAssistiveMessage: assistiveMessage
|
|
852
854
|
});
|
|
853
|
-
if (allowResizing &&
|
|
855
|
+
if (allowResizing && allowPixelResizing) {
|
|
854
856
|
return _objectSpread(_objectSpread({}, toolbarConfig), {}, {
|
|
855
857
|
width: mediaPluginState.isResizing ? undefined : (0, _utils2.getMaxToolbarWidth)()
|
|
856
858
|
});
|
|
@@ -272,7 +272,7 @@ var getMediaInlineImageToolbar = function getMediaInlineImageToolbar(state, intl
|
|
|
272
272
|
LEGACY_fallbackIcon: _card.IconEmbed
|
|
273
273
|
});
|
|
274
274
|
},
|
|
275
|
-
onClick: (0, _commands.changeMediaInlineToMediaSingle)(editorAnalyticsAPI, widthPluginState)
|
|
275
|
+
onClick: (0, _commands.changeMediaInlineToMediaSingle)(editorAnalyticsAPI, widthPluginState, options === null || options === void 0 ? void 0 : options.allowPixelResizing)
|
|
276
276
|
}, {
|
|
277
277
|
type: 'separator'
|
|
278
278
|
}, {
|
|
@@ -10,7 +10,6 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
10
10
|
var _media = require("@atlaskit/editor-common/media");
|
|
11
11
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
12
12
|
var _growHorizontal = _interopRequireDefault(require("@atlaskit/icon/core/grow-horizontal"));
|
|
13
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
14
13
|
var _commands = require("../../pm-plugins/pixel-resizing/commands");
|
|
15
14
|
var _ui = require("../../pm-plugins/pixel-resizing/ui");
|
|
16
15
|
var _constants = require("../../pm-plugins/pixel-resizing/ui/constants");
|
|
@@ -56,9 +55,10 @@ var getResizeDropdownOption = exports.getResizeDropdownOption = function getResi
|
|
|
56
55
|
}
|
|
57
56
|
var allowResizing = mediaOptions.allowResizing,
|
|
58
57
|
allowResizingInTables = mediaOptions.allowResizingInTables,
|
|
59
|
-
allowAdvancedToolBarOptions = mediaOptions.allowAdvancedToolBarOptions
|
|
58
|
+
allowAdvancedToolBarOptions = mediaOptions.allowAdvancedToolBarOptions,
|
|
59
|
+
allowPixelResizing = mediaOptions.allowPixelResizing;
|
|
60
60
|
var isWithinTable = (0, _utils.hasParentNodeOfType)(state.schema.nodes.table)(state.selection);
|
|
61
|
-
if (allowAdvancedToolBarOptions && allowResizing && (!isWithinTable || allowResizingInTables === true) &&
|
|
61
|
+
if (allowAdvancedToolBarOptions && allowResizing && (!isWithinTable || allowResizingInTables === true) && allowPixelResizing) {
|
|
62
62
|
return [{
|
|
63
63
|
title: formatMessage(_media.pixelEntryMessages.resizeOption),
|
|
64
64
|
onClick: (0, _commands.openPixelEditor)(),
|
|
@@ -100,7 +100,7 @@ export const mediaPlugin = ({
|
|
|
100
100
|
actions: {
|
|
101
101
|
insertMediaAsMediaSingle: (view, node, inputMethod, insertMediaVia) => {
|
|
102
102
|
var _api$analytics;
|
|
103
|
-
return insertMediaAsMediaSingle(view, node, inputMethod, api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, insertMediaVia);
|
|
103
|
+
return insertMediaAsMediaSingle(view, node, inputMethod, api === null || api === void 0 ? 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);
|
|
104
104
|
},
|
|
105
105
|
setProvider: provider => {
|
|
106
106
|
var _api$core$actions$exe;
|
|
@@ -125,17 +125,15 @@ export const mediaPlugin = ({
|
|
|
125
125
|
const {
|
|
126
126
|
allowMediaGroup = true,
|
|
127
127
|
allowMediaSingle = false,
|
|
128
|
+
allowPixelResizing = false,
|
|
128
129
|
allowCaptions,
|
|
129
130
|
allowMediaInlineImages,
|
|
130
131
|
featureFlags: mediaFeatureFlags
|
|
131
132
|
} = options || {};
|
|
132
133
|
const allowMediaInline = fg('platform_editor_remove_media_inline_feature_flag') ? allowMediaInlineImages : getMediaFeatureFlag('mediaInline', mediaFeatureFlags);
|
|
133
|
-
const mediaSingleOption =
|
|
134
|
+
const mediaSingleOption = {
|
|
134
135
|
withCaption: allowCaptions,
|
|
135
|
-
withExtendedWidthTypes:
|
|
136
|
-
} : {
|
|
137
|
-
withCaption: allowCaptions,
|
|
138
|
-
withExtendedWidthTypes: false
|
|
136
|
+
withExtendedWidthTypes: allowPixelResizing
|
|
139
137
|
};
|
|
140
138
|
return [{
|
|
141
139
|
name: 'mediaGroup',
|
|
@@ -238,7 +236,7 @@ export const mediaPlugin = ({
|
|
|
238
236
|
}) => keymapLinkingPlugin(schema)
|
|
239
237
|
});
|
|
240
238
|
}
|
|
241
|
-
if (options && options.allowAdvancedToolBarOptions && options.allowResizing && editorExperiment('platform_editor_controls', 'variant1') &&
|
|
239
|
+
if (options && options.allowAdvancedToolBarOptions && options.allowResizing && editorExperiment('platform_editor_controls', 'variant1') && options.allowPixelResizing) {
|
|
242
240
|
pmPlugins.push({
|
|
243
241
|
name: 'mediaPixelResizing',
|
|
244
242
|
plugin: createMediaPixelResizingPlugin
|
|
@@ -347,7 +345,8 @@ export const mediaPlugin = ({
|
|
|
347
345
|
altTextValidator: options && options.altTextValidator,
|
|
348
346
|
fullWidthEnabled: options && options.fullWidthEnabled,
|
|
349
347
|
allowMediaInlineImages: options && options.allowMediaInlineImages,
|
|
350
|
-
isViewOnly: (api === null || api === void 0 ? void 0 : (_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 ? void 0 : (_api$editorViewMode$s = _api$editorViewMode.sharedState.currentState()) === null || _api$editorViewMode$s === void 0 ? void 0 : _api$editorViewMode$s.mode) === 'view'
|
|
348
|
+
isViewOnly: (api === null || api === void 0 ? void 0 : (_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 ? void 0 : (_api$editorViewMode$s = _api$editorViewMode.sharedState.currentState()) === null || _api$editorViewMode$s === void 0 ? void 0 : _api$editorViewMode$s.mode) === 'view',
|
|
349
|
+
allowPixelResizing: options === null || options === void 0 ? void 0 : options.allowPixelResizing
|
|
351
350
|
}, api);
|
|
352
351
|
}
|
|
353
352
|
}
|