@atlaskit/editor-plugin-media 24.0.9 → 24.1.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 +25 -0
- package/dist/cjs/mediaPlugin.js +5 -9
- package/dist/cjs/nodeviews/mediaGroupNext.js +4 -8
- package/dist/cjs/pm-plugins/main.js +66 -43
- package/dist/cjs/pm-plugins/utils/media-inline.js +3 -12
- package/dist/cjs/ui/toolbar/index.js +10 -26
- package/dist/es2019/mediaPlugin.js +2 -6
- package/dist/es2019/nodeviews/mediaGroupNext.js +4 -8
- package/dist/es2019/pm-plugins/main.js +33 -22
- package/dist/es2019/pm-plugins/utils/media-inline.js +3 -12
- package/dist/es2019/ui/toolbar/index.js +8 -26
- package/dist/esm/mediaPlugin.js +2 -6
- package/dist/esm/nodeviews/mediaGroupNext.js +4 -8
- package/dist/esm/pm-plugins/main.js +63 -40
- package/dist/esm/pm-plugins/utils/media-inline.js +3 -12
- package/dist/esm/ui/toolbar/index.js +8 -24
- package/dist/types/pm-plugins/main.d.ts +1 -0
- package/dist/types/pm-plugins/types.d.ts +2 -0
- package/package.json +1 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-media
|
|
2
2
|
|
|
3
|
+
## 24.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`051cd10867eae`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/051cd10867eae) -
|
|
8
|
+
Expose uploadStatus and mentionProviderStatus to distinguish pending providers from unavailable
|
|
9
|
+
capabilities. Under platform_editor_ssr_toolbar_optimistic, keep mention and media toolbar buttons
|
|
10
|
+
enabled while providers are pending, avoiding class changes on successful initialization while
|
|
11
|
+
preserving existing insertion restrictions.
|
|
12
|
+
|
|
13
|
+
When a view-only synchronous SSR media provider accompanies a pending full provider, keep uploads
|
|
14
|
+
pending until the full provider resolves instead of treating the SSR config as a permission
|
|
15
|
+
denial.
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Updated dependencies
|
|
20
|
+
|
|
21
|
+
## 24.0.10
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- [`b67e12494653e`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/b67e12494653e) -
|
|
26
|
+
Clean up feature gate `platform_editor_remove_media_inline_feature_flag`
|
|
27
|
+
|
|
3
28
|
## 24.0.9
|
|
4
29
|
|
|
5
30
|
### Patch Changes
|
package/dist/cjs/mediaPlugin.js
CHANGED
|
@@ -15,9 +15,7 @@ var _quickInsert = require("@atlaskit/editor-common/quick-insert");
|
|
|
15
15
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
16
16
|
var _toolbarFlagCheck = require("@atlaskit/editor-common/toolbar-flag-check");
|
|
17
17
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
18
|
-
var _mediaCommon = require("@atlaskit/media-common");
|
|
19
18
|
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
20
|
-
var _fg = require("@atlaskit/platform-feature-flags/fg");
|
|
21
19
|
var _lazyMediaGroup = require("./nodeviews/lazy-media-group");
|
|
22
20
|
var _lazyMediaInline = require("./nodeviews/lazy-media-inline");
|
|
23
21
|
var _mediaNodeView = require("./nodeviews/mediaNodeView");
|
|
@@ -37,7 +35,7 @@ var _keymap3 = _interopRequireDefault(require("./pm-plugins/linking/keymap"));
|
|
|
37
35
|
var _main = require("./pm-plugins/main");
|
|
38
36
|
var _pixelResizing = require("./pm-plugins/pixel-resizing");
|
|
39
37
|
var _pluginKey = require("./pm-plugins/plugin-key");
|
|
40
|
-
var
|
|
38
|
+
var _mediaCommon = require("./pm-plugins/utils/media-common");
|
|
41
39
|
var _mediaSingle3 = require("./pm-plugins/utils/media-single");
|
|
42
40
|
var _MediaPicker = require("./ui/MediaPicker");
|
|
43
41
|
var _PortalWrapper = require("./ui/MediaViewer/PortalWrapper");
|
|
@@ -92,8 +90,8 @@ var MediaViewerFunctionalComponent = function MediaViewerFunctionalComponent(_re
|
|
|
92
90
|
mediaClientConfig = _useSharedPluginState2.mediaClientConfig;
|
|
93
91
|
var mediaItems = (0, _react.useMemo)(function () {
|
|
94
92
|
if (isMediaViewerVisible) {
|
|
95
|
-
var mediaNodes = (0,
|
|
96
|
-
return (0,
|
|
93
|
+
var mediaNodes = (0, _mediaCommon.extractMediaNodes)(editorView.state.doc);
|
|
94
|
+
return (0, _mediaCommon.createMediaIdentifierArray)(mediaNodes);
|
|
97
95
|
}
|
|
98
96
|
// eslint-disable-next-line react-hooks/exhaustive-deps -- only update mediaItems once when media viewer is visible
|
|
99
97
|
}, [isMediaViewerVisible]);
|
|
@@ -195,9 +193,8 @@ var mediaPlugin = exports.mediaPlugin = function mediaPlugin(_ref3) {
|
|
|
195
193
|
_ref5$allowPixelResiz = _ref5.allowPixelResizing,
|
|
196
194
|
allowPixelResizing = _ref5$allowPixelResiz === void 0 ? false : _ref5$allowPixelResiz,
|
|
197
195
|
allowCaptions = _ref5.allowCaptions,
|
|
198
|
-
allowMediaInlineImages = _ref5.allowMediaInlineImages
|
|
199
|
-
|
|
200
|
-
var allowMediaInline = (0, _fg.fg)('platform_editor_remove_media_inline_feature_flag') ? allowMediaInlineImages : (0, _mediaCommon.getMediaFeatureFlag)('mediaInline', mediaFeatureFlags);
|
|
196
|
+
allowMediaInlineImages = _ref5.allowMediaInlineImages;
|
|
197
|
+
var allowMediaInline = allowMediaInlineImages;
|
|
201
198
|
var mediaSingleOption = {
|
|
202
199
|
withCaption: allowCaptions,
|
|
203
200
|
withExtendedWidthTypes: allowPixelResizing
|
|
@@ -407,7 +404,6 @@ var mediaPlugin = exports.mediaPlugin = function mediaPlugin(_ref3) {
|
|
|
407
404
|
var _api$editorViewMode;
|
|
408
405
|
return (0, _toolbar.floatingToolbar)(state, intl, {
|
|
409
406
|
providerFactory: providerFactory,
|
|
410
|
-
allowMediaInline: options && (0, _mediaCommon.getMediaFeatureFlag)('mediaInline', options.featureFlags),
|
|
411
407
|
allowResizing: options && options.allowResizing,
|
|
412
408
|
allowResizingInTables: options && options.allowResizingInTables,
|
|
413
409
|
allowCommentsOnMedia: options && options.allowCommentsOnMedia,
|
|
@@ -16,9 +16,7 @@ var _hooks = require("@atlaskit/editor-common/hooks");
|
|
|
16
16
|
var _media = require("@atlaskit/editor-common/media");
|
|
17
17
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
18
18
|
var _cross = _interopRequireDefault(require("@atlaskit/icon/core/cross"));
|
|
19
|
-
var _mediaCommon = require("@atlaskit/media-common");
|
|
20
19
|
var _mediaFilmstrip = require("@atlaskit/media-filmstrip");
|
|
21
|
-
var _fg = require("@atlaskit/platform-feature-flags/fg");
|
|
22
20
|
var _editorExperiment = require("@atlaskit/tmp-editor-statsig/editor-experiment");
|
|
23
21
|
var _pluginKey = require("../pm-plugins/plugin-key");
|
|
24
22
|
var _mediaNodeUpdater = require("./mediaNodeUpdater");
|
|
@@ -58,8 +56,7 @@ var prepareFilmstripItem = function prepareFilmstripItem(_ref) {
|
|
|
58
56
|
getPos = _ref.getPos,
|
|
59
57
|
intl = _ref.intl,
|
|
60
58
|
isMediaItemSelected = _ref.isMediaItemSelected,
|
|
61
|
-
setMediaGroupNodeSelection = _ref.setMediaGroupNodeSelection
|
|
62
|
-
featureFlags = _ref.featureFlags;
|
|
59
|
+
setMediaGroupNodeSelection = _ref.setMediaGroupNodeSelection;
|
|
63
60
|
return function (item, idx) {
|
|
64
61
|
// We declared this to get a fresh position every time
|
|
65
62
|
var getNodePos = function getNodePos() {
|
|
@@ -98,7 +95,7 @@ var prepareFilmstripItem = function prepareFilmstripItem(_ref) {
|
|
|
98
95
|
onClick: function onClick() {
|
|
99
96
|
setMediaGroupNodeSelection(getNodePos());
|
|
100
97
|
}
|
|
101
|
-
}, mediaInlineOptions(
|
|
98
|
+
}, mediaInlineOptions(allowMediaInlineImages));
|
|
102
99
|
};
|
|
103
100
|
};
|
|
104
101
|
|
|
@@ -234,10 +231,9 @@ var MediaGroupNext = exports.MediaGroupNext = (0, _reactIntl.injectIntl)( /*#__P
|
|
|
234
231
|
getPos: _getPos,
|
|
235
232
|
intl: intl,
|
|
236
233
|
isMediaItemSelected: isMediaItemSelected,
|
|
237
|
-
setMediaGroupNodeSelection: setMediaGroupNodeSelection
|
|
238
|
-
featureFlags: featureFlags
|
|
234
|
+
setMediaGroupNodeSelection: setMediaGroupNodeSelection
|
|
239
235
|
});
|
|
240
|
-
}, [allowLazyLoading, allowMediaInlineImages, enableDownloadButton, handleMediaNodeRemoval, _getPos, intl, isMediaItemSelected, setMediaGroupNodeSelection
|
|
236
|
+
}, [allowLazyLoading, allowMediaInlineImages, enableDownloadButton, handleMediaNodeRemoval, _getPos, intl, isMediaItemSelected, setMediaGroupNodeSelection]);
|
|
241
237
|
var items = (0, _react.useMemo)(function () {
|
|
242
238
|
return mediaNodesWithOffsets.map(function (_ref4) {
|
|
243
239
|
var node = _ref4.node,
|
|
@@ -18,7 +18,6 @@ var _uuid = require("uuid");
|
|
|
18
18
|
var _setAttrs = require("@atlaskit/adf-schema/steps/set-attrs");
|
|
19
19
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
20
20
|
var _browser = require("@atlaskit/editor-common/browser");
|
|
21
|
-
var _mediaInline = require("@atlaskit/editor-common/media-inline");
|
|
22
21
|
var _mediaSingle = require("@atlaskit/editor-common/media-single");
|
|
23
22
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
24
23
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
@@ -29,20 +28,20 @@ var _view3 = require("@atlaskit/editor-prosemirror/view");
|
|
|
29
28
|
var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
|
|
30
29
|
var _mediaClient = require("@atlaskit/media-client");
|
|
31
30
|
var _mediaCommon = require("@atlaskit/media-common");
|
|
32
|
-
var
|
|
31
|
+
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
33
32
|
var _mediaNodeUpdater = require("../nodeviews/mediaNodeUpdater");
|
|
34
33
|
var _helpers = _interopRequireWildcard(require("../pm-plugins/commands/helpers"));
|
|
35
34
|
var helpers = _helpers;
|
|
36
35
|
var _mediaCommon2 = require("../pm-plugins/utils/media-common");
|
|
37
36
|
var _mediaFiles = require("../pm-plugins/utils/media-files");
|
|
38
|
-
var
|
|
37
|
+
var _mediaInline = require("../pm-plugins/utils/media-inline");
|
|
39
38
|
var _mediaSingle2 = require("../pm-plugins/utils/media-single");
|
|
40
39
|
var _DropPlaceholder = _interopRequireDefault(require("../ui/Media/DropPlaceholder"));
|
|
41
40
|
var _actions = require("./actions");
|
|
42
41
|
var _mediaTaskManager = require("./mediaTaskManager");
|
|
43
42
|
var _pickerFacade = _interopRequireDefault(require("./picker-facade"));
|
|
44
43
|
var _pluginKey = require("./plugin-key");
|
|
45
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var
|
|
44
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t4 in e) "default" !== _t4 && {}.hasOwnProperty.call(e, _t4) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t4)) && (i.get || i.set) ? o(f, _t4, i) : f[_t4] = e[_t4]); return f; })(e, t); }
|
|
46
45
|
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
47
46
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
48
47
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
@@ -77,9 +76,11 @@ var createDropPlaceholder = function createDropPlaceholder(intl, nodeViewPortalP
|
|
|
77
76
|
var MEDIA_RESOLVED_STATES = ['ready', 'error', 'cancelled'];
|
|
78
77
|
var MediaPluginStateImplementation = exports.MediaPluginStateImplementation = /*#__PURE__*/function () {
|
|
79
78
|
function MediaPluginStateImplementation(_state, options, mediaOptions, _dispatch, pluginInjectionApi) {
|
|
80
|
-
var _this = this
|
|
79
|
+
var _this = this,
|
|
80
|
+
_this$mediaOptions2;
|
|
81
81
|
(0, _classCallCheck2.default)(this, MediaPluginStateImplementation);
|
|
82
82
|
(0, _defineProperty2.default)(this, "allowsUploads", false);
|
|
83
|
+
(0, _defineProperty2.default)(this, "uploadStatus", 'pending');
|
|
83
84
|
(0, _defineProperty2.default)(this, "ignoreLinks", false);
|
|
84
85
|
(0, _defineProperty2.default)(this, "waitForMediaUpload", true);
|
|
85
86
|
(0, _defineProperty2.default)(this, "allUploadsFinished", true);
|
|
@@ -289,7 +290,7 @@ var MediaPluginStateImplementation = exports.MediaPluginStateImplementation = /*
|
|
|
289
290
|
}
|
|
290
291
|
return;
|
|
291
292
|
}
|
|
292
|
-
switch ((0,
|
|
293
|
+
switch ((0, _mediaInline.getMediaNodeInsertionType)(state, _this.mediaOptions, mediaStateWithContext.fileMimeType)) {
|
|
293
294
|
case 'inline':
|
|
294
295
|
(0, _mediaFiles.insertMediaInlineNode)(editorAnalyticsAPI)(_this.view, mediaStateWithContext, collection, _this.allowInlineImages, _this.getInputMethod(pickerType), insertMediaVia);
|
|
295
296
|
break;
|
|
@@ -659,20 +660,20 @@ var MediaPluginStateImplementation = exports.MediaPluginStateImplementation = /*
|
|
|
659
660
|
var nodes = _state.schema.nodes;
|
|
660
661
|
(0, _assert.default)(nodes.media && (nodes.mediaGroup || nodes.mediaSingle), 'Editor: unable to init media plugin - media or mediaGroup/mediaSingle node absent in schema');
|
|
661
662
|
if (mediaOptions !== null && mediaOptions !== void 0 && mediaOptions.syncProvider) {
|
|
662
|
-
this.setMediaProvider(mediaOptions
|
|
663
|
+
this.setMediaProvider(mediaOptions.syncProvider);
|
|
664
|
+
if (mediaOptions.provider && (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_ssr_toolbar_optimistic')) {
|
|
665
|
+
// The synchronous SSR provider may only support viewing. Keep its view
|
|
666
|
+
// config, but wait for the full provider before deciding upload availability.
|
|
667
|
+
if (!this.allowsUploads) {
|
|
668
|
+
this.uploadStatus = 'pending';
|
|
669
|
+
}
|
|
670
|
+
this.setMediaProvider(mediaOptions.provider);
|
|
671
|
+
}
|
|
663
672
|
} else if (mediaOptions !== null && mediaOptions !== void 0 && mediaOptions.provider) {
|
|
664
673
|
this.setMediaProvider(mediaOptions === null || mediaOptions === void 0 ? void 0 : mediaOptions.provider);
|
|
665
674
|
}
|
|
666
|
-
if ((0
|
|
667
|
-
|
|
668
|
-
if ((_this$mediaOptions2 = this.mediaOptions) !== null && _this$mediaOptions2 !== void 0 && _this$mediaOptions2.allowMediaInlineImages) {
|
|
669
|
-
this.allowInlineImages = true;
|
|
670
|
-
}
|
|
671
|
-
} else {
|
|
672
|
-
var _this$mediaOptions3, _this$mediaOptions4;
|
|
673
|
-
if ((0, _mediaInline.mediaInlineImagesEnabled)((0, _mediaCommon.getMediaFeatureFlag)('mediaInline', (_this$mediaOptions3 = this.mediaOptions) === null || _this$mediaOptions3 === void 0 ? void 0 : _this$mediaOptions3.featureFlags), (_this$mediaOptions4 = this.mediaOptions) === null || _this$mediaOptions4 === void 0 ? void 0 : _this$mediaOptions4.allowMediaInlineImages)) {
|
|
674
|
-
this.allowInlineImages = true;
|
|
675
|
-
}
|
|
675
|
+
if ((_this$mediaOptions2 = this.mediaOptions) !== null && _this$mediaOptions2 !== void 0 && _this$mediaOptions2.allowMediaInlineImages) {
|
|
676
|
+
this.allowInlineImages = true;
|
|
676
677
|
}
|
|
677
678
|
this.errorReporter = options.errorReporter || new _utils.ErrorReporter();
|
|
678
679
|
this.singletonCreatedAt = (performance || Date).now();
|
|
@@ -715,11 +716,11 @@ var MediaPluginStateImplementation = exports.MediaPluginStateImplementation = /*
|
|
|
715
716
|
key: "setMediaProvider",
|
|
716
717
|
value: function () {
|
|
717
718
|
var _setMediaProvider = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(mediaProvider) {
|
|
718
|
-
var viewMediaClientConfig, wrappedError, view, allowsUploads, _t;
|
|
719
|
+
var resolvedProvider, viewMediaClientConfig, wrappedError, view, allowsUploads, _t, _t2;
|
|
719
720
|
return _regenerator.default.wrap(function (_context) {
|
|
720
721
|
while (1) switch (_context.prev = _context.next) {
|
|
721
722
|
case 0:
|
|
722
|
-
if (!(this.previousMediaProvider === mediaProvider)) {
|
|
723
|
+
if (!(this.previousMediaProvider === mediaProvider && !((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_ssr_toolbar_optimistic') && this.uploadStatus === 'pending' && !mediaProvider))) {
|
|
723
724
|
_context.next = 1;
|
|
724
725
|
break;
|
|
725
726
|
}
|
|
@@ -732,7 +733,8 @@ var MediaPluginStateImplementation = exports.MediaPluginStateImplementation = /*
|
|
|
732
733
|
}
|
|
733
734
|
this.destroyPickers();
|
|
734
735
|
this.allowsUploads = false;
|
|
735
|
-
|
|
736
|
+
this.uploadStatus = 'unavailable';
|
|
737
|
+
if (!this.destroyed && (this.view || !(0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_ssr_toolbar_optimistic'))) {
|
|
736
738
|
this.view.dispatch(this.view.state.tr.setMeta(_pluginKey.stateKey, {
|
|
737
739
|
allowsUploads: this.allowsUploads
|
|
738
740
|
}));
|
|
@@ -747,12 +749,21 @@ var MediaPluginStateImplementation = exports.MediaPluginStateImplementation = /*
|
|
|
747
749
|
_context.next = 3;
|
|
748
750
|
return mediaProvider;
|
|
749
751
|
case 3:
|
|
750
|
-
|
|
752
|
+
_t = _context.sent;
|
|
751
753
|
_context.next = 5;
|
|
752
754
|
break;
|
|
753
755
|
case 4:
|
|
754
|
-
|
|
756
|
+
_t = mediaProvider;
|
|
755
757
|
case 5:
|
|
758
|
+
resolvedProvider = _t;
|
|
759
|
+
if (!((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_ssr_toolbar_optimistic') && (this.destroyed || this.previousMediaProvider !== mediaProvider))) {
|
|
760
|
+
_context.next = 6;
|
|
761
|
+
break;
|
|
762
|
+
}
|
|
763
|
+
return _context.abrupt("return");
|
|
764
|
+
case 6:
|
|
765
|
+
this.mediaProvider = resolvedProvider;
|
|
766
|
+
|
|
756
767
|
// Ignored via go/ees007
|
|
757
768
|
// eslint-disable-next-line @atlaskit/editor/enforce-todo-comment-format
|
|
758
769
|
// TODO [MS-2038]: remove once context api is removed
|
|
@@ -765,24 +776,32 @@ var MediaPluginStateImplementation = exports.MediaPluginStateImplementation = /*
|
|
|
765
776
|
}
|
|
766
777
|
}
|
|
767
778
|
(0, _assert.default)(this.mediaProvider.viewMediaClientConfig, "MediaProvider promise did not resolve to a valid instance of MediaProvider - ".concat(this.mediaProvider));
|
|
768
|
-
_context.next =
|
|
779
|
+
_context.next = 9;
|
|
769
780
|
break;
|
|
770
|
-
case
|
|
771
|
-
_context.prev =
|
|
772
|
-
|
|
773
|
-
|
|
781
|
+
case 7:
|
|
782
|
+
_context.prev = 7;
|
|
783
|
+
_t2 = _context["catch"](2);
|
|
784
|
+
if (!((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_ssr_toolbar_optimistic') && (this.destroyed || this.previousMediaProvider !== mediaProvider))) {
|
|
785
|
+
_context.next = 8;
|
|
786
|
+
break;
|
|
787
|
+
}
|
|
788
|
+
return _context.abrupt("return");
|
|
789
|
+
case 8:
|
|
790
|
+
wrappedError = new Error("Media functionality disabled due to rejected provider: ".concat(_t2 instanceof Error ? _t2.message : String(_t2)));
|
|
774
791
|
this.errorReporter.captureException(wrappedError);
|
|
775
792
|
this.destroyPickers();
|
|
776
793
|
this.allowsUploads = false;
|
|
777
|
-
|
|
794
|
+
this.uploadStatus = 'unavailable';
|
|
795
|
+
if (!this.destroyed && (this.view || !(0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_ssr_toolbar_optimistic'))) {
|
|
778
796
|
this.view.dispatch(this.view.state.tr.setMeta(_pluginKey.stateKey, {
|
|
779
797
|
allowsUploads: this.allowsUploads
|
|
780
798
|
}));
|
|
781
799
|
}
|
|
782
800
|
return _context.abrupt("return");
|
|
783
|
-
case
|
|
801
|
+
case 9:
|
|
784
802
|
this.mediaClientConfig = this.mediaProvider.viewMediaClientConfig;
|
|
785
803
|
this.allowsUploads = !!this.mediaProvider.uploadMediaClientConfig;
|
|
804
|
+
this.uploadStatus = this.allowsUploads ? 'available' : 'unavailable';
|
|
786
805
|
view = this.view, allowsUploads = this.allowsUploads; // make sure editable DOM node is mounted
|
|
787
806
|
if (!this.destroyed && view && view.dom.parentNode) {
|
|
788
807
|
// make PM plugin aware of the state change to update UI during 'apply' hook
|
|
@@ -791,31 +810,31 @@ var MediaPluginStateImplementation = exports.MediaPluginStateImplementation = /*
|
|
|
791
810
|
}));
|
|
792
811
|
}
|
|
793
812
|
if (!this.allowsUploads) {
|
|
794
|
-
_context.next =
|
|
813
|
+
_context.next = 13;
|
|
795
814
|
break;
|
|
796
815
|
}
|
|
797
816
|
this.uploadMediaClientConfig = this.mediaProvider.uploadMediaClientConfig;
|
|
798
817
|
if (!(this.mediaProvider.uploadParams && this.uploadMediaClientConfig)) {
|
|
799
|
-
_context.next =
|
|
818
|
+
_context.next = 11;
|
|
800
819
|
break;
|
|
801
820
|
}
|
|
802
|
-
_context.next = 8;
|
|
803
|
-
return this.initPickers(this.mediaProvider.uploadParams, _pickerFacade.default);
|
|
804
|
-
case 8:
|
|
805
821
|
_context.next = 10;
|
|
806
|
-
|
|
807
|
-
case 9:
|
|
808
|
-
this.destroyPickers();
|
|
822
|
+
return this.initPickers(this.mediaProvider.uploadParams, _pickerFacade.default);
|
|
809
823
|
case 10:
|
|
810
824
|
_context.next = 12;
|
|
811
825
|
break;
|
|
812
826
|
case 11:
|
|
813
827
|
this.destroyPickers();
|
|
814
828
|
case 12:
|
|
829
|
+
_context.next = 14;
|
|
830
|
+
break;
|
|
831
|
+
case 13:
|
|
832
|
+
this.destroyPickers();
|
|
833
|
+
case 14:
|
|
815
834
|
case "end":
|
|
816
835
|
return _context.stop();
|
|
817
836
|
}
|
|
818
|
-
}, _callee, this, [[2,
|
|
837
|
+
}, _callee, this, [[2, 7]]);
|
|
819
838
|
}));
|
|
820
839
|
function setMediaProvider(_x) {
|
|
821
840
|
return _setMediaProvider.apply(this, arguments);
|
|
@@ -877,10 +896,10 @@ var MediaPluginStateImplementation = exports.MediaPluginStateImplementation = /*
|
|
|
877
896
|
}, {
|
|
878
897
|
key: "selectLastAddedMediaNode",
|
|
879
898
|
value: function selectLastAddedMediaNode() {
|
|
880
|
-
var _this$
|
|
899
|
+
var _this$mediaOptions3,
|
|
881
900
|
_this2 = this;
|
|
882
901
|
// if preventAutoFocusOnUpload is enabled, skip auto-selection and just clear the tracking array
|
|
883
|
-
if ((_this$
|
|
902
|
+
if ((_this$mediaOptions3 = this.mediaOptions) !== null && _this$mediaOptions3 !== void 0 && _this$mediaOptions3.preventAutoFocusOnUpload) {
|
|
884
903
|
this.lastAddedMediaSingleFileIds = [];
|
|
885
904
|
return;
|
|
886
905
|
}
|
|
@@ -915,6 +934,10 @@ var MediaPluginStateImplementation = exports.MediaPluginStateImplementation = /*
|
|
|
915
934
|
key: "setView",
|
|
916
935
|
value: function setView(view) {
|
|
917
936
|
this.view = view;
|
|
937
|
+
if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_ssr_toolbar_optimistic') && this.uploadStatus === 'pending' && !this.previousMediaProvider) {
|
|
938
|
+
// No provider was configured for this client editor. SSR has no view and stays pending.
|
|
939
|
+
this.uploadStatus = 'unavailable';
|
|
940
|
+
}
|
|
918
941
|
}
|
|
919
942
|
}, {
|
|
920
943
|
key: "destroy",
|
|
@@ -933,7 +956,7 @@ var MediaPluginStateImplementation = exports.MediaPluginStateImplementation = /*
|
|
|
933
956
|
value: function () {
|
|
934
957
|
var _initPickers = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(uploadParams, Picker) {
|
|
935
958
|
var _this3 = this;
|
|
936
|
-
var errorReporter, pickers, pickerPromises, pickerFacadeConfig, customPicker,
|
|
959
|
+
var errorReporter, pickers, pickerPromises, pickerFacadeConfig, customPicker, _t3;
|
|
937
960
|
return _regenerator.default.wrap(function (_context2) {
|
|
938
961
|
while (1) switch (_context2.prev = _context2.next) {
|
|
939
962
|
case 0:
|
|
@@ -958,11 +981,11 @@ var MediaPluginStateImplementation = exports.MediaPluginStateImplementation = /*
|
|
|
958
981
|
}
|
|
959
982
|
customPicker = new Picker('customMediaPicker', pickerFacadeConfig, this.options.customMediaPicker).init();
|
|
960
983
|
pickerPromises.push(customPicker);
|
|
961
|
-
|
|
984
|
+
_t3 = pickers;
|
|
962
985
|
_context2.next = 2;
|
|
963
986
|
return customPicker;
|
|
964
987
|
case 2:
|
|
965
|
-
|
|
988
|
+
_t3.push.call(_t3, this.customPicker = _context2.sent);
|
|
966
989
|
case 3:
|
|
967
990
|
pickers.forEach(function (picker) {
|
|
968
991
|
picker.onNewMedia(_this3.insertFile);
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.isInSupportedInlineImageParent = exports.getMediaNodeInsertionType = void 0;
|
|
7
|
-
var _mediaInline = require("@atlaskit/editor-common/media-inline");
|
|
8
7
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
9
8
|
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
10
9
|
var _mediaCommon = require("@atlaskit/media-common");
|
|
@@ -24,17 +23,9 @@ var getMediaNodeInsertionType = exports.getMediaNodeInsertionType = function get
|
|
|
24
23
|
return 'group';
|
|
25
24
|
}
|
|
26
25
|
var canInsertInlineNode = (0, _mediaCommon.getMediaFeatureFlag)('mediaInline', mediaOptions === null || mediaOptions === void 0 ? void 0 : mediaOptions.featureFlags) && !(0, _utils.isInEmptyLine)(state) && (!(0, _mediaCommon2.isInsidePotentialEmptyParagraph)(state) || isInSupportedInlineImageParent(state)) && (0, _mediaFiles.canInsertMediaInline)(state);
|
|
27
|
-
if (
|
|
28
|
-
if (
|
|
29
|
-
|
|
30
|
-
return 'inline';
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
} else {
|
|
34
|
-
if ((0, _mediaInline.mediaInlineImagesEnabled)((0, _mediaCommon.getMediaFeatureFlag)('mediaInline', mediaOptions === null || mediaOptions === void 0 ? void 0 : mediaOptions.featureFlags), mediaOptions === null || mediaOptions === void 0 ? void 0 : mediaOptions.allowMediaInlineImages)) {
|
|
35
|
-
if (canInsertInlineNode && !(0, _isType.isVideo)(fileMimeType)) {
|
|
36
|
-
return 'inline';
|
|
37
|
-
}
|
|
26
|
+
if (mediaOptions !== null && mediaOptions !== void 0 && mediaOptions.allowMediaInlineImages) {
|
|
27
|
+
if (canInsertInlineNode && !(0, _isType.isVideo)(fileMimeType)) {
|
|
28
|
+
return 'inline';
|
|
38
29
|
}
|
|
39
30
|
}
|
|
40
31
|
if ((0, _mediaSingle.isMediaSingle)(state.schema, fileMimeType)) {
|
|
@@ -13,7 +13,6 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
13
13
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
14
14
|
var _card = require("@atlaskit/editor-common/card");
|
|
15
15
|
var _editorAnalytics = require("@atlaskit/editor-common/editor-analytics");
|
|
16
|
-
var _mediaInline = require("@atlaskit/editor-common/media-inline");
|
|
17
16
|
var _messages = _interopRequireWildcard(require("@atlaskit/editor-common/messages"));
|
|
18
17
|
var _toolbarFlagCheck = require("@atlaskit/editor-common/toolbar-flag-check");
|
|
19
18
|
var _editorPluginConnectivity = require("@atlaskit/editor-plugin-connectivity");
|
|
@@ -51,7 +50,7 @@ var _imageBorder = require("./imageBorder");
|
|
|
51
50
|
var _layoutGroup = require("./layout-group");
|
|
52
51
|
var _linking3 = require("./linking");
|
|
53
52
|
var _linkingToolbarAppearance = require("./linking-toolbar-appearance");
|
|
54
|
-
var
|
|
53
|
+
var _mediaInline = require("./mediaInline");
|
|
55
54
|
var _pixelResizing2 = require("./pixel-resizing");
|
|
56
55
|
var _utils2 = require("./utils");
|
|
57
56
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
@@ -282,7 +281,6 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
282
281
|
allowCommentsOnMedia = options.allowCommentsOnMedia,
|
|
283
282
|
allowResizingInTables = options.allowResizingInTables,
|
|
284
283
|
allowAltTextOnImages = options.allowAltTextOnImages,
|
|
285
|
-
allowMediaInline = options.allowMediaInline,
|
|
286
284
|
allowMediaInlineImages = options.allowMediaInlineImages,
|
|
287
285
|
allowImageEditing = options.allowImageEditing,
|
|
288
286
|
allowImagePreview = options.allowImagePreview,
|
|
@@ -382,27 +380,14 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
382
380
|
}
|
|
383
381
|
}
|
|
384
382
|
};
|
|
385
|
-
if (
|
|
386
|
-
|
|
387
|
-
addLayoutDropdownToToolbar();
|
|
388
|
-
} else {
|
|
389
|
-
toolbarButtons = [].concat((0, _toConsumableArray2.default)(toolbarButtons), (0, _toConsumableArray2.default)(layoutButtons));
|
|
390
|
-
if (layoutButtons.length && !mauiToolbarSeparatorsUpdateEnabled) {
|
|
391
|
-
toolbarButtons.push({
|
|
392
|
-
type: 'separator'
|
|
393
|
-
});
|
|
394
|
-
}
|
|
395
|
-
}
|
|
383
|
+
if (allowMediaInlineImages && selectedNode) {
|
|
384
|
+
addLayoutDropdownToToolbar();
|
|
396
385
|
} else {
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
toolbarButtons.push({
|
|
403
|
-
type: 'separator'
|
|
404
|
-
});
|
|
405
|
-
}
|
|
386
|
+
toolbarButtons = [].concat((0, _toConsumableArray2.default)(toolbarButtons), (0, _toConsumableArray2.default)(layoutButtons));
|
|
387
|
+
if (layoutButtons.length && !mauiToolbarSeparatorsUpdateEnabled) {
|
|
388
|
+
toolbarButtons.push({
|
|
389
|
+
type: 'separator'
|
|
390
|
+
});
|
|
406
391
|
}
|
|
407
392
|
}
|
|
408
393
|
|
|
@@ -809,8 +794,7 @@ var floatingToolbar = exports.floatingToolbar = function floatingToolbar(state,
|
|
|
809
794
|
allowResizingInTables = options.allowResizingInTables,
|
|
810
795
|
allowAdvancedToolBarOptions = options.allowAdvancedToolBarOptions,
|
|
811
796
|
allowPixelResizing = options.allowPixelResizing;
|
|
812
|
-
var allowMediaInline =
|
|
813
|
-
allowMediaInline = (0, _fg.fg)('platform_editor_remove_media_inline_feature_flag') ? allowMediaInlineImages : allowMediaInline;
|
|
797
|
+
var allowMediaInline = allowMediaInlineImages;
|
|
814
798
|
var mediaPluginState = _pluginKey.stateKey.getState(state);
|
|
815
799
|
var mediaLinkingState = (0, _linking2.getMediaLinkingState)(state);
|
|
816
800
|
var _ref4 = (_pluginInjectionApi$d3 = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$d4 = pluginInjectionApi.decorations) === null || _pluginInjectionApi$d4 === void 0 ? void 0 : _pluginInjectionApi$d4.actions) !== null && _pluginInjectionApi$d3 !== void 0 ? _pluginInjectionApi$d3 : {},
|
|
@@ -887,7 +871,7 @@ var floatingToolbar = exports.floatingToolbar = function floatingToolbar(state,
|
|
|
887
871
|
};
|
|
888
872
|
items = generateMediaCardFloatingToolbar(state, intl, mediaPluginState, hoverDecoration, pluginInjectionApi, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a9 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a9 === void 0 ? void 0 : _pluginInjectionApi$a9.actions, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$f2 = pluginInjectionApi.floatingToolbar) === null || _pluginInjectionApi$f2 === void 0 || (_pluginInjectionApi$f2 = _pluginInjectionApi$f2.actions) === null || _pluginInjectionApi$f2 === void 0 ? void 0 : _pluginInjectionApi$f2.forceFocusSelector, isViewOnly);
|
|
889
873
|
} else if (allowMediaInline && selectedNodeType && selectedNodeType === mediaInline) {
|
|
890
|
-
items = (0,
|
|
874
|
+
items = (0, _mediaInline.generateMediaInlineFloatingToolbar)(state, intl, mediaPluginState, hoverDecoration, pluginInjectionApi, options);
|
|
891
875
|
} else {
|
|
892
876
|
baseToolbar.getDomRef = function () {
|
|
893
877
|
var _mediaPluginState$ele3;
|
|
@@ -6,9 +6,7 @@ import { IconImages } from '@atlaskit/editor-common/quick-insert';
|
|
|
6
6
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
7
7
|
import { areToolbarFlagsEnabled } from '@atlaskit/editor-common/toolbar-flag-check';
|
|
8
8
|
import { NodeSelection, PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
9
|
-
import { getMediaFeatureFlag } from '@atlaskit/media-common';
|
|
10
9
|
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
11
|
-
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
12
10
|
import { lazyMediaGroupView } from './nodeviews/lazy-media-group';
|
|
13
11
|
import { lazyMediaInlineView } from './nodeviews/lazy-media-inline';
|
|
14
12
|
import { ReactMediaNode } from './nodeviews/mediaNodeView';
|
|
@@ -183,10 +181,9 @@ export const mediaPlugin = ({
|
|
|
183
181
|
allowMediaSingle = false,
|
|
184
182
|
allowPixelResizing = false,
|
|
185
183
|
allowCaptions,
|
|
186
|
-
allowMediaInlineImages
|
|
187
|
-
featureFlags: mediaFeatureFlags
|
|
184
|
+
allowMediaInlineImages
|
|
188
185
|
} = options || {};
|
|
189
|
-
const allowMediaInline =
|
|
186
|
+
const allowMediaInline = allowMediaInlineImages;
|
|
190
187
|
const mediaSingleOption = {
|
|
191
188
|
withCaption: allowCaptions,
|
|
192
189
|
withExtendedWidthTypes: allowPixelResizing
|
|
@@ -398,7 +395,6 @@ export const mediaPlugin = ({
|
|
|
398
395
|
var _api$editorViewMode, _api$editorViewMode$s;
|
|
399
396
|
return floatingToolbar(state, intl, {
|
|
400
397
|
providerFactory,
|
|
401
|
-
allowMediaInline: options && getMediaFeatureFlag('mediaInline', options.featureFlags),
|
|
402
398
|
allowResizing: options && options.allowResizing,
|
|
403
399
|
allowResizingInTables: options && options.allowResizingInTables,
|
|
404
400
|
allowCommentsOnMedia: options && options.allowCommentsOnMedia,
|
|
@@ -4,9 +4,7 @@ import { usePreviousState } from '@atlaskit/editor-common/hooks';
|
|
|
4
4
|
import { nodeViewsMessages as messages } from '@atlaskit/editor-common/media';
|
|
5
5
|
import { isNodeSelectedOrInRange, SelectedState, setNodeSelection } from '@atlaskit/editor-common/utils';
|
|
6
6
|
import EditorCloseIcon from '@atlaskit/icon/core/cross';
|
|
7
|
-
import { getMediaFeatureFlag } from '@atlaskit/media-common';
|
|
8
7
|
import { Filmstrip } from '@atlaskit/media-filmstrip';
|
|
9
|
-
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
10
8
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
|
|
11
9
|
import { stateKey as mediaStateKey } from '../pm-plugins/plugin-key';
|
|
12
10
|
import { createMediaNodeUpdater } from './mediaNodeUpdater';
|
|
@@ -41,8 +39,7 @@ const prepareFilmstripItem = ({
|
|
|
41
39
|
getPos,
|
|
42
40
|
intl,
|
|
43
41
|
isMediaItemSelected,
|
|
44
|
-
setMediaGroupNodeSelection
|
|
45
|
-
featureFlags
|
|
42
|
+
setMediaGroupNodeSelection
|
|
46
43
|
}) => (item, idx) => {
|
|
47
44
|
// We declared this to get a fresh position every time
|
|
48
45
|
const getNodePos = () => {
|
|
@@ -80,7 +77,7 @@ const prepareFilmstripItem = ({
|
|
|
80
77
|
onClick: () => {
|
|
81
78
|
setMediaGroupNodeSelection(getNodePos());
|
|
82
79
|
},
|
|
83
|
-
...mediaInlineOptions(
|
|
80
|
+
...mediaInlineOptions(allowMediaInlineImages)
|
|
84
81
|
};
|
|
85
82
|
};
|
|
86
83
|
|
|
@@ -189,10 +186,9 @@ export const MediaGroupNext = injectIntl( /*#__PURE__*/React.memo(props => {
|
|
|
189
186
|
getPos,
|
|
190
187
|
intl,
|
|
191
188
|
isMediaItemSelected,
|
|
192
|
-
setMediaGroupNodeSelection
|
|
193
|
-
featureFlags
|
|
189
|
+
setMediaGroupNodeSelection
|
|
194
190
|
});
|
|
195
|
-
}, [allowLazyLoading, allowMediaInlineImages, enableDownloadButton, handleMediaNodeRemoval, getPos, intl, isMediaItemSelected, setMediaGroupNodeSelection
|
|
191
|
+
}, [allowLazyLoading, allowMediaInlineImages, enableDownloadButton, handleMediaNodeRemoval, getPos, intl, isMediaItemSelected, setMediaGroupNodeSelection]);
|
|
196
192
|
const items = useMemo(() => {
|
|
197
193
|
return mediaNodesWithOffsets.map(({
|
|
198
194
|
node,
|
|
@@ -7,7 +7,6 @@ import { v4 as uuid } from 'uuid';
|
|
|
7
7
|
import { SetAttrsStep } from '@atlaskit/adf-schema/steps/set-attrs';
|
|
8
8
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
9
9
|
import { getBrowserInfo } from '@atlaskit/editor-common/browser';
|
|
10
|
-
import { mediaInlineImagesEnabled } from '@atlaskit/editor-common/media-inline';
|
|
11
10
|
import { CAPTION_PLACEHOLDER_ID, getMaxWidthForNestedNodeNext } from '@atlaskit/editor-common/media-single';
|
|
12
11
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
13
12
|
import { ErrorReporter } from '@atlaskit/editor-common/utils';
|
|
@@ -18,7 +17,7 @@ import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
|
18
17
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
19
18
|
import { isFileIdentifier } from '@atlaskit/media-client';
|
|
20
19
|
import { getMediaFeatureFlag } from '@atlaskit/media-common';
|
|
21
|
-
import {
|
|
20
|
+
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
22
21
|
import { createMediaNodeUpdater } from '../nodeviews/mediaNodeUpdater';
|
|
23
22
|
// Ignored via go/ees005
|
|
24
23
|
// eslint-disable-next-line import/no-namespace
|
|
@@ -56,7 +55,9 @@ const createDropPlaceholder = (intl, nodeViewPortalProviderAPI, dropPlaceholderK
|
|
|
56
55
|
const MEDIA_RESOLVED_STATES = ['ready', 'error', 'cancelled'];
|
|
57
56
|
export class MediaPluginStateImplementation {
|
|
58
57
|
constructor(_state, options, mediaOptions, _dispatch, pluginInjectionApi) {
|
|
58
|
+
var _this$mediaOptions2;
|
|
59
59
|
_defineProperty(this, "allowsUploads", false);
|
|
60
|
+
_defineProperty(this, "uploadStatus", 'pending');
|
|
60
61
|
_defineProperty(this, "ignoreLinks", false);
|
|
61
62
|
_defineProperty(this, "waitForMediaUpload", true);
|
|
62
63
|
_defineProperty(this, "allUploadsFinished", true);
|
|
@@ -650,20 +651,20 @@ export class MediaPluginStateImplementation {
|
|
|
650
651
|
} = _state.schema;
|
|
651
652
|
assert(nodes.media && (nodes.mediaGroup || nodes.mediaSingle), 'Editor: unable to init media plugin - media or mediaGroup/mediaSingle node absent in schema');
|
|
652
653
|
if (mediaOptions !== null && mediaOptions !== void 0 && mediaOptions.syncProvider) {
|
|
653
|
-
this.setMediaProvider(mediaOptions
|
|
654
|
+
this.setMediaProvider(mediaOptions.syncProvider);
|
|
655
|
+
if (mediaOptions.provider && isExperimentEnabled('platform_editor_ssr_toolbar_optimistic')) {
|
|
656
|
+
// The synchronous SSR provider may only support viewing. Keep its view
|
|
657
|
+
// config, but wait for the full provider before deciding upload availability.
|
|
658
|
+
if (!this.allowsUploads) {
|
|
659
|
+
this.uploadStatus = 'pending';
|
|
660
|
+
}
|
|
661
|
+
this.setMediaProvider(mediaOptions.provider);
|
|
662
|
+
}
|
|
654
663
|
} else if (mediaOptions !== null && mediaOptions !== void 0 && mediaOptions.provider) {
|
|
655
664
|
this.setMediaProvider(mediaOptions === null || mediaOptions === void 0 ? void 0 : mediaOptions.provider);
|
|
656
665
|
}
|
|
657
|
-
if (
|
|
658
|
-
|
|
659
|
-
if ((_this$mediaOptions2 = this.mediaOptions) !== null && _this$mediaOptions2 !== void 0 && _this$mediaOptions2.allowMediaInlineImages) {
|
|
660
|
-
this.allowInlineImages = true;
|
|
661
|
-
}
|
|
662
|
-
} else {
|
|
663
|
-
var _this$mediaOptions3, _this$mediaOptions4;
|
|
664
|
-
if (mediaInlineImagesEnabled(getMediaFeatureFlag('mediaInline', (_this$mediaOptions3 = this.mediaOptions) === null || _this$mediaOptions3 === void 0 ? void 0 : _this$mediaOptions3.featureFlags), (_this$mediaOptions4 = this.mediaOptions) === null || _this$mediaOptions4 === void 0 ? void 0 : _this$mediaOptions4.allowMediaInlineImages)) {
|
|
665
|
-
this.allowInlineImages = true;
|
|
666
|
-
}
|
|
666
|
+
if ((_this$mediaOptions2 = this.mediaOptions) !== null && _this$mediaOptions2 !== void 0 && _this$mediaOptions2.allowMediaInlineImages) {
|
|
667
|
+
this.allowInlineImages = true;
|
|
667
668
|
}
|
|
668
669
|
this.errorReporter = options.errorReporter || new ErrorReporter();
|
|
669
670
|
this.singletonCreatedAt = (performance || Date).now();
|
|
@@ -696,14 +697,15 @@ export class MediaPluginStateImplementation {
|
|
|
696
697
|
}
|
|
697
698
|
async setMediaProvider(mediaProvider) {
|
|
698
699
|
// Prevent someone trying to set the exact same provider twice for performance reasons
|
|
699
|
-
if (this.previousMediaProvider === mediaProvider) {
|
|
700
|
+
if (this.previousMediaProvider === mediaProvider && !(isExperimentEnabled('platform_editor_ssr_toolbar_optimistic') && this.uploadStatus === 'pending' && !mediaProvider)) {
|
|
700
701
|
return;
|
|
701
702
|
}
|
|
702
703
|
this.previousMediaProvider = mediaProvider;
|
|
703
704
|
if (!mediaProvider) {
|
|
704
705
|
this.destroyPickers();
|
|
705
706
|
this.allowsUploads = false;
|
|
706
|
-
|
|
707
|
+
this.uploadStatus = 'unavailable';
|
|
708
|
+
if (!this.destroyed && (this.view || !isExperimentEnabled('platform_editor_ssr_toolbar_optimistic'))) {
|
|
707
709
|
this.view.dispatch(this.view.state.tr.setMeta(stateKey, {
|
|
708
710
|
allowsUploads: this.allowsUploads
|
|
709
711
|
}));
|
|
@@ -715,11 +717,11 @@ export class MediaPluginStateImplementation {
|
|
|
715
717
|
// eslint-disable-next-line @atlaskit/editor/enforce-todo-comment-format
|
|
716
718
|
// TODO disable (not destroy!) pickers until mediaProvider is resolved
|
|
717
719
|
try {
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
this.mediaProvider = mediaProvider;
|
|
720
|
+
const resolvedProvider = mediaProvider instanceof Promise ? await mediaProvider : mediaProvider;
|
|
721
|
+
if (isExperimentEnabled('platform_editor_ssr_toolbar_optimistic') && (this.destroyed || this.previousMediaProvider !== mediaProvider)) {
|
|
722
|
+
return;
|
|
722
723
|
}
|
|
724
|
+
this.mediaProvider = resolvedProvider;
|
|
723
725
|
|
|
724
726
|
// Ignored via go/ees007
|
|
725
727
|
// eslint-disable-next-line @atlaskit/editor/enforce-todo-comment-format
|
|
@@ -734,11 +736,15 @@ export class MediaPluginStateImplementation {
|
|
|
734
736
|
}
|
|
735
737
|
assert(this.mediaProvider.viewMediaClientConfig, `MediaProvider promise did not resolve to a valid instance of MediaProvider - ${this.mediaProvider}`);
|
|
736
738
|
} catch (err) {
|
|
739
|
+
if (isExperimentEnabled('platform_editor_ssr_toolbar_optimistic') && (this.destroyed || this.previousMediaProvider !== mediaProvider)) {
|
|
740
|
+
return;
|
|
741
|
+
}
|
|
737
742
|
const wrappedError = new Error(`Media functionality disabled due to rejected provider: ${err instanceof Error ? err.message : String(err)}`);
|
|
738
743
|
this.errorReporter.captureException(wrappedError);
|
|
739
744
|
this.destroyPickers();
|
|
740
745
|
this.allowsUploads = false;
|
|
741
|
-
|
|
746
|
+
this.uploadStatus = 'unavailable';
|
|
747
|
+
if (!this.destroyed && (this.view || !isExperimentEnabled('platform_editor_ssr_toolbar_optimistic'))) {
|
|
742
748
|
this.view.dispatch(this.view.state.tr.setMeta(stateKey, {
|
|
743
749
|
allowsUploads: this.allowsUploads
|
|
744
750
|
}));
|
|
@@ -747,6 +753,7 @@ export class MediaPluginStateImplementation {
|
|
|
747
753
|
}
|
|
748
754
|
this.mediaClientConfig = this.mediaProvider.viewMediaClientConfig;
|
|
749
755
|
this.allowsUploads = !!this.mediaProvider.uploadMediaClientConfig;
|
|
756
|
+
this.uploadStatus = this.allowsUploads ? 'available' : 'unavailable';
|
|
750
757
|
const {
|
|
751
758
|
view,
|
|
752
759
|
allowsUploads
|
|
@@ -814,9 +821,9 @@ export class MediaPluginStateImplementation {
|
|
|
814
821
|
return (_this$pluginInjection10 = this.pluginInjectionApi) === null || _this$pluginInjection10 === void 0 ? void 0 : (_this$pluginInjection11 = _this$pluginInjection10.contextIdentifier) === null || _this$pluginInjection11 === void 0 ? void 0 : (_this$pluginInjection12 = _this$pluginInjection11.sharedState.currentState()) === null || _this$pluginInjection12 === void 0 ? void 0 : _this$pluginInjection12.contextIdentifierProvider;
|
|
815
822
|
}
|
|
816
823
|
selectLastAddedMediaNode() {
|
|
817
|
-
var _this$
|
|
824
|
+
var _this$mediaOptions3;
|
|
818
825
|
// if preventAutoFocusOnUpload is enabled, skip auto-selection and just clear the tracking array
|
|
819
|
-
if ((_this$
|
|
826
|
+
if ((_this$mediaOptions3 = this.mediaOptions) !== null && _this$mediaOptions3 !== void 0 && _this$mediaOptions3.preventAutoFocusOnUpload) {
|
|
820
827
|
this.lastAddedMediaSingleFileIds = [];
|
|
821
828
|
return;
|
|
822
829
|
}
|
|
@@ -850,6 +857,10 @@ export class MediaPluginStateImplementation {
|
|
|
850
857
|
}
|
|
851
858
|
setView(view) {
|
|
852
859
|
this.view = view;
|
|
860
|
+
if (isExperimentEnabled('platform_editor_ssr_toolbar_optimistic') && this.uploadStatus === 'pending' && !this.previousMediaProvider) {
|
|
861
|
+
// No provider was configured for this client editor. SSR has no view and stays pending.
|
|
862
|
+
this.uploadStatus = 'unavailable';
|
|
863
|
+
}
|
|
853
864
|
}
|
|
854
865
|
destroy() {
|
|
855
866
|
if (this.destroyed) {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { mediaInlineImagesEnabled } from '@atlaskit/editor-common/media-inline';
|
|
2
1
|
import { isInEmptyLine } from '@atlaskit/editor-common/utils';
|
|
3
2
|
import { hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
4
3
|
import { getMediaFeatureFlag } from '@atlaskit/media-common';
|
|
@@ -18,17 +17,9 @@ export const getMediaNodeInsertionType = (state, mediaOptions, fileMimeType) =>
|
|
|
18
17
|
return 'group';
|
|
19
18
|
}
|
|
20
19
|
const canInsertInlineNode = getMediaFeatureFlag('mediaInline', mediaOptions === null || mediaOptions === void 0 ? void 0 : mediaOptions.featureFlags) && !isInEmptyLine(state) && (!isInsidePotentialEmptyParagraph(state) || isInSupportedInlineImageParent(state)) && canInsertMediaInline(state);
|
|
21
|
-
if (
|
|
22
|
-
if (
|
|
23
|
-
|
|
24
|
-
return 'inline';
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
} else {
|
|
28
|
-
if (mediaInlineImagesEnabled(getMediaFeatureFlag('mediaInline', mediaOptions === null || mediaOptions === void 0 ? void 0 : mediaOptions.featureFlags), mediaOptions === null || mediaOptions === void 0 ? void 0 : mediaOptions.allowMediaInlineImages)) {
|
|
29
|
-
if (canInsertInlineNode && !isVideo(fileMimeType)) {
|
|
30
|
-
return 'inline';
|
|
31
|
-
}
|
|
20
|
+
if (mediaOptions !== null && mediaOptions !== void 0 && mediaOptions.allowMediaInlineImages) {
|
|
21
|
+
if (canInsertInlineNode && !isVideo(fileMimeType)) {
|
|
22
|
+
return 'inline';
|
|
32
23
|
}
|
|
33
24
|
}
|
|
34
25
|
if (isMediaSingle(state.schema, fileMimeType)) {
|
|
@@ -3,7 +3,6 @@ import React from 'react';
|
|
|
3
3
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
4
4
|
import { alignmentIcons, buildLayoutButtons, buildLayoutDropdown, layoutToMessages, wrappingIcons } from '@atlaskit/editor-common/card';
|
|
5
5
|
import { withAnalytics } from '@atlaskit/editor-common/editor-analytics';
|
|
6
|
-
import { mediaInlineImagesEnabled } from '@atlaskit/editor-common/media-inline';
|
|
7
6
|
import commonMessages, { cardMessages, mediaAndEmbedToolbarMessages } from '@atlaskit/editor-common/messages';
|
|
8
7
|
import { areToolbarFlagsEnabled } from '@atlaskit/editor-common/toolbar-flag-check';
|
|
9
8
|
import { isOfflineMode } from '@atlaskit/editor-plugin-connectivity';
|
|
@@ -271,7 +270,6 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
|
|
|
271
270
|
allowCommentsOnMedia,
|
|
272
271
|
allowResizingInTables,
|
|
273
272
|
allowAltTextOnImages,
|
|
274
|
-
allowMediaInline,
|
|
275
273
|
allowMediaInlineImages,
|
|
276
274
|
allowImageEditing,
|
|
277
275
|
allowImagePreview,
|
|
@@ -375,27 +373,14 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
|
|
|
375
373
|
}
|
|
376
374
|
}
|
|
377
375
|
};
|
|
378
|
-
if (
|
|
379
|
-
|
|
380
|
-
addLayoutDropdownToToolbar();
|
|
381
|
-
} else {
|
|
382
|
-
toolbarButtons = [...toolbarButtons, ...layoutButtons];
|
|
383
|
-
if (layoutButtons.length && !mauiToolbarSeparatorsUpdateEnabled) {
|
|
384
|
-
toolbarButtons.push({
|
|
385
|
-
type: 'separator'
|
|
386
|
-
});
|
|
387
|
-
}
|
|
388
|
-
}
|
|
376
|
+
if (allowMediaInlineImages && selectedNode) {
|
|
377
|
+
addLayoutDropdownToToolbar();
|
|
389
378
|
} else {
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
toolbarButtons.push({
|
|
396
|
-
type: 'separator'
|
|
397
|
-
});
|
|
398
|
-
}
|
|
379
|
+
toolbarButtons = [...toolbarButtons, ...layoutButtons];
|
|
380
|
+
if (layoutButtons.length && !mauiToolbarSeparatorsUpdateEnabled) {
|
|
381
|
+
toolbarButtons.push({
|
|
382
|
+
type: 'separator'
|
|
383
|
+
});
|
|
399
384
|
}
|
|
400
385
|
}
|
|
401
386
|
|
|
@@ -802,10 +787,7 @@ export const floatingToolbar = (state, intl, options = {}, pluginInjectionApi) =
|
|
|
802
787
|
allowAdvancedToolBarOptions,
|
|
803
788
|
allowPixelResizing
|
|
804
789
|
} = options;
|
|
805
|
-
|
|
806
|
-
allowMediaInline
|
|
807
|
-
} = options;
|
|
808
|
-
allowMediaInline = fg('platform_editor_remove_media_inline_feature_flag') ? allowMediaInlineImages : allowMediaInline;
|
|
790
|
+
const allowMediaInline = allowMediaInlineImages;
|
|
809
791
|
const mediaPluginState = stateKey.getState(state);
|
|
810
792
|
const mediaLinkingState = getMediaLinkingState(state);
|
|
811
793
|
const {
|
package/dist/esm/mediaPlugin.js
CHANGED
|
@@ -9,9 +9,7 @@ import { IconImages } from '@atlaskit/editor-common/quick-insert';
|
|
|
9
9
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
10
10
|
import { areToolbarFlagsEnabled } from '@atlaskit/editor-common/toolbar-flag-check';
|
|
11
11
|
import { NodeSelection, PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
12
|
-
import { getMediaFeatureFlag } from '@atlaskit/media-common';
|
|
13
12
|
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
14
|
-
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
15
13
|
import { lazyMediaGroupView } from './nodeviews/lazy-media-group';
|
|
16
14
|
import { lazyMediaInlineView } from './nodeviews/lazy-media-inline';
|
|
17
15
|
import { ReactMediaNode } from './nodeviews/mediaNodeView';
|
|
@@ -186,9 +184,8 @@ export var mediaPlugin = function mediaPlugin(_ref3) {
|
|
|
186
184
|
_ref5$allowPixelResiz = _ref5.allowPixelResizing,
|
|
187
185
|
allowPixelResizing = _ref5$allowPixelResiz === void 0 ? false : _ref5$allowPixelResiz,
|
|
188
186
|
allowCaptions = _ref5.allowCaptions,
|
|
189
|
-
allowMediaInlineImages = _ref5.allowMediaInlineImages
|
|
190
|
-
|
|
191
|
-
var allowMediaInline = fg('platform_editor_remove_media_inline_feature_flag') ? allowMediaInlineImages : getMediaFeatureFlag('mediaInline', mediaFeatureFlags);
|
|
187
|
+
allowMediaInlineImages = _ref5.allowMediaInlineImages;
|
|
188
|
+
var allowMediaInline = allowMediaInlineImages;
|
|
192
189
|
var mediaSingleOption = {
|
|
193
190
|
withCaption: allowCaptions,
|
|
194
191
|
withExtendedWidthTypes: allowPixelResizing
|
|
@@ -398,7 +395,6 @@ export var mediaPlugin = function mediaPlugin(_ref3) {
|
|
|
398
395
|
var _api$editorViewMode;
|
|
399
396
|
return _floatingToolbar(state, intl, {
|
|
400
397
|
providerFactory: providerFactory,
|
|
401
|
-
allowMediaInline: options && getMediaFeatureFlag('mediaInline', options.featureFlags),
|
|
402
398
|
allowResizing: options && options.allowResizing,
|
|
403
399
|
allowResizingInTables: options && options.allowResizingInTables,
|
|
404
400
|
allowCommentsOnMedia: options && options.allowCommentsOnMedia,
|
|
@@ -10,9 +10,7 @@ import { usePreviousState } from '@atlaskit/editor-common/hooks';
|
|
|
10
10
|
import { nodeViewsMessages as messages } from '@atlaskit/editor-common/media';
|
|
11
11
|
import { isNodeSelectedOrInRange, SelectedState, setNodeSelection } from '@atlaskit/editor-common/utils';
|
|
12
12
|
import EditorCloseIcon from '@atlaskit/icon/core/cross';
|
|
13
|
-
import { getMediaFeatureFlag } from '@atlaskit/media-common';
|
|
14
13
|
import { Filmstrip } from '@atlaskit/media-filmstrip';
|
|
15
|
-
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
16
14
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
|
|
17
15
|
import { stateKey as mediaStateKey } from '../pm-plugins/plugin-key';
|
|
18
16
|
import { createMediaNodeUpdater } from './mediaNodeUpdater';
|
|
@@ -49,8 +47,7 @@ var prepareFilmstripItem = function prepareFilmstripItem(_ref) {
|
|
|
49
47
|
getPos = _ref.getPos,
|
|
50
48
|
intl = _ref.intl,
|
|
51
49
|
isMediaItemSelected = _ref.isMediaItemSelected,
|
|
52
|
-
setMediaGroupNodeSelection = _ref.setMediaGroupNodeSelection
|
|
53
|
-
featureFlags = _ref.featureFlags;
|
|
50
|
+
setMediaGroupNodeSelection = _ref.setMediaGroupNodeSelection;
|
|
54
51
|
return function (item, idx) {
|
|
55
52
|
// We declared this to get a fresh position every time
|
|
56
53
|
var getNodePos = function getNodePos() {
|
|
@@ -89,7 +86,7 @@ var prepareFilmstripItem = function prepareFilmstripItem(_ref) {
|
|
|
89
86
|
onClick: function onClick() {
|
|
90
87
|
setMediaGroupNodeSelection(getNodePos());
|
|
91
88
|
}
|
|
92
|
-
}, mediaInlineOptions(
|
|
89
|
+
}, mediaInlineOptions(allowMediaInlineImages));
|
|
93
90
|
};
|
|
94
91
|
};
|
|
95
92
|
|
|
@@ -225,10 +222,9 @@ export var MediaGroupNext = injectIntl( /*#__PURE__*/React.memo(function (props)
|
|
|
225
222
|
getPos: _getPos,
|
|
226
223
|
intl: intl,
|
|
227
224
|
isMediaItemSelected: isMediaItemSelected,
|
|
228
|
-
setMediaGroupNodeSelection: setMediaGroupNodeSelection
|
|
229
|
-
featureFlags: featureFlags
|
|
225
|
+
setMediaGroupNodeSelection: setMediaGroupNodeSelection
|
|
230
226
|
});
|
|
231
|
-
}, [allowLazyLoading, allowMediaInlineImages, enableDownloadButton, handleMediaNodeRemoval, _getPos, intl, isMediaItemSelected, setMediaGroupNodeSelection
|
|
227
|
+
}, [allowLazyLoading, allowMediaInlineImages, enableDownloadButton, handleMediaNodeRemoval, _getPos, intl, isMediaItemSelected, setMediaGroupNodeSelection]);
|
|
232
228
|
var items = useMemo(function () {
|
|
233
229
|
return mediaNodesWithOffsets.map(function (_ref4) {
|
|
234
230
|
var node = _ref4.node,
|
|
@@ -16,7 +16,6 @@ import { v4 as uuid } from 'uuid';
|
|
|
16
16
|
import { SetAttrsStep } from '@atlaskit/adf-schema/steps/set-attrs';
|
|
17
17
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
18
18
|
import { getBrowserInfo } from '@atlaskit/editor-common/browser';
|
|
19
|
-
import { mediaInlineImagesEnabled } from '@atlaskit/editor-common/media-inline';
|
|
20
19
|
import { CAPTION_PLACEHOLDER_ID, getMaxWidthForNestedNodeNext } from '@atlaskit/editor-common/media-single';
|
|
21
20
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
22
21
|
import { ErrorReporter } from '@atlaskit/editor-common/utils';
|
|
@@ -27,7 +26,7 @@ import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
|
27
26
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
28
27
|
import { isFileIdentifier } from '@atlaskit/media-client';
|
|
29
28
|
import { getMediaFeatureFlag } from '@atlaskit/media-common';
|
|
30
|
-
import {
|
|
29
|
+
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
31
30
|
import { createMediaNodeUpdater } from '../nodeviews/mediaNodeUpdater';
|
|
32
31
|
// Ignored via go/ees005
|
|
33
32
|
// eslint-disable-next-line import/no-namespace
|
|
@@ -69,9 +68,11 @@ var createDropPlaceholder = function createDropPlaceholder(intl, nodeViewPortalP
|
|
|
69
68
|
var MEDIA_RESOLVED_STATES = ['ready', 'error', 'cancelled'];
|
|
70
69
|
export var MediaPluginStateImplementation = /*#__PURE__*/function () {
|
|
71
70
|
function MediaPluginStateImplementation(_state, options, mediaOptions, _dispatch, pluginInjectionApi) {
|
|
72
|
-
var _this = this
|
|
71
|
+
var _this = this,
|
|
72
|
+
_this$mediaOptions2;
|
|
73
73
|
_classCallCheck(this, MediaPluginStateImplementation);
|
|
74
74
|
_defineProperty(this, "allowsUploads", false);
|
|
75
|
+
_defineProperty(this, "uploadStatus", 'pending');
|
|
75
76
|
_defineProperty(this, "ignoreLinks", false);
|
|
76
77
|
_defineProperty(this, "waitForMediaUpload", true);
|
|
77
78
|
_defineProperty(this, "allUploadsFinished", true);
|
|
@@ -651,20 +652,20 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
|
|
|
651
652
|
var nodes = _state.schema.nodes;
|
|
652
653
|
assert(nodes.media && (nodes.mediaGroup || nodes.mediaSingle), 'Editor: unable to init media plugin - media or mediaGroup/mediaSingle node absent in schema');
|
|
653
654
|
if (mediaOptions !== null && mediaOptions !== void 0 && mediaOptions.syncProvider) {
|
|
654
|
-
this.setMediaProvider(mediaOptions
|
|
655
|
+
this.setMediaProvider(mediaOptions.syncProvider);
|
|
656
|
+
if (mediaOptions.provider && isExperimentEnabled('platform_editor_ssr_toolbar_optimistic')) {
|
|
657
|
+
// The synchronous SSR provider may only support viewing. Keep its view
|
|
658
|
+
// config, but wait for the full provider before deciding upload availability.
|
|
659
|
+
if (!this.allowsUploads) {
|
|
660
|
+
this.uploadStatus = 'pending';
|
|
661
|
+
}
|
|
662
|
+
this.setMediaProvider(mediaOptions.provider);
|
|
663
|
+
}
|
|
655
664
|
} else if (mediaOptions !== null && mediaOptions !== void 0 && mediaOptions.provider) {
|
|
656
665
|
this.setMediaProvider(mediaOptions === null || mediaOptions === void 0 ? void 0 : mediaOptions.provider);
|
|
657
666
|
}
|
|
658
|
-
if (
|
|
659
|
-
|
|
660
|
-
if ((_this$mediaOptions2 = this.mediaOptions) !== null && _this$mediaOptions2 !== void 0 && _this$mediaOptions2.allowMediaInlineImages) {
|
|
661
|
-
this.allowInlineImages = true;
|
|
662
|
-
}
|
|
663
|
-
} else {
|
|
664
|
-
var _this$mediaOptions3, _this$mediaOptions4;
|
|
665
|
-
if (mediaInlineImagesEnabled(getMediaFeatureFlag('mediaInline', (_this$mediaOptions3 = this.mediaOptions) === null || _this$mediaOptions3 === void 0 ? void 0 : _this$mediaOptions3.featureFlags), (_this$mediaOptions4 = this.mediaOptions) === null || _this$mediaOptions4 === void 0 ? void 0 : _this$mediaOptions4.allowMediaInlineImages)) {
|
|
666
|
-
this.allowInlineImages = true;
|
|
667
|
-
}
|
|
667
|
+
if ((_this$mediaOptions2 = this.mediaOptions) !== null && _this$mediaOptions2 !== void 0 && _this$mediaOptions2.allowMediaInlineImages) {
|
|
668
|
+
this.allowInlineImages = true;
|
|
668
669
|
}
|
|
669
670
|
this.errorReporter = options.errorReporter || new ErrorReporter();
|
|
670
671
|
this.singletonCreatedAt = (performance || Date).now();
|
|
@@ -707,11 +708,11 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
|
|
|
707
708
|
key: "setMediaProvider",
|
|
708
709
|
value: function () {
|
|
709
710
|
var _setMediaProvider = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(mediaProvider) {
|
|
710
|
-
var viewMediaClientConfig, wrappedError, view, allowsUploads, _t;
|
|
711
|
+
var resolvedProvider, viewMediaClientConfig, wrappedError, view, allowsUploads, _t, _t2;
|
|
711
712
|
return _regeneratorRuntime.wrap(function (_context) {
|
|
712
713
|
while (1) switch (_context.prev = _context.next) {
|
|
713
714
|
case 0:
|
|
714
|
-
if (!(this.previousMediaProvider === mediaProvider)) {
|
|
715
|
+
if (!(this.previousMediaProvider === mediaProvider && !(isExperimentEnabled('platform_editor_ssr_toolbar_optimistic') && this.uploadStatus === 'pending' && !mediaProvider))) {
|
|
715
716
|
_context.next = 1;
|
|
716
717
|
break;
|
|
717
718
|
}
|
|
@@ -724,7 +725,8 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
|
|
|
724
725
|
}
|
|
725
726
|
this.destroyPickers();
|
|
726
727
|
this.allowsUploads = false;
|
|
727
|
-
|
|
728
|
+
this.uploadStatus = 'unavailable';
|
|
729
|
+
if (!this.destroyed && (this.view || !isExperimentEnabled('platform_editor_ssr_toolbar_optimistic'))) {
|
|
728
730
|
this.view.dispatch(this.view.state.tr.setMeta(stateKey, {
|
|
729
731
|
allowsUploads: this.allowsUploads
|
|
730
732
|
}));
|
|
@@ -739,12 +741,21 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
|
|
|
739
741
|
_context.next = 3;
|
|
740
742
|
return mediaProvider;
|
|
741
743
|
case 3:
|
|
742
|
-
|
|
744
|
+
_t = _context.sent;
|
|
743
745
|
_context.next = 5;
|
|
744
746
|
break;
|
|
745
747
|
case 4:
|
|
746
|
-
|
|
748
|
+
_t = mediaProvider;
|
|
747
749
|
case 5:
|
|
750
|
+
resolvedProvider = _t;
|
|
751
|
+
if (!(isExperimentEnabled('platform_editor_ssr_toolbar_optimistic') && (this.destroyed || this.previousMediaProvider !== mediaProvider))) {
|
|
752
|
+
_context.next = 6;
|
|
753
|
+
break;
|
|
754
|
+
}
|
|
755
|
+
return _context.abrupt("return");
|
|
756
|
+
case 6:
|
|
757
|
+
this.mediaProvider = resolvedProvider;
|
|
758
|
+
|
|
748
759
|
// Ignored via go/ees007
|
|
749
760
|
// eslint-disable-next-line @atlaskit/editor/enforce-todo-comment-format
|
|
750
761
|
// TODO [MS-2038]: remove once context api is removed
|
|
@@ -757,24 +768,32 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
|
|
|
757
768
|
}
|
|
758
769
|
}
|
|
759
770
|
assert(this.mediaProvider.viewMediaClientConfig, "MediaProvider promise did not resolve to a valid instance of MediaProvider - ".concat(this.mediaProvider));
|
|
760
|
-
_context.next =
|
|
771
|
+
_context.next = 9;
|
|
761
772
|
break;
|
|
762
|
-
case
|
|
763
|
-
_context.prev =
|
|
764
|
-
|
|
765
|
-
|
|
773
|
+
case 7:
|
|
774
|
+
_context.prev = 7;
|
|
775
|
+
_t2 = _context["catch"](2);
|
|
776
|
+
if (!(isExperimentEnabled('platform_editor_ssr_toolbar_optimistic') && (this.destroyed || this.previousMediaProvider !== mediaProvider))) {
|
|
777
|
+
_context.next = 8;
|
|
778
|
+
break;
|
|
779
|
+
}
|
|
780
|
+
return _context.abrupt("return");
|
|
781
|
+
case 8:
|
|
782
|
+
wrappedError = new Error("Media functionality disabled due to rejected provider: ".concat(_t2 instanceof Error ? _t2.message : String(_t2)));
|
|
766
783
|
this.errorReporter.captureException(wrappedError);
|
|
767
784
|
this.destroyPickers();
|
|
768
785
|
this.allowsUploads = false;
|
|
769
|
-
|
|
786
|
+
this.uploadStatus = 'unavailable';
|
|
787
|
+
if (!this.destroyed && (this.view || !isExperimentEnabled('platform_editor_ssr_toolbar_optimistic'))) {
|
|
770
788
|
this.view.dispatch(this.view.state.tr.setMeta(stateKey, {
|
|
771
789
|
allowsUploads: this.allowsUploads
|
|
772
790
|
}));
|
|
773
791
|
}
|
|
774
792
|
return _context.abrupt("return");
|
|
775
|
-
case
|
|
793
|
+
case 9:
|
|
776
794
|
this.mediaClientConfig = this.mediaProvider.viewMediaClientConfig;
|
|
777
795
|
this.allowsUploads = !!this.mediaProvider.uploadMediaClientConfig;
|
|
796
|
+
this.uploadStatus = this.allowsUploads ? 'available' : 'unavailable';
|
|
778
797
|
view = this.view, allowsUploads = this.allowsUploads; // make sure editable DOM node is mounted
|
|
779
798
|
if (!this.destroyed && view && view.dom.parentNode) {
|
|
780
799
|
// make PM plugin aware of the state change to update UI during 'apply' hook
|
|
@@ -783,31 +802,31 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
|
|
|
783
802
|
}));
|
|
784
803
|
}
|
|
785
804
|
if (!this.allowsUploads) {
|
|
786
|
-
_context.next =
|
|
805
|
+
_context.next = 13;
|
|
787
806
|
break;
|
|
788
807
|
}
|
|
789
808
|
this.uploadMediaClientConfig = this.mediaProvider.uploadMediaClientConfig;
|
|
790
809
|
if (!(this.mediaProvider.uploadParams && this.uploadMediaClientConfig)) {
|
|
791
|
-
_context.next =
|
|
810
|
+
_context.next = 11;
|
|
792
811
|
break;
|
|
793
812
|
}
|
|
794
|
-
_context.next = 8;
|
|
795
|
-
return this.initPickers(this.mediaProvider.uploadParams, PickerFacade);
|
|
796
|
-
case 8:
|
|
797
813
|
_context.next = 10;
|
|
798
|
-
|
|
799
|
-
case 9:
|
|
800
|
-
this.destroyPickers();
|
|
814
|
+
return this.initPickers(this.mediaProvider.uploadParams, PickerFacade);
|
|
801
815
|
case 10:
|
|
802
816
|
_context.next = 12;
|
|
803
817
|
break;
|
|
804
818
|
case 11:
|
|
805
819
|
this.destroyPickers();
|
|
806
820
|
case 12:
|
|
821
|
+
_context.next = 14;
|
|
822
|
+
break;
|
|
823
|
+
case 13:
|
|
824
|
+
this.destroyPickers();
|
|
825
|
+
case 14:
|
|
807
826
|
case "end":
|
|
808
827
|
return _context.stop();
|
|
809
828
|
}
|
|
810
|
-
}, _callee, this, [[2,
|
|
829
|
+
}, _callee, this, [[2, 7]]);
|
|
811
830
|
}));
|
|
812
831
|
function setMediaProvider(_x) {
|
|
813
832
|
return _setMediaProvider.apply(this, arguments);
|
|
@@ -869,10 +888,10 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
|
|
|
869
888
|
}, {
|
|
870
889
|
key: "selectLastAddedMediaNode",
|
|
871
890
|
value: function selectLastAddedMediaNode() {
|
|
872
|
-
var _this$
|
|
891
|
+
var _this$mediaOptions3,
|
|
873
892
|
_this2 = this;
|
|
874
893
|
// if preventAutoFocusOnUpload is enabled, skip auto-selection and just clear the tracking array
|
|
875
|
-
if ((_this$
|
|
894
|
+
if ((_this$mediaOptions3 = this.mediaOptions) !== null && _this$mediaOptions3 !== void 0 && _this$mediaOptions3.preventAutoFocusOnUpload) {
|
|
876
895
|
this.lastAddedMediaSingleFileIds = [];
|
|
877
896
|
return;
|
|
878
897
|
}
|
|
@@ -907,6 +926,10 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
|
|
|
907
926
|
key: "setView",
|
|
908
927
|
value: function setView(view) {
|
|
909
928
|
this.view = view;
|
|
929
|
+
if (isExperimentEnabled('platform_editor_ssr_toolbar_optimistic') && this.uploadStatus === 'pending' && !this.previousMediaProvider) {
|
|
930
|
+
// No provider was configured for this client editor. SSR has no view and stays pending.
|
|
931
|
+
this.uploadStatus = 'unavailable';
|
|
932
|
+
}
|
|
910
933
|
}
|
|
911
934
|
}, {
|
|
912
935
|
key: "destroy",
|
|
@@ -925,7 +948,7 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
|
|
|
925
948
|
value: function () {
|
|
926
949
|
var _initPickers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(uploadParams, Picker) {
|
|
927
950
|
var _this3 = this;
|
|
928
|
-
var errorReporter, pickers, pickerPromises, pickerFacadeConfig, customPicker,
|
|
951
|
+
var errorReporter, pickers, pickerPromises, pickerFacadeConfig, customPicker, _t3;
|
|
929
952
|
return _regeneratorRuntime.wrap(function (_context2) {
|
|
930
953
|
while (1) switch (_context2.prev = _context2.next) {
|
|
931
954
|
case 0:
|
|
@@ -950,11 +973,11 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
|
|
|
950
973
|
}
|
|
951
974
|
customPicker = new Picker('customMediaPicker', pickerFacadeConfig, this.options.customMediaPicker).init();
|
|
952
975
|
pickerPromises.push(customPicker);
|
|
953
|
-
|
|
976
|
+
_t3 = pickers;
|
|
954
977
|
_context2.next = 2;
|
|
955
978
|
return customPicker;
|
|
956
979
|
case 2:
|
|
957
|
-
|
|
980
|
+
_t3.push.call(_t3, this.customPicker = _context2.sent);
|
|
958
981
|
case 3:
|
|
959
982
|
pickers.forEach(function (picker) {
|
|
960
983
|
picker.onNewMedia(_this3.insertFile);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { mediaInlineImagesEnabled } from '@atlaskit/editor-common/media-inline';
|
|
2
1
|
import { isInEmptyLine } from '@atlaskit/editor-common/utils';
|
|
3
2
|
import { hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
4
3
|
import { getMediaFeatureFlag } from '@atlaskit/media-common';
|
|
@@ -18,17 +17,9 @@ export var getMediaNodeInsertionType = function getMediaNodeInsertionType(state,
|
|
|
18
17
|
return 'group';
|
|
19
18
|
}
|
|
20
19
|
var canInsertInlineNode = getMediaFeatureFlag('mediaInline', mediaOptions === null || mediaOptions === void 0 ? void 0 : mediaOptions.featureFlags) && !isInEmptyLine(state) && (!isInsidePotentialEmptyParagraph(state) || isInSupportedInlineImageParent(state)) && canInsertMediaInline(state);
|
|
21
|
-
if (
|
|
22
|
-
if (
|
|
23
|
-
|
|
24
|
-
return 'inline';
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
} else {
|
|
28
|
-
if (mediaInlineImagesEnabled(getMediaFeatureFlag('mediaInline', mediaOptions === null || mediaOptions === void 0 ? void 0 : mediaOptions.featureFlags), mediaOptions === null || mediaOptions === void 0 ? void 0 : mediaOptions.allowMediaInlineImages)) {
|
|
29
|
-
if (canInsertInlineNode && !isVideo(fileMimeType)) {
|
|
30
|
-
return 'inline';
|
|
31
|
-
}
|
|
20
|
+
if (mediaOptions !== null && mediaOptions !== void 0 && mediaOptions.allowMediaInlineImages) {
|
|
21
|
+
if (canInsertInlineNode && !isVideo(fileMimeType)) {
|
|
22
|
+
return 'inline';
|
|
32
23
|
}
|
|
33
24
|
}
|
|
34
25
|
if (isMediaSingle(state.schema, fileMimeType)) {
|
|
@@ -7,7 +7,6 @@ import React from 'react';
|
|
|
7
7
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
8
8
|
import { alignmentIcons, buildLayoutButtons, buildLayoutDropdown, layoutToMessages, wrappingIcons } from '@atlaskit/editor-common/card';
|
|
9
9
|
import { withAnalytics } from '@atlaskit/editor-common/editor-analytics';
|
|
10
|
-
import { mediaInlineImagesEnabled } from '@atlaskit/editor-common/media-inline';
|
|
11
10
|
import commonMessages, { cardMessages, mediaAndEmbedToolbarMessages } from '@atlaskit/editor-common/messages';
|
|
12
11
|
import { areToolbarFlagsEnabled } from '@atlaskit/editor-common/toolbar-flag-check';
|
|
13
12
|
import { isOfflineMode } from '@atlaskit/editor-plugin-connectivity';
|
|
@@ -273,7 +272,6 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
273
272
|
allowCommentsOnMedia = options.allowCommentsOnMedia,
|
|
274
273
|
allowResizingInTables = options.allowResizingInTables,
|
|
275
274
|
allowAltTextOnImages = options.allowAltTextOnImages,
|
|
276
|
-
allowMediaInline = options.allowMediaInline,
|
|
277
275
|
allowMediaInlineImages = options.allowMediaInlineImages,
|
|
278
276
|
allowImageEditing = options.allowImageEditing,
|
|
279
277
|
allowImagePreview = options.allowImagePreview,
|
|
@@ -373,27 +371,14 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
373
371
|
}
|
|
374
372
|
}
|
|
375
373
|
};
|
|
376
|
-
if (
|
|
377
|
-
|
|
378
|
-
addLayoutDropdownToToolbar();
|
|
379
|
-
} else {
|
|
380
|
-
toolbarButtons = [].concat(_toConsumableArray(toolbarButtons), _toConsumableArray(layoutButtons));
|
|
381
|
-
if (layoutButtons.length && !mauiToolbarSeparatorsUpdateEnabled) {
|
|
382
|
-
toolbarButtons.push({
|
|
383
|
-
type: 'separator'
|
|
384
|
-
});
|
|
385
|
-
}
|
|
386
|
-
}
|
|
374
|
+
if (allowMediaInlineImages && selectedNode) {
|
|
375
|
+
addLayoutDropdownToToolbar();
|
|
387
376
|
} else {
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
toolbarButtons.push({
|
|
394
|
-
type: 'separator'
|
|
395
|
-
});
|
|
396
|
-
}
|
|
377
|
+
toolbarButtons = [].concat(_toConsumableArray(toolbarButtons), _toConsumableArray(layoutButtons));
|
|
378
|
+
if (layoutButtons.length && !mauiToolbarSeparatorsUpdateEnabled) {
|
|
379
|
+
toolbarButtons.push({
|
|
380
|
+
type: 'separator'
|
|
381
|
+
});
|
|
397
382
|
}
|
|
398
383
|
}
|
|
399
384
|
|
|
@@ -800,8 +785,7 @@ export var floatingToolbar = function floatingToolbar(state, intl) {
|
|
|
800
785
|
allowResizingInTables = options.allowResizingInTables,
|
|
801
786
|
allowAdvancedToolBarOptions = options.allowAdvancedToolBarOptions,
|
|
802
787
|
allowPixelResizing = options.allowPixelResizing;
|
|
803
|
-
var allowMediaInline =
|
|
804
|
-
allowMediaInline = fg('platform_editor_remove_media_inline_feature_flag') ? allowMediaInlineImages : allowMediaInline;
|
|
788
|
+
var allowMediaInline = allowMediaInlineImages;
|
|
805
789
|
var mediaPluginState = stateKey.getState(state);
|
|
806
790
|
var mediaLinkingState = getMediaLinkingState(state);
|
|
807
791
|
var _ref4 = (_pluginInjectionApi$d3 = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$d4 = pluginInjectionApi.decorations) === null || _pluginInjectionApi$d4 === void 0 ? void 0 : _pluginInjectionApi$d4.actions) !== null && _pluginInjectionApi$d3 !== void 0 ? _pluginInjectionApi$d3 : {},
|
|
@@ -21,6 +21,7 @@ export declare const MEDIA_PLUGIN_IS_RESIZING_KEY = "mediaSinglePlugin.isResizin
|
|
|
21
21
|
export declare const MEDIA_PLUGIN_RESIZING_WIDTH_KEY = "mediaSinglePlugin.resizing-width";
|
|
22
22
|
export declare class MediaPluginStateImplementation implements MediaPluginState {
|
|
23
23
|
allowsUploads: boolean;
|
|
24
|
+
uploadStatus: 'pending' | 'available' | 'unavailable';
|
|
24
25
|
mediaClientConfig?: MediaClientConfig;
|
|
25
26
|
uploadMediaClientConfig?: MediaClientConfig;
|
|
26
27
|
ignoreLinks: boolean;
|
|
@@ -76,6 +76,8 @@ export interface MediaPluginState {
|
|
|
76
76
|
updateElement: () => void;
|
|
77
77
|
updateMediaSingleNodeAttrs: (id: string, attrs: object) => undefined | boolean;
|
|
78
78
|
uploadMediaClientConfig?: MediaClientConfig;
|
|
79
|
+
/** Initial upload capability resolution; does not grant permission to upload. */
|
|
80
|
+
uploadStatus?: 'pending' | 'available' | 'unavailable';
|
|
79
81
|
videoControlsWrapperRef?: HTMLElement;
|
|
80
82
|
waitForMediaUpload: boolean;
|
|
81
83
|
waitForPendingTasks: (timeout?: number, lastTask?: Promise<MediaState | null>) => Promise<MediaState | null>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-media",
|
|
3
|
-
"version": "24.0
|
|
3
|
+
"version": "24.1.0",
|
|
4
4
|
"description": "Media plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -102,9 +102,6 @@
|
|
|
102
102
|
"platform_editor_safari_media_clipboard_fix": {
|
|
103
103
|
"type": "boolean"
|
|
104
104
|
},
|
|
105
|
-
"platform_editor_remove_media_inline_feature_flag": {
|
|
106
|
-
"type": "boolean"
|
|
107
|
-
},
|
|
108
105
|
"platform_editor_content_mode_button_mvp": {
|
|
109
106
|
"type": "boolean"
|
|
110
107
|
},
|