@atlaskit/editor-plugin-media 1.24.4 → 1.25.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 +14 -0
- package/dist/cjs/hooks/useMediaProvider.js +16 -0
- package/dist/cjs/nodeviews/mediaGroup.js +32 -3
- package/dist/cjs/nodeviews/mediaInline.js +30 -4
- package/dist/cjs/nodeviews/mediaNodeView/index.js +13 -6
- package/dist/cjs/nodeviews/mediaSingle.js +12 -3
- package/dist/cjs/nodeviews/styles.js +4 -1
- package/dist/cjs/plugin.js +45 -36
- package/dist/cjs/pm-plugins/alt-text/ui/AltTextEdit.js +4 -1
- package/dist/cjs/pm-plugins/main.js +9 -2
- package/dist/cjs/toolbar/layout-group.js +4 -1
- package/dist/cjs/toolbar/linking-toolbar-appearance.js +4 -1
- package/dist/cjs/ui/CaptionPlaceholder/index.js +4 -1
- package/dist/cjs/ui/ImageBorder/index.js +4 -1
- package/dist/cjs/ui/Media/DropPlaceholder.js +4 -1
- package/dist/cjs/ui/MediaLinkingToolbar.js +4 -1
- package/dist/cjs/ui/MediaPicker/PickerFacadeProvider.js +140 -34
- package/dist/cjs/ui/MediaViewer/MediaViewerContainer.js +4 -1
- package/dist/cjs/ui/PixelEntry/index.js +4 -1
- package/dist/cjs/ui/ResizableMediaSingle/ResizableMediaMigrationNotification.js +4 -1
- package/dist/cjs/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +4 -1
- package/dist/cjs/ui/ResizableMediaSingle/index.js +4 -1
- package/dist/es2019/hooks/useMediaProvider.js +11 -0
- package/dist/es2019/nodeviews/mediaGroup.js +32 -3
- package/dist/es2019/nodeviews/mediaInline.js +29 -5
- package/dist/es2019/nodeviews/mediaNodeView/index.js +13 -6
- package/dist/es2019/nodeviews/mediaSingle.js +11 -4
- package/dist/es2019/nodeviews/styles.js +4 -1
- package/dist/es2019/plugin.js +8 -0
- package/dist/es2019/pm-plugins/alt-text/ui/AltTextEdit.js +4 -1
- package/dist/es2019/pm-plugins/main.js +9 -2
- package/dist/es2019/toolbar/layout-group.js +4 -1
- package/dist/es2019/toolbar/linking-toolbar-appearance.js +4 -1
- package/dist/es2019/ui/CaptionPlaceholder/index.js +4 -1
- package/dist/es2019/ui/ImageBorder/index.js +4 -1
- package/dist/es2019/ui/Media/DropPlaceholder.js +4 -1
- package/dist/es2019/ui/MediaLinkingToolbar.js +4 -1
- package/dist/es2019/ui/MediaPicker/PickerFacadeProvider.js +64 -3
- package/dist/es2019/ui/MediaViewer/MediaViewerContainer.js +4 -1
- package/dist/es2019/ui/PixelEntry/index.js +4 -1
- package/dist/es2019/ui/ResizableMediaSingle/ResizableMediaMigrationNotification.js +4 -1
- package/dist/es2019/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +4 -1
- package/dist/es2019/ui/ResizableMediaSingle/index.js +4 -1
- package/dist/esm/hooks/useMediaProvider.js +10 -0
- package/dist/esm/nodeviews/mediaGroup.js +32 -3
- package/dist/esm/nodeviews/mediaInline.js +31 -5
- package/dist/esm/nodeviews/mediaNodeView/index.js +13 -6
- package/dist/esm/nodeviews/mediaSingle.js +13 -4
- package/dist/esm/nodeviews/styles.js +4 -1
- package/dist/esm/plugin.js +45 -36
- package/dist/esm/pm-plugins/alt-text/ui/AltTextEdit.js +4 -1
- package/dist/esm/pm-plugins/main.js +9 -2
- package/dist/esm/toolbar/layout-group.js +4 -1
- package/dist/esm/toolbar/linking-toolbar-appearance.js +4 -1
- package/dist/esm/ui/CaptionPlaceholder/index.js +4 -1
- package/dist/esm/ui/ImageBorder/index.js +4 -1
- package/dist/esm/ui/Media/DropPlaceholder.js +4 -1
- package/dist/esm/ui/MediaLinkingToolbar.js +4 -1
- package/dist/esm/ui/MediaPicker/PickerFacadeProvider.js +136 -34
- package/dist/esm/ui/MediaViewer/MediaViewerContainer.js +4 -1
- package/dist/esm/ui/PixelEntry/index.js +4 -1
- package/dist/esm/ui/ResizableMediaSingle/ResizableMediaMigrationNotification.js +4 -1
- package/dist/esm/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +4 -1
- package/dist/esm/ui/ResizableMediaSingle/index.js +4 -1
- package/dist/types/hooks/useMediaProvider.d.ts +3 -0
- package/dist/types/next-plugin-type.d.ts +8 -0
- package/dist/types/nodeviews/mediaNodeView/index.d.ts +5 -3
- package/dist/types/nodeviews/mediaSingle.d.ts +4 -1
- package/dist/types/nodeviews/styles.d.ts +4 -1
- package/dist/types/toolbar/layout-group.d.ts +4 -1
- package/dist/types/toolbar/linking-toolbar-appearance.d.ts +4 -1
- package/dist/types/ui/CaptionPlaceholder/index.d.ts +4 -1
- package/dist/types/ui/Media/DropPlaceholder.d.ts +4 -1
- package/dist/types/ui/MediaLinkingToolbar.d.ts +4 -1
- package/dist/types/ui/MediaPicker/PickerFacadeProvider.d.ts +1 -13
- package/dist/types/ui/MediaViewer/MediaViewerContainer.d.ts +4 -1
- package/dist/types/ui/ResizableMediaSingle/ResizableMediaMigrationNotification.d.ts +4 -1
- package/dist/types/ui/ResizableMediaSingle/ResizableMediaSingleNext.d.ts +4 -1
- package/dist/types/ui/ResizableMediaSingle/index.d.ts +4 -1
- package/dist/types-ts4.5/hooks/useMediaProvider.d.ts +3 -0
- package/dist/types-ts4.5/next-plugin-type.d.ts +8 -0
- package/dist/types-ts4.5/nodeviews/mediaNodeView/index.d.ts +5 -3
- package/dist/types-ts4.5/nodeviews/mediaSingle.d.ts +4 -1
- package/dist/types-ts4.5/nodeviews/styles.d.ts +4 -1
- package/dist/types-ts4.5/toolbar/layout-group.d.ts +4 -1
- package/dist/types-ts4.5/toolbar/linking-toolbar-appearance.d.ts +4 -1
- package/dist/types-ts4.5/ui/CaptionPlaceholder/index.d.ts +4 -1
- package/dist/types-ts4.5/ui/Media/DropPlaceholder.d.ts +4 -1
- package/dist/types-ts4.5/ui/MediaLinkingToolbar.d.ts +4 -1
- package/dist/types-ts4.5/ui/MediaPicker/PickerFacadeProvider.d.ts +1 -13
- package/dist/types-ts4.5/ui/MediaViewer/MediaViewerContainer.d.ts +4 -1
- package/dist/types-ts4.5/ui/ResizableMediaSingle/ResizableMediaMigrationNotification.d.ts +4 -1
- package/dist/types-ts4.5/ui/ResizableMediaSingle/ResizableMediaSingleNext.d.ts +4 -1
- package/dist/types-ts4.5/ui/ResizableMediaSingle/index.d.ts +4 -1
- package/package.json +5 -5
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
6
7
|
});
|
|
7
|
-
exports.default =
|
|
8
|
+
exports.default = PickerFacadeProvider;
|
|
8
9
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
10
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
11
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
12
12
|
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
@@ -14,11 +14,15 @@ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits
|
|
|
14
14
|
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
15
15
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
16
16
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
17
|
-
var
|
|
17
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
18
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
19
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
18
20
|
var _reactDom = require("react-dom");
|
|
19
21
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
20
22
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
21
23
|
var _pickerFacade = _interopRequireDefault(require("../../picker-facade"));
|
|
24
|
+
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); }
|
|
25
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(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 && Object.prototype.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; }
|
|
22
26
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
23
27
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
24
28
|
var dummyMediaPickerObject = {
|
|
@@ -28,55 +32,154 @@ var dummyMediaPickerObject = {
|
|
|
28
32
|
destroy: function destroy() {},
|
|
29
33
|
setUploadParams: function setUploadParams() {}
|
|
30
34
|
};
|
|
35
|
+
function PickerFacadeProviderNew(_ref) {
|
|
36
|
+
var mediaState = _ref.mediaState,
|
|
37
|
+
analyticsName = _ref.analyticsName,
|
|
38
|
+
children = _ref.children;
|
|
39
|
+
var _useState = (0, _react.useState)({
|
|
40
|
+
pickerFacadeInstance: undefined,
|
|
41
|
+
config: undefined,
|
|
42
|
+
mediaClientConfig: undefined
|
|
43
|
+
}),
|
|
44
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
45
|
+
state = _useState2[0],
|
|
46
|
+
setState = _useState2[1];
|
|
47
|
+
var mediaProvider = (0, _react.useMemo)(function () {
|
|
48
|
+
return mediaState === null || mediaState === void 0 ? void 0 : mediaState.mediaProvider;
|
|
49
|
+
}, [mediaState === null || mediaState === void 0 ? void 0 : mediaState.mediaProvider]);
|
|
50
|
+
var handleMediaProvider = (0, _react.useCallback)( /*#__PURE__*/function () {
|
|
51
|
+
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(_name, provider) {
|
|
52
|
+
var mediaProvider, resolvedMediaClientConfig, pickerFacadeConfig, pickerFacadeInstance, config;
|
|
53
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
54
|
+
while (1) switch (_context.prev = _context.next) {
|
|
55
|
+
case 0:
|
|
56
|
+
_context.next = 2;
|
|
57
|
+
return provider;
|
|
58
|
+
case 2:
|
|
59
|
+
mediaProvider = _context.sent;
|
|
60
|
+
if (!(!mediaProvider || !mediaProvider.uploadParams)) {
|
|
61
|
+
_context.next = 5;
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
return _context.abrupt("return");
|
|
65
|
+
case 5:
|
|
66
|
+
_context.next = 7;
|
|
67
|
+
return mediaProvider.uploadMediaClientConfig;
|
|
68
|
+
case 7:
|
|
69
|
+
_context.t0 = _context.sent;
|
|
70
|
+
if (_context.t0) {
|
|
71
|
+
_context.next = 12;
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
_context.next = 11;
|
|
75
|
+
return mediaProvider.viewMediaClientConfig;
|
|
76
|
+
case 11:
|
|
77
|
+
_context.t0 = _context.sent;
|
|
78
|
+
case 12:
|
|
79
|
+
resolvedMediaClientConfig = _context.t0;
|
|
80
|
+
if (resolvedMediaClientConfig) {
|
|
81
|
+
_context.next = 15;
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
return _context.abrupt("return");
|
|
85
|
+
case 15:
|
|
86
|
+
pickerFacadeConfig = {
|
|
87
|
+
mediaClientConfig: resolvedMediaClientConfig,
|
|
88
|
+
errorReporter: mediaState.options.errorReporter || new _utils.ErrorReporter(),
|
|
89
|
+
featureFlags: mediaState.mediaOptions && mediaState.mediaOptions.featureFlags
|
|
90
|
+
};
|
|
91
|
+
_context.next = 18;
|
|
92
|
+
return new _pickerFacade.default('customMediaPicker', pickerFacadeConfig, dummyMediaPickerObject, analyticsName).init();
|
|
93
|
+
case 18:
|
|
94
|
+
pickerFacadeInstance = _context.sent;
|
|
95
|
+
pickerFacadeInstance.onNewMedia(mediaState.insertFile);
|
|
96
|
+
pickerFacadeInstance.setUploadParams(mediaProvider.uploadParams);
|
|
97
|
+
config = {
|
|
98
|
+
uploadParams: mediaProvider.uploadParams
|
|
99
|
+
};
|
|
100
|
+
(0, _reactDom.flushSync)(function () {
|
|
101
|
+
setState({
|
|
102
|
+
pickerFacadeInstance: pickerFacadeInstance,
|
|
103
|
+
config: config,
|
|
104
|
+
mediaClientConfig: resolvedMediaClientConfig
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
case 23:
|
|
108
|
+
case "end":
|
|
109
|
+
return _context.stop();
|
|
110
|
+
}
|
|
111
|
+
}, _callee);
|
|
112
|
+
}));
|
|
113
|
+
return function (_x, _x2) {
|
|
114
|
+
return _ref2.apply(this, arguments);
|
|
115
|
+
};
|
|
116
|
+
}(), [analyticsName, mediaState.insertFile, mediaState.mediaOptions, mediaState.options.errorReporter]);
|
|
117
|
+
(0, _react.useEffect)(function () {
|
|
118
|
+
if (mediaProvider) {
|
|
119
|
+
handleMediaProvider('mediaProvider', Promise.resolve(mediaProvider));
|
|
120
|
+
}
|
|
121
|
+
}, [mediaProvider, handleMediaProvider]);
|
|
122
|
+
var mediaClientConfig = state.mediaClientConfig,
|
|
123
|
+
config = state.config,
|
|
124
|
+
pickerFacadeInstance = state.pickerFacadeInstance;
|
|
125
|
+
if (!mediaClientConfig || !config || !pickerFacadeInstance) {
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
return children({
|
|
129
|
+
mediaClientConfig: mediaClientConfig,
|
|
130
|
+
config: config,
|
|
131
|
+
pickerFacadeInstance: pickerFacadeInstance
|
|
132
|
+
});
|
|
133
|
+
}
|
|
31
134
|
|
|
32
|
-
//eslint-disable-next-line @repo/internal/react/no-class-components
|
|
33
|
-
var
|
|
34
|
-
(0, _inherits2.default)(
|
|
35
|
-
var _super = _createSuper(
|
|
36
|
-
function
|
|
135
|
+
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
136
|
+
var PickerFacadeProviderOld = /*#__PURE__*/function (_React$Component) {
|
|
137
|
+
(0, _inherits2.default)(PickerFacadeProviderOld, _React$Component);
|
|
138
|
+
var _super = _createSuper(PickerFacadeProviderOld);
|
|
139
|
+
function PickerFacadeProviderOld() {
|
|
37
140
|
var _this;
|
|
38
|
-
(0, _classCallCheck2.default)(this,
|
|
141
|
+
(0, _classCallCheck2.default)(this, PickerFacadeProviderOld);
|
|
39
142
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
40
143
|
args[_key] = arguments[_key];
|
|
41
144
|
}
|
|
42
145
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
43
146
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "state", {});
|
|
44
147
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleMediaProvider", /*#__PURE__*/function () {
|
|
45
|
-
var
|
|
148
|
+
var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(_name, provider) {
|
|
46
149
|
var _this$props, mediaState, analyticsName, mediaProvider, resolvedMediaClientConfig, pickerFacadeConfig, pickerFacadeInstance, config;
|
|
47
|
-
return _regenerator.default.wrap(function
|
|
48
|
-
while (1) switch (
|
|
150
|
+
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
151
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
49
152
|
case 0:
|
|
50
153
|
_this$props = _this.props, mediaState = _this$props.mediaState, analyticsName = _this$props.analyticsName;
|
|
51
|
-
|
|
154
|
+
_context2.next = 3;
|
|
52
155
|
return provider;
|
|
53
156
|
case 3:
|
|
54
|
-
mediaProvider =
|
|
157
|
+
mediaProvider = _context2.sent;
|
|
55
158
|
if (!(!mediaProvider || !mediaProvider.uploadParams)) {
|
|
56
|
-
|
|
159
|
+
_context2.next = 6;
|
|
57
160
|
break;
|
|
58
161
|
}
|
|
59
|
-
return
|
|
162
|
+
return _context2.abrupt("return");
|
|
60
163
|
case 6:
|
|
61
|
-
|
|
164
|
+
_context2.next = 8;
|
|
62
165
|
return mediaProvider.uploadMediaClientConfig;
|
|
63
166
|
case 8:
|
|
64
|
-
|
|
65
|
-
if (
|
|
66
|
-
|
|
167
|
+
_context2.t0 = _context2.sent;
|
|
168
|
+
if (_context2.t0) {
|
|
169
|
+
_context2.next = 13;
|
|
67
170
|
break;
|
|
68
171
|
}
|
|
69
|
-
|
|
172
|
+
_context2.next = 12;
|
|
70
173
|
return mediaProvider.viewMediaClientConfig;
|
|
71
174
|
case 12:
|
|
72
|
-
|
|
175
|
+
_context2.t0 = _context2.sent;
|
|
73
176
|
case 13:
|
|
74
|
-
resolvedMediaClientConfig =
|
|
177
|
+
resolvedMediaClientConfig = _context2.t0;
|
|
75
178
|
if (resolvedMediaClientConfig) {
|
|
76
|
-
|
|
179
|
+
_context2.next = 16;
|
|
77
180
|
break;
|
|
78
181
|
}
|
|
79
|
-
return
|
|
182
|
+
return _context2.abrupt("return");
|
|
80
183
|
case 16:
|
|
81
184
|
pickerFacadeConfig = {
|
|
82
185
|
mediaClientConfig: resolvedMediaClientConfig,
|
|
@@ -91,10 +194,10 @@ var PickerFacadeProvider = exports.default = /*#__PURE__*/function (_React$Compo
|
|
|
91
194
|
* But we don't want this to do anything since it's all part of the new React component (`Clipboard` component in this case).
|
|
92
195
|
* Eventually PickerFacade will be removed and replaced with a new abstraction explained here https://product-fabric.atlassian.net/browse/MS-1937
|
|
93
196
|
*/
|
|
94
|
-
|
|
197
|
+
_context2.next = 19;
|
|
95
198
|
return new _pickerFacade.default('customMediaPicker', pickerFacadeConfig, dummyMediaPickerObject, analyticsName).init();
|
|
96
199
|
case 19:
|
|
97
|
-
pickerFacadeInstance =
|
|
200
|
+
pickerFacadeInstance = _context2.sent;
|
|
98
201
|
/**
|
|
99
202
|
* Based on the `initPickers` method in `MediaPluginState` we need these 2 `onNewMedia` subscriptions.
|
|
100
203
|
* First one in order to trigger the entire process of uploading a file for when `onPreviewUpdate` is called
|
|
@@ -114,17 +217,17 @@ var PickerFacadeProvider = exports.default = /*#__PURE__*/function (_React$Compo
|
|
|
114
217
|
});
|
|
115
218
|
case 24:
|
|
116
219
|
case "end":
|
|
117
|
-
return
|
|
220
|
+
return _context2.stop();
|
|
118
221
|
}
|
|
119
|
-
},
|
|
222
|
+
}, _callee2);
|
|
120
223
|
}));
|
|
121
|
-
return function (
|
|
122
|
-
return
|
|
224
|
+
return function (_x3, _x4) {
|
|
225
|
+
return _ref3.apply(this, arguments);
|
|
123
226
|
};
|
|
124
227
|
}());
|
|
125
228
|
return _this;
|
|
126
229
|
}
|
|
127
|
-
(0, _createClass2.default)(
|
|
230
|
+
(0, _createClass2.default)(PickerFacadeProviderOld, [{
|
|
128
231
|
key: "componentDidMount",
|
|
129
232
|
value: function componentDidMount() {
|
|
130
233
|
var mediaProvider = this.props.mediaState.mediaProvider;
|
|
@@ -156,5 +259,8 @@ var PickerFacadeProvider = exports.default = /*#__PURE__*/function (_React$Compo
|
|
|
156
259
|
});
|
|
157
260
|
}
|
|
158
261
|
}]);
|
|
159
|
-
return
|
|
160
|
-
}(_react.default.Component);
|
|
262
|
+
return PickerFacadeProviderOld;
|
|
263
|
+
}(_react.default.Component);
|
|
264
|
+
function PickerFacadeProvider(props) {
|
|
265
|
+
return (0, _platformFeatureFlags.fg)('platform_editor_media_provider_from_plugin_config') ? /*#__PURE__*/_react.default.createElement(PickerFacadeProviderNew, props) : /*#__PURE__*/_react.default.createElement(PickerFacadeProviderOld, props);
|
|
266
|
+
}
|
|
@@ -15,7 +15,10 @@ var _isType = require("../../utils/is-type");
|
|
|
15
15
|
var _PortalWrapper = require("./PortalWrapper");
|
|
16
16
|
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); }
|
|
17
17
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(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 && Object.prototype.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; }
|
|
18
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* @jsxRuntime classic
|
|
20
|
+
* @jsx jsx
|
|
21
|
+
*/
|
|
19
22
|
|
|
20
23
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
21
24
|
|
|
@@ -19,7 +19,10 @@ var _constants = require("./constants");
|
|
|
19
19
|
var _styles = require("./styles");
|
|
20
20
|
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); }
|
|
21
21
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(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 && Object.prototype.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; }
|
|
22
|
-
/**
|
|
22
|
+
/**
|
|
23
|
+
* @jsxRuntime classic
|
|
24
|
+
* @jsx jsx
|
|
25
|
+
*/
|
|
23
26
|
|
|
24
27
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
25
28
|
|
|
@@ -6,7 +6,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.ResizableMediaMigrationNotification = void 0;
|
|
7
7
|
var _react = require("@emotion/react");
|
|
8
8
|
var _styles = require("./styles");
|
|
9
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* @jsxRuntime classic
|
|
11
|
+
* @jsx jsx
|
|
12
|
+
*/
|
|
10
13
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
11
14
|
|
|
12
15
|
var ResizableMediaMigrationNotification = exports.ResizableMediaMigrationNotification = function ResizableMediaMigrationNotification() {
|
|
@@ -34,7 +34,10 @@ var _checkMediaType = require("../../utils/check-media-type");
|
|
|
34
34
|
var _ResizableMediaMigrationNotification = require("./ResizableMediaMigrationNotification");
|
|
35
35
|
var _styled = require("./styled");
|
|
36
36
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
37
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } /**
|
|
37
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } /**
|
|
38
|
+
* @jsxRuntime classic
|
|
39
|
+
* @jsx jsx
|
|
40
|
+
*/ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
38
41
|
var resizerNextTestId = exports.resizerNextTestId = 'mediaSingle.resizerNext.testid';
|
|
39
42
|
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
40
43
|
var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
@@ -25,7 +25,10 @@ var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
|
25
25
|
var _checkMediaType = require("../../utils/check-media-type");
|
|
26
26
|
var _styled = require("./styled");
|
|
27
27
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
28
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } /**
|
|
28
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } /**
|
|
29
|
+
* @jsxRuntime classic
|
|
30
|
+
* @jsx jsx
|
|
31
|
+
*/ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
29
32
|
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
30
33
|
var ResizableMediaSingle = exports.default = /*#__PURE__*/function (_React$Component) {
|
|
31
34
|
(0, _inherits2.default)(ResizableMediaSingle, _React$Component);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
3
|
+
export const useMediaProvider = pluginInjectionApi => {
|
|
4
|
+
const {
|
|
5
|
+
mediaState
|
|
6
|
+
} = useSharedPluginState(pluginInjectionApi, ['media']);
|
|
7
|
+
const provider = useMemo(() => {
|
|
8
|
+
return mediaState === null || mediaState === void 0 ? void 0 : mediaState.mediaProvider;
|
|
9
|
+
}, [mediaState === null || mediaState === void 0 ? void 0 : mediaState.mediaProvider]);
|
|
10
|
+
return provider;
|
|
11
|
+
};
|
|
@@ -9,6 +9,8 @@ import { isNodeSelectedOrInRange, SelectedState, setNodeSelection } from '@atlas
|
|
|
9
9
|
import EditorCloseIcon from '@atlaskit/icon/glyph/editor/close';
|
|
10
10
|
import { getMediaFeatureFlag } from '@atlaskit/media-common';
|
|
11
11
|
import { Filmstrip } from '@atlaskit/media-filmstrip';
|
|
12
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
13
|
+
import { useMediaProvider } from '../hooks/useMediaProvider';
|
|
12
14
|
import { stateKey as mediaStateKey } from '../pm-plugins/plugin-key';
|
|
13
15
|
import { MediaNodeUpdater } from './mediaNodeUpdater';
|
|
14
16
|
const isMediaGroupSelectedFromProps = props => {
|
|
@@ -259,9 +261,11 @@ function MediaGroupNodeViewInternal({
|
|
|
259
261
|
editorDisabledState: editorDisabledPlugin,
|
|
260
262
|
editorViewModeState: editorViewModePlugin
|
|
261
263
|
} = useSharedPluginState(pluginInjectionApi, ['editorDisabled', 'editorViewMode']);
|
|
264
|
+
const mediaProvider = useMediaProvider(pluginInjectionApi);
|
|
262
265
|
return renderFn({
|
|
263
266
|
editorDisabledPlugin,
|
|
264
|
-
editorViewModePlugin
|
|
267
|
+
editorViewModePlugin,
|
|
268
|
+
mediaProvider
|
|
265
269
|
});
|
|
266
270
|
}
|
|
267
271
|
class MediaGroupNodeView extends ReactNodeView {
|
|
@@ -272,7 +276,10 @@ class MediaGroupNodeView extends ReactNodeView {
|
|
|
272
276
|
pluginInjectionApi
|
|
273
277
|
} = props;
|
|
274
278
|
const getPos = this.getPos;
|
|
275
|
-
return /*#__PURE__*/React.createElement(WithProviders
|
|
279
|
+
return /*#__PURE__*/React.createElement(WithProviders
|
|
280
|
+
// Cleanup: `platform_editor_media_provider_from_plugin_config`
|
|
281
|
+
// Remove `mediaProvider`
|
|
282
|
+
, {
|
|
276
283
|
providers: ['mediaProvider', 'contextIdentifierProvider'],
|
|
277
284
|
providerFactory: providerFactory,
|
|
278
285
|
renderNode: ({
|
|
@@ -281,8 +288,30 @@ class MediaGroupNodeView extends ReactNodeView {
|
|
|
281
288
|
}) => {
|
|
282
289
|
const renderFn = ({
|
|
283
290
|
editorDisabledPlugin,
|
|
284
|
-
editorViewModePlugin
|
|
291
|
+
editorViewModePlugin,
|
|
292
|
+
mediaProvider: mediaProviderFromState
|
|
285
293
|
}) => {
|
|
294
|
+
if (fg('platform_editor_media_provider_from_plugin_config')) {
|
|
295
|
+
const newMediaProvider = mediaProviderFromState ? Promise.resolve(mediaProviderFromState) : undefined;
|
|
296
|
+
if (!newMediaProvider) {
|
|
297
|
+
return null;
|
|
298
|
+
}
|
|
299
|
+
return /*#__PURE__*/React.createElement(IntlMediaGroup, {
|
|
300
|
+
node: this.node,
|
|
301
|
+
getPos: getPos,
|
|
302
|
+
view: this.view,
|
|
303
|
+
forwardRef: forwardRef,
|
|
304
|
+
disabled: (editorDisabledPlugin || {}).editorDisabled,
|
|
305
|
+
allowLazyLoading: mediaOptions.allowLazyLoading,
|
|
306
|
+
mediaProvider: newMediaProvider,
|
|
307
|
+
contextIdentifierProvider: contextIdentifierProvider,
|
|
308
|
+
isCopyPasteEnabled: mediaOptions.isCopyPasteEnabled,
|
|
309
|
+
anchorPos: this.view.state.selection.$anchor.pos,
|
|
310
|
+
headPos: this.view.state.selection.$head.pos,
|
|
311
|
+
mediaOptions: mediaOptions,
|
|
312
|
+
editorViewMode: (editorViewModePlugin === null || editorViewModePlugin === void 0 ? void 0 : editorViewModePlugin.mode) === 'view'
|
|
313
|
+
});
|
|
314
|
+
}
|
|
286
315
|
if (!mediaProvider) {
|
|
287
316
|
return null;
|
|
288
317
|
}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @jsxRuntime classic
|
|
3
|
+
* @jsx jsx
|
|
4
|
+
*/
|
|
5
|
+
import { useEffect, useMemo, useState } from 'react';
|
|
3
6
|
|
|
4
7
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
5
8
|
import { jsx } from '@emotion/react';
|
|
@@ -10,6 +13,7 @@ import { SelectionBasedNodeView } from '@atlaskit/editor-common/selection-based-
|
|
|
10
13
|
import { MediaInlineCard } from '@atlaskit/media-card';
|
|
11
14
|
import { getMediaClient } from '@atlaskit/media-client-react';
|
|
12
15
|
import { MediaInlineCardLoadingView } from '@atlaskit/media-ui';
|
|
16
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
13
17
|
import { MediaViewerContainer } from '../ui/MediaViewer/MediaViewerContainer';
|
|
14
18
|
import { isImage } from '../utils/is-type';
|
|
15
19
|
import { MediaNodeUpdater } from './mediaNodeUpdater';
|
|
@@ -159,7 +163,24 @@ const MediaInlineSharedState = ({
|
|
|
159
163
|
editorViewModeState,
|
|
160
164
|
mediaState
|
|
161
165
|
} = useSharedPluginState(api, ['editorViewMode', 'media']);
|
|
162
|
-
|
|
166
|
+
const newMediaProvider = useMemo(() => mediaState !== null && mediaState !== void 0 && mediaState.mediaProvider ? Promise.resolve(mediaState === null || mediaState === void 0 ? void 0 : mediaState.mediaProvider) : undefined, [mediaState === null || mediaState === void 0 ? void 0 : mediaState.mediaProvider]);
|
|
167
|
+
if (fg('platform_editor_media_provider_from_plugin_config')) {
|
|
168
|
+
if (!mediaState || !newMediaProvider) {
|
|
169
|
+
return null;
|
|
170
|
+
}
|
|
171
|
+
return jsx(MediaInline, {
|
|
172
|
+
identifier: identifier,
|
|
173
|
+
mediaProvider: newMediaProvider,
|
|
174
|
+
mediaPluginState: mediaState,
|
|
175
|
+
node: node,
|
|
176
|
+
isSelected: isSelected,
|
|
177
|
+
view: view,
|
|
178
|
+
getPos: getPos,
|
|
179
|
+
contextIdentifierProvider: contextIdentifierProvider,
|
|
180
|
+
editorViewMode: (editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'view'
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
if (!mediaState || !mediaProvider) {
|
|
163
184
|
return null;
|
|
164
185
|
}
|
|
165
186
|
return jsx(MediaInline, {
|
|
@@ -198,14 +219,17 @@ export class MediaInlineNodeView extends SelectionBasedNodeView {
|
|
|
198
219
|
view
|
|
199
220
|
} = this;
|
|
200
221
|
const getPos = this.getPos;
|
|
201
|
-
return jsx(WithProviders
|
|
222
|
+
return jsx(WithProviders
|
|
223
|
+
// Cleanup: `platform_editor_media_provider_from_plugin_config`
|
|
224
|
+
// Remove `mediaProvider`
|
|
225
|
+
, {
|
|
202
226
|
providers: ['mediaProvider', 'contextIdentifierProvider'],
|
|
203
227
|
providerFactory: providerFactory,
|
|
204
228
|
renderNode: ({
|
|
205
229
|
mediaProvider,
|
|
206
230
|
contextIdentifierProvider
|
|
207
231
|
}) => {
|
|
208
|
-
if (!mediaProvider) {
|
|
232
|
+
if (!mediaProvider && !fg('platform_editor_media_provider_from_plugin_config')) {
|
|
209
233
|
return null;
|
|
210
234
|
}
|
|
211
235
|
return jsx(MediaInlineSharedState, {
|
|
@@ -5,6 +5,7 @@ import { DEFAULT_IMAGE_HEIGHT, DEFAULT_IMAGE_WIDTH } from '@atlaskit/editor-comm
|
|
|
5
5
|
import { WithProviders } from '@atlaskit/editor-common/provider-factory';
|
|
6
6
|
import { SelectionBasedNodeView } from '@atlaskit/editor-common/selection-based-node-view';
|
|
7
7
|
import { getAttrsFromUrl } from '@atlaskit/media-client';
|
|
8
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
8
9
|
import { updateCurrentMediaNodeAttrs } from '../../commands/helpers';
|
|
9
10
|
import { isMediaBlobUrlFromAttrs } from '../../utils/media-common';
|
|
10
11
|
import MediaNode from './media';
|
|
@@ -13,10 +14,12 @@ const MediaNodeWithProviders = ({
|
|
|
13
14
|
innerComponent
|
|
14
15
|
}) => {
|
|
15
16
|
const {
|
|
16
|
-
widthState
|
|
17
|
-
|
|
17
|
+
widthState,
|
|
18
|
+
mediaState
|
|
19
|
+
} = useSharedPluginState(pluginInjectionApi, ['width', 'media']);
|
|
18
20
|
return innerComponent({
|
|
19
|
-
width: widthState
|
|
21
|
+
width: widthState,
|
|
22
|
+
newMediaProvider: mediaState !== null && mediaState !== void 0 && mediaState.mediaProvider ? Promise.resolve(mediaState === null || mediaState === void 0 ? void 0 : mediaState.mediaProvider) : undefined
|
|
20
23
|
});
|
|
21
24
|
};
|
|
22
25
|
function isMediaDecorationSpec(decoration) {
|
|
@@ -46,7 +49,8 @@ class MediaNodeView extends SelectionBasedNodeView {
|
|
|
46
49
|
});
|
|
47
50
|
_defineProperty(this, "renderMediaNodeWithState", (mediaProvider, contextIdentifierProvider) => {
|
|
48
51
|
return ({
|
|
49
|
-
width: editorWidth
|
|
52
|
+
width: editorWidth,
|
|
53
|
+
newMediaProvider
|
|
50
54
|
}) => {
|
|
51
55
|
const getPos = this.getPos;
|
|
52
56
|
const {
|
|
@@ -89,7 +93,7 @@ class MediaNodeView extends SelectionBasedNodeView {
|
|
|
89
93
|
originalDimensions: originalDimensions,
|
|
90
94
|
maxDimensions: maxDimensions,
|
|
91
95
|
url: url,
|
|
92
|
-
mediaProvider: mediaProvider,
|
|
96
|
+
mediaProvider: fg('platform_editor_media_provider_from_plugin_config') ? newMediaProvider : mediaProvider,
|
|
93
97
|
contextIdentifierProvider: contextIdentifierProvider,
|
|
94
98
|
mediaOptions: mediaOptions,
|
|
95
99
|
onExternalImageLoaded: this.onExternalImageLoaded
|
|
@@ -153,7 +157,10 @@ class MediaNodeView extends SelectionBasedNodeView {
|
|
|
153
157
|
const {
|
|
154
158
|
providerFactory
|
|
155
159
|
} = this.reactComponentProps;
|
|
156
|
-
return /*#__PURE__*/React.createElement(WithProviders
|
|
160
|
+
return /*#__PURE__*/React.createElement(WithProviders
|
|
161
|
+
// Cleanup: `platform_editor_media_provider_from_plugin_config`
|
|
162
|
+
// Remove `mediaProvider`
|
|
163
|
+
, {
|
|
157
164
|
providers: ['mediaProvider', 'contextIdentifierProvider'],
|
|
158
165
|
providerFactory: providerFactory,
|
|
159
166
|
renderNode: this.renderMediaNodeWithProviders
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* @jsxRuntime classic
|
|
5
|
+
* @jsx jsx
|
|
6
|
+
*/
|
|
4
7
|
|
|
5
|
-
import React, { Component, Fragment } from 'react';
|
|
8
|
+
import React, { Component, Fragment, useMemo } from 'react';
|
|
6
9
|
|
|
7
10
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
8
11
|
import { css, jsx } from '@emotion/react';
|
|
@@ -423,12 +426,13 @@ const MediaSingleNodeWrapper = ({
|
|
|
423
426
|
editorDisabledState,
|
|
424
427
|
editorViewModeState
|
|
425
428
|
} = useSharedPluginState(pluginInjectionApi, ['width', 'media', 'annotation', 'editorDisabled', 'editorViewMode']);
|
|
429
|
+
const newMediaProvider = useMemo(() => mediaState !== null && mediaState !== void 0 && mediaState.mediaProvider ? Promise.resolve(mediaState === null || mediaState === void 0 ? void 0 : mediaState.mediaProvider) : undefined, [mediaState === null || mediaState === void 0 ? void 0 : mediaState.mediaProvider]);
|
|
426
430
|
return jsx(MediaSingleNode, {
|
|
427
431
|
width: widthState.width,
|
|
428
432
|
lineLength: widthState.lineLength,
|
|
429
433
|
node: node,
|
|
430
434
|
getPos: getPos,
|
|
431
|
-
mediaProvider: mediaProvider,
|
|
435
|
+
mediaProvider: fg('platform_editor_media_provider_from_plugin_config') ? newMediaProvider : mediaProvider,
|
|
432
436
|
contextIdentifierProvider: contextIdentifierProvider,
|
|
433
437
|
mediaOptions: mediaOptions,
|
|
434
438
|
view: view,
|
|
@@ -546,7 +550,10 @@ class MediaSingleNodeView extends ReactNodeView {
|
|
|
546
550
|
|
|
547
551
|
// getPos is a boolean for marks, since this is a node we know it must be a function
|
|
548
552
|
const getPos = this.getPos;
|
|
549
|
-
return jsx(WithProviders
|
|
553
|
+
return jsx(WithProviders
|
|
554
|
+
// Cleanup: `platform_editor_media_provider_from_plugin_config`
|
|
555
|
+
// Remove `mediaProvider`
|
|
556
|
+
, {
|
|
550
557
|
providers: ['mediaProvider', 'contextIdentifierProvider'],
|
|
551
558
|
providerFactory: providerFactory,
|
|
552
559
|
renderNode: ({
|
package/dist/es2019/plugin.js
CHANGED
|
@@ -59,6 +59,14 @@ export const mediaPlugin = ({
|
|
|
59
59
|
insertMediaAsMediaSingle: (view, node, inputMethod) => {
|
|
60
60
|
var _api$analytics;
|
|
61
61
|
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);
|
|
62
|
+
},
|
|
63
|
+
setProvider: provider => {
|
|
64
|
+
var _api$core$actions$exe;
|
|
65
|
+
return (_api$core$actions$exe = api === null || api === void 0 ? void 0 : api.core.actions.execute(({
|
|
66
|
+
tr
|
|
67
|
+
}) => tr.setMeta(stateKey, {
|
|
68
|
+
mediaProvider: provider
|
|
69
|
+
}))) !== null && _api$core$actions$exe !== void 0 ? _api$core$actions$exe : false;
|
|
62
70
|
}
|
|
63
71
|
},
|
|
64
72
|
nodes() {
|
|
@@ -445,8 +445,10 @@ export class MediaPluginStateImplementation {
|
|
|
445
445
|
nodes
|
|
446
446
|
} = _state.schema;
|
|
447
447
|
assert(nodes.media && (nodes.mediaGroup || nodes.mediaSingle), 'Editor: unable to init media plugin - media or mediaGroup/mediaSingle node absent in schema');
|
|
448
|
-
if (
|
|
449
|
-
|
|
448
|
+
if (fg('platform_editor_media_provider_from_plugin_config')) {
|
|
449
|
+
if (mediaOptions !== null && mediaOptions !== void 0 && mediaOptions.provider) {
|
|
450
|
+
this.setMediaProvider(mediaOptions === null || mediaOptions === void 0 ? void 0 : mediaOptions.provider);
|
|
451
|
+
}
|
|
450
452
|
} else {
|
|
451
453
|
options.providerFactory.subscribe('mediaProvider', (_name, provider) => this.setMediaProvider(provider));
|
|
452
454
|
}
|
|
@@ -617,8 +619,10 @@ export const createPlugin = (_schema, options, reactContext, getIntl, pluginInje
|
|
|
617
619
|
return new MediaPluginStateImplementation(state, options, mediaOptions, newInsertionBehaviour, dispatch, pluginInjectionApi);
|
|
618
620
|
},
|
|
619
621
|
apply(tr, pluginState) {
|
|
622
|
+
var _tr$getMeta;
|
|
620
623
|
const isResizing = tr.getMeta(MEDIA_PLUGIN_IS_RESIZING_KEY);
|
|
621
624
|
const resizingWidth = tr.getMeta(MEDIA_PLUGIN_RESIZING_WIDTH_KEY);
|
|
625
|
+
const mediaProvider = (_tr$getMeta = tr.getMeta(stateKey)) === null || _tr$getMeta === void 0 ? void 0 : _tr$getMeta.mediaProvider;
|
|
622
626
|
// Yes, I agree with you; this approach, using the clone() fuction, below is horrifying.
|
|
623
627
|
// However, we needed to implement this workaround to solve the singleton Media PluginState.
|
|
624
628
|
// The entire PluginInjectionAPI relies on the following axiom: "A PluginState that reflects a new EditorState.". We can not have the mutable singleton instance for all EditorState.
|
|
@@ -628,6 +632,9 @@ export const createPlugin = (_schema, options, reactContext, getIntl, pluginInje
|
|
|
628
632
|
pluginState.setIsResizing(isResizing);
|
|
629
633
|
nextPluginState = nextPluginState.clone();
|
|
630
634
|
}
|
|
635
|
+
if (mediaProvider && fg('platform_editor_media_provider_from_plugin_config')) {
|
|
636
|
+
pluginState.setMediaProvider(mediaProvider);
|
|
637
|
+
}
|
|
631
638
|
if (resizingWidth) {
|
|
632
639
|
pluginState.setResizingWidth(resizingWidth);
|
|
633
640
|
nextPluginState = nextPluginState.clone();
|