@atlaskit/editor-plugin-media 2.5.0 → 2.6.1
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 +21 -0
- package/dist/cjs/nodeviews/lazy-media-single.js +2 -1
- package/dist/cjs/nodeviews/lazy-media.js +2 -1
- package/dist/cjs/nodeviews/mediaNodeView/media.js +7 -1
- package/dist/cjs/pm-plugins/main.js +29 -18
- package/dist/cjs/pm-plugins/utils/media-inline.js +3 -1
- package/dist/cjs/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +1 -1
- package/dist/es2019/nodeviews/lazy-media-single.js +2 -1
- package/dist/es2019/nodeviews/lazy-media.js +2 -1
- package/dist/es2019/nodeviews/mediaNodeView/media.js +7 -1
- package/dist/es2019/pm-plugins/main.js +8 -2
- package/dist/es2019/pm-plugins/utils/media-inline.js +3 -1
- package/dist/es2019/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +1 -1
- package/dist/esm/nodeviews/lazy-media-single.js +2 -1
- package/dist/esm/nodeviews/lazy-media.js +2 -1
- package/dist/esm/nodeviews/mediaNodeView/media.js +7 -1
- package/dist/esm/pm-plugins/main.js +29 -18
- package/dist/esm/pm-plugins/utils/media-inline.js +3 -1
- package/dist/esm/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +1 -1
- package/dist/types/pm-plugins/main.d.ts +1 -1
- package/dist/types/types/index.d.ts +2 -1
- package/dist/types-ts4.5/pm-plugins/main.d.ts +1 -1
- package/dist/types-ts4.5/types/index.d.ts +2 -1
- package/package.json +11 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-media
|
|
2
2
|
|
|
3
|
+
## 2.6.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 2.6.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [#123268](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/123268)
|
|
14
|
+
[`f47a830143188`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/f47a830143188) -
|
|
15
|
+
Allow for passing in a resolved media provider to enable SSR'ing media in the editor
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- [#140448](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/140448)
|
|
20
|
+
[`1bbf6b1e2ade5`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/1bbf6b1e2ade5) -
|
|
21
|
+
[HOT-116646] Fix inline media check
|
|
22
|
+
- Updated dependencies
|
|
23
|
+
|
|
3
24
|
## 2.5.0
|
|
4
25
|
|
|
5
26
|
### Minor Changes
|
|
@@ -7,13 +7,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.lazyMediaSingleView = void 0;
|
|
8
8
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
9
9
|
var _lazyNodeView = require("@atlaskit/editor-common/lazy-node-view");
|
|
10
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
10
11
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
11
12
|
var _mediaSingle = require("./mediaSingle");
|
|
12
13
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
13
14
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != (0, _typeof2.default)(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
14
15
|
var lazyMediaSingleView = exports.lazyMediaSingleView = function lazyMediaSingleView(portalProviderAPI, eventDispatcher, providerFactory, api, dispatchAnalyticsEvent) {
|
|
15
16
|
var options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
|
|
16
|
-
if ((0, _experiments.editorExperiment)('platform_editor_exp_lazy_node_views', false)) {
|
|
17
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_ssr_media') || (0, _experiments.editorExperiment)('platform_editor_exp_lazy_node_views', false)) {
|
|
17
18
|
return (0, _mediaSingle.ReactMediaSingleNode)(portalProviderAPI, eventDispatcher, providerFactory, api, dispatchAnalyticsEvent, options);
|
|
18
19
|
}
|
|
19
20
|
return (0, _lazyNodeView.withLazyLoading)({
|
|
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.lazyMediaView = void 0;
|
|
8
8
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
9
9
|
var _lazyNodeView = require("@atlaskit/editor-common/lazy-node-view");
|
|
10
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
10
11
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
11
12
|
var _mediaNodeView = require("./mediaNodeView");
|
|
12
13
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
@@ -14,7 +15,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
14
15
|
var lazyMediaView = exports.lazyMediaView = function lazyMediaView(portalProviderAPI, eventDispatcher, providerFactory) {
|
|
15
16
|
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
16
17
|
var api = arguments.length > 4 ? arguments[4] : undefined;
|
|
17
|
-
if ((0, _experiments.editorExperiment)('platform_editor_exp_lazy_node_views', false)) {
|
|
18
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_ssr_media') || (0, _experiments.editorExperiment)('platform_editor_exp_lazy_node_views', false)) {
|
|
18
19
|
return (0, _mediaNodeView.ReactMediaNode)(portalProviderAPI, eventDispatcher, providerFactory, options, api);
|
|
19
20
|
}
|
|
20
21
|
return (0, _lazyNodeView.withLazyLoading)({
|
|
@@ -21,6 +21,7 @@ var _analyticsNext = require("@atlaskit/analytics-next");
|
|
|
21
21
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
22
22
|
var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
|
|
23
23
|
var _mediaCard = require("@atlaskit/media-card");
|
|
24
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
24
25
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
25
26
|
var _pluginKey = require("../../pm-plugins/plugin-key");
|
|
26
27
|
var _styles = require("../styles");
|
|
@@ -285,6 +286,10 @@ var MediaNode = exports.MediaNode = /*#__PURE__*/function (_Component) {
|
|
|
285
286
|
return {};
|
|
286
287
|
}
|
|
287
288
|
};
|
|
289
|
+
var ssr;
|
|
290
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_ssr_media')) {
|
|
291
|
+
ssr = process.env.REACT_SSR ? 'server' : 'client';
|
|
292
|
+
}
|
|
288
293
|
return /*#__PURE__*/_react.default.createElement(_styles.MediaCardWrapper, {
|
|
289
294
|
dimensions: originalDimensions,
|
|
290
295
|
onContextMenu: this.selectMediaSingle,
|
|
@@ -310,7 +315,8 @@ var MediaNode = exports.MediaNode = /*#__PURE__*/function (_Component) {
|
|
|
310
315
|
featureFlags: mediaOptions && mediaOptions.featureFlags,
|
|
311
316
|
contextId: contextId,
|
|
312
317
|
alt: alt,
|
|
313
|
-
videoControlsWrapperRef: this.videoControlsWrapperRef
|
|
318
|
+
videoControlsWrapperRef: this.videoControlsWrapperRef,
|
|
319
|
+
ssr: ssr
|
|
314
320
|
})));
|
|
315
321
|
}
|
|
316
322
|
}]);
|
|
@@ -461,7 +461,9 @@ var MediaPluginStateImplementation = exports.MediaPluginStateImplementation = /*
|
|
|
461
461
|
this.waitForMediaUpload = options.waitForMediaUpload === undefined ? true : options.waitForMediaUpload;
|
|
462
462
|
var nodes = _state.schema.nodes;
|
|
463
463
|
(0, _assert.default)(nodes.media && (nodes.mediaGroup || nodes.mediaSingle), 'Editor: unable to init media plugin - media or mediaGroup/mediaSingle node absent in schema');
|
|
464
|
-
if (mediaOptions !== null && mediaOptions !== void 0 && mediaOptions.
|
|
464
|
+
if (mediaOptions !== null && mediaOptions !== void 0 && mediaOptions.syncProvider) {
|
|
465
|
+
this.setMediaProvider(mediaOptions === null || mediaOptions === void 0 ? void 0 : mediaOptions.syncProvider);
|
|
466
|
+
} else if (mediaOptions !== null && mediaOptions !== void 0 && mediaOptions.provider) {
|
|
465
467
|
this.setMediaProvider(mediaOptions === null || mediaOptions === void 0 ? void 0 : mediaOptions.provider);
|
|
466
468
|
}
|
|
467
469
|
if ((0, _platformFeatureFlags.fg)('platform_editor_remove_media_inline_feature_flag')) {
|
|
@@ -532,10 +534,19 @@ var MediaPluginStateImplementation = exports.MediaPluginStateImplementation = /*
|
|
|
532
534
|
return _context.abrupt("return");
|
|
533
535
|
case 8:
|
|
534
536
|
_context.prev = 8;
|
|
535
|
-
|
|
537
|
+
if (!(mediaProvider instanceof Promise)) {
|
|
538
|
+
_context.next = 15;
|
|
539
|
+
break;
|
|
540
|
+
}
|
|
541
|
+
_context.next = 12;
|
|
536
542
|
return mediaProvider;
|
|
537
|
-
case
|
|
543
|
+
case 12:
|
|
538
544
|
this.mediaProvider = _context.sent;
|
|
545
|
+
_context.next = 16;
|
|
546
|
+
break;
|
|
547
|
+
case 15:
|
|
548
|
+
this.mediaProvider = mediaProvider;
|
|
549
|
+
case 16:
|
|
539
550
|
// Ignored via go/ees007
|
|
540
551
|
// eslint-disable-next-line @atlaskit/editor/enforce-todo-comment-format
|
|
541
552
|
// TODO [MS-2038]: remove once context api is removed
|
|
@@ -548,10 +559,10 @@ var MediaPluginStateImplementation = exports.MediaPluginStateImplementation = /*
|
|
|
548
559
|
}
|
|
549
560
|
}
|
|
550
561
|
(0, _assert.default)(this.mediaProvider.viewMediaClientConfig, "MediaProvider promise did not resolve to a valid instance of MediaProvider - ".concat(this.mediaProvider));
|
|
551
|
-
_context.next =
|
|
562
|
+
_context.next = 28;
|
|
552
563
|
break;
|
|
553
|
-
case
|
|
554
|
-
_context.prev =
|
|
564
|
+
case 20:
|
|
565
|
+
_context.prev = 20;
|
|
555
566
|
_context.t0 = _context["catch"](8);
|
|
556
567
|
wrappedError = new Error("Media functionality disabled due to rejected provider: ".concat(_context.t0 instanceof Error ? _context.t0.message : String(_context.t0)));
|
|
557
568
|
this.errorReporter.captureException(wrappedError);
|
|
@@ -563,7 +574,7 @@ var MediaPluginStateImplementation = exports.MediaPluginStateImplementation = /*
|
|
|
563
574
|
}));
|
|
564
575
|
}
|
|
565
576
|
return _context.abrupt("return");
|
|
566
|
-
case
|
|
577
|
+
case 28:
|
|
567
578
|
this.mediaClientConfig = this.mediaProvider.viewMediaClientConfig;
|
|
568
579
|
this.allowsUploads = !!this.mediaProvider.uploadMediaClientConfig;
|
|
569
580
|
view = this.view, allowsUploads = this.allowsUploads; // make sure editable DOM node is mounted
|
|
@@ -574,31 +585,31 @@ var MediaPluginStateImplementation = exports.MediaPluginStateImplementation = /*
|
|
|
574
585
|
}));
|
|
575
586
|
}
|
|
576
587
|
if (!this.allowsUploads) {
|
|
577
|
-
_context.next =
|
|
588
|
+
_context.next = 42;
|
|
578
589
|
break;
|
|
579
590
|
}
|
|
580
591
|
this.uploadMediaClientConfig = this.mediaProvider.uploadMediaClientConfig;
|
|
581
592
|
if (!(this.mediaProvider.uploadParams && this.uploadMediaClientConfig)) {
|
|
582
|
-
_context.next =
|
|
593
|
+
_context.next = 39;
|
|
583
594
|
break;
|
|
584
595
|
}
|
|
585
|
-
_context.next =
|
|
596
|
+
_context.next = 37;
|
|
586
597
|
return this.initPickers(this.mediaProvider.uploadParams, _pickerFacade.default);
|
|
587
|
-
case
|
|
588
|
-
_context.next =
|
|
598
|
+
case 37:
|
|
599
|
+
_context.next = 40;
|
|
589
600
|
break;
|
|
590
|
-
case
|
|
601
|
+
case 39:
|
|
591
602
|
this.destroyPickers();
|
|
592
|
-
case
|
|
593
|
-
_context.next =
|
|
603
|
+
case 40:
|
|
604
|
+
_context.next = 43;
|
|
594
605
|
break;
|
|
595
|
-
case
|
|
606
|
+
case 42:
|
|
596
607
|
this.destroyPickers();
|
|
597
|
-
case
|
|
608
|
+
case 43:
|
|
598
609
|
case "end":
|
|
599
610
|
return _context.stop();
|
|
600
611
|
}
|
|
601
|
-
}, _callee, this, [[8,
|
|
612
|
+
}, _callee, this, [[8, 20]]);
|
|
602
613
|
}));
|
|
603
614
|
function setMediaProvider(_x) {
|
|
604
615
|
return _setMediaProvider.apply(this, arguments);
|
|
@@ -26,7 +26,9 @@ var getMediaNodeInsertionType = exports.getMediaNodeInsertionType = function get
|
|
|
26
26
|
var canInsertInlineNode = (0, _mediaCommon.getMediaFeatureFlag)('mediaInline', mediaOptions === null || mediaOptions === void 0 ? void 0 : mediaOptions.featureFlags) && !(0, _utils.isInEmptyLine)(state) && (!(0, _mediaCommon2.isInsidePotentialEmptyParagraph)(state) || isInSupportedInlineImageParent(state)) && (0, _mediaFiles.canInsertMediaInline)(state);
|
|
27
27
|
if ((0, _platformFeatureFlags.fg)('platform_editor_remove_media_inline_feature_flag')) {
|
|
28
28
|
if (mediaOptions !== null && mediaOptions !== void 0 && mediaOptions.allowMediaInlineImages) {
|
|
29
|
-
|
|
29
|
+
if (canInsertInlineNode && !(0, _isType.isVideo)(fileMimeType)) {
|
|
30
|
+
return 'inline';
|
|
31
|
+
}
|
|
30
32
|
}
|
|
31
33
|
} else {
|
|
32
34
|
if ((0, _mediaInline.mediaInlineImagesEnabled)((0, _mediaCommon.getMediaFeatureFlag)('mediaInline', mediaOptions === null || mediaOptions === void 0 ? void 0 : mediaOptions.featureFlags), mediaOptions === null || mediaOptions === void 0 ? void 0 : mediaOptions.allowMediaInlineImages)) {
|
|
@@ -734,7 +734,7 @@ var ResizableMediaSingleNextFunctional = exports.ResizableMediaSingleNextFunctio
|
|
|
734
734
|
_useState6 = (0, _slicedToArray2.default)(_useState5, 2),
|
|
735
735
|
isResizing = _useState6[0],
|
|
736
736
|
setIsResizing = _useState6[1];
|
|
737
|
-
var _useState7 = (0, _react.useState)(
|
|
737
|
+
var _useState7 = (0, _react.useState)(!(0, _platformFeatureFlags.fg)('platform_editor_ssr_media')),
|
|
738
738
|
_useState8 = (0, _slicedToArray2.default)(_useState7, 2),
|
|
739
739
|
isVideoFile = _useState8[0],
|
|
740
740
|
setIsVideoFile = _useState8[1];
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { withLazyLoading } from '@atlaskit/editor-common/lazy-node-view';
|
|
2
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
3
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
3
4
|
import { ReactMediaSingleNode } from './mediaSingle';
|
|
4
5
|
export const lazyMediaSingleView = (portalProviderAPI, eventDispatcher, providerFactory, api, dispatchAnalyticsEvent, options = {}) => {
|
|
5
|
-
if (editorExperiment('platform_editor_exp_lazy_node_views', false)) {
|
|
6
|
+
if (fg('platform_editor_ssr_media') || editorExperiment('platform_editor_exp_lazy_node_views', false)) {
|
|
6
7
|
return ReactMediaSingleNode(portalProviderAPI, eventDispatcher, providerFactory, api, dispatchAnalyticsEvent, options);
|
|
7
8
|
}
|
|
8
9
|
return withLazyLoading({
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { withLazyLoading } from '@atlaskit/editor-common/lazy-node-view';
|
|
2
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
3
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
3
4
|
import { ReactMediaNode } from './mediaNodeView';
|
|
4
5
|
export const lazyMediaView = (portalProviderAPI, eventDispatcher, providerFactory, options = {}, api) => {
|
|
5
|
-
if (editorExperiment('platform_editor_exp_lazy_node_views', false)) {
|
|
6
|
+
if (fg('platform_editor_ssr_media') || editorExperiment('platform_editor_exp_lazy_node_views', false)) {
|
|
6
7
|
return ReactMediaNode(portalProviderAPI, eventDispatcher, providerFactory, options, api);
|
|
7
8
|
}
|
|
8
9
|
return withLazyLoading({
|
|
@@ -6,6 +6,7 @@ import { AnalyticsContext } from '@atlaskit/analytics-next';
|
|
|
6
6
|
import { setNodeSelection, setTextSelection, withImageLoader } from '@atlaskit/editor-common/utils';
|
|
7
7
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
8
8
|
import { Card, CardLoading } from '@atlaskit/media-card';
|
|
9
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
9
10
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
10
11
|
import { stateKey as mediaStateKey } from '../../pm-plugins/plugin-key';
|
|
11
12
|
import { MediaCardWrapper } from '../styles';
|
|
@@ -224,6 +225,10 @@ export class MediaNode extends Component {
|
|
|
224
225
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
225
226
|
authProvider: () => ({})
|
|
226
227
|
};
|
|
228
|
+
let ssr;
|
|
229
|
+
if (fg('platform_editor_ssr_media')) {
|
|
230
|
+
ssr = process.env.REACT_SSR ? 'server' : 'client';
|
|
231
|
+
}
|
|
227
232
|
return /*#__PURE__*/React.createElement(MediaCardWrapper, {
|
|
228
233
|
dimensions: originalDimensions,
|
|
229
234
|
onContextMenu: this.selectMediaSingle,
|
|
@@ -251,7 +256,8 @@ export class MediaNode extends Component {
|
|
|
251
256
|
featureFlags: mediaOptions && mediaOptions.featureFlags,
|
|
252
257
|
contextId: contextId,
|
|
253
258
|
alt: alt,
|
|
254
|
-
videoControlsWrapperRef: this.videoControlsWrapperRef
|
|
259
|
+
videoControlsWrapperRef: this.videoControlsWrapperRef,
|
|
260
|
+
ssr: ssr
|
|
255
261
|
})));
|
|
256
262
|
}
|
|
257
263
|
}
|
|
@@ -439,7 +439,9 @@ export class MediaPluginStateImplementation {
|
|
|
439
439
|
nodes
|
|
440
440
|
} = _state.schema;
|
|
441
441
|
assert(nodes.media && (nodes.mediaGroup || nodes.mediaSingle), 'Editor: unable to init media plugin - media or mediaGroup/mediaSingle node absent in schema');
|
|
442
|
-
if (mediaOptions !== null && mediaOptions !== void 0 && mediaOptions.
|
|
442
|
+
if (mediaOptions !== null && mediaOptions !== void 0 && mediaOptions.syncProvider) {
|
|
443
|
+
this.setMediaProvider(mediaOptions === null || mediaOptions === void 0 ? void 0 : mediaOptions.syncProvider);
|
|
444
|
+
} else if (mediaOptions !== null && mediaOptions !== void 0 && mediaOptions.provider) {
|
|
443
445
|
this.setMediaProvider(mediaOptions === null || mediaOptions === void 0 ? void 0 : mediaOptions.provider);
|
|
444
446
|
}
|
|
445
447
|
if (fg('platform_editor_remove_media_inline_feature_flag')) {
|
|
@@ -494,7 +496,11 @@ export class MediaPluginStateImplementation {
|
|
|
494
496
|
// eslint-disable-next-line @atlaskit/editor/enforce-todo-comment-format
|
|
495
497
|
// TODO disable (not destroy!) pickers until mediaProvider is resolved
|
|
496
498
|
try {
|
|
497
|
-
|
|
499
|
+
if (mediaProvider instanceof Promise) {
|
|
500
|
+
this.mediaProvider = await mediaProvider;
|
|
501
|
+
} else {
|
|
502
|
+
this.mediaProvider = mediaProvider;
|
|
503
|
+
}
|
|
498
504
|
|
|
499
505
|
// Ignored via go/ees007
|
|
500
506
|
// eslint-disable-next-line @atlaskit/editor/enforce-todo-comment-format
|
|
@@ -20,7 +20,9 @@ export const getMediaNodeInsertionType = (state, mediaOptions, fileMimeType) =>
|
|
|
20
20
|
const canInsertInlineNode = getMediaFeatureFlag('mediaInline', mediaOptions === null || mediaOptions === void 0 ? void 0 : mediaOptions.featureFlags) && !isInEmptyLine(state) && (!isInsidePotentialEmptyParagraph(state) || isInSupportedInlineImageParent(state)) && canInsertMediaInline(state);
|
|
21
21
|
if (fg('platform_editor_remove_media_inline_feature_flag')) {
|
|
22
22
|
if (mediaOptions !== null && mediaOptions !== void 0 && mediaOptions.allowMediaInlineImages) {
|
|
23
|
-
|
|
23
|
+
if (canInsertInlineNode && !isVideo(fileMimeType)) {
|
|
24
|
+
return 'inline';
|
|
25
|
+
}
|
|
24
26
|
}
|
|
25
27
|
} else {
|
|
26
28
|
if (mediaInlineImagesEnabled(getMediaFeatureFlag('mediaInline', mediaOptions === null || mediaOptions === void 0 ? void 0 : mediaOptions.featureFlags), mediaOptions === null || mediaOptions === void 0 ? void 0 : mediaOptions.allowMediaInlineImages)) {
|
|
@@ -642,7 +642,7 @@ export const ResizableMediaSingleNextFunctional = props => {
|
|
|
642
642
|
const lastSnappedGuidelineKeysRef = useRef([]);
|
|
643
643
|
const [snaps, setSnaps] = useState({});
|
|
644
644
|
const [isResizing, setIsResizing] = useState(false);
|
|
645
|
-
const [isVideoFile, setIsVideoFile] = useState(
|
|
645
|
+
const [isVideoFile, setIsVideoFile] = useState(!fg('platform_editor_ssr_media'));
|
|
646
646
|
const nodePosition = useMemo(() => {
|
|
647
647
|
if (typeof getPos !== 'function') {
|
|
648
648
|
return null;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { withLazyLoading } from '@atlaskit/editor-common/lazy-node-view';
|
|
2
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
3
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
3
4
|
import { ReactMediaSingleNode } from './mediaSingle';
|
|
4
5
|
export var lazyMediaSingleView = function lazyMediaSingleView(portalProviderAPI, eventDispatcher, providerFactory, api, dispatchAnalyticsEvent) {
|
|
5
6
|
var options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
|
|
6
|
-
if (editorExperiment('platform_editor_exp_lazy_node_views', false)) {
|
|
7
|
+
if (fg('platform_editor_ssr_media') || editorExperiment('platform_editor_exp_lazy_node_views', false)) {
|
|
7
8
|
return ReactMediaSingleNode(portalProviderAPI, eventDispatcher, providerFactory, api, dispatchAnalyticsEvent, options);
|
|
8
9
|
}
|
|
9
10
|
return withLazyLoading({
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { withLazyLoading } from '@atlaskit/editor-common/lazy-node-view';
|
|
2
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
3
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
3
4
|
import { ReactMediaNode } from './mediaNodeView';
|
|
4
5
|
export var lazyMediaView = function lazyMediaView(portalProviderAPI, eventDispatcher, providerFactory) {
|
|
5
6
|
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
6
7
|
var api = arguments.length > 4 ? arguments[4] : undefined;
|
|
7
|
-
if (editorExperiment('platform_editor_exp_lazy_node_views', false)) {
|
|
8
|
+
if (fg('platform_editor_ssr_media') || editorExperiment('platform_editor_exp_lazy_node_views', false)) {
|
|
8
9
|
return ReactMediaNode(portalProviderAPI, eventDispatcher, providerFactory, options, api);
|
|
9
10
|
}
|
|
10
11
|
return withLazyLoading({
|
|
@@ -15,6 +15,7 @@ import { AnalyticsContext } from '@atlaskit/analytics-next';
|
|
|
15
15
|
import { setNodeSelection, setTextSelection, withImageLoader } from '@atlaskit/editor-common/utils';
|
|
16
16
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
17
17
|
import { Card, CardLoading } from '@atlaskit/media-card';
|
|
18
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
18
19
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
19
20
|
import { stateKey as mediaStateKey } from '../../pm-plugins/plugin-key';
|
|
20
21
|
import { MediaCardWrapper } from '../styles';
|
|
@@ -276,6 +277,10 @@ export var MediaNode = /*#__PURE__*/function (_Component) {
|
|
|
276
277
|
return {};
|
|
277
278
|
}
|
|
278
279
|
};
|
|
280
|
+
var ssr;
|
|
281
|
+
if (fg('platform_editor_ssr_media')) {
|
|
282
|
+
ssr = process.env.REACT_SSR ? 'server' : 'client';
|
|
283
|
+
}
|
|
279
284
|
return /*#__PURE__*/React.createElement(MediaCardWrapper, {
|
|
280
285
|
dimensions: originalDimensions,
|
|
281
286
|
onContextMenu: this.selectMediaSingle,
|
|
@@ -301,7 +306,8 @@ export var MediaNode = /*#__PURE__*/function (_Component) {
|
|
|
301
306
|
featureFlags: mediaOptions && mediaOptions.featureFlags,
|
|
302
307
|
contextId: contextId,
|
|
303
308
|
alt: alt,
|
|
304
|
-
videoControlsWrapperRef: this.videoControlsWrapperRef
|
|
309
|
+
videoControlsWrapperRef: this.videoControlsWrapperRef,
|
|
310
|
+
ssr: ssr
|
|
305
311
|
})));
|
|
306
312
|
}
|
|
307
313
|
}]);
|
|
@@ -452,7 +452,9 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
|
|
|
452
452
|
this.waitForMediaUpload = options.waitForMediaUpload === undefined ? true : options.waitForMediaUpload;
|
|
453
453
|
var nodes = _state.schema.nodes;
|
|
454
454
|
assert(nodes.media && (nodes.mediaGroup || nodes.mediaSingle), 'Editor: unable to init media plugin - media or mediaGroup/mediaSingle node absent in schema');
|
|
455
|
-
if (mediaOptions !== null && mediaOptions !== void 0 && mediaOptions.
|
|
455
|
+
if (mediaOptions !== null && mediaOptions !== void 0 && mediaOptions.syncProvider) {
|
|
456
|
+
this.setMediaProvider(mediaOptions === null || mediaOptions === void 0 ? void 0 : mediaOptions.syncProvider);
|
|
457
|
+
} else if (mediaOptions !== null && mediaOptions !== void 0 && mediaOptions.provider) {
|
|
456
458
|
this.setMediaProvider(mediaOptions === null || mediaOptions === void 0 ? void 0 : mediaOptions.provider);
|
|
457
459
|
}
|
|
458
460
|
if (fg('platform_editor_remove_media_inline_feature_flag')) {
|
|
@@ -523,10 +525,19 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
|
|
|
523
525
|
return _context.abrupt("return");
|
|
524
526
|
case 8:
|
|
525
527
|
_context.prev = 8;
|
|
526
|
-
|
|
528
|
+
if (!(mediaProvider instanceof Promise)) {
|
|
529
|
+
_context.next = 15;
|
|
530
|
+
break;
|
|
531
|
+
}
|
|
532
|
+
_context.next = 12;
|
|
527
533
|
return mediaProvider;
|
|
528
|
-
case
|
|
534
|
+
case 12:
|
|
529
535
|
this.mediaProvider = _context.sent;
|
|
536
|
+
_context.next = 16;
|
|
537
|
+
break;
|
|
538
|
+
case 15:
|
|
539
|
+
this.mediaProvider = mediaProvider;
|
|
540
|
+
case 16:
|
|
530
541
|
// Ignored via go/ees007
|
|
531
542
|
// eslint-disable-next-line @atlaskit/editor/enforce-todo-comment-format
|
|
532
543
|
// TODO [MS-2038]: remove once context api is removed
|
|
@@ -539,10 +550,10 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
|
|
|
539
550
|
}
|
|
540
551
|
}
|
|
541
552
|
assert(this.mediaProvider.viewMediaClientConfig, "MediaProvider promise did not resolve to a valid instance of MediaProvider - ".concat(this.mediaProvider));
|
|
542
|
-
_context.next =
|
|
553
|
+
_context.next = 28;
|
|
543
554
|
break;
|
|
544
|
-
case
|
|
545
|
-
_context.prev =
|
|
555
|
+
case 20:
|
|
556
|
+
_context.prev = 20;
|
|
546
557
|
_context.t0 = _context["catch"](8);
|
|
547
558
|
wrappedError = new Error("Media functionality disabled due to rejected provider: ".concat(_context.t0 instanceof Error ? _context.t0.message : String(_context.t0)));
|
|
548
559
|
this.errorReporter.captureException(wrappedError);
|
|
@@ -554,7 +565,7 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
|
|
|
554
565
|
}));
|
|
555
566
|
}
|
|
556
567
|
return _context.abrupt("return");
|
|
557
|
-
case
|
|
568
|
+
case 28:
|
|
558
569
|
this.mediaClientConfig = this.mediaProvider.viewMediaClientConfig;
|
|
559
570
|
this.allowsUploads = !!this.mediaProvider.uploadMediaClientConfig;
|
|
560
571
|
view = this.view, allowsUploads = this.allowsUploads; // make sure editable DOM node is mounted
|
|
@@ -565,31 +576,31 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
|
|
|
565
576
|
}));
|
|
566
577
|
}
|
|
567
578
|
if (!this.allowsUploads) {
|
|
568
|
-
_context.next =
|
|
579
|
+
_context.next = 42;
|
|
569
580
|
break;
|
|
570
581
|
}
|
|
571
582
|
this.uploadMediaClientConfig = this.mediaProvider.uploadMediaClientConfig;
|
|
572
583
|
if (!(this.mediaProvider.uploadParams && this.uploadMediaClientConfig)) {
|
|
573
|
-
_context.next =
|
|
584
|
+
_context.next = 39;
|
|
574
585
|
break;
|
|
575
586
|
}
|
|
576
|
-
_context.next =
|
|
587
|
+
_context.next = 37;
|
|
577
588
|
return this.initPickers(this.mediaProvider.uploadParams, PickerFacade);
|
|
578
|
-
case
|
|
579
|
-
_context.next =
|
|
589
|
+
case 37:
|
|
590
|
+
_context.next = 40;
|
|
580
591
|
break;
|
|
581
|
-
case
|
|
592
|
+
case 39:
|
|
582
593
|
this.destroyPickers();
|
|
583
|
-
case
|
|
584
|
-
_context.next =
|
|
594
|
+
case 40:
|
|
595
|
+
_context.next = 43;
|
|
585
596
|
break;
|
|
586
|
-
case
|
|
597
|
+
case 42:
|
|
587
598
|
this.destroyPickers();
|
|
588
|
-
case
|
|
599
|
+
case 43:
|
|
589
600
|
case "end":
|
|
590
601
|
return _context.stop();
|
|
591
602
|
}
|
|
592
|
-
}, _callee, this, [[8,
|
|
603
|
+
}, _callee, this, [[8, 20]]);
|
|
593
604
|
}));
|
|
594
605
|
function setMediaProvider(_x) {
|
|
595
606
|
return _setMediaProvider.apply(this, arguments);
|
|
@@ -20,7 +20,9 @@ export var getMediaNodeInsertionType = function getMediaNodeInsertionType(state,
|
|
|
20
20
|
var canInsertInlineNode = getMediaFeatureFlag('mediaInline', mediaOptions === null || mediaOptions === void 0 ? void 0 : mediaOptions.featureFlags) && !isInEmptyLine(state) && (!isInsidePotentialEmptyParagraph(state) || isInSupportedInlineImageParent(state)) && canInsertMediaInline(state);
|
|
21
21
|
if (fg('platform_editor_remove_media_inline_feature_flag')) {
|
|
22
22
|
if (mediaOptions !== null && mediaOptions !== void 0 && mediaOptions.allowMediaInlineImages) {
|
|
23
|
-
|
|
23
|
+
if (canInsertInlineNode && !isVideo(fileMimeType)) {
|
|
24
|
+
return 'inline';
|
|
25
|
+
}
|
|
24
26
|
}
|
|
25
27
|
} else {
|
|
26
28
|
if (mediaInlineImagesEnabled(getMediaFeatureFlag('mediaInline', mediaOptions === null || mediaOptions === void 0 ? void 0 : mediaOptions.featureFlags), mediaOptions === null || mediaOptions === void 0 ? void 0 : mediaOptions.allowMediaInlineImages)) {
|
|
@@ -727,7 +727,7 @@ export var ResizableMediaSingleNextFunctional = function ResizableMediaSingleNex
|
|
|
727
727
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
728
728
|
isResizing = _useState6[0],
|
|
729
729
|
setIsResizing = _useState6[1];
|
|
730
|
-
var _useState7 = useState(
|
|
730
|
+
var _useState7 = useState(!fg('platform_editor_ssr_media')),
|
|
731
731
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
732
732
|
isVideoFile = _useState8[0],
|
|
733
733
|
setIsVideoFile = _useState8[1];
|
|
@@ -68,7 +68,7 @@ export declare class MediaPluginStateImplementation implements MediaPluginState
|
|
|
68
68
|
subscribeToUploadInProgressState(fn: (isUploading: boolean) => void): void;
|
|
69
69
|
unsubscribeFromUploadInProgressState(fn: (isUploading: boolean) => void): void;
|
|
70
70
|
private previousMediaProvider;
|
|
71
|
-
setMediaProvider(mediaProvider?: Promise<MediaProvider>): Promise<void>;
|
|
71
|
+
setMediaProvider(mediaProvider?: Promise<MediaProvider> | MediaProvider): Promise<void>;
|
|
72
72
|
getMediaOptions: () => MediaPluginOptions;
|
|
73
73
|
setIsResizing(isResizing: boolean): void;
|
|
74
74
|
setResizingWidth(width: number): void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { MediaADFAttrs, MediaInlineAttributes } from '@atlaskit/adf-schema';
|
|
2
|
-
import type { ProviderFactory, Providers } from '@atlaskit/editor-common/provider-factory';
|
|
2
|
+
import type { MediaProvider, ProviderFactory, Providers } from '@atlaskit/editor-common/provider-factory';
|
|
3
3
|
import type { HandlePositioning } from '@atlaskit/editor-common/resizer';
|
|
4
4
|
import type { EditorSelectionAPI } from '@atlaskit/editor-common/selection';
|
|
5
5
|
import type { EditorAppearance, GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
|
|
@@ -17,6 +17,7 @@ export type MediaSingleWithType = 'pixel' | 'percentage';
|
|
|
17
17
|
export type MediaCopyScope = 'editor' | 'context';
|
|
18
18
|
export interface MediaPluginOptions {
|
|
19
19
|
provider?: Providers['mediaProvider'];
|
|
20
|
+
syncProvider?: MediaProvider;
|
|
20
21
|
/**
|
|
21
22
|
* @experimental
|
|
22
23
|
* Still under development. Use with caution.
|
|
@@ -68,7 +68,7 @@ export declare class MediaPluginStateImplementation implements MediaPluginState
|
|
|
68
68
|
subscribeToUploadInProgressState(fn: (isUploading: boolean) => void): void;
|
|
69
69
|
unsubscribeFromUploadInProgressState(fn: (isUploading: boolean) => void): void;
|
|
70
70
|
private previousMediaProvider;
|
|
71
|
-
setMediaProvider(mediaProvider?: Promise<MediaProvider>): Promise<void>;
|
|
71
|
+
setMediaProvider(mediaProvider?: Promise<MediaProvider> | MediaProvider): Promise<void>;
|
|
72
72
|
getMediaOptions: () => MediaPluginOptions;
|
|
73
73
|
setIsResizing(isResizing: boolean): void;
|
|
74
74
|
setResizingWidth(width: number): void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { MediaADFAttrs, MediaInlineAttributes } from '@atlaskit/adf-schema';
|
|
2
|
-
import type { ProviderFactory, Providers } from '@atlaskit/editor-common/provider-factory';
|
|
2
|
+
import type { MediaProvider, ProviderFactory, Providers } from '@atlaskit/editor-common/provider-factory';
|
|
3
3
|
import type { HandlePositioning } from '@atlaskit/editor-common/resizer';
|
|
4
4
|
import type { EditorSelectionAPI } from '@atlaskit/editor-common/selection';
|
|
5
5
|
import type { EditorAppearance, GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
|
|
@@ -17,6 +17,7 @@ export type MediaSingleWithType = 'pixel' | 'percentage';
|
|
|
17
17
|
export type MediaCopyScope = 'editor' | 'context';
|
|
18
18
|
export interface MediaPluginOptions {
|
|
19
19
|
provider?: Providers['mediaProvider'];
|
|
20
|
+
syncProvider?: MediaProvider;
|
|
20
21
|
/**
|
|
21
22
|
* @experimental
|
|
22
23
|
* Still under development. Use with caution.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-media",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.1",
|
|
4
4
|
"description": "Media plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -38,15 +38,15 @@
|
|
|
38
38
|
"@atlaskit/analytics-namespaced-context": "^7.0.0",
|
|
39
39
|
"@atlaskit/analytics-next": "^11.0.0",
|
|
40
40
|
"@atlaskit/button": "^23.0.0",
|
|
41
|
-
"@atlaskit/editor-common": "^103.
|
|
41
|
+
"@atlaskit/editor-common": "^103.11.0",
|
|
42
42
|
"@atlaskit/editor-palette": "^2.1.0",
|
|
43
43
|
"@atlaskit/editor-plugin-analytics": "^2.2.0",
|
|
44
|
-
"@atlaskit/editor-plugin-annotation": "^2.
|
|
44
|
+
"@atlaskit/editor-plugin-annotation": "^2.7.0",
|
|
45
45
|
"@atlaskit/editor-plugin-connectivity": "^2.0.0",
|
|
46
46
|
"@atlaskit/editor-plugin-decorations": "^2.0.0",
|
|
47
47
|
"@atlaskit/editor-plugin-editor-disabled": "^2.0.0",
|
|
48
48
|
"@atlaskit/editor-plugin-editor-viewmode": "^3.1.0",
|
|
49
|
-
"@atlaskit/editor-plugin-floating-toolbar": "^
|
|
49
|
+
"@atlaskit/editor-plugin-floating-toolbar": "^4.0.0",
|
|
50
50
|
"@atlaskit/editor-plugin-focus": "^1.5.0",
|
|
51
51
|
"@atlaskit/editor-plugin-grid": "^2.0.0",
|
|
52
52
|
"@atlaskit/editor-plugin-guideline": "^2.0.0",
|
|
@@ -56,8 +56,8 @@
|
|
|
56
56
|
"@atlaskit/editor-shared-styles": "^3.4.0",
|
|
57
57
|
"@atlaskit/editor-tables": "^2.9.0",
|
|
58
58
|
"@atlaskit/form": "^12.0.0",
|
|
59
|
-
"@atlaskit/icon": "^25.
|
|
60
|
-
"@atlaskit/media-card": "^79.
|
|
59
|
+
"@atlaskit/icon": "^25.6.0",
|
|
60
|
+
"@atlaskit/media-card": "^79.2.0",
|
|
61
61
|
"@atlaskit/media-client": "^32.0.0",
|
|
62
62
|
"@atlaskit/media-client-react": "^4.0.0",
|
|
63
63
|
"@atlaskit/media-common": "^12.0.0",
|
|
@@ -69,8 +69,8 @@
|
|
|
69
69
|
"@atlaskit/primitives": "^14.4.0",
|
|
70
70
|
"@atlaskit/textfield": "^8.0.0",
|
|
71
71
|
"@atlaskit/theme": "^18.0.0",
|
|
72
|
-
"@atlaskit/tmp-editor-statsig": "^4.
|
|
73
|
-
"@atlaskit/tokens": "^4.
|
|
72
|
+
"@atlaskit/tmp-editor-statsig": "^4.12.0",
|
|
73
|
+
"@atlaskit/tokens": "^4.8.0",
|
|
74
74
|
"@atlaskit/tooltip": "^20.0.0",
|
|
75
75
|
"@babel/runtime": "^7.0.0",
|
|
76
76
|
"@emotion/react": "^11.7.1",
|
|
@@ -176,6 +176,9 @@
|
|
|
176
176
|
},
|
|
177
177
|
"platform_editor_media_single_toolbar_target": {
|
|
178
178
|
"type": "boolean"
|
|
179
|
+
},
|
|
180
|
+
"platform_editor_ssr_media": {
|
|
181
|
+
"type": "boolean"
|
|
179
182
|
}
|
|
180
183
|
},
|
|
181
184
|
"stricter": {
|