@atlaskit/editor-plugin-media 2.7.0 → 2.7.2
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 +24 -0
- package/dist/cjs/mediaPlugin.js +21 -6
- package/dist/cjs/nodeviews/mediaGroup.js +21 -6
- package/dist/cjs/nodeviews/mediaInline.js +55 -13
- package/dist/cjs/nodeviews/mediaNodeView/index.js +11 -3
- package/dist/cjs/nodeviews/mediaSingle.js +87 -48
- package/dist/cjs/nodeviews/mediaSingleNext.js +5 -4
- package/dist/cjs/pm-plugins/utils/media-files.js +64 -6
- package/dist/cjs/ui/CommentBadge/index.js +44 -14
- package/dist/cjs/ui/ImageBorder/styles.js +1 -2
- package/dist/cjs/ui/MediaPicker/index.js +15 -3
- package/dist/cjs/ui/MediaViewer/MediaViewerContainer.js +3 -3
- package/dist/cjs/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +2 -1
- package/dist/cjs/ui/ToolbarMedia/index.js +17 -5
- package/dist/cjs/ui/hooks/useMediaProvider.js +11 -3
- package/dist/cjs/ui/toolbar/utils.js +6 -4
- package/dist/es2019/mediaPlugin.js +21 -6
- package/dist/es2019/nodeviews/mediaGroup.js +21 -6
- package/dist/es2019/nodeviews/mediaInline.js +54 -12
- package/dist/es2019/nodeviews/mediaNodeView/index.js +11 -3
- package/dist/es2019/nodeviews/mediaSingle.js +59 -24
- package/dist/es2019/nodeviews/mediaSingleNext.js +5 -4
- package/dist/es2019/pm-plugins/utils/media-files.js +63 -5
- package/dist/es2019/ui/CommentBadge/index.js +40 -10
- package/dist/es2019/ui/ImageBorder/styles.js +1 -2
- package/dist/es2019/ui/MediaPicker/index.js +15 -3
- package/dist/es2019/ui/MediaViewer/MediaViewerContainer.js +4 -4
- package/dist/es2019/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +2 -1
- package/dist/es2019/ui/ToolbarMedia/index.js +17 -5
- package/dist/es2019/ui/hooks/useMediaProvider.js +11 -3
- package/dist/es2019/ui/toolbar/utils.js +5 -3
- package/dist/esm/mediaPlugin.js +21 -6
- package/dist/esm/nodeviews/mediaGroup.js +21 -6
- package/dist/esm/nodeviews/mediaInline.js +55 -13
- package/dist/esm/nodeviews/mediaNodeView/index.js +11 -3
- package/dist/esm/nodeviews/mediaSingle.js +87 -48
- package/dist/esm/nodeviews/mediaSingleNext.js +5 -4
- package/dist/esm/pm-plugins/utils/media-files.js +63 -5
- package/dist/esm/ui/CommentBadge/index.js +44 -14
- package/dist/esm/ui/ImageBorder/styles.js +1 -2
- package/dist/esm/ui/MediaPicker/index.js +15 -3
- package/dist/esm/ui/MediaViewer/MediaViewerContainer.js +4 -4
- package/dist/esm/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +2 -1
- package/dist/esm/ui/ToolbarMedia/index.js +17 -5
- package/dist/esm/ui/hooks/useMediaProvider.js +11 -3
- package/dist/esm/ui/toolbar/utils.js +5 -3
- package/dist/types/nodeviews/mediaInline.d.ts +7 -2
- package/dist/types/nodeviews/mediaSingleNext.d.ts +3 -4
- package/dist/types/nodeviews/types.d.ts +3 -4
- package/dist/types/pm-plugins/utils/media-files.d.ts +3 -2
- package/dist/types/ui/MediaViewer/MediaViewerContainer.d.ts +4 -3
- package/dist/types/ui/toolbar/utils.d.ts +1 -0
- package/dist/types-ts4.5/nodeviews/mediaInline.d.ts +7 -2
- package/dist/types-ts4.5/nodeviews/mediaSingleNext.d.ts +3 -4
- package/dist/types-ts4.5/nodeviews/types.d.ts +3 -4
- package/dist/types-ts4.5/pm-plugins/utils/media-files.d.ts +3 -2
- package/dist/types-ts4.5/ui/MediaViewer/MediaViewerContainer.d.ts +4 -3
- package/dist/types-ts4.5/ui/toolbar/utils.d.ts +1 -0
- package/package.json +10 -4
|
@@ -36,6 +36,7 @@ import { findParentNodeOfTypeClosestToPos } from '@atlaskit/editor-prosemirror/u
|
|
|
36
36
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
37
37
|
import { getAttrsFromUrl } from '@atlaskit/media-client';
|
|
38
38
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
39
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
39
40
|
import { insertAndSelectCaptionFromMediaSinglePos } from '../pm-plugins/commands/captions';
|
|
40
41
|
import { MEDIA_CONTENT_WRAP_CLASS_NAME } from '../pm-plugins/main';
|
|
41
42
|
import { isMediaBlobUrlFromAttrs } from '../pm-plugins/utils/media-common';
|
|
@@ -122,78 +123,85 @@ var MediaSingleNode = /*#__PURE__*/function (_Component) {
|
|
|
122
123
|
while (1) switch (_context2.prev = _context2.next) {
|
|
123
124
|
case 0:
|
|
124
125
|
_this.createOrUpdateMediaNodeUpdater(props);
|
|
125
|
-
addPendingTask = _this.props.
|
|
126
|
+
addPendingTask = _this.props.addPendingTask;
|
|
127
|
+
if (addPendingTask) {
|
|
128
|
+
_context2.next = 4;
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
return _context2.abrupt("return");
|
|
132
|
+
case 4:
|
|
133
|
+
// we want the first child of MediaSingle (type "media")
|
|
126
134
|
node = _this.props.node.firstChild;
|
|
127
135
|
if (node) {
|
|
128
|
-
_context2.next =
|
|
136
|
+
_context2.next = 7;
|
|
129
137
|
break;
|
|
130
138
|
}
|
|
131
139
|
return _context2.abrupt("return");
|
|
132
|
-
case 5:
|
|
133
|
-
_context2.next = 7;
|
|
134
|
-
return (_this$mediaNodeUpdate2 = _this.mediaNodeUpdater) === null || _this$mediaNodeUpdate2 === void 0 ? void 0 : _this$mediaNodeUpdate2.getRemoteDimensions();
|
|
135
140
|
case 7:
|
|
141
|
+
_context2.next = 9;
|
|
142
|
+
return (_this$mediaNodeUpdate2 = _this.mediaNodeUpdater) === null || _this$mediaNodeUpdate2 === void 0 ? void 0 : _this$mediaNodeUpdate2.getRemoteDimensions();
|
|
143
|
+
case 9:
|
|
136
144
|
updatedDimensions = _context2.sent;
|
|
137
145
|
currentAttrs = (_this$props$node$firs = _this.props.node.firstChild) === null || _this$props$node$firs === void 0 ? void 0 : _this$props$node$firs.attrs;
|
|
138
146
|
if (updatedDimensions && ((currentAttrs === null || currentAttrs === void 0 ? void 0 : currentAttrs.width) !== updatedDimensions.width || (currentAttrs === null || currentAttrs === void 0 ? void 0 : currentAttrs.height) !== updatedDimensions.height)) {
|
|
139
147
|
(_this$mediaNodeUpdate3 = _this.mediaNodeUpdater) === null || _this$mediaNodeUpdate3 === void 0 || _this$mediaNodeUpdate3.updateDimensions(updatedDimensions);
|
|
140
148
|
}
|
|
141
149
|
if (!(node.attrs.type === 'external' && node.attrs.__external)) {
|
|
142
|
-
_context2.next =
|
|
150
|
+
_context2.next = 18;
|
|
143
151
|
break;
|
|
144
152
|
}
|
|
145
153
|
// Ignored via go/ees005
|
|
146
154
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
147
155
|
updatingNode = _this.mediaNodeUpdater.handleExternalMedia(_this.props.getPos);
|
|
148
156
|
addPendingTask(updatingNode);
|
|
149
|
-
_context2.next =
|
|
157
|
+
_context2.next = 17;
|
|
150
158
|
return updatingNode;
|
|
151
|
-
case
|
|
159
|
+
case 17:
|
|
152
160
|
return _context2.abrupt("return");
|
|
153
|
-
case
|
|
161
|
+
case 18:
|
|
154
162
|
contextId = (_this$mediaNodeUpdate4 = _this.mediaNodeUpdater) === null || _this$mediaNodeUpdate4 === void 0 ? void 0 : _this$mediaNodeUpdate4.getNodeContextId();
|
|
155
163
|
if (contextId) {
|
|
156
|
-
_context2.next =
|
|
164
|
+
_context2.next = 22;
|
|
157
165
|
break;
|
|
158
166
|
}
|
|
159
|
-
_context2.next = 20;
|
|
160
|
-
return (_this$mediaNodeUpdate5 = _this.mediaNodeUpdater) === null || _this$mediaNodeUpdate5 === void 0 ? void 0 : _this$mediaNodeUpdate5.updateContextId();
|
|
161
|
-
case 20:
|
|
162
167
|
_context2.next = 22;
|
|
163
|
-
return (_this$
|
|
168
|
+
return (_this$mediaNodeUpdate5 = _this.mediaNodeUpdater) === null || _this$mediaNodeUpdate5 === void 0 ? void 0 : _this$mediaNodeUpdate5.updateContextId();
|
|
164
169
|
case 22:
|
|
170
|
+
_context2.next = 24;
|
|
171
|
+
return (_this$mediaNodeUpdate6 = _this.mediaNodeUpdater) === null || _this$mediaNodeUpdate6 === void 0 ? void 0 : _this$mediaNodeUpdate6.shouldNodeBeDeepCopied();
|
|
172
|
+
case 24:
|
|
165
173
|
shouldNodeBeDeepCopied = _context2.sent;
|
|
166
174
|
if (!shouldNodeBeDeepCopied) {
|
|
167
|
-
_context2.next =
|
|
175
|
+
_context2.next = 37;
|
|
168
176
|
break;
|
|
169
177
|
}
|
|
170
178
|
_this.setState({
|
|
171
179
|
isCopying: true
|
|
172
180
|
});
|
|
173
|
-
_context2.prev =
|
|
181
|
+
_context2.prev = 27;
|
|
174
182
|
// Ignored via go/ees005
|
|
175
183
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
176
184
|
copyNode = _this.mediaNodeUpdater.copyNode({
|
|
177
185
|
traceId: node.attrs.__mediaTraceId
|
|
178
186
|
});
|
|
179
187
|
addPendingTask(copyNode);
|
|
180
|
-
_context2.next =
|
|
188
|
+
_context2.next = 32;
|
|
181
189
|
return copyNode;
|
|
182
|
-
case 30:
|
|
183
|
-
_context2.next = 35;
|
|
184
|
-
break;
|
|
185
190
|
case 32:
|
|
186
|
-
_context2.
|
|
187
|
-
|
|
191
|
+
_context2.next = 37;
|
|
192
|
+
break;
|
|
193
|
+
case 34:
|
|
194
|
+
_context2.prev = 34;
|
|
195
|
+
_context2.t0 = _context2["catch"](27);
|
|
188
196
|
// if copyNode fails, let's set isCopying false so we can show the eventual error
|
|
189
197
|
_this.setState({
|
|
190
198
|
isCopying: false
|
|
191
199
|
});
|
|
192
|
-
case
|
|
200
|
+
case 37:
|
|
193
201
|
case "end":
|
|
194
202
|
return _context2.stop();
|
|
195
203
|
}
|
|
196
|
-
}, _callee2, null, [[
|
|
204
|
+
}, _callee2, null, [[27, 34]]);
|
|
197
205
|
}));
|
|
198
206
|
return function (_x2) {
|
|
199
207
|
return _ref2.apply(this, arguments);
|
|
@@ -356,7 +364,8 @@ var MediaSingleNode = /*#__PURE__*/function (_Component) {
|
|
|
356
364
|
dispatchAnalyticsEvent = _this$props2.dispatchAnalyticsEvent,
|
|
357
365
|
editorViewMode = _this$props2.editorViewMode,
|
|
358
366
|
editorDisabled = _this$props2.editorDisabled,
|
|
359
|
-
|
|
367
|
+
isDrafting = _this$props2.isDrafting,
|
|
368
|
+
targetNodeId = _this$props2.targetNodeId,
|
|
360
369
|
editorAppearance = _this$props2.editorAppearance;
|
|
361
370
|
var _ref4 = node.attrs,
|
|
362
371
|
layout = _ref4.layout,
|
|
@@ -453,7 +462,7 @@ var MediaSingleNode = /*#__PURE__*/function (_Component) {
|
|
|
453
462
|
var badgeOffsetRight = isBadgePosOffsetRight();
|
|
454
463
|
var shouldShowPlaceholder = mediaOptions.allowCaptions && node.childCount !== 2 && isSelected && state.selection instanceof NodeSelection;
|
|
455
464
|
shouldShowPlaceholder = !editorDisabled && shouldShowPlaceholder;
|
|
456
|
-
var isCurrentNodeDrafting = (
|
|
465
|
+
var isCurrentNodeDrafting = Boolean(isDrafting && targetNodeId === (node === null || node === void 0 || (_node$firstChild = node.firstChild) === null || _node$firstChild === void 0 ? void 0 : _node$firstChild.attrs.id));
|
|
457
466
|
var pos = getPos();
|
|
458
467
|
var isInsideTable = pos !== undefined && findParentNodeOfTypeClosestToPos(state.doc.resolve(pos), [state.schema.nodes.table]);
|
|
459
468
|
var currentMediaElement = function currentMediaElement() {
|
|
@@ -552,23 +561,57 @@ var MediaSingleNodeWrapper = function MediaSingleNodeWrapper(_ref6) {
|
|
|
552
561
|
dispatchAnalyticsEvent = _ref6.dispatchAnalyticsEvent,
|
|
553
562
|
forwardRef = _ref6.forwardRef,
|
|
554
563
|
editorAppearance = _ref6.editorAppearance;
|
|
555
|
-
var _useSharedPluginState = useSharedPluginState(pluginInjectionApi, ['width', 'media', 'annotation', 'editorDisabled', 'editorViewMode']
|
|
564
|
+
var _useSharedPluginState = useSharedPluginState(pluginInjectionApi, ['width', 'media', 'annotation', 'editorDisabled', 'editorViewMode'], {
|
|
565
|
+
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
|
|
566
|
+
}),
|
|
556
567
|
widthState = _useSharedPluginState.widthState,
|
|
557
568
|
mediaState = _useSharedPluginState.mediaState,
|
|
558
569
|
annotationState = _useSharedPluginState.annotationState,
|
|
559
570
|
editorDisabledState = _useSharedPluginState.editorDisabledState,
|
|
560
571
|
editorViewModeState = _useSharedPluginState.editorViewModeState;
|
|
572
|
+
var mediaProviderSelector = useSharedPluginStateSelector(pluginInjectionApi, 'media.mediaProvider', {
|
|
573
|
+
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
574
|
+
});
|
|
575
|
+
var addPendingTaskSelector = useSharedPluginStateSelector(pluginInjectionApi, 'media.addPendingTask', {
|
|
576
|
+
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
577
|
+
});
|
|
578
|
+
var isDraftingSelector = useSharedPluginStateSelector(pluginInjectionApi, 'annotation.isDrafting', {
|
|
579
|
+
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
580
|
+
});
|
|
581
|
+
var targetNodeIdSelector = useSharedPluginStateSelector(pluginInjectionApi, 'annotation.targetNodeId', {
|
|
582
|
+
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
583
|
+
});
|
|
584
|
+
var widthSelector = useSharedPluginStateSelector(pluginInjectionApi, 'width.width', {
|
|
585
|
+
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
586
|
+
});
|
|
587
|
+
var lineLengthSelector = useSharedPluginStateSelector(pluginInjectionApi, 'width.lineLength', {
|
|
588
|
+
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
589
|
+
});
|
|
590
|
+
var editorDisabledSelector = useSharedPluginStateSelector(pluginInjectionApi, 'editorDisabled.editorDisabled', {
|
|
591
|
+
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
592
|
+
});
|
|
593
|
+
var viewModeSelector = useSharedPluginStateSelector(pluginInjectionApi, 'editorViewMode.mode', {
|
|
594
|
+
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
595
|
+
});
|
|
596
|
+
var mediaProviderState = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? mediaProviderSelector : mediaState === null || mediaState === void 0 ? void 0 : mediaState.mediaProvider;
|
|
597
|
+
var addPendingTask = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? addPendingTaskSelector : mediaState === null || mediaState === void 0 ? void 0 : mediaState.addPendingTask;
|
|
598
|
+
var isDrafting = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? isDraftingSelector : annotationState === null || annotationState === void 0 ? void 0 : annotationState.isDrafting;
|
|
599
|
+
var targetNodeId = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? targetNodeIdSelector : annotationState === null || annotationState === void 0 ? void 0 : annotationState.targetNodeId;
|
|
600
|
+
var width = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? widthSelector : widthState === null || widthState === void 0 ? void 0 : widthState.width;
|
|
601
|
+
var lineLength = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? lineLengthSelector : widthState === null || widthState === void 0 ? void 0 : widthState.lineLength;
|
|
602
|
+
var editorDisabled = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? editorDisabledSelector : editorDisabledState === null || editorDisabledState === void 0 ? void 0 : editorDisabledState.editorDisabled;
|
|
603
|
+
var viewMode = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? viewModeSelector : editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode;
|
|
561
604
|
var hasHadInteraction = useSharedPluginStateSelector(pluginInjectionApi, 'interaction.hasHadInteraction');
|
|
562
605
|
var mediaProvider = useMemo(function () {
|
|
563
|
-
return
|
|
564
|
-
}, [
|
|
606
|
+
return mediaProviderState ? Promise.resolve(mediaProviderState) : undefined;
|
|
607
|
+
}, [mediaProviderState]);
|
|
565
608
|
var isSelectedAndInteracted = useCallback(function () {
|
|
566
609
|
return Boolean(selected() && hasHadInteraction !== false);
|
|
567
610
|
}, [hasHadInteraction, selected]);
|
|
568
611
|
if (fg('platform_editor_react18_phase2__media_single') || fg('platform_editor_react18_phase2__media_single_jira')) {
|
|
569
612
|
return jsx(MediaSingleNodeNext, {
|
|
570
|
-
width:
|
|
571
|
-
lineLength:
|
|
613
|
+
width: width || 0,
|
|
614
|
+
lineLength: lineLength || 0,
|
|
572
615
|
node: node,
|
|
573
616
|
getPos: getPos,
|
|
574
617
|
mediaProvider: mediaProvider,
|
|
@@ -578,25 +621,20 @@ var MediaSingleNodeWrapper = function MediaSingleNodeWrapper(_ref6) {
|
|
|
578
621
|
fullWidthMode: fullWidthMode,
|
|
579
622
|
selected: fg('platform_editor_no_selection_until_interaction') ? isSelectedAndInteracted : selected,
|
|
580
623
|
eventDispatcher: eventDispatcher,
|
|
581
|
-
|
|
582
|
-
|
|
624
|
+
addPendingTask: addPendingTask,
|
|
625
|
+
isDrafting: isDrafting,
|
|
626
|
+
targetNodeId: targetNodeId,
|
|
583
627
|
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
584
628
|
forwardRef: forwardRef,
|
|
585
629
|
pluginInjectionApi: pluginInjectionApi,
|
|
586
|
-
editorDisabled:
|
|
587
|
-
editorViewMode:
|
|
630
|
+
editorDisabled: editorDisabled,
|
|
631
|
+
editorViewMode: viewMode === 'view',
|
|
588
632
|
editorAppearance: editorAppearance
|
|
589
633
|
});
|
|
590
634
|
}
|
|
591
|
-
return jsx(MediaSingleNode
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
, {
|
|
595
|
-
width: widthState.width
|
|
596
|
-
// Ignored via go/ees005
|
|
597
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
598
|
-
,
|
|
599
|
-
lineLength: widthState.lineLength,
|
|
635
|
+
return jsx(MediaSingleNode, {
|
|
636
|
+
width: width,
|
|
637
|
+
lineLength: lineLength,
|
|
600
638
|
node: node,
|
|
601
639
|
getPos: getPos,
|
|
602
640
|
mediaProvider: mediaProvider,
|
|
@@ -606,13 +644,14 @@ var MediaSingleNodeWrapper = function MediaSingleNodeWrapper(_ref6) {
|
|
|
606
644
|
fullWidthMode: fullWidthMode,
|
|
607
645
|
selected: fg('platform_editor_no_selection_until_interaction') ? isSelectedAndInteracted : selected,
|
|
608
646
|
eventDispatcher: eventDispatcher,
|
|
609
|
-
|
|
610
|
-
|
|
647
|
+
addPendingTask: addPendingTask,
|
|
648
|
+
isDrafting: isDrafting,
|
|
649
|
+
targetNodeId: targetNodeId,
|
|
611
650
|
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
612
651
|
forwardRef: forwardRef,
|
|
613
652
|
pluginInjectionApi: pluginInjectionApi,
|
|
614
|
-
editorDisabled:
|
|
615
|
-
editorViewMode:
|
|
653
|
+
editorDisabled: editorDisabled,
|
|
654
|
+
editorViewMode: viewMode === 'view',
|
|
616
655
|
editorAppearance: editorAppearance
|
|
617
656
|
});
|
|
618
657
|
};
|
|
@@ -293,12 +293,13 @@ export var MediaSingleNodeNext = function MediaSingleNodeNext(mediaSingleNodeNex
|
|
|
293
293
|
dispatchAnalyticsEvent = mediaSingleNodeNextProps.dispatchAnalyticsEvent,
|
|
294
294
|
editorViewMode = mediaSingleNodeNextProps.editorViewMode,
|
|
295
295
|
editorDisabled = mediaSingleNodeNextProps.editorDisabled,
|
|
296
|
-
|
|
296
|
+
isDrafting = mediaSingleNodeNextProps.isDrafting,
|
|
297
|
+
targetNodeId = mediaSingleNodeNextProps.targetNodeId,
|
|
297
298
|
editorAppearance = mediaSingleNodeNextProps.editorAppearance,
|
|
298
299
|
mediaProviderPromise = mediaSingleNodeNextProps.mediaProvider,
|
|
299
300
|
forwardRef = mediaSingleNodeNextProps.forwardRef,
|
|
300
301
|
contextIdentifierProviderPromise = mediaSingleNodeNextProps.contextIdentifierProvider,
|
|
301
|
-
|
|
302
|
+
addPendingTask = mediaSingleNodeNextProps.addPendingTask;
|
|
302
303
|
var _React$useState3 = React.useState(null),
|
|
303
304
|
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
304
305
|
mediaProvider = _React$useState4[0],
|
|
@@ -326,7 +327,7 @@ export var MediaSingleNodeNext = function MediaSingleNodeNext(mediaSingleNodeNex
|
|
|
326
327
|
mediaNodeUpdater: mediaNodeUpdater,
|
|
327
328
|
getPos: getPos,
|
|
328
329
|
mediaNode: mediaNode,
|
|
329
|
-
addPendingTask:
|
|
330
|
+
addPendingTask: addPendingTask || noop
|
|
330
331
|
});
|
|
331
332
|
React.useLayoutEffect(function () {
|
|
332
333
|
mountedRef.current = true;
|
|
@@ -430,7 +431,7 @@ export var MediaSingleNodeNext = function MediaSingleNodeNext(mediaSingleNodeNex
|
|
|
430
431
|
}, [mediaSingleWidthAttribute, widthType, width, layout, contentWidthForLegacyExperience, containerWidth]);
|
|
431
432
|
var currentMaxWidth = isSelected ? pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$m = pluginInjectionApi.media) === null || _pluginInjectionApi$m === void 0 || (_pluginInjectionApi$m = _pluginInjectionApi$m.sharedState.currentState()) === null || _pluginInjectionApi$m === void 0 ? void 0 : _pluginInjectionApi$m.currentMaxWidth : undefined;
|
|
432
433
|
var contentWidth = currentMaxWidth || lineLength;
|
|
433
|
-
var isCurrentNodeDrafting = Boolean(
|
|
434
|
+
var isCurrentNodeDrafting = Boolean(isDrafting && targetNodeId === (mediaNode === null || mediaNode === void 0 || (_mediaNode$firstChild = mediaNode.firstChild) === null || _mediaNode$firstChild === void 0 ? void 0 : _mediaNode$firstChild.attrs.id));
|
|
434
435
|
var mediaSingleWrapperRef = /*#__PURE__*/React.createRef();
|
|
435
436
|
var captionPlaceHolderRef = /*#__PURE__*/React.createRef();
|
|
436
437
|
var onMediaSingleClicked = React.useCallback(function (event) {
|
|
@@ -3,7 +3,9 @@ import { DEFAULT_IMAGE_HEIGHT, DEFAULT_IMAGE_WIDTH } from '@atlaskit/editor-comm
|
|
|
3
3
|
import { atTheBeginningOfBlock, atTheEndOfBlock, atTheEndOfDoc, endPositionOfParent, startPositionOfParent } from '@atlaskit/editor-common/selection';
|
|
4
4
|
import { findFarthestParentNode, insideTableCell, isInLayoutColumn, isInListItem, isSupportedInParent, setNodeSelection, setTextSelection } from '@atlaskit/editor-common/utils';
|
|
5
5
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
6
|
+
import { ReplaceStep } from '@atlaskit/editor-prosemirror/transform';
|
|
6
7
|
import { canInsert, hasParentNode, safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
8
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
7
9
|
import { isImage } from './is-type';
|
|
8
10
|
import { copyOptionalAttrsFromMediaState, isInsidePotentialEmptyParagraph, isSelectionNonMediaBlockNode, posOfMediaGroupNearby, posOfParentMediaGroup, posOfPrecedingMediaGroup } from './media-common';
|
|
9
11
|
import { isInSupportedInlineImageParent } from './media-inline';
|
|
@@ -46,7 +48,21 @@ var getInsertMediaInlineAnalytics = function getInsertMediaInlineAnalytics(media
|
|
|
46
48
|
eventType: EVENT_TYPE.TRACK
|
|
47
49
|
};
|
|
48
50
|
};
|
|
49
|
-
|
|
51
|
+
export var getFailToInsertAnalytics = function getFailToInsertAnalytics(mediaState, actionSubjectId, inputMethod, insertMediaVia, reason) {
|
|
52
|
+
var media = mediaState.fileMimeType || 'unknown';
|
|
53
|
+
return {
|
|
54
|
+
action: ACTION.FAILED_TO_INSERT,
|
|
55
|
+
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
56
|
+
actionSubjectId: actionSubjectId,
|
|
57
|
+
attributes: {
|
|
58
|
+
inputMethod: inputMethod,
|
|
59
|
+
fileExtension: media,
|
|
60
|
+
insertMediaVia: insertMediaVia,
|
|
61
|
+
reason: reason
|
|
62
|
+
},
|
|
63
|
+
eventType: EVENT_TYPE.OPERATIONAL
|
|
64
|
+
};
|
|
65
|
+
};
|
|
50
66
|
/**
|
|
51
67
|
* Check if current editor selections is a media group or not.
|
|
52
68
|
* @param state Editor state
|
|
@@ -69,6 +85,27 @@ function shouldAppendParagraph(state, node) {
|
|
|
69
85
|
return (insideTableCell(state) || isInListItem(state) || isInLayoutColumn(state) || atTheEndOfDoc(state) && (!posOfPrecedingMediaGroup(state) || isSelectionNonMediaBlockNode(state))) && !wasMediaNode;
|
|
70
86
|
}
|
|
71
87
|
|
|
88
|
+
/**
|
|
89
|
+
* Check if node of type has been inserted successfully
|
|
90
|
+
*/
|
|
91
|
+
var hasInsertedNodeOfType = function hasInsertedNodeOfType(tr, nodeType) {
|
|
92
|
+
var _tr$doc$nodeAt;
|
|
93
|
+
var insertPos = -1;
|
|
94
|
+
tr.steps.forEach(function (step) {
|
|
95
|
+
if (step instanceof ReplaceStep) {
|
|
96
|
+
step.slice.content.forEach(function (node) {
|
|
97
|
+
if (node.type.name === nodeType) {
|
|
98
|
+
insertPos = step.from;
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
if (insertPos === -1 || ((_tr$doc$nodeAt = tr.doc.nodeAt(insertPos)) === null || _tr$doc$nodeAt === void 0 ? void 0 : _tr$doc$nodeAt.type.name) !== nodeType) {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
return true;
|
|
107
|
+
};
|
|
108
|
+
|
|
72
109
|
/**
|
|
73
110
|
* Create a new media inline to insert the new media.
|
|
74
111
|
* @param view Editor view
|
|
@@ -123,12 +160,33 @@ export var insertMediaInlineNode = function insertMediaInlineNode(editorAnalytic
|
|
|
123
160
|
|
|
124
161
|
// Delete the selection if a selection is made
|
|
125
162
|
var deleteRange = findDeleteRange(state);
|
|
126
|
-
if (
|
|
127
|
-
|
|
163
|
+
if (fg('platform_editor_track_media_fail_to_insert')) {
|
|
164
|
+
var payload;
|
|
165
|
+
try {
|
|
166
|
+
if (!deleteRange) {
|
|
167
|
+
tr.insert(pos, content);
|
|
168
|
+
} else {
|
|
169
|
+
tr.insert(pos, content).deleteRange(deleteRange.start, deleteRange.end);
|
|
170
|
+
}
|
|
171
|
+
if (hasInsertedNodeOfType(tr, 'mediaInline')) {
|
|
172
|
+
payload = getInsertMediaInlineAnalytics(mediaState, inputMethod, insertMediaVia);
|
|
173
|
+
} else {
|
|
174
|
+
payload = getFailToInsertAnalytics(mediaState, ACTION_SUBJECT_ID.MEDIA_INLINE, inputMethod, insertMediaVia);
|
|
175
|
+
}
|
|
176
|
+
} catch (error) {
|
|
177
|
+
payload = getFailToInsertAnalytics(mediaState, ACTION_SUBJECT_ID.MEDIA_INLINE, inputMethod, insertMediaVia,
|
|
178
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
179
|
+
error.toString());
|
|
180
|
+
}
|
|
181
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent(payload)(tr);
|
|
128
182
|
} else {
|
|
129
|
-
|
|
183
|
+
if (!deleteRange) {
|
|
184
|
+
tr.insert(pos, content);
|
|
185
|
+
} else {
|
|
186
|
+
tr.insert(pos, content).deleteRange(deleteRange.start, deleteRange.end);
|
|
187
|
+
}
|
|
188
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent(getInsertMediaInlineAnalytics(mediaState, inputMethod, insertMediaVia))(tr);
|
|
130
189
|
}
|
|
131
|
-
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent(getInsertMediaInlineAnalytics(mediaState, inputMethod, insertMediaVia))(tr);
|
|
132
190
|
dispatch(tr);
|
|
133
191
|
return true;
|
|
134
192
|
};
|
|
@@ -4,6 +4,8 @@ import { injectIntl } from 'react-intl-next';
|
|
|
4
4
|
import { VIEW_METHOD } from '@atlaskit/editor-common/analytics';
|
|
5
5
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
6
6
|
import { CommentBadge as CommentBadgeComponent, CommentBadgeNext } from '@atlaskit/editor-common/media-single';
|
|
7
|
+
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
8
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
7
9
|
var CommentBadgeWrapper = function CommentBadgeWrapper(_ref) {
|
|
8
10
|
var api = _ref.api,
|
|
9
11
|
mediaNode = _ref.mediaNode,
|
|
@@ -16,23 +18,37 @@ var CommentBadgeWrapper = function CommentBadgeWrapper(_ref) {
|
|
|
16
18
|
_useState2 = _slicedToArray(_useState, 2),
|
|
17
19
|
entered = _useState2[0],
|
|
18
20
|
setEntered = _useState2[1];
|
|
19
|
-
var _useSharedPluginState = useSharedPluginState(api, ['annotation']
|
|
21
|
+
var _useSharedPluginState = useSharedPluginState(api, ['annotation'], {
|
|
22
|
+
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
|
|
23
|
+
}),
|
|
20
24
|
annotationState = _useSharedPluginState.annotationState;
|
|
25
|
+
var selectedAnnotationsSelector = useSharedPluginStateSelector(api, 'annotation.selectedAnnotations', {
|
|
26
|
+
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
27
|
+
});
|
|
28
|
+
var isInlineCommentViewClosedSelector = useSharedPluginStateSelector(api, 'annotation.isInlineCommentViewClosed', {
|
|
29
|
+
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
30
|
+
});
|
|
31
|
+
var annotationsSelector = useSharedPluginStateSelector(api, 'annotation.annotations', {
|
|
32
|
+
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
33
|
+
});
|
|
34
|
+
var selectedAnnotations = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? selectedAnnotationsSelector : annotationState === null || annotationState === void 0 ? void 0 : annotationState.selectedAnnotations;
|
|
35
|
+
var isInlineCommentViewClosed = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? isInlineCommentViewClosedSelector : annotationState === null || annotationState === void 0 ? void 0 : annotationState.isInlineCommentViewClosed;
|
|
36
|
+
var annotations = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? annotationsSelector : annotationState === null || annotationState === void 0 ? void 0 : annotationState.annotations;
|
|
21
37
|
var _view$state$schema = view.state.schema,
|
|
22
38
|
media = _view$state$schema.nodes.media,
|
|
23
39
|
annotation = _view$state$schema.marks.annotation,
|
|
24
40
|
state = view.state,
|
|
25
41
|
dispatch = view.dispatch;
|
|
26
42
|
var status = useMemo(function () {
|
|
27
|
-
if (!
|
|
43
|
+
if (!selectedAnnotations || !mediaNode) {
|
|
28
44
|
return 'default';
|
|
29
45
|
}
|
|
30
|
-
return
|
|
46
|
+
return selectedAnnotations.some(function (annotation) {
|
|
31
47
|
return !!mediaNode.marks.find(function (mark) {
|
|
32
48
|
return mark.attrs.id === annotation.id;
|
|
33
49
|
});
|
|
34
|
-
}) && !
|
|
35
|
-
}, [
|
|
50
|
+
}) && !isInlineCommentViewClosed ? 'active' : 'default';
|
|
51
|
+
}, [selectedAnnotations, isInlineCommentViewClosed, mediaNode]);
|
|
36
52
|
var onClick = useCallback(function () {
|
|
37
53
|
if (api.annotation && mediaNode) {
|
|
38
54
|
var showCommentForBlockNode = api.annotation.actions.showCommentForBlockNode;
|
|
@@ -40,8 +56,8 @@ var CommentBadgeWrapper = function CommentBadgeWrapper(_ref) {
|
|
|
40
56
|
}
|
|
41
57
|
}, [api.annotation, dispatch, mediaNode, state]);
|
|
42
58
|
var pos = getPos();
|
|
43
|
-
var hasNoComments = !Number.isFinite(pos) || !
|
|
44
|
-
return maybeAnnotation.type !== annotation || !(maybeAnnotation.attrs.id in
|
|
59
|
+
var hasNoComments = !Number.isFinite(pos) || !annotations || !mediaNode || mediaNode.type !== media || mediaNode.marks.every(function (maybeAnnotation) {
|
|
60
|
+
return maybeAnnotation.type !== annotation || !(maybeAnnotation.attrs.id in annotations) || annotations[maybeAnnotation.attrs.id];
|
|
45
61
|
});
|
|
46
62
|
if (!isDrafting && hasNoComments || !mediaNode) {
|
|
47
63
|
return null;
|
|
@@ -88,23 +104,37 @@ export var CommentBadgeNextWrapper = function CommentBadgeNextWrapper(_ref2) {
|
|
|
88
104
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
89
105
|
entered = _useState4[0],
|
|
90
106
|
setEntered = _useState4[1];
|
|
91
|
-
var _useSharedPluginState2 = useSharedPluginState(api, ['annotation']
|
|
107
|
+
var _useSharedPluginState2 = useSharedPluginState(api, ['annotation'], {
|
|
108
|
+
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
|
|
109
|
+
}),
|
|
92
110
|
annotationState = _useSharedPluginState2.annotationState;
|
|
111
|
+
var selectedAnnotationsSelector = useSharedPluginStateSelector(api, 'annotation.selectedAnnotations', {
|
|
112
|
+
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
113
|
+
});
|
|
114
|
+
var isInlineCommentViewClosedSelector = useSharedPluginStateSelector(api, 'annotation.isInlineCommentViewClosed', {
|
|
115
|
+
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
116
|
+
});
|
|
117
|
+
var annotationsSelector = useSharedPluginStateSelector(api, 'annotation.annotations', {
|
|
118
|
+
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
119
|
+
});
|
|
120
|
+
var selectedAnnotations = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? selectedAnnotationsSelector : annotationState === null || annotationState === void 0 ? void 0 : annotationState.selectedAnnotations;
|
|
121
|
+
var isInlineCommentViewClosed = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? isInlineCommentViewClosedSelector : annotationState === null || annotationState === void 0 ? void 0 : annotationState.isInlineCommentViewClosed;
|
|
122
|
+
var annotations = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? annotationsSelector : annotationState === null || annotationState === void 0 ? void 0 : annotationState.annotations;
|
|
93
123
|
var _view$state$schema2 = view.state.schema,
|
|
94
124
|
media = _view$state$schema2.nodes.media,
|
|
95
125
|
annotation = _view$state$schema2.marks.annotation,
|
|
96
126
|
state = view.state,
|
|
97
127
|
dispatch = view.dispatch;
|
|
98
128
|
var status = useMemo(function () {
|
|
99
|
-
if (!
|
|
129
|
+
if (!selectedAnnotations || !mediaNode) {
|
|
100
130
|
return 'default';
|
|
101
131
|
}
|
|
102
|
-
return
|
|
132
|
+
return selectedAnnotations.some(function (annotation) {
|
|
103
133
|
return !!mediaNode.marks.find(function (mark) {
|
|
104
134
|
return mark.attrs.id === annotation.id;
|
|
105
135
|
});
|
|
106
|
-
}) && !
|
|
107
|
-
}, [
|
|
136
|
+
}) && !isInlineCommentViewClosed ? 'active' : 'default';
|
|
137
|
+
}, [selectedAnnotations, isInlineCommentViewClosed, mediaNode]);
|
|
108
138
|
var onClick = useCallback(function () {
|
|
109
139
|
if (api.annotation && mediaNode) {
|
|
110
140
|
var showCommentForBlockNode = api.annotation.actions.showCommentForBlockNode;
|
|
@@ -112,8 +142,8 @@ export var CommentBadgeNextWrapper = function CommentBadgeNextWrapper(_ref2) {
|
|
|
112
142
|
}
|
|
113
143
|
}, [api.annotation, dispatch, mediaNode, state]);
|
|
114
144
|
var pos = getPos();
|
|
115
|
-
var hasNoComments = !Number.isFinite(pos) || !
|
|
116
|
-
return maybeAnnotation.type !== annotation || !(maybeAnnotation.attrs.id in
|
|
145
|
+
var hasNoComments = !Number.isFinite(pos) || !annotations || !mediaNode || mediaNode.type !== media || mediaNode.marks.every(function (maybeAnnotation) {
|
|
146
|
+
return maybeAnnotation.type !== annotation || !(maybeAnnotation.attrs.id in annotations) || annotations[maybeAnnotation.attrs.id];
|
|
117
147
|
});
|
|
118
148
|
if (!isDrafting && hasNoComments || !mediaNode) {
|
|
119
149
|
return null;
|
|
@@ -34,9 +34,8 @@ export var buttonStyle = function buttonStyle(selected) {
|
|
|
34
34
|
return css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n\theight: 26px;\n\twidth: 26px;\n\tpadding: 0;\n\tborder-radius: 4px;\n\tbackground-color: ", ";\n\tborder: 1px solid ", ";\n\tcursor: pointer;\n\tdisplay: block;\n"])), selected ? "var(--ds-text, ".concat(N800, ")") : "var(--ds-background-neutral, ".concat(N20A, ")"), DEFAULT_BORDER_COLOR);
|
|
35
35
|
};
|
|
36
36
|
|
|
37
|
-
/* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
|
|
38
37
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles -- Ignored via go/DSP-18766
|
|
39
|
-
export var buttonWrapperStyle = css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n\tborder: 1px solid transparent;\n\tmargin: ", ";\n\tfont-size: 0;\n\tdisplay: flex;\n\talign-items: center;\n\tpadding: ", ";\n\tborder-radius: 6px;\n\t&:focus-within,\n\t&:focus,\n\t&:hover {\n\t\tborder-color: ", " !important;\n\t}\n"])), "var(--ds-space-025, 2px)", "var(--ds-space-025, 2px)", N50);
|
|
38
|
+
export var buttonWrapperStyle = css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n\tborder: 1px solid transparent;\n\tmargin: ", ";\n\tfont-size: 0;\n\tdisplay: flex;\n\talign-items: center;\n\tpadding: ", ";\n\tborder-radius: 6px;\n\t&:focus-within,\n\t&:focus,\n\t&:hover {\n\t\tborder-color: ", " !important;\n\t}\n"])), "var(--ds-space-025, 2px)", "var(--ds-space-025, 2px)", "var(--ds-border, ".concat(N50, ")"));
|
|
40
39
|
export var line = function line(size, selected) {
|
|
41
40
|
return css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n\tposition: relative;\n\t&:before {\n\t\tcontent: '';\n\t\tdisplay: block;\n\t\tposition: absolute;\n\t\ttop: 50%;\n\t\tleft: 50%;\n\t\twidth: 12px;\n\t\theight: ", "px;\n\t\tbackground-color: ", ";\n\t\tborder-radius: 90px;\n\t\ttransform: translate(-50%, -50%) rotate(135deg);\n\t}\n"])), size, selected ? "var(--ds-icon-inverse, ".concat(N0, ")") : "var(--ds-icon, #44546F)");
|
|
42
41
|
};
|
|
@@ -8,6 +8,8 @@ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstruct
|
|
|
8
8
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
9
9
|
import React from 'react';
|
|
10
10
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
11
|
+
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
12
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
11
13
|
import { BrowserWrapper } from './BrowserWrapper';
|
|
12
14
|
import { ClipboardWrapper } from './ClipboardWrapper';
|
|
13
15
|
import { DropzoneWrapper } from './DropzoneWrapper';
|
|
@@ -19,9 +21,19 @@ var MediaPicker = function MediaPicker(_ref) {
|
|
|
19
21
|
mediaState = _ref.mediaState,
|
|
20
22
|
onBrowseFn = _ref.onBrowseFn,
|
|
21
23
|
editorDomElement = _ref.editorDomElement;
|
|
22
|
-
var _useSharedPluginState = useSharedPluginState(api, ['focus', 'connectivity']
|
|
24
|
+
var _useSharedPluginState = useSharedPluginState(api, ['focus', 'connectivity'], {
|
|
25
|
+
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
|
|
26
|
+
}),
|
|
23
27
|
focusState = _useSharedPluginState.focusState,
|
|
24
28
|
connectivityState = _useSharedPluginState.connectivityState;
|
|
29
|
+
var hasFocusSelector = useSharedPluginStateSelector(api, 'focus.hasFocus', {
|
|
30
|
+
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
31
|
+
});
|
|
32
|
+
var connectivityModeSelector = useSharedPluginStateSelector(api, 'connectivity.mode', {
|
|
33
|
+
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
34
|
+
});
|
|
35
|
+
var hasFocus = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? hasFocusSelector : focusState === null || focusState === void 0 ? void 0 : focusState.hasFocus;
|
|
36
|
+
var connectivityMode = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? connectivityModeSelector : connectivityState === null || connectivityState === void 0 ? void 0 : connectivityState.mode;
|
|
25
37
|
var featureFlags = mediaState.mediaOptions && mediaState.mediaOptions.featureFlags;
|
|
26
38
|
|
|
27
39
|
// Ignored via go/ees005
|
|
@@ -36,7 +48,7 @@ var MediaPicker = function MediaPicker(_ref) {
|
|
|
36
48
|
* as stopImmediatePropagation could cause race condition issues
|
|
37
49
|
*/
|
|
38
50
|
var container = editorParent;
|
|
39
|
-
var clipboard =
|
|
51
|
+
var clipboard = hasFocus ? /*#__PURE__*/React.createElement(ClipboardWrapper, {
|
|
40
52
|
mediaState: mediaState,
|
|
41
53
|
featureFlags: featureFlags,
|
|
42
54
|
container: container
|
|
@@ -45,7 +57,7 @@ var MediaPicker = function MediaPicker(_ref) {
|
|
|
45
57
|
mediaState: mediaState,
|
|
46
58
|
isActive: !isPopupOpened &&
|
|
47
59
|
// If we're offline don't show the dropzone
|
|
48
|
-
|
|
60
|
+
connectivityMode !== 'offline',
|
|
49
61
|
featureFlags: featureFlags,
|
|
50
62
|
editorDomElement: editorDomElement,
|
|
51
63
|
appearance: appearance
|
|
@@ -9,7 +9,7 @@ import React, { Fragment, useEffect, useState } from 'react';
|
|
|
9
9
|
import { css, jsx } from '@emotion/react';
|
|
10
10
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
11
11
|
import { isVideo } from '../../pm-plugins/utils/is-type';
|
|
12
|
-
import {
|
|
12
|
+
import { getSelectedNearestMediaContainerNodeAttrsFunction } from '../../ui/toolbar/utils';
|
|
13
13
|
import { RenderMediaViewer } from './PortalWrapper';
|
|
14
14
|
var interactiveStyles = css({
|
|
15
15
|
cursor: 'pointer'
|
|
@@ -18,7 +18,8 @@ var mediaViewerContainerTestID = 'media-viewer-container-test';
|
|
|
18
18
|
export var MediaViewerContainer = function MediaViewerContainer(_ref) {
|
|
19
19
|
var _mediaNode$firstChild;
|
|
20
20
|
var mediaNode = _ref.mediaNode,
|
|
21
|
-
|
|
21
|
+
selectedMediaContainerNode = _ref.selectedMediaContainerNode,
|
|
22
|
+
mediaClientConfig = _ref.mediaClientConfig,
|
|
22
23
|
_ref$isEditorViewMode = _ref.isEditorViewMode,
|
|
23
24
|
isEditorViewMode = _ref$isEditorViewMode === void 0 ? false : _ref$isEditorViewMode,
|
|
24
25
|
_ref$isSelected = _ref.isSelected,
|
|
@@ -33,8 +34,7 @@ export var MediaViewerContainer = function MediaViewerContainer(_ref) {
|
|
|
33
34
|
useEffect(function () {
|
|
34
35
|
setShowMediaViewer(isSelected);
|
|
35
36
|
}, [isSelected]);
|
|
36
|
-
var selectedNodeAttrs =
|
|
37
|
-
var mediaClientConfig = mediaPluginState.mediaClientConfig;
|
|
37
|
+
var selectedNodeAttrs = getSelectedNearestMediaContainerNodeAttrsFunction(selectedMediaContainerNode);
|
|
38
38
|
var showMediaViewer = function showMediaViewer() {
|
|
39
39
|
setShowMediaViewer(true);
|
|
40
40
|
};
|
|
@@ -21,6 +21,7 @@ import { jsx } from '@emotion/react';
|
|
|
21
21
|
import classnames from 'classnames';
|
|
22
22
|
import throttle from 'lodash/throttle';
|
|
23
23
|
import memoizeOne from 'memoize-one';
|
|
24
|
+
import { isSSR } from '@atlaskit/editor-common/core-utils';
|
|
24
25
|
import { findClosestSnap, generateDefaultGuidelines, generateDynamicGuidelines, getGuidelineSnaps, getGuidelinesWithHighlights, getGuidelineTypeFromKey, getRelativeGuidelines, getRelativeGuideSnaps } from '@atlaskit/editor-common/guideline';
|
|
25
26
|
import { calcMediaSingleMaxWidth, DEFAULT_IMAGE_WIDTH, MEDIA_SINGLE_ADJACENT_HANDLE_MARGIN, MEDIA_SINGLE_DEFAULT_MIN_PIXEL_WIDTH, MEDIA_SINGLE_RESIZE_THROTTLE_TIME, MEDIA_SINGLE_SNAP_GAP, MEDIA_SINGLE_VIDEO_MIN_PIXEL_WIDTH } from '@atlaskit/editor-common/media-single';
|
|
26
27
|
import { ResizerNext } from '@atlaskit/editor-common/resizer';
|
|
@@ -536,7 +537,7 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
536
537
|
var resizerNextClassName = classnames(className, resizerStyles);
|
|
537
538
|
var isNestedNode = this.isAdjacentMode();
|
|
538
539
|
var handlePositioning = this.getHandlePositioning();
|
|
539
|
-
var maxWidth = this.getMaxWidth();
|
|
540
|
+
var maxWidth = isSSR() && size.width && fg('platform_editor_fix_image_size_diff_during_ssr') ? undefined : this.getMaxWidth();
|
|
540
541
|
var minWidth = this.calcMinWidth(isVideoFile, lineLength);
|
|
541
542
|
|
|
542
543
|
// while is not resizing, we take 100% as min-width if the container width is less than the min-width
|