@atlaskit/editor-plugin-media 3.0.3 → 3.0.4
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 +9 -0
- package/dist/cjs/mediaPlugin.js +43 -22
- package/dist/cjs/nodeviews/mediaGroup.js +22 -20
- package/dist/cjs/nodeviews/mediaInline.js +43 -38
- package/dist/cjs/nodeviews/mediaNodeView/index.js +20 -11
- package/dist/cjs/nodeviews/mediaSingle.js +48 -43
- package/dist/cjs/ui/CommentBadge/index.js +26 -33
- package/dist/cjs/ui/MediaPicker/BrowserWrapper.js +2 -2
- package/dist/cjs/ui/MediaPicker/ClipboardWrapper.js +4 -4
- package/dist/cjs/ui/MediaPicker/DropzoneWrapper.js +72 -31
- package/dist/cjs/ui/MediaPicker/PickerFacadeProvider.js +37 -9
- package/dist/cjs/ui/MediaPicker/index.js +32 -25
- package/dist/cjs/ui/ToolbarMedia/index.js +18 -13
- package/dist/cjs/ui/hooks/useMediaProvider.js +14 -9
- package/dist/es2019/mediaPlugin.js +47 -24
- package/dist/es2019/nodeviews/mediaGroup.js +23 -20
- package/dist/es2019/nodeviews/mediaInline.js +45 -39
- package/dist/es2019/nodeviews/mediaNodeView/index.js +22 -12
- package/dist/es2019/nodeviews/mediaSingle.js +49 -43
- package/dist/es2019/ui/CommentBadge/index.js +29 -35
- package/dist/es2019/ui/MediaPicker/BrowserWrapper.js +2 -2
- package/dist/es2019/ui/MediaPicker/ClipboardWrapper.js +4 -4
- package/dist/es2019/ui/MediaPicker/DropzoneWrapper.js +53 -14
- package/dist/es2019/ui/MediaPicker/PickerFacadeProvider.js +37 -7
- package/dist/es2019/ui/MediaPicker/index.js +34 -26
- package/dist/es2019/ui/ToolbarMedia/index.js +20 -14
- package/dist/es2019/ui/hooks/useMediaProvider.js +16 -10
- package/dist/esm/mediaPlugin.js +44 -23
- package/dist/esm/nodeviews/mediaGroup.js +23 -21
- package/dist/esm/nodeviews/mediaInline.js +44 -39
- package/dist/esm/nodeviews/mediaNodeView/index.js +21 -12
- package/dist/esm/nodeviews/mediaSingle.js +49 -44
- package/dist/esm/ui/CommentBadge/index.js +27 -34
- package/dist/esm/ui/MediaPicker/BrowserWrapper.js +2 -2
- package/dist/esm/ui/MediaPicker/ClipboardWrapper.js +4 -4
- package/dist/esm/ui/MediaPicker/DropzoneWrapper.js +72 -31
- package/dist/esm/ui/MediaPicker/PickerFacadeProvider.js +37 -9
- package/dist/esm/ui/MediaPicker/index.js +33 -26
- package/dist/esm/ui/ToolbarMedia/index.js +19 -14
- package/dist/esm/ui/hooks/useMediaProvider.js +15 -10
- package/dist/types/ui/MediaPicker/BrowserWrapper.d.ts +4 -3
- package/dist/types/ui/MediaPicker/ClipboardWrapper.d.ts +4 -3
- package/dist/types/ui/MediaPicker/DropzoneWrapper.d.ts +4 -4
- package/dist/types/ui/MediaPicker/PickerFacadeProvider.d.ts +4 -3
- package/dist/types/ui/MediaPicker/index.d.ts +2 -2
- package/dist/types-ts4.5/ui/MediaPicker/BrowserWrapper.d.ts +4 -3
- package/dist/types-ts4.5/ui/MediaPicker/ClipboardWrapper.d.ts +4 -3
- package/dist/types-ts4.5/ui/MediaPicker/DropzoneWrapper.d.ts +4 -4
- package/dist/types-ts4.5/ui/MediaPicker/PickerFacadeProvider.d.ts +4 -3
- package/dist/types-ts4.5/ui/MediaPicker/index.d.ts +2 -2
- package/package.json +4 -4
|
@@ -6,7 +6,7 @@ import { useEffect, useMemo, useState } from 'react';
|
|
|
6
6
|
|
|
7
7
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
8
8
|
import { jsx } from '@emotion/react';
|
|
9
|
-
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
9
|
+
import { sharedPluginStateHookMigratorFactory, useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
10
10
|
import { MediaInlineImageCard } from '@atlaskit/editor-common/media-inline';
|
|
11
11
|
import { WithProviders } from '@atlaskit/editor-common/provider-factory';
|
|
12
12
|
import { SelectionBasedNodeView } from '@atlaskit/editor-common/selection-based-node-view';
|
|
@@ -14,7 +14,6 @@ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared
|
|
|
14
14
|
import { MediaInlineCard } from '@atlaskit/media-card';
|
|
15
15
|
import { getMediaClient } from '@atlaskit/media-client-react';
|
|
16
16
|
import { MediaInlineCardLoadingView } from '@atlaskit/media-ui';
|
|
17
|
-
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
18
17
|
import { isImage } from '../pm-plugins/utils/is-type';
|
|
19
18
|
import { MediaViewerContainer } from '../ui/MediaViewer/MediaViewerContainer';
|
|
20
19
|
import { MediaNodeUpdater } from './mediaNodeUpdater';
|
|
@@ -155,6 +154,41 @@ export const MediaInline = props => {
|
|
|
155
154
|
mediaClientConfig: viewMediaClientConfig
|
|
156
155
|
}));
|
|
157
156
|
};
|
|
157
|
+
const useSharedState = sharedPluginStateHookMigratorFactory(api => {
|
|
158
|
+
const viewMode = useSharedPluginStateSelector(api, 'editorViewMode.mode');
|
|
159
|
+
const mediaProvider = useSharedPluginStateSelector(api, 'media.mediaProvider');
|
|
160
|
+
const handleMediaNodeMount = useSharedPluginStateSelector(api, 'media.handleMediaNodeMount');
|
|
161
|
+
const handleMediaNodeUnmount = useSharedPluginStateSelector(api, 'media.handleMediaNodeUnmount');
|
|
162
|
+
const allowInlineImages = useSharedPluginStateSelector(api, 'media.allowInlineImages');
|
|
163
|
+
const addPendingTask = useSharedPluginStateSelector(api, 'media.addPendingTask');
|
|
164
|
+
const selectedMediaContainerNode = useSharedPluginStateSelector(api, 'media.selectedMediaContainerNode');
|
|
165
|
+
const mediaClientConfig = useSharedPluginStateSelector(api, 'media.mediaClientConfig');
|
|
166
|
+
return {
|
|
167
|
+
viewMode,
|
|
168
|
+
mediaProvider,
|
|
169
|
+
handleMediaNodeMount,
|
|
170
|
+
handleMediaNodeUnmount,
|
|
171
|
+
allowInlineImages,
|
|
172
|
+
addPendingTask,
|
|
173
|
+
selectedMediaContainerNode,
|
|
174
|
+
mediaClientConfig
|
|
175
|
+
};
|
|
176
|
+
}, api => {
|
|
177
|
+
const {
|
|
178
|
+
editorViewModeState,
|
|
179
|
+
mediaState
|
|
180
|
+
} = useSharedPluginState(api, ['editorViewMode', 'media']);
|
|
181
|
+
return {
|
|
182
|
+
viewMode: editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode,
|
|
183
|
+
mediaProvider: mediaState === null || mediaState === void 0 ? void 0 : mediaState.mediaProvider,
|
|
184
|
+
handleMediaNodeMount: mediaState === null || mediaState === void 0 ? void 0 : mediaState.handleMediaNodeMount,
|
|
185
|
+
handleMediaNodeUnmount: mediaState === null || mediaState === void 0 ? void 0 : mediaState.handleMediaNodeUnmount,
|
|
186
|
+
allowInlineImages: mediaState === null || mediaState === void 0 ? void 0 : mediaState.allowInlineImages,
|
|
187
|
+
addPendingTask: mediaState === null || mediaState === void 0 ? void 0 : mediaState.addPendingTask,
|
|
188
|
+
selectedMediaContainerNode: mediaState === null || mediaState === void 0 ? void 0 : mediaState.selectedMediaContainerNode,
|
|
189
|
+
mediaClientConfig: mediaState === null || mediaState === void 0 ? void 0 : mediaState.mediaClientConfig
|
|
190
|
+
};
|
|
191
|
+
});
|
|
158
192
|
const MediaInlineSharedState = ({
|
|
159
193
|
identifier,
|
|
160
194
|
node,
|
|
@@ -165,43 +199,15 @@ const MediaInlineSharedState = ({
|
|
|
165
199
|
view
|
|
166
200
|
}) => {
|
|
167
201
|
const {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
178
|
-
});
|
|
179
|
-
const handleMediaNodeMountSelector = useSharedPluginStateSelector(api, 'media.handleMediaNodeMount', {
|
|
180
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
181
|
-
});
|
|
182
|
-
const handleMediaNodeUnmountSelector = useSharedPluginStateSelector(api, 'media.handleMediaNodeUnmount', {
|
|
183
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
184
|
-
});
|
|
185
|
-
const allowInlineImagesSelector = useSharedPluginStateSelector(api, 'media.allowInlineImages', {
|
|
186
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
187
|
-
});
|
|
188
|
-
const addPendingTaskSelector = useSharedPluginStateSelector(api, 'media.addPendingTask', {
|
|
189
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
190
|
-
});
|
|
191
|
-
const selectedMediaContainerNodeSelector = useSharedPluginStateSelector(api, 'media.selectedMediaContainerNode', {
|
|
192
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
193
|
-
});
|
|
194
|
-
const mediaClientConfigSelector = useSharedPluginStateSelector(api, 'media.mediaClientConfig', {
|
|
195
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
196
|
-
});
|
|
197
|
-
const viewMode = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? viewModeSelector : editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode;
|
|
198
|
-
const mediaProvider = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? mediaProviderSelector : mediaState === null || mediaState === void 0 ? void 0 : mediaState.mediaProvider;
|
|
199
|
-
const handleMediaNodeMount = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? handleMediaNodeMountSelector : mediaState === null || mediaState === void 0 ? void 0 : mediaState.handleMediaNodeMount;
|
|
200
|
-
const handleMediaNodeUnmount = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? handleMediaNodeUnmountSelector : mediaState === null || mediaState === void 0 ? void 0 : mediaState.handleMediaNodeUnmount;
|
|
201
|
-
const allowInlineImages = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? allowInlineImagesSelector : mediaState === null || mediaState === void 0 ? void 0 : mediaState.allowInlineImages;
|
|
202
|
-
const addPendingTask = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? addPendingTaskSelector : mediaState === null || mediaState === void 0 ? void 0 : mediaState.addPendingTask;
|
|
203
|
-
const selectedMediaContainerNode = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? selectedMediaContainerNodeSelector : mediaState === null || mediaState === void 0 ? void 0 : mediaState.selectedMediaContainerNode;
|
|
204
|
-
const mediaClientConfig = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? mediaClientConfigSelector : mediaState === null || mediaState === void 0 ? void 0 : mediaState.mediaClientConfig;
|
|
202
|
+
mediaProvider,
|
|
203
|
+
allowInlineImages,
|
|
204
|
+
handleMediaNodeMount,
|
|
205
|
+
handleMediaNodeUnmount,
|
|
206
|
+
addPendingTask,
|
|
207
|
+
selectedMediaContainerNode,
|
|
208
|
+
mediaClientConfig,
|
|
209
|
+
viewMode
|
|
210
|
+
} = useSharedState(api);
|
|
205
211
|
const newMediaProvider = useMemo(() => mediaProvider ? Promise.resolve(mediaProvider) : undefined, [mediaProvider]);
|
|
206
212
|
if (!handleMediaNodeMount || !handleMediaNodeUnmount || !addPendingTask || !selectedMediaContainerNode || !mediaClientConfig || !newMediaProvider) {
|
|
207
213
|
return null;
|
|
@@ -1,33 +1,43 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
3
|
+
import { sharedPluginStateHookMigratorFactory, useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
4
4
|
import { DEFAULT_IMAGE_HEIGHT, DEFAULT_IMAGE_WIDTH } from '@atlaskit/editor-common/media-single';
|
|
5
5
|
import { WithProviders } from '@atlaskit/editor-common/provider-factory';
|
|
6
6
|
import { SelectionBasedNodeView } from '@atlaskit/editor-common/selection-based-node-view';
|
|
7
7
|
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
8
8
|
import { getAttrsFromUrl } from '@atlaskit/media-client';
|
|
9
|
-
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
10
9
|
import { updateCurrentMediaNodeAttrs } from '../../pm-plugins/commands/helpers';
|
|
11
10
|
import { isMediaBlobUrlFromAttrs } from '../../pm-plugins/utils/media-common';
|
|
12
11
|
// Ignored via go/ees005
|
|
13
12
|
// eslint-disable-next-line import/no-named-as-default
|
|
14
13
|
import MediaNode from './media';
|
|
14
|
+
const useSharedState = sharedPluginStateHookMigratorFactory(pluginInjectionApi => {
|
|
15
|
+
const mediaProvider = useSharedPluginStateSelector(pluginInjectionApi, 'media.mediaProvider');
|
|
16
|
+
return {
|
|
17
|
+
mediaProvider,
|
|
18
|
+
widthState: undefined
|
|
19
|
+
};
|
|
20
|
+
}, pluginInjectionApi => {
|
|
21
|
+
const {
|
|
22
|
+
widthState,
|
|
23
|
+
mediaState
|
|
24
|
+
} = useSharedPluginState(pluginInjectionApi, ['width', 'media']);
|
|
25
|
+
return {
|
|
26
|
+
mediaProvider: mediaState === null || mediaState === void 0 ? void 0 : mediaState.mediaProvider,
|
|
27
|
+
widthState
|
|
28
|
+
};
|
|
29
|
+
});
|
|
15
30
|
const MediaNodeWithProviders = ({
|
|
16
31
|
pluginInjectionApi,
|
|
17
32
|
innerComponent
|
|
18
33
|
}) => {
|
|
19
34
|
const {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
} =
|
|
23
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
|
|
24
|
-
});
|
|
25
|
-
const mediaProviderSelector = useSharedPluginStateSelector(pluginInjectionApi, 'media.mediaProvider', {
|
|
26
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
27
|
-
});
|
|
28
|
-
const mediaProvider = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? mediaProviderSelector : mediaState === null || mediaState === void 0 ? void 0 : mediaState.mediaProvider;
|
|
35
|
+
mediaProvider,
|
|
36
|
+
widthState
|
|
37
|
+
} = useSharedState(pluginInjectionApi);
|
|
29
38
|
return innerComponent({
|
|
30
|
-
width:
|
|
39
|
+
width: widthState,
|
|
40
|
+
// Remove when platform_editor_usesharedpluginstateselector is cleaned up
|
|
31
41
|
mediaProvider: mediaProvider ? Promise.resolve(mediaProvider) : undefined
|
|
32
42
|
});
|
|
33
43
|
};
|
|
@@ -10,7 +10,7 @@ import React, { Component, Fragment, useCallback, useMemo } from 'react';
|
|
|
10
10
|
|
|
11
11
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
12
12
|
import { css, jsx } from '@emotion/react';
|
|
13
|
-
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
13
|
+
import { sharedPluginStateHookMigratorFactory, useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
14
14
|
import { captionMessages } from '@atlaskit/editor-common/media';
|
|
15
15
|
import { calcMediaSinglePixelWidth, DEFAULT_IMAGE_HEIGHT, DEFAULT_IMAGE_WIDTH, ExternalImageBadge, getMaxWidthForNestedNode, MEDIA_SINGLE_GUTTER_SIZE, MediaBadges } from '@atlaskit/editor-common/media-single';
|
|
16
16
|
import { WithProviders } from '@atlaskit/editor-common/provider-factory';
|
|
@@ -23,7 +23,6 @@ import { findParentNodeOfTypeClosestToPos } from '@atlaskit/editor-prosemirror/u
|
|
|
23
23
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
24
24
|
import { getAttrsFromUrl } from '@atlaskit/media-client';
|
|
25
25
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
26
|
-
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
27
26
|
import { insertAndSelectCaptionFromMediaSinglePos } from '../pm-plugins/commands/captions';
|
|
28
27
|
import { MEDIA_CONTENT_WRAP_CLASS_NAME } from '../pm-plugins/main';
|
|
29
28
|
import { isMediaBlobUrlFromAttrs } from '../pm-plugins/utils/media-common';
|
|
@@ -464,6 +463,44 @@ _defineProperty(MediaSingleNode, "defaultProps", {
|
|
|
464
463
|
mediaOptions: {}
|
|
465
464
|
});
|
|
466
465
|
_defineProperty(MediaSingleNode, "displayName", 'MediaSingleNode');
|
|
466
|
+
const useSharedState = sharedPluginStateHookMigratorFactory(pluginInjectionApi => {
|
|
467
|
+
const mediaProviderPromise = useSharedPluginStateSelector(pluginInjectionApi, 'media.mediaProvider');
|
|
468
|
+
const addPendingTask = useSharedPluginStateSelector(pluginInjectionApi, 'media.addPendingTask');
|
|
469
|
+
const isDrafting = useSharedPluginStateSelector(pluginInjectionApi, 'annotation.isDrafting');
|
|
470
|
+
const targetNodeId = useSharedPluginStateSelector(pluginInjectionApi, 'annotation.targetNodeId');
|
|
471
|
+
const width = useSharedPluginStateSelector(pluginInjectionApi, 'width.width');
|
|
472
|
+
const lineLength = useSharedPluginStateSelector(pluginInjectionApi, 'width.lineLength');
|
|
473
|
+
const editorDisabled = useSharedPluginStateSelector(pluginInjectionApi, 'editorDisabled.editorDisabled');
|
|
474
|
+
const viewMode = useSharedPluginStateSelector(pluginInjectionApi, 'editorViewMode.mode');
|
|
475
|
+
return {
|
|
476
|
+
mediaProviderPromise,
|
|
477
|
+
addPendingTask,
|
|
478
|
+
isDrafting,
|
|
479
|
+
targetNodeId,
|
|
480
|
+
width,
|
|
481
|
+
lineLength,
|
|
482
|
+
editorDisabled,
|
|
483
|
+
viewMode
|
|
484
|
+
};
|
|
485
|
+
}, pluginInjectionApi => {
|
|
486
|
+
const {
|
|
487
|
+
widthState,
|
|
488
|
+
mediaState,
|
|
489
|
+
annotationState,
|
|
490
|
+
editorDisabledState,
|
|
491
|
+
editorViewModeState
|
|
492
|
+
} = useSharedPluginState(pluginInjectionApi, ['width', 'media', 'annotation', 'editorDisabled', 'editorViewMode']);
|
|
493
|
+
return {
|
|
494
|
+
mediaProviderPromise: mediaState === null || mediaState === void 0 ? void 0 : mediaState.mediaProvider,
|
|
495
|
+
addPendingTask: mediaState === null || mediaState === void 0 ? void 0 : mediaState.addPendingTask,
|
|
496
|
+
isDrafting: annotationState === null || annotationState === void 0 ? void 0 : annotationState.isDrafting,
|
|
497
|
+
targetNodeId: annotationState === null || annotationState === void 0 ? void 0 : annotationState.targetNodeId,
|
|
498
|
+
width: widthState === null || widthState === void 0 ? void 0 : widthState.width,
|
|
499
|
+
lineLength: widthState === null || widthState === void 0 ? void 0 : widthState.lineLength,
|
|
500
|
+
editorDisabled: editorDisabledState === null || editorDisabledState === void 0 ? void 0 : editorDisabledState.editorDisabled,
|
|
501
|
+
viewMode: editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode
|
|
502
|
+
};
|
|
503
|
+
});
|
|
467
504
|
const MediaSingleNodeWrapper = ({
|
|
468
505
|
pluginInjectionApi,
|
|
469
506
|
contextIdentifierProvider,
|
|
@@ -479,48 +516,17 @@ const MediaSingleNodeWrapper = ({
|
|
|
479
516
|
editorAppearance
|
|
480
517
|
}) => {
|
|
481
518
|
const {
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
492
|
-
});
|
|
493
|
-
const addPendingTaskSelector = useSharedPluginStateSelector(pluginInjectionApi, 'media.addPendingTask', {
|
|
494
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
495
|
-
});
|
|
496
|
-
const isDraftingSelector = useSharedPluginStateSelector(pluginInjectionApi, 'annotation.isDrafting', {
|
|
497
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
498
|
-
});
|
|
499
|
-
const targetNodeIdSelector = useSharedPluginStateSelector(pluginInjectionApi, 'annotation.targetNodeId', {
|
|
500
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
501
|
-
});
|
|
502
|
-
const widthSelector = useSharedPluginStateSelector(pluginInjectionApi, 'width.width', {
|
|
503
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
504
|
-
});
|
|
505
|
-
const lineLengthSelector = useSharedPluginStateSelector(pluginInjectionApi, 'width.lineLength', {
|
|
506
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
507
|
-
});
|
|
508
|
-
const editorDisabledSelector = useSharedPluginStateSelector(pluginInjectionApi, 'editorDisabled.editorDisabled', {
|
|
509
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
510
|
-
});
|
|
511
|
-
const viewModeSelector = useSharedPluginStateSelector(pluginInjectionApi, 'editorViewMode.mode', {
|
|
512
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
513
|
-
});
|
|
514
|
-
const mediaProviderState = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? mediaProviderSelector : mediaState === null || mediaState === void 0 ? void 0 : mediaState.mediaProvider;
|
|
515
|
-
const addPendingTask = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? addPendingTaskSelector : mediaState === null || mediaState === void 0 ? void 0 : mediaState.addPendingTask;
|
|
516
|
-
const isDrafting = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? isDraftingSelector : annotationState === null || annotationState === void 0 ? void 0 : annotationState.isDrafting;
|
|
517
|
-
const targetNodeId = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? targetNodeIdSelector : annotationState === null || annotationState === void 0 ? void 0 : annotationState.targetNodeId;
|
|
518
|
-
const width = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? widthSelector : widthState === null || widthState === void 0 ? void 0 : widthState.width;
|
|
519
|
-
const lineLength = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? lineLengthSelector : widthState === null || widthState === void 0 ? void 0 : widthState.lineLength;
|
|
520
|
-
const editorDisabled = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? editorDisabledSelector : editorDisabledState === null || editorDisabledState === void 0 ? void 0 : editorDisabledState.editorDisabled;
|
|
521
|
-
const viewMode = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? viewModeSelector : editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode;
|
|
519
|
+
mediaProviderPromise,
|
|
520
|
+
addPendingTask,
|
|
521
|
+
isDrafting,
|
|
522
|
+
targetNodeId,
|
|
523
|
+
width,
|
|
524
|
+
lineLength,
|
|
525
|
+
editorDisabled,
|
|
526
|
+
viewMode
|
|
527
|
+
} = useSharedState(pluginInjectionApi);
|
|
522
528
|
const hasHadInteraction = useSharedPluginStateSelector(pluginInjectionApi, 'interaction.hasHadInteraction');
|
|
523
|
-
const mediaProvider = useMemo(() =>
|
|
529
|
+
const mediaProvider = useMemo(() => mediaProviderPromise ? Promise.resolve(mediaProviderPromise) : undefined, [mediaProviderPromise]);
|
|
524
530
|
const isSelectedAndInteracted = useCallback(() => Boolean(selected() && hasHadInteraction !== false), [hasHadInteraction, selected]);
|
|
525
531
|
if (fg('platform_editor_react18_phase2__media_single') || fg('platform_editor_react18_phase2__media_single_jira')) {
|
|
526
532
|
return jsx(MediaSingleNodeNext, {
|
|
@@ -1,10 +1,28 @@
|
|
|
1
1
|
import React, { useCallback, useMemo, useState } from 'react';
|
|
2
2
|
import { injectIntl } from 'react-intl-next';
|
|
3
3
|
import { VIEW_METHOD } from '@atlaskit/editor-common/analytics';
|
|
4
|
-
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
4
|
+
import { sharedPluginStateHookMigratorFactory, useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
5
5
|
import { CommentBadge as CommentBadgeComponent, CommentBadgeNext } from '@atlaskit/editor-common/media-single';
|
|
6
6
|
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
7
|
-
|
|
7
|
+
const useSharedState = sharedPluginStateHookMigratorFactory(api => {
|
|
8
|
+
const selectedAnnotations = useSharedPluginStateSelector(api, 'annotation.selectedAnnotations');
|
|
9
|
+
const isInlineCommentViewClosed = useSharedPluginStateSelector(api, 'annotation.isInlineCommentViewClosed');
|
|
10
|
+
const annotations = useSharedPluginStateSelector(api, 'annotation.annotations');
|
|
11
|
+
return {
|
|
12
|
+
selectedAnnotations,
|
|
13
|
+
isInlineCommentViewClosed,
|
|
14
|
+
annotations
|
|
15
|
+
};
|
|
16
|
+
}, api => {
|
|
17
|
+
const {
|
|
18
|
+
annotationState
|
|
19
|
+
} = useSharedPluginState(api, ['annotation']);
|
|
20
|
+
return {
|
|
21
|
+
selectedAnnotations: annotationState === null || annotationState === void 0 ? void 0 : annotationState.selectedAnnotations,
|
|
22
|
+
isInlineCommentViewClosed: annotationState === null || annotationState === void 0 ? void 0 : annotationState.isInlineCommentViewClosed,
|
|
23
|
+
annotations: annotationState === null || annotationState === void 0 ? void 0 : annotationState.annotations
|
|
24
|
+
};
|
|
25
|
+
});
|
|
8
26
|
const CommentBadgeWrapper = ({
|
|
9
27
|
api,
|
|
10
28
|
mediaNode,
|
|
@@ -14,24 +32,12 @@ const CommentBadgeWrapper = ({
|
|
|
14
32
|
isDrafting,
|
|
15
33
|
badgeOffsetRight
|
|
16
34
|
}) => {
|
|
17
|
-
const [entered, setEntered] = useState(false);
|
|
18
35
|
const {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
});
|
|
23
|
-
const
|
|
24
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
25
|
-
});
|
|
26
|
-
const isInlineCommentViewClosedSelector = useSharedPluginStateSelector(api, 'annotation.isInlineCommentViewClosed', {
|
|
27
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
28
|
-
});
|
|
29
|
-
const annotationsSelector = useSharedPluginStateSelector(api, 'annotation.annotations', {
|
|
30
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
31
|
-
});
|
|
32
|
-
const selectedAnnotations = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? selectedAnnotationsSelector : annotationState === null || annotationState === void 0 ? void 0 : annotationState.selectedAnnotations;
|
|
33
|
-
const isInlineCommentViewClosed = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? isInlineCommentViewClosedSelector : annotationState === null || annotationState === void 0 ? void 0 : annotationState.isInlineCommentViewClosed;
|
|
34
|
-
const annotations = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? annotationsSelector : annotationState === null || annotationState === void 0 ? void 0 : annotationState.annotations;
|
|
36
|
+
selectedAnnotations,
|
|
37
|
+
isInlineCommentViewClosed,
|
|
38
|
+
annotations
|
|
39
|
+
} = useSharedState(api);
|
|
40
|
+
const [entered, setEntered] = useState(false);
|
|
35
41
|
const {
|
|
36
42
|
state: {
|
|
37
43
|
schema: {
|
|
@@ -102,22 +108,10 @@ export const CommentBadgeNextWrapper = ({
|
|
|
102
108
|
}) => {
|
|
103
109
|
const [entered, setEntered] = useState(false);
|
|
104
110
|
const {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
});
|
|
109
|
-
const selectedAnnotationsSelector = useSharedPluginStateSelector(api, 'annotation.selectedAnnotations', {
|
|
110
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
111
|
-
});
|
|
112
|
-
const isInlineCommentViewClosedSelector = useSharedPluginStateSelector(api, 'annotation.isInlineCommentViewClosed', {
|
|
113
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
114
|
-
});
|
|
115
|
-
const annotationsSelector = useSharedPluginStateSelector(api, 'annotation.annotations', {
|
|
116
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
117
|
-
});
|
|
118
|
-
const selectedAnnotations = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? selectedAnnotationsSelector : annotationState === null || annotationState === void 0 ? void 0 : annotationState.selectedAnnotations;
|
|
119
|
-
const isInlineCommentViewClosed = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? isInlineCommentViewClosedSelector : annotationState === null || annotationState === void 0 ? void 0 : annotationState.isInlineCommentViewClosed;
|
|
120
|
-
const annotations = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? annotationsSelector : annotationState === null || annotationState === void 0 ? void 0 : annotationState.annotations;
|
|
111
|
+
selectedAnnotations,
|
|
112
|
+
isInlineCommentViewClosed,
|
|
113
|
+
annotations
|
|
114
|
+
} = useSharedState(api);
|
|
121
115
|
const {
|
|
122
116
|
state: {
|
|
123
117
|
schema: {
|
|
@@ -2,12 +2,12 @@ import React from 'react';
|
|
|
2
2
|
import { Browser } from '@atlaskit/media-picker';
|
|
3
3
|
import PickerFacadeProvider from './PickerFacadeProvider';
|
|
4
4
|
export const BrowserWrapper = ({
|
|
5
|
-
|
|
5
|
+
api,
|
|
6
6
|
isOpen,
|
|
7
7
|
onBrowseFn,
|
|
8
8
|
featureFlags
|
|
9
9
|
}) => /*#__PURE__*/React.createElement(PickerFacadeProvider, {
|
|
10
|
-
|
|
10
|
+
api: api,
|
|
11
11
|
analyticsName: "browser"
|
|
12
12
|
}, ({
|
|
13
13
|
mediaClientConfig,
|
|
@@ -2,11 +2,11 @@ import React from 'react';
|
|
|
2
2
|
import { Clipboard } from '@atlaskit/media-picker';
|
|
3
3
|
import PickerFacadeProvider from './PickerFacadeProvider';
|
|
4
4
|
export const ClipboardWrapper = ({
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
api,
|
|
6
|
+
container,
|
|
7
|
+
featureFlags
|
|
8
8
|
}) => /*#__PURE__*/React.createElement(PickerFacadeProvider, {
|
|
9
|
-
|
|
9
|
+
api: api,
|
|
10
10
|
analyticsName: "clipboard"
|
|
11
11
|
}, ({
|
|
12
12
|
mediaClientConfig,
|
|
@@ -1,27 +1,43 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { sharedPluginStateHookMigratorFactory, useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
2
3
|
import { findOverflowScrollParent } from '@atlaskit/editor-common/ui';
|
|
4
|
+
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
3
5
|
import { Dropzone } from '@atlaskit/media-picker';
|
|
4
6
|
import PickerFacadeProvider from './PickerFacadeProvider';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
+
const useSharedState = sharedPluginStateHookMigratorFactory(api => {
|
|
8
|
+
const options = useSharedPluginStateSelector(api, 'media.options');
|
|
9
|
+
const handleDrag = useSharedPluginStateSelector(api, 'media.handleDrag');
|
|
10
|
+
return {
|
|
11
|
+
options,
|
|
12
|
+
handleDrag
|
|
13
|
+
};
|
|
14
|
+
}, api => {
|
|
15
|
+
const {
|
|
16
|
+
mediaState
|
|
17
|
+
} = useSharedPluginState(api, ['media']);
|
|
18
|
+
return {
|
|
19
|
+
options: mediaState === null || mediaState === void 0 ? void 0 : mediaState.options,
|
|
20
|
+
handleDrag: mediaState === null || mediaState === void 0 ? void 0 : mediaState.handleDrag
|
|
21
|
+
};
|
|
22
|
+
});
|
|
23
|
+
const DropzoneWrapperInternal = ({
|
|
24
|
+
api,
|
|
7
25
|
isActive,
|
|
8
26
|
featureFlags,
|
|
9
27
|
editorDomElement,
|
|
10
|
-
appearance
|
|
11
|
-
}) => /*#__PURE__*/React.createElement(PickerFacadeProvider, {
|
|
12
|
-
mediaState: mediaState,
|
|
13
|
-
analyticsName: "dropzone"
|
|
14
|
-
}, ({
|
|
28
|
+
appearance,
|
|
15
29
|
mediaClientConfig,
|
|
16
30
|
config,
|
|
17
31
|
pickerFacadeInstance
|
|
18
32
|
}) => {
|
|
19
33
|
const {
|
|
20
|
-
options
|
|
21
|
-
customDropzoneContainer
|
|
22
|
-
},
|
|
34
|
+
options,
|
|
23
35
|
handleDrag
|
|
24
|
-
} =
|
|
36
|
+
} = useSharedState(api);
|
|
37
|
+
const {
|
|
38
|
+
customDropzoneContainer
|
|
39
|
+
} = options || {};
|
|
40
|
+
|
|
25
41
|
// Ignored via go/ees005
|
|
26
42
|
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
27
43
|
const editorHtmlElement = editorDomElement;
|
|
@@ -37,8 +53,31 @@ export const DropzoneWrapper = ({
|
|
|
37
53
|
onError: pickerFacadeInstance.handleUploadError,
|
|
38
54
|
onPreviewUpdate: pickerFacadeInstance.handleUploadPreviewUpdate,
|
|
39
55
|
onEnd: pickerFacadeInstance.handleReady,
|
|
40
|
-
onDragEnter: () => handleDrag('enter'),
|
|
41
|
-
onDragLeave: () => handleDrag('leave'),
|
|
56
|
+
onDragEnter: () => handleDrag === null || handleDrag === void 0 ? void 0 : handleDrag('enter'),
|
|
57
|
+
onDragLeave: () => handleDrag === null || handleDrag === void 0 ? void 0 : handleDrag('leave'),
|
|
42
58
|
featureFlags: featureFlags
|
|
43
59
|
}) : null;
|
|
44
|
-
}
|
|
60
|
+
};
|
|
61
|
+
export const DropzoneWrapper = ({
|
|
62
|
+
api,
|
|
63
|
+
isActive,
|
|
64
|
+
featureFlags,
|
|
65
|
+
editorDomElement,
|
|
66
|
+
appearance
|
|
67
|
+
}) => /*#__PURE__*/React.createElement(PickerFacadeProvider, {
|
|
68
|
+
api: api,
|
|
69
|
+
analyticsName: "dropzone"
|
|
70
|
+
}, ({
|
|
71
|
+
mediaClientConfig,
|
|
72
|
+
config,
|
|
73
|
+
pickerFacadeInstance
|
|
74
|
+
}) => /*#__PURE__*/React.createElement(DropzoneWrapperInternal, {
|
|
75
|
+
api: api,
|
|
76
|
+
isActive: isActive,
|
|
77
|
+
featureFlags: featureFlags,
|
|
78
|
+
editorDomElement: editorDomElement,
|
|
79
|
+
appearance: appearance,
|
|
80
|
+
mediaClientConfig: mediaClientConfig,
|
|
81
|
+
config: config,
|
|
82
|
+
pickerFacadeInstance: pickerFacadeInstance
|
|
83
|
+
}));
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
2
2
|
import { flushSync } from 'react-dom';
|
|
3
|
+
import { sharedPluginStateHookMigratorFactory, useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
4
|
+
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
3
5
|
import { ErrorReporter } from '@atlaskit/editor-common/utils';
|
|
4
6
|
import PickerFacade from '../../pm-plugins/picker-facade';
|
|
5
7
|
const dummyMediaPickerObject = {
|
|
@@ -9,8 +11,31 @@ const dummyMediaPickerObject = {
|
|
|
9
11
|
destroy: () => {},
|
|
10
12
|
setUploadParams: () => {}
|
|
11
13
|
};
|
|
14
|
+
const useSharedState = sharedPluginStateHookMigratorFactory(api => {
|
|
15
|
+
const mediaProvider = useSharedPluginStateSelector(api, 'media.mediaProvider');
|
|
16
|
+
const mediaOptions = useSharedPluginStateSelector(api, 'media.mediaOptions');
|
|
17
|
+
const insertFile = useSharedPluginStateSelector(api, 'media.insertFile');
|
|
18
|
+
const options = useSharedPluginStateSelector(api, 'media.options');
|
|
19
|
+
return {
|
|
20
|
+
mediaProvider,
|
|
21
|
+
mediaOptions,
|
|
22
|
+
insertFile,
|
|
23
|
+
options
|
|
24
|
+
};
|
|
25
|
+
}, api => {
|
|
26
|
+
const {
|
|
27
|
+
mediaState
|
|
28
|
+
} = useSharedPluginState(api, ['media']);
|
|
29
|
+
const mediaProvider = useMemo(() => mediaState === null || mediaState === void 0 ? void 0 : mediaState.mediaProvider, [mediaState === null || mediaState === void 0 ? void 0 : mediaState.mediaProvider]);
|
|
30
|
+
return {
|
|
31
|
+
mediaProvider,
|
|
32
|
+
mediaOptions: mediaState === null || mediaState === void 0 ? void 0 : mediaState.mediaOptions,
|
|
33
|
+
insertFile: mediaState === null || mediaState === void 0 ? void 0 : mediaState.insertFile,
|
|
34
|
+
options: mediaState === null || mediaState === void 0 ? void 0 : mediaState.options
|
|
35
|
+
};
|
|
36
|
+
});
|
|
12
37
|
export default function PickerFacadeProvider({
|
|
13
|
-
|
|
38
|
+
api,
|
|
14
39
|
analyticsName,
|
|
15
40
|
children
|
|
16
41
|
}) {
|
|
@@ -19,10 +44,15 @@ export default function PickerFacadeProvider({
|
|
|
19
44
|
config: undefined,
|
|
20
45
|
mediaClientConfig: undefined
|
|
21
46
|
});
|
|
22
|
-
const
|
|
47
|
+
const {
|
|
48
|
+
mediaProvider,
|
|
49
|
+
mediaOptions,
|
|
50
|
+
insertFile,
|
|
51
|
+
options
|
|
52
|
+
} = useSharedState(api);
|
|
23
53
|
const handleMediaProvider = useCallback(async (_name, provider) => {
|
|
24
54
|
const mediaProvider = await provider;
|
|
25
|
-
if (!mediaProvider || !mediaProvider.uploadParams) {
|
|
55
|
+
if (!mediaProvider || !mediaProvider.uploadParams || !insertFile) {
|
|
26
56
|
return;
|
|
27
57
|
}
|
|
28
58
|
const resolvedMediaClientConfig = (await mediaProvider.uploadMediaClientConfig) || (await mediaProvider.viewMediaClientConfig);
|
|
@@ -31,11 +61,11 @@ export default function PickerFacadeProvider({
|
|
|
31
61
|
}
|
|
32
62
|
const pickerFacadeConfig = {
|
|
33
63
|
mediaClientConfig: resolvedMediaClientConfig,
|
|
34
|
-
errorReporter:
|
|
35
|
-
featureFlags:
|
|
64
|
+
errorReporter: (options === null || options === void 0 ? void 0 : options.errorReporter) || new ErrorReporter(),
|
|
65
|
+
featureFlags: mediaOptions && mediaOptions.featureFlags
|
|
36
66
|
};
|
|
37
67
|
const pickerFacadeInstance = await new PickerFacade('customMediaPicker', pickerFacadeConfig, dummyMediaPickerObject, analyticsName).init();
|
|
38
|
-
pickerFacadeInstance.onNewMedia(
|
|
68
|
+
pickerFacadeInstance.onNewMedia(insertFile);
|
|
39
69
|
pickerFacadeInstance.setUploadParams(mediaProvider.uploadParams);
|
|
40
70
|
const config = {
|
|
41
71
|
uploadParams: mediaProvider.uploadParams
|
|
@@ -47,7 +77,7 @@ export default function PickerFacadeProvider({
|
|
|
47
77
|
mediaClientConfig: resolvedMediaClientConfig
|
|
48
78
|
});
|
|
49
79
|
});
|
|
50
|
-
}, [analyticsName,
|
|
80
|
+
}, [analyticsName, insertFile, mediaOptions, options === null || options === void 0 ? void 0 : options.errorReporter]);
|
|
51
81
|
useEffect(() => {
|
|
52
82
|
if (mediaProvider) {
|
|
53
83
|
handleMediaProvider('mediaProvider', Promise.resolve(mediaProvider));
|