@atlaskit/editor-plugin-media 1.36.3 → 1.36.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/cjs/pm-plugins/main.js +18 -0
- package/dist/cjs/toolbar/index.js +6 -2
- package/dist/cjs/toolbar/mediaInline.js +18 -14
- package/dist/cjs/utils/media-common.js +15 -1
- package/dist/es2019/pm-plugins/main.js +20 -2
- package/dist/es2019/toolbar/index.js +6 -2
- package/dist/es2019/toolbar/mediaInline.js +19 -15
- package/dist/es2019/utils/media-common.js +15 -0
- package/dist/esm/pm-plugins/main.js +20 -2
- package/dist/esm/toolbar/index.js +6 -2
- package/dist/esm/toolbar/mediaInline.js +18 -14
- package/dist/esm/utils/media-common.js +14 -0
- package/dist/types/pm-plugins/main.d.ts +1 -1
- package/dist/types/utils/media-common.d.ts +1 -0
- package/dist/types-ts4.5/pm-plugins/main.d.ts +1 -1
- package/dist/types-ts4.5/utils/media-common.d.ts +1 -0
- package/package.json +7 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-media
|
|
2
2
|
|
|
3
|
+
## 1.36.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#154581](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/154581)
|
|
8
|
+
[`27d560bd2b6b6`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/27d560bd2b6b6) -
|
|
9
|
+
[ux] ED-25201 Enable double click to open media viewer in editor
|
|
10
|
+
|
|
11
|
+
## 1.36.4
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies
|
|
16
|
+
|
|
3
17
|
## 1.36.3
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -924,6 +924,24 @@ var createPlugin = exports.createPlugin = function createPlugin(_schema, options
|
|
|
924
924
|
}
|
|
925
925
|
return false;
|
|
926
926
|
},
|
|
927
|
+
handleDoubleClickOn: function handleDoubleClickOn(view) {
|
|
928
|
+
var _pluginInjectionApi$e;
|
|
929
|
+
if (!(0, _platformFeatureFlags.fg)('platform_editor_media_previewer_bugfix') || !(0, _platformFeatureFlags.fg)('platform_editor_media_interaction_improvements') || (pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$e = pluginInjectionApi.editorViewMode) === null || _pluginInjectionApi$e === void 0 || (_pluginInjectionApi$e = _pluginInjectionApi$e.sharedState.currentState()) === null || _pluginInjectionApi$e === void 0 ? void 0 : _pluginInjectionApi$e.mode) === 'view') {
|
|
930
|
+
return;
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
// Double Click support for Media Viewer Nodes
|
|
934
|
+
var maybeMediaNode = (0, _mediaCommon2.getMediaFromSupportedMediaNodesFromSelection)(view.state);
|
|
935
|
+
if (maybeMediaNode) {
|
|
936
|
+
// If media type is video, do not open media viewer
|
|
937
|
+
if ((0, _mediaSingle2.isVideo)(maybeMediaNode.attrs.__fileMimeType)) {
|
|
938
|
+
return false;
|
|
939
|
+
}
|
|
940
|
+
pluginInjectionApi === null || pluginInjectionApi === void 0 || pluginInjectionApi.core.actions.execute(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.media.commands.showMediaViewer(maybeMediaNode.attrs));
|
|
941
|
+
return true;
|
|
942
|
+
}
|
|
943
|
+
return false;
|
|
944
|
+
},
|
|
927
945
|
handleDOMEvents: {
|
|
928
946
|
keydown: function keydown(view, event) {
|
|
929
947
|
var selection = view.state.selection;
|
|
@@ -128,6 +128,7 @@ var generateMediaCardFloatingToolbar = function generateMediaCardFloatingToolbar
|
|
|
128
128
|
type: 'separator'
|
|
129
129
|
}, (0, _platformFeatureFlags.fg)('platform_editor_media_previewer_bugfix') ? {
|
|
130
130
|
id: 'editor.media.viewer',
|
|
131
|
+
testId: 'file-preview-toolbar-button',
|
|
131
132
|
type: 'button',
|
|
132
133
|
icon: _maximize.default,
|
|
133
134
|
iconFallback: _filePreview.default,
|
|
@@ -138,7 +139,8 @@ var generateMediaCardFloatingToolbar = function generateMediaCardFloatingToolbar
|
|
|
138
139
|
mediaPluginState: mediaPluginState,
|
|
139
140
|
api: pluginInjectionApi
|
|
140
141
|
})) !== null && _handleShowMediaViewe !== void 0 ? _handleShowMediaViewe : false;
|
|
141
|
-
}
|
|
142
|
+
},
|
|
143
|
+
supportsViewMode: true
|
|
142
144
|
} : generateFilePreviewItem(mediaPluginState, intl), {
|
|
143
145
|
type: 'separator'
|
|
144
146
|
}, {
|
|
@@ -480,6 +482,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
480
482
|
if (!(0, _mediaSingle2.isVideo)(mediaNode === null || mediaNode === void 0 || (_mediaNode$attrs = mediaNode.attrs) === null || _mediaNode$attrs === void 0 ? void 0 : _mediaNode$attrs.__fileMimeType)) {
|
|
481
483
|
toolbarButtons.push((0, _platformFeatureFlags.fg)('platform_editor_media_previewer_bugfix') ? {
|
|
482
484
|
id: 'editor.media.viewer',
|
|
485
|
+
testId: 'file-preview-toolbar-button',
|
|
483
486
|
type: 'button',
|
|
484
487
|
icon: _maximize.default,
|
|
485
488
|
iconFallback: _filePreview.default,
|
|
@@ -490,7 +493,8 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
490
493
|
api: pluginInjectionApi,
|
|
491
494
|
mediaPluginState: pluginState
|
|
492
495
|
})) !== null && _handleShowMediaViewe2 !== void 0 ? _handleShowMediaViewe2 : false;
|
|
493
|
-
}
|
|
496
|
+
},
|
|
497
|
+
supportsViewMode: true
|
|
494
498
|
} : generateFilePreviewItem(pluginState, intl), {
|
|
495
499
|
type: 'separator',
|
|
496
500
|
supportsViewMode: true
|
|
@@ -27,7 +27,6 @@ var _currentMediaNode = require("../utils/current-media-node");
|
|
|
27
27
|
var _isType = require("../utils/is-type");
|
|
28
28
|
var _altText = require("./alt-text");
|
|
29
29
|
var _commands = require("./commands");
|
|
30
|
-
var _filePreviewItem = require("./filePreviewItem");
|
|
31
30
|
var _imageBorder = require("./imageBorder");
|
|
32
31
|
var _linkingToolbarAppearance = require("./linking-toolbar-appearance");
|
|
33
32
|
var _utils = require("./utils");
|
|
@@ -73,17 +72,20 @@ var generateMediaInlineFloatingToolbar = exports.generateMediaInlineFloatingTool
|
|
|
73
72
|
className: 'thumbnail-appearance' // a11y. uses to force focus on item
|
|
74
73
|
}, {
|
|
75
74
|
type: 'separator'
|
|
76
|
-
}, {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
75
|
+
}, (0, _platformFeatureFlags.fg)('platform_editor_media_previewer_bugfix') ? {
|
|
76
|
+
id: 'editor.media.viewer',
|
|
77
|
+
testId: 'file-preview-toolbar-button',
|
|
78
|
+
type: 'button',
|
|
79
|
+
icon: _filePreview.default,
|
|
80
|
+
title: intl.formatMessage(_mediaUi.messages.preview),
|
|
81
|
+
onClick: function onClick() {
|
|
82
|
+
var _handleShowMediaViewe;
|
|
83
|
+
return (_handleShowMediaViewe = (0, _index.handleShowMediaViewer)({
|
|
82
84
|
mediaPluginState: mediaPluginState,
|
|
83
|
-
|
|
84
|
-
});
|
|
85
|
+
api: pluginInjectionApi
|
|
86
|
+
})) !== null && _handleShowMediaViewe !== void 0 ? _handleShowMediaViewe : false;
|
|
85
87
|
}
|
|
86
|
-
}, {
|
|
88
|
+
} : (0, _index.generateFilePreviewItem)(mediaPluginState, intl), {
|
|
87
89
|
type: 'separator'
|
|
88
90
|
}, {
|
|
89
91
|
id: 'editor.media.card.download',
|
|
@@ -243,16 +245,18 @@ var getMediaInlineImageToolbar = function getMediaInlineImageToolbar(state, intl
|
|
|
243
245
|
if (options.allowImagePreview) {
|
|
244
246
|
inlineImageItems.push((0, _platformFeatureFlags.fg)('platform_editor_media_previewer_bugfix') ? {
|
|
245
247
|
id: 'editor.media.viewer',
|
|
248
|
+
testId: 'file-preview-toolbar-button',
|
|
246
249
|
type: 'button',
|
|
247
250
|
icon: _filePreview.default,
|
|
248
251
|
title: intl.formatMessage(_mediaUi.messages.preview),
|
|
249
252
|
onClick: function onClick() {
|
|
250
|
-
var
|
|
251
|
-
return (
|
|
253
|
+
var _handleShowMediaViewe2;
|
|
254
|
+
return (_handleShowMediaViewe2 = (0, _index.handleShowMediaViewer)({
|
|
252
255
|
mediaPluginState: mediaPluginState,
|
|
253
256
|
api: pluginInjectionApi
|
|
254
|
-
})) !== null &&
|
|
255
|
-
}
|
|
257
|
+
})) !== null && _handleShowMediaViewe2 !== void 0 ? _handleShowMediaViewe2 : false;
|
|
258
|
+
},
|
|
259
|
+
supportsViewMode: true
|
|
256
260
|
} : (0, _index.generateFilePreviewItem)(mediaPluginState, intl), {
|
|
257
261
|
type: 'separator',
|
|
258
262
|
supportsViewMode: true
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.splitMediaGroup = exports.removeMediaNode = exports.posOfPrecedingMediaGroup = exports.posOfParentMediaGroup = exports.posOfMediaGroupNearby = exports.isSelectionNonMediaBlockNode = exports.isSelectionMediaSingleNode = exports.isMediaSingleOrInlineNodeSelected = exports.isMediaBlobUrlFromAttrs = exports.isInsidePotentialEmptyParagraph = exports.getMediaSingleOrInlineNodeFromSelection = exports.getMediaNodeFromSelection = exports.copyOptionalAttrsFromMediaState = void 0;
|
|
6
|
+
exports.splitMediaGroup = exports.removeMediaNode = exports.posOfPrecedingMediaGroup = exports.posOfParentMediaGroup = exports.posOfMediaGroupNearby = exports.isSelectionNonMediaBlockNode = exports.isSelectionMediaSingleNode = exports.isMediaSingleOrInlineNodeSelected = exports.isMediaBlobUrlFromAttrs = exports.isInsidePotentialEmptyParagraph = exports.getMediaSingleOrInlineNodeFromSelection = exports.getMediaNodeFromSelection = exports.getMediaFromSupportedMediaNodesFromSelection = exports.copyOptionalAttrsFromMediaState = void 0;
|
|
7
7
|
var _selection = require("@atlaskit/editor-common/selection");
|
|
8
8
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
9
9
|
var _commands = require("@atlaskit/editor-prosemirror/commands");
|
|
@@ -204,4 +204,18 @@ var getMediaSingleOrInlineNodeFromSelection = exports.getMediaSingleOrInlineNode
|
|
|
204
204
|
allowInlineImages = _getMediaPluginState2.allowInlineImages;
|
|
205
205
|
var mediaNode = getMediaNodeFromSelection(state) || allowInlineImages && getMediaInlineNodeFromSelection(state);
|
|
206
206
|
return mediaNode || null;
|
|
207
|
+
};
|
|
208
|
+
var getMediaFromSupportedMediaNodesFromSelection = exports.getMediaFromSupportedMediaNodesFromSelection = function getMediaFromSupportedMediaNodesFromSelection(state) {
|
|
209
|
+
var _ref4 = state.selection,
|
|
210
|
+
node = _ref4.node;
|
|
211
|
+
switch (node.type) {
|
|
212
|
+
case node.type.schema.nodes.media:
|
|
213
|
+
case node.type.schema.nodes.mediaInline:
|
|
214
|
+
return node;
|
|
215
|
+
case node.type.schema.nodes.mediaSingle:
|
|
216
|
+
case node.type.schema.nodes.mediaGroup:
|
|
217
|
+
return node.firstChild;
|
|
218
|
+
default:
|
|
219
|
+
return null;
|
|
220
|
+
}
|
|
207
221
|
};
|
|
@@ -20,10 +20,10 @@ import * as helpers from '../commands/helpers';
|
|
|
20
20
|
import { updateMediaNodeAttrs } from '../commands/helpers';
|
|
21
21
|
import PickerFacade from '../picker-facade';
|
|
22
22
|
import DropPlaceholder from '../ui/Media/DropPlaceholder';
|
|
23
|
-
import { removeMediaNode, splitMediaGroup } from '../utils/media-common';
|
|
23
|
+
import { getMediaFromSupportedMediaNodesFromSelection, removeMediaNode, splitMediaGroup } from '../utils/media-common';
|
|
24
24
|
import { insertMediaGroupNode, insertMediaInlineNode } from '../utils/media-files';
|
|
25
25
|
import { getMediaNodeInsertionType } from '../utils/media-inline';
|
|
26
|
-
import { insertMediaSingleNode } from '../utils/media-single';
|
|
26
|
+
import { insertMediaSingleNode, isVideo } from '../utils/media-single';
|
|
27
27
|
import { ACTIONS } from './actions';
|
|
28
28
|
import { MediaTaskManager } from './mediaTaskManager';
|
|
29
29
|
import { stateKey } from './plugin-key';
|
|
@@ -808,6 +808,24 @@ export const createPlugin = (_schema, options, getIntl, pluginInjectionApi, disp
|
|
|
808
808
|
}
|
|
809
809
|
return false;
|
|
810
810
|
},
|
|
811
|
+
handleDoubleClickOn: view => {
|
|
812
|
+
var _pluginInjectionApi$e, _pluginInjectionApi$e2;
|
|
813
|
+
if (!fg('platform_editor_media_previewer_bugfix') || !fg('platform_editor_media_interaction_improvements') || (pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$e = pluginInjectionApi.editorViewMode) === null || _pluginInjectionApi$e === void 0 ? void 0 : (_pluginInjectionApi$e2 = _pluginInjectionApi$e.sharedState.currentState()) === null || _pluginInjectionApi$e2 === void 0 ? void 0 : _pluginInjectionApi$e2.mode) === 'view') {
|
|
814
|
+
return;
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
// Double Click support for Media Viewer Nodes
|
|
818
|
+
const maybeMediaNode = getMediaFromSupportedMediaNodesFromSelection(view.state);
|
|
819
|
+
if (maybeMediaNode) {
|
|
820
|
+
// If media type is video, do not open media viewer
|
|
821
|
+
if (isVideo(maybeMediaNode.attrs.__fileMimeType)) {
|
|
822
|
+
return false;
|
|
823
|
+
}
|
|
824
|
+
pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.core.actions.execute(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.media.commands.showMediaViewer(maybeMediaNode.attrs));
|
|
825
|
+
return true;
|
|
826
|
+
}
|
|
827
|
+
return false;
|
|
828
|
+
},
|
|
811
829
|
handleDOMEvents: {
|
|
812
830
|
keydown: (view, event) => {
|
|
813
831
|
const {
|
|
@@ -115,6 +115,7 @@ const generateMediaCardFloatingToolbar = (state, intl, mediaPluginState, hoverDe
|
|
|
115
115
|
type: 'separator'
|
|
116
116
|
}, fg('platform_editor_media_previewer_bugfix') ? {
|
|
117
117
|
id: 'editor.media.viewer',
|
|
118
|
+
testId: 'file-preview-toolbar-button',
|
|
118
119
|
type: 'button',
|
|
119
120
|
icon: MaximizeIcon,
|
|
120
121
|
iconFallback: FilePreviewIcon,
|
|
@@ -125,7 +126,8 @@ const generateMediaCardFloatingToolbar = (state, intl, mediaPluginState, hoverDe
|
|
|
125
126
|
mediaPluginState,
|
|
126
127
|
api: pluginInjectionApi
|
|
127
128
|
})) !== null && _handleShowMediaViewe !== void 0 ? _handleShowMediaViewe : false;
|
|
128
|
-
}
|
|
129
|
+
},
|
|
130
|
+
supportsViewMode: true
|
|
129
131
|
} : generateFilePreviewItem(mediaPluginState, intl), {
|
|
130
132
|
type: 'separator'
|
|
131
133
|
}, {
|
|
@@ -484,6 +486,7 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
|
|
|
484
486
|
if (!isVideo(mediaNode === null || mediaNode === void 0 ? void 0 : (_mediaNode$attrs = mediaNode.attrs) === null || _mediaNode$attrs === void 0 ? void 0 : _mediaNode$attrs.__fileMimeType)) {
|
|
485
487
|
toolbarButtons.push(fg('platform_editor_media_previewer_bugfix') ? {
|
|
486
488
|
id: 'editor.media.viewer',
|
|
489
|
+
testId: 'file-preview-toolbar-button',
|
|
487
490
|
type: 'button',
|
|
488
491
|
icon: MaximizeIcon,
|
|
489
492
|
iconFallback: FilePreviewIcon,
|
|
@@ -494,7 +497,8 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
|
|
|
494
497
|
api: pluginInjectionApi,
|
|
495
498
|
mediaPluginState: pluginState
|
|
496
499
|
})) !== null && _handleShowMediaViewe2 !== void 0 ? _handleShowMediaViewe2 : false;
|
|
497
|
-
}
|
|
500
|
+
},
|
|
501
|
+
supportsViewMode: true
|
|
498
502
|
} : generateFilePreviewItem(pluginState, intl), {
|
|
499
503
|
type: 'separator',
|
|
500
504
|
supportsViewMode: true
|
|
@@ -19,7 +19,6 @@ import { currentMediaOrInlineNodeBorderMark } from '../utils/current-media-node'
|
|
|
19
19
|
import { isImage } from '../utils/is-type';
|
|
20
20
|
import { altTextButton } from './alt-text';
|
|
21
21
|
import { changeInlineToMediaCard, changeMediaInlineToMediaSingle, removeInlineCard, setBorderMark, toggleBorderMark } from './commands';
|
|
22
|
-
import { FilePreviewItem } from './filePreviewItem';
|
|
23
22
|
import { shouldShowImageBorder } from './imageBorder';
|
|
24
23
|
import { LinkToolbarAppearance } from './linking-toolbar-appearance';
|
|
25
24
|
import { downloadMedia } from './utils';
|
|
@@ -62,17 +61,20 @@ export const generateMediaInlineFloatingToolbar = (state, intl, mediaPluginState
|
|
|
62
61
|
className: 'thumbnail-appearance' // a11y. uses to force focus on item
|
|
63
62
|
}, {
|
|
64
63
|
type: 'separator'
|
|
65
|
-
}, {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
64
|
+
}, fg('platform_editor_media_previewer_bugfix') ? {
|
|
65
|
+
id: 'editor.media.viewer',
|
|
66
|
+
testId: 'file-preview-toolbar-button',
|
|
67
|
+
type: 'button',
|
|
68
|
+
icon: FilePreviewIcon,
|
|
69
|
+
title: intl.formatMessage(messages.preview),
|
|
70
|
+
onClick: () => {
|
|
71
|
+
var _handleShowMediaViewe;
|
|
72
|
+
return (_handleShowMediaViewe = handleShowMediaViewer({
|
|
73
|
+
mediaPluginState,
|
|
74
|
+
api: pluginInjectionApi
|
|
75
|
+
})) !== null && _handleShowMediaViewe !== void 0 ? _handleShowMediaViewe : false;
|
|
74
76
|
}
|
|
75
|
-
}, {
|
|
77
|
+
} : generateFilePreviewItem(mediaPluginState, intl), {
|
|
76
78
|
type: 'separator'
|
|
77
79
|
}, {
|
|
78
80
|
id: 'editor.media.card.download',
|
|
@@ -237,16 +239,18 @@ const getMediaInlineImageToolbar = (state, intl, mediaPluginState, hoverDecorati
|
|
|
237
239
|
if (options.allowImagePreview) {
|
|
238
240
|
inlineImageItems.push(fg('platform_editor_media_previewer_bugfix') ? {
|
|
239
241
|
id: 'editor.media.viewer',
|
|
242
|
+
testId: 'file-preview-toolbar-button',
|
|
240
243
|
type: 'button',
|
|
241
244
|
icon: FilePreviewIcon,
|
|
242
245
|
title: intl.formatMessage(messages.preview),
|
|
243
246
|
onClick: () => {
|
|
244
|
-
var
|
|
245
|
-
return (
|
|
247
|
+
var _handleShowMediaViewe2;
|
|
248
|
+
return (_handleShowMediaViewe2 = handleShowMediaViewer({
|
|
246
249
|
mediaPluginState,
|
|
247
250
|
api: pluginInjectionApi
|
|
248
|
-
})) !== null &&
|
|
249
|
-
}
|
|
251
|
+
})) !== null && _handleShowMediaViewe2 !== void 0 ? _handleShowMediaViewe2 : false;
|
|
252
|
+
},
|
|
253
|
+
supportsViewMode: true
|
|
250
254
|
} : generateFilePreviewItem(mediaPluginState, intl), {
|
|
251
255
|
type: 'separator',
|
|
252
256
|
supportsViewMode: true
|
|
@@ -215,4 +215,19 @@ export const getMediaSingleOrInlineNodeFromSelection = state => {
|
|
|
215
215
|
} = getMediaPluginState(state);
|
|
216
216
|
const mediaNode = getMediaNodeFromSelection(state) || allowInlineImages && getMediaInlineNodeFromSelection(state);
|
|
217
217
|
return mediaNode || null;
|
|
218
|
+
};
|
|
219
|
+
export const getMediaFromSupportedMediaNodesFromSelection = state => {
|
|
220
|
+
const {
|
|
221
|
+
node
|
|
222
|
+
} = state.selection;
|
|
223
|
+
switch (node.type) {
|
|
224
|
+
case node.type.schema.nodes.media:
|
|
225
|
+
case node.type.schema.nodes.mediaInline:
|
|
226
|
+
return node;
|
|
227
|
+
case node.type.schema.nodes.mediaSingle:
|
|
228
|
+
case node.type.schema.nodes.mediaGroup:
|
|
229
|
+
return node.firstChild;
|
|
230
|
+
default:
|
|
231
|
+
return null;
|
|
232
|
+
}
|
|
218
233
|
};
|
|
@@ -29,10 +29,10 @@ import * as helpers from '../commands/helpers';
|
|
|
29
29
|
import { updateMediaNodeAttrs } from '../commands/helpers';
|
|
30
30
|
import PickerFacade from '../picker-facade';
|
|
31
31
|
import DropPlaceholder from '../ui/Media/DropPlaceholder';
|
|
32
|
-
import { removeMediaNode, splitMediaGroup } from '../utils/media-common';
|
|
32
|
+
import { getMediaFromSupportedMediaNodesFromSelection, removeMediaNode, splitMediaGroup } from '../utils/media-common';
|
|
33
33
|
import { insertMediaGroupNode, insertMediaInlineNode } from '../utils/media-files';
|
|
34
34
|
import { getMediaNodeInsertionType } from '../utils/media-inline';
|
|
35
|
-
import { insertMediaSingleNode } from '../utils/media-single';
|
|
35
|
+
import { insertMediaSingleNode, isVideo } from '../utils/media-single';
|
|
36
36
|
import { ACTIONS } from './actions';
|
|
37
37
|
import { MediaTaskManager } from './mediaTaskManager';
|
|
38
38
|
import { stateKey } from './plugin-key';
|
|
@@ -909,6 +909,24 @@ export var createPlugin = function createPlugin(_schema, options, getIntl, plugi
|
|
|
909
909
|
}
|
|
910
910
|
return false;
|
|
911
911
|
},
|
|
912
|
+
handleDoubleClickOn: function handleDoubleClickOn(view) {
|
|
913
|
+
var _pluginInjectionApi$e;
|
|
914
|
+
if (!fg('platform_editor_media_previewer_bugfix') || !fg('platform_editor_media_interaction_improvements') || (pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$e = pluginInjectionApi.editorViewMode) === null || _pluginInjectionApi$e === void 0 || (_pluginInjectionApi$e = _pluginInjectionApi$e.sharedState.currentState()) === null || _pluginInjectionApi$e === void 0 ? void 0 : _pluginInjectionApi$e.mode) === 'view') {
|
|
915
|
+
return;
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
// Double Click support for Media Viewer Nodes
|
|
919
|
+
var maybeMediaNode = getMediaFromSupportedMediaNodesFromSelection(view.state);
|
|
920
|
+
if (maybeMediaNode) {
|
|
921
|
+
// If media type is video, do not open media viewer
|
|
922
|
+
if (isVideo(maybeMediaNode.attrs.__fileMimeType)) {
|
|
923
|
+
return false;
|
|
924
|
+
}
|
|
925
|
+
pluginInjectionApi === null || pluginInjectionApi === void 0 || pluginInjectionApi.core.actions.execute(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.media.commands.showMediaViewer(maybeMediaNode.attrs));
|
|
926
|
+
return true;
|
|
927
|
+
}
|
|
928
|
+
return false;
|
|
929
|
+
},
|
|
912
930
|
handleDOMEvents: {
|
|
913
931
|
keydown: function keydown(view, event) {
|
|
914
932
|
var selection = view.state.selection;
|
|
@@ -118,6 +118,7 @@ var generateMediaCardFloatingToolbar = function generateMediaCardFloatingToolbar
|
|
|
118
118
|
type: 'separator'
|
|
119
119
|
}, fg('platform_editor_media_previewer_bugfix') ? {
|
|
120
120
|
id: 'editor.media.viewer',
|
|
121
|
+
testId: 'file-preview-toolbar-button',
|
|
121
122
|
type: 'button',
|
|
122
123
|
icon: MaximizeIcon,
|
|
123
124
|
iconFallback: FilePreviewIcon,
|
|
@@ -128,7 +129,8 @@ var generateMediaCardFloatingToolbar = function generateMediaCardFloatingToolbar
|
|
|
128
129
|
mediaPluginState: mediaPluginState,
|
|
129
130
|
api: pluginInjectionApi
|
|
130
131
|
})) !== null && _handleShowMediaViewe !== void 0 ? _handleShowMediaViewe : false;
|
|
131
|
-
}
|
|
132
|
+
},
|
|
133
|
+
supportsViewMode: true
|
|
132
134
|
} : generateFilePreviewItem(mediaPluginState, intl), {
|
|
133
135
|
type: 'separator'
|
|
134
136
|
}, {
|
|
@@ -470,6 +472,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
470
472
|
if (!isVideo(mediaNode === null || mediaNode === void 0 || (_mediaNode$attrs = mediaNode.attrs) === null || _mediaNode$attrs === void 0 ? void 0 : _mediaNode$attrs.__fileMimeType)) {
|
|
471
473
|
toolbarButtons.push(fg('platform_editor_media_previewer_bugfix') ? {
|
|
472
474
|
id: 'editor.media.viewer',
|
|
475
|
+
testId: 'file-preview-toolbar-button',
|
|
473
476
|
type: 'button',
|
|
474
477
|
icon: MaximizeIcon,
|
|
475
478
|
iconFallback: FilePreviewIcon,
|
|
@@ -480,7 +483,8 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
480
483
|
api: pluginInjectionApi,
|
|
481
484
|
mediaPluginState: pluginState
|
|
482
485
|
})) !== null && _handleShowMediaViewe2 !== void 0 ? _handleShowMediaViewe2 : false;
|
|
483
|
-
}
|
|
486
|
+
},
|
|
487
|
+
supportsViewMode: true
|
|
484
488
|
} : generateFilePreviewItem(pluginState, intl), {
|
|
485
489
|
type: 'separator',
|
|
486
490
|
supportsViewMode: true
|
|
@@ -19,7 +19,6 @@ import { currentMediaOrInlineNodeBorderMark } from '../utils/current-media-node'
|
|
|
19
19
|
import { isImage } from '../utils/is-type';
|
|
20
20
|
import { altTextButton } from './alt-text';
|
|
21
21
|
import { changeInlineToMediaCard, changeMediaInlineToMediaSingle, removeInlineCard, setBorderMark, toggleBorderMark } from './commands';
|
|
22
|
-
import { FilePreviewItem } from './filePreviewItem';
|
|
23
22
|
import { shouldShowImageBorder } from './imageBorder';
|
|
24
23
|
import { LinkToolbarAppearance } from './linking-toolbar-appearance';
|
|
25
24
|
import { downloadMedia } from './utils';
|
|
@@ -63,17 +62,20 @@ export var generateMediaInlineFloatingToolbar = function generateMediaInlineFloa
|
|
|
63
62
|
className: 'thumbnail-appearance' // a11y. uses to force focus on item
|
|
64
63
|
}, {
|
|
65
64
|
type: 'separator'
|
|
66
|
-
}, {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
65
|
+
}, fg('platform_editor_media_previewer_bugfix') ? {
|
|
66
|
+
id: 'editor.media.viewer',
|
|
67
|
+
testId: 'file-preview-toolbar-button',
|
|
68
|
+
type: 'button',
|
|
69
|
+
icon: FilePreviewIcon,
|
|
70
|
+
title: intl.formatMessage(messages.preview),
|
|
71
|
+
onClick: function onClick() {
|
|
72
|
+
var _handleShowMediaViewe;
|
|
73
|
+
return (_handleShowMediaViewe = handleShowMediaViewer({
|
|
72
74
|
mediaPluginState: mediaPluginState,
|
|
73
|
-
|
|
74
|
-
});
|
|
75
|
+
api: pluginInjectionApi
|
|
76
|
+
})) !== null && _handleShowMediaViewe !== void 0 ? _handleShowMediaViewe : false;
|
|
75
77
|
}
|
|
76
|
-
}, {
|
|
78
|
+
} : generateFilePreviewItem(mediaPluginState, intl), {
|
|
77
79
|
type: 'separator'
|
|
78
80
|
}, {
|
|
79
81
|
id: 'editor.media.card.download',
|
|
@@ -233,16 +235,18 @@ var getMediaInlineImageToolbar = function getMediaInlineImageToolbar(state, intl
|
|
|
233
235
|
if (options.allowImagePreview) {
|
|
234
236
|
inlineImageItems.push(fg('platform_editor_media_previewer_bugfix') ? {
|
|
235
237
|
id: 'editor.media.viewer',
|
|
238
|
+
testId: 'file-preview-toolbar-button',
|
|
236
239
|
type: 'button',
|
|
237
240
|
icon: FilePreviewIcon,
|
|
238
241
|
title: intl.formatMessage(messages.preview),
|
|
239
242
|
onClick: function onClick() {
|
|
240
|
-
var
|
|
241
|
-
return (
|
|
243
|
+
var _handleShowMediaViewe2;
|
|
244
|
+
return (_handleShowMediaViewe2 = handleShowMediaViewer({
|
|
242
245
|
mediaPluginState: mediaPluginState,
|
|
243
246
|
api: pluginInjectionApi
|
|
244
|
-
})) !== null &&
|
|
245
|
-
}
|
|
247
|
+
})) !== null && _handleShowMediaViewe2 !== void 0 ? _handleShowMediaViewe2 : false;
|
|
248
|
+
},
|
|
249
|
+
supportsViewMode: true
|
|
246
250
|
} : generateFilePreviewItem(mediaPluginState, intl), {
|
|
247
251
|
type: 'separator',
|
|
248
252
|
supportsViewMode: true
|
|
@@ -198,4 +198,18 @@ export var getMediaSingleOrInlineNodeFromSelection = function getMediaSingleOrIn
|
|
|
198
198
|
allowInlineImages = _getMediaPluginState2.allowInlineImages;
|
|
199
199
|
var mediaNode = getMediaNodeFromSelection(state) || allowInlineImages && getMediaInlineNodeFromSelection(state);
|
|
200
200
|
return mediaNode || null;
|
|
201
|
+
};
|
|
202
|
+
export var getMediaFromSupportedMediaNodesFromSelection = function getMediaFromSupportedMediaNodesFromSelection(state) {
|
|
203
|
+
var _ref4 = state.selection,
|
|
204
|
+
node = _ref4.node;
|
|
205
|
+
switch (node.type) {
|
|
206
|
+
case node.type.schema.nodes.media:
|
|
207
|
+
case node.type.schema.nodes.mediaInline:
|
|
208
|
+
return node;
|
|
209
|
+
case node.type.schema.nodes.mediaSingle:
|
|
210
|
+
case node.type.schema.nodes.mediaGroup:
|
|
211
|
+
return node.firstChild;
|
|
212
|
+
default:
|
|
213
|
+
return null;
|
|
214
|
+
}
|
|
201
215
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IntlShape } from 'react-intl-next';
|
|
2
2
|
import type { RichMediaLayout as MediaSingleLayout } from '@atlaskit/adf-schema';
|
|
3
|
-
import {
|
|
3
|
+
import type { InsertMediaVia } from '@atlaskit/editor-common/analytics';
|
|
4
4
|
import type { Dispatch } from '@atlaskit/editor-common/event-dispatcher';
|
|
5
5
|
import type { MediaProvider } from '@atlaskit/editor-common/provider-factory';
|
|
6
6
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
@@ -20,3 +20,4 @@ export declare const copyOptionalAttrsFromMediaState: (mediaState: MediaState, n
|
|
|
20
20
|
export declare const getMediaNodeFromSelection: (state: EditorState) => PMNode | null;
|
|
21
21
|
export declare const isMediaSingleOrInlineNodeSelected: (state: EditorState) => boolean | undefined;
|
|
22
22
|
export declare const getMediaSingleOrInlineNodeFromSelection: (state: EditorState) => PMNode | null;
|
|
23
|
+
export declare const getMediaFromSupportedMediaNodesFromSelection: (state: EditorState) => PMNode | null;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IntlShape } from 'react-intl-next';
|
|
2
2
|
import type { RichMediaLayout as MediaSingleLayout } from '@atlaskit/adf-schema';
|
|
3
|
-
import {
|
|
3
|
+
import type { InsertMediaVia } from '@atlaskit/editor-common/analytics';
|
|
4
4
|
import type { Dispatch } from '@atlaskit/editor-common/event-dispatcher';
|
|
5
5
|
import type { MediaProvider } from '@atlaskit/editor-common/provider-factory';
|
|
6
6
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
@@ -20,3 +20,4 @@ export declare const copyOptionalAttrsFromMediaState: (mediaState: MediaState, n
|
|
|
20
20
|
export declare const getMediaNodeFromSelection: (state: EditorState) => PMNode | null;
|
|
21
21
|
export declare const isMediaSingleOrInlineNodeSelected: (state: EditorState) => boolean | undefined;
|
|
22
22
|
export declare const getMediaSingleOrInlineNodeFromSelection: (state: EditorState) => PMNode | null;
|
|
23
|
+
export declare const getMediaFromSupportedMediaNodesFromSelection: (state: EditorState) => PMNode | null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-media",
|
|
3
|
-
"version": "1.36.
|
|
3
|
+
"version": "1.36.5",
|
|
4
4
|
"description": "Media plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"@atlaskit/analytics-namespaced-context": "^6.12.0",
|
|
37
37
|
"@atlaskit/analytics-next": "^10.1.0",
|
|
38
38
|
"@atlaskit/button": "^20.2.0",
|
|
39
|
-
"@atlaskit/editor-common": "^93.
|
|
39
|
+
"@atlaskit/editor-common": "^93.6.0",
|
|
40
40
|
"@atlaskit/editor-palette": "1.6.1",
|
|
41
41
|
"@atlaskit/editor-plugin-analytics": "^1.10.0",
|
|
42
42
|
"@atlaskit/editor-plugin-annotation": "1.21.1",
|
|
@@ -65,8 +65,8 @@
|
|
|
65
65
|
"@atlaskit/platform-feature-flags": "^0.3.0",
|
|
66
66
|
"@atlaskit/primitives": "^12.2.0",
|
|
67
67
|
"@atlaskit/textfield": "^6.5.0",
|
|
68
|
-
"@atlaskit/theme": "^
|
|
69
|
-
"@atlaskit/tmp-editor-statsig": "^2.
|
|
68
|
+
"@atlaskit/theme": "^14.0.0",
|
|
69
|
+
"@atlaskit/tmp-editor-statsig": "^2.7.0",
|
|
70
70
|
"@atlaskit/tokens": "^2.0.0",
|
|
71
71
|
"@atlaskit/tooltip": "^18.8.0",
|
|
72
72
|
"@babel/runtime": "^7.0.0",
|
|
@@ -137,6 +137,9 @@
|
|
|
137
137
|
"platform_editor_media_previewer_bugfix": {
|
|
138
138
|
"type": "boolean"
|
|
139
139
|
},
|
|
140
|
+
"platform_editor_media_interaction_improvements": {
|
|
141
|
+
"type": "boolean"
|
|
142
|
+
},
|
|
140
143
|
"editor_nest_media_and_codeblock_in_quotes_jira": {
|
|
141
144
|
"type": "boolean"
|
|
142
145
|
},
|