@atlaskit/editor-plugin-media-insert 2.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +26 -0
- package/dist/cjs/ui/FromURL.js +32 -13
- package/dist/cjs/ui/MediaInsertContent.js +6 -3
- package/dist/cjs/ui/MediaInsertPicker.js +6 -7
- package/dist/cjs/ui/MediaInsertWrapper.js +2 -1
- package/dist/es2019/ui/FromURL.js +32 -13
- package/dist/es2019/ui/MediaInsertContent.js +6 -3
- package/dist/es2019/ui/MediaInsertPicker.js +6 -5
- package/dist/es2019/ui/MediaInsertWrapper.js +2 -1
- package/dist/esm/ui/FromURL.js +32 -13
- package/dist/esm/ui/MediaInsertContent.js +6 -3
- package/dist/esm/ui/MediaInsertPicker.js +6 -7
- package/dist/esm/ui/MediaInsertWrapper.js +2 -1
- package/dist/types/ui/FromURL.d.ts +3 -3
- package/dist/types/ui/MediaInsertContent.d.ts +2 -2
- package/dist/types-ts4.5/ui/FromURL.d.ts +3 -3
- package/dist/types-ts4.5/ui/MediaInsertContent.d.ts +2 -2
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-media-insert
|
|
2
2
|
|
|
3
|
+
## 2.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#129457](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/129457)
|
|
8
|
+
[`171c73d4033f0`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/171c73d4033f0) -
|
|
9
|
+
[ux] [ED-24566]
|
|
10
|
+
|
|
11
|
+
- Internationalisation strings in editor-common for editor-plugin-media-insert
|
|
12
|
+
- Removed default pre-filled URL for editor-plugin-media-insert popup
|
|
13
|
+
- Added background color for editor-plugin-media-insert popup
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
|
|
19
|
+
## 2.0.1
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- [#130061](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/130061)
|
|
24
|
+
[`bdad694cb2c24`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/bdad694cb2c24) -
|
|
25
|
+
[ux] [ED-24566] **@atlaskit/editor-plugin-media-insert**: When user clicks "Cancel" button on
|
|
26
|
+
insert media popup the focus is returned to the editor **@atlaskit/editor-common**: Added event
|
|
27
|
+
type for media insert cancelled analytics
|
|
28
|
+
|
|
3
29
|
## 2.0.0
|
|
4
30
|
|
|
5
31
|
### Major Changes
|
package/dist/cjs/ui/FromURL.js
CHANGED
|
@@ -13,6 +13,7 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
13
13
|
var _reactIntlNext = require("react-intl-next");
|
|
14
14
|
var _buttonGroup = _interopRequireDefault(require("@atlaskit/button/button-group"));
|
|
15
15
|
var _new = _interopRequireDefault(require("@atlaskit/button/new"));
|
|
16
|
+
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
16
17
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
17
18
|
var _filePreview = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/file-preview"));
|
|
18
19
|
var _mediaClientReact = require("@atlaskit/media-client-react");
|
|
@@ -69,19 +70,12 @@ var previewStateReducer = function previewStateReducer(state, action) {
|
|
|
69
70
|
return state;
|
|
70
71
|
}
|
|
71
72
|
};
|
|
72
|
-
// TODO: Delete these before rollout
|
|
73
|
-
var placeholders = ['https://picsum.photos/200/300',
|
|
74
|
-
// has cors
|
|
75
|
-
'https://placedog.net/500/280',
|
|
76
|
-
// has cors
|
|
77
|
-
'https://preview.redd.it/gabriel-medina-at-the-olympics-after-riding-a-nearly-v0-dbyczz2fkifd1.jpeg?auto=webp&s=045550d672718427b67fb929bc6efc57116a7596' // no cors
|
|
78
|
-
];
|
|
79
73
|
function MediaFromURL(_ref) {
|
|
80
74
|
var mediaProvider = _ref.mediaProvider,
|
|
81
75
|
onInsert = _ref.onInsert,
|
|
82
76
|
onExternalInsert = _ref.onExternalInsert,
|
|
83
77
|
dispatchAnalyticsEvent = _ref.dispatchAnalyticsEvent,
|
|
84
|
-
|
|
78
|
+
closeMediaInsertPicker = _ref.closeMediaInsertPicker;
|
|
85
79
|
var intl = (0, _reactIntlNext.useIntl)();
|
|
86
80
|
var strings = {
|
|
87
81
|
loadPreview: intl.formatMessage(_messages.mediaInsertMessages.loadPreview),
|
|
@@ -91,7 +85,7 @@ function MediaFromURL(_ref) {
|
|
|
91
85
|
errorMessage: intl.formatMessage(_messages.mediaInsertMessages.errorMessage),
|
|
92
86
|
warning: intl.formatMessage(_messages.mediaInsertMessages.warning)
|
|
93
87
|
};
|
|
94
|
-
var _React$useState = _react.default.useState(
|
|
88
|
+
var _React$useState = _react.default.useState(''),
|
|
95
89
|
_React$useState2 = (0, _slicedToArray2.default)(_React$useState, 2),
|
|
96
90
|
inputUrl = _React$useState2[0],
|
|
97
91
|
setUrl = _React$useState2[1];
|
|
@@ -212,9 +206,33 @@ function MediaFromURL(_ref) {
|
|
|
212
206
|
}, [onExternalInsert, onInsert, previewState.previewInfo, previewState.warning, inputUrl]);
|
|
213
207
|
var onInputKeyPress = _react.default.useCallback(function (event) {
|
|
214
208
|
if (event && event.key === 'Esc') {
|
|
215
|
-
|
|
209
|
+
if (dispatchAnalyticsEvent) {
|
|
210
|
+
var payload = {
|
|
211
|
+
action: _analytics.ACTION.CLOSED,
|
|
212
|
+
actionSubject: _analytics.ACTION_SUBJECT.PICKER,
|
|
213
|
+
actionSubjectId: _analytics.ACTION_SUBJECT_ID.PICKER_MEDIA,
|
|
214
|
+
eventType: _analytics.EVENT_TYPE.UI,
|
|
215
|
+
attributes: {
|
|
216
|
+
exitMethod: _analytics.INPUT_METHOD.KEYBOARD
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
dispatchAnalyticsEvent(payload);
|
|
220
|
+
}
|
|
221
|
+
closeMediaInsertPicker();
|
|
216
222
|
}
|
|
217
|
-
}, [
|
|
223
|
+
}, [dispatchAnalyticsEvent, closeMediaInsertPicker]);
|
|
224
|
+
var onCancel = _react.default.useCallback(function () {
|
|
225
|
+
if (dispatchAnalyticsEvent) {
|
|
226
|
+
var payload = {
|
|
227
|
+
action: _analytics.ACTION.CANCELLED,
|
|
228
|
+
actionSubject: _analytics.ACTION_SUBJECT.PICKER,
|
|
229
|
+
actionSubjectId: _analytics.ACTION_SUBJECT_ID.PICKER_MEDIA,
|
|
230
|
+
eventType: _analytics.EVENT_TYPE.UI
|
|
231
|
+
};
|
|
232
|
+
dispatchAnalyticsEvent(payload);
|
|
233
|
+
}
|
|
234
|
+
closeMediaInsertPicker();
|
|
235
|
+
}, [closeMediaInsertPicker, dispatchAnalyticsEvent]);
|
|
218
236
|
return /*#__PURE__*/_react.default.createElement(_primitives.Box, {
|
|
219
237
|
as: "form",
|
|
220
238
|
onSubmit: function onSubmit(e) {
|
|
@@ -251,12 +269,13 @@ function MediaFromURL(_ref) {
|
|
|
251
269
|
}, /*#__PURE__*/_react.default.createElement(_new.default, {
|
|
252
270
|
type: "submit",
|
|
253
271
|
isLoading: previewState.isLoading,
|
|
254
|
-
isDisabled:
|
|
272
|
+
isDisabled: inputUrl.length === 0,
|
|
255
273
|
iconBefore: _filePreview.default
|
|
256
274
|
}, strings.loadPreview)), /*#__PURE__*/_react.default.createElement(_primitives.Box, {
|
|
257
275
|
xcss: ButtonGroupStyles
|
|
258
276
|
}, /*#__PURE__*/_react.default.createElement(_buttonGroup.default, null, /*#__PURE__*/_react.default.createElement(_new.default, {
|
|
259
|
-
appearance: "subtle"
|
|
277
|
+
appearance: "subtle",
|
|
278
|
+
onClick: onCancel
|
|
260
279
|
}, strings.cancel), /*#__PURE__*/_react.default.createElement(_new.default, {
|
|
261
280
|
appearance: "primary",
|
|
262
281
|
isDisabled: !previewState.previewInfo && !previewState.warning,
|
|
@@ -7,6 +7,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports.MediaInsertContent = void 0;
|
|
9
9
|
var _react = _interopRequireDefault(require("react"));
|
|
10
|
+
var _reactIntlNext = require("react-intl-next");
|
|
11
|
+
var _messages = require("@atlaskit/editor-common/messages");
|
|
10
12
|
var _primitives = require("@atlaskit/primitives");
|
|
11
13
|
var _tabs = _interopRequireWildcard(require("@atlaskit/tabs"));
|
|
12
14
|
var _FromURL = require("./FromURL");
|
|
@@ -15,16 +17,17 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
15
17
|
var MediaInsertContent = exports.MediaInsertContent = function MediaInsertContent(_ref) {
|
|
16
18
|
var mediaProvider = _ref.mediaProvider,
|
|
17
19
|
dispatchAnalyticsEvent = _ref.dispatchAnalyticsEvent,
|
|
18
|
-
|
|
20
|
+
closeMediaInsertPicker = _ref.closeMediaInsertPicker;
|
|
21
|
+
var intl = (0, _reactIntlNext.useIntl)();
|
|
19
22
|
return /*#__PURE__*/_react.default.createElement(_tabs.default, {
|
|
20
23
|
id: "media-insert-tab-navigation"
|
|
21
24
|
}, /*#__PURE__*/_react.default.createElement(_primitives.Box, {
|
|
22
25
|
paddingBlockEnd: "space.150"
|
|
23
|
-
}, /*#__PURE__*/_react.default.createElement(_tabs.TabList, null, /*#__PURE__*/_react.default.createElement(_tabs.Tab, null,
|
|
26
|
+
}, /*#__PURE__*/_react.default.createElement(_tabs.TabList, null, /*#__PURE__*/_react.default.createElement(_tabs.Tab, null, intl.formatMessage(_messages.mediaInsertMessages.linkTabTitle)))), /*#__PURE__*/_react.default.createElement(_tabs.TabPanel, null, /*#__PURE__*/_react.default.createElement(_FromURL.MediaFromURL, {
|
|
24
27
|
mediaProvider: mediaProvider,
|
|
25
28
|
onExternalInsert: function onExternalInsert() {},
|
|
26
29
|
onInsert: function onInsert() {},
|
|
27
30
|
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
28
|
-
|
|
31
|
+
closeMediaInsertPicker: closeMediaInsertPicker
|
|
29
32
|
})));
|
|
30
33
|
};
|
|
@@ -6,8 +6,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.MediaInsertPicker = void 0;
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _reactIntlNext = require("react-intl-next");
|
|
9
10
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
10
11
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
12
|
+
var _messages = require("@atlaskit/editor-common/messages");
|
|
11
13
|
var _ui = require("@atlaskit/editor-common/ui");
|
|
12
14
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
13
15
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
@@ -49,6 +51,7 @@ var MediaInsertPicker = exports.MediaInsertPicker = function MediaInsertPicker(_
|
|
|
49
51
|
var targetRef = getDomRefFromSelection(editorView, dispatchAnalyticsEvent);
|
|
50
52
|
var isOpen = (_useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['mediaInsert'])) === null || _useSharedPluginState === void 0 || (_useSharedPluginState = _useSharedPluginState.mediaInsertState) === null || _useSharedPluginState === void 0 ? void 0 : _useSharedPluginState.isOpen;
|
|
51
53
|
var mediaProvider = (_useSharedPluginState2 = (0, _hooks.useSharedPluginState)(api, ['media'])) === null || _useSharedPluginState2 === void 0 || (_useSharedPluginState2 = _useSharedPluginState2.mediaState) === null || _useSharedPluginState2 === void 0 ? void 0 : _useSharedPluginState2.mediaProvider;
|
|
54
|
+
var intl = (0, _reactIntlNext.useIntl)();
|
|
52
55
|
if (!isOpen || !mediaProvider) {
|
|
53
56
|
return null;
|
|
54
57
|
}
|
|
@@ -70,10 +73,8 @@ var MediaInsertPicker = exports.MediaInsertPicker = function MediaInsertPicker(_
|
|
|
70
73
|
closeMediaInsertPicker();
|
|
71
74
|
};
|
|
72
75
|
};
|
|
73
|
-
return /*#__PURE__*/_react.default.createElement(PopupWithListeners
|
|
74
|
-
|
|
75
|
-
, {
|
|
76
|
-
ariaLabel: 'Media Insert',
|
|
76
|
+
return /*#__PURE__*/_react.default.createElement(PopupWithListeners, {
|
|
77
|
+
ariaLabel: intl.formatMessage(_messages.mediaInsertMessages.mediaPickerPopupAriaLabel),
|
|
77
78
|
offset: [0, 12],
|
|
78
79
|
target: targetRef,
|
|
79
80
|
zIndex: _editorSharedStyles.akEditorFloatingDialogZIndex,
|
|
@@ -89,8 +90,6 @@ var MediaInsertPicker = exports.MediaInsertPicker = function MediaInsertPicker(_
|
|
|
89
90
|
}, /*#__PURE__*/_react.default.createElement(_MediaInsertWrapper.MediaInsertWrapper, null, /*#__PURE__*/_react.default.createElement(_MediaInsertContent.MediaInsertContent, {
|
|
90
91
|
mediaProvider: mediaProvider,
|
|
91
92
|
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
92
|
-
|
|
93
|
-
return handleClose(_analytics.INPUT_METHOD.KEYBOARD);
|
|
94
|
-
}
|
|
93
|
+
closeMediaInsertPicker: closeMediaInsertPicker
|
|
95
94
|
})));
|
|
96
95
|
};
|
|
@@ -11,7 +11,8 @@ var styles = (0, _primitives.xcss)({
|
|
|
11
11
|
boxShadow: 'elevation.shadow.overflow',
|
|
12
12
|
width: '340px',
|
|
13
13
|
padding: 'space.200',
|
|
14
|
-
borderRadius: 'border.radius'
|
|
14
|
+
borderRadius: 'border.radius',
|
|
15
|
+
backgroundColor: 'elevation.surface.overlay'
|
|
15
16
|
});
|
|
16
17
|
var MediaInsertWrapper = exports.MediaInsertWrapper = function MediaInsertWrapper(_ref) {
|
|
17
18
|
var children = _ref.children;
|
|
@@ -2,6 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { useIntl } from 'react-intl-next';
|
|
3
3
|
import ButtonGroup from '@atlaskit/button/button-group';
|
|
4
4
|
import Button from '@atlaskit/button/new';
|
|
5
|
+
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
5
6
|
import { mediaInsertMessages } from '@atlaskit/editor-common/messages';
|
|
6
7
|
import EditorFilePreviewIcon from '@atlaskit/icon/glyph/editor/file-preview';
|
|
7
8
|
import { getMediaClient } from '@atlaskit/media-client-react';
|
|
@@ -60,19 +61,12 @@ const previewStateReducer = (state, action) => {
|
|
|
60
61
|
return state;
|
|
61
62
|
}
|
|
62
63
|
};
|
|
63
|
-
// TODO: Delete these before rollout
|
|
64
|
-
const placeholders = ['https://picsum.photos/200/300',
|
|
65
|
-
// has cors
|
|
66
|
-
'https://placedog.net/500/280',
|
|
67
|
-
// has cors
|
|
68
|
-
'https://preview.redd.it/gabriel-medina-at-the-olympics-after-riding-a-nearly-v0-dbyczz2fkifd1.jpeg?auto=webp&s=045550d672718427b67fb929bc6efc57116a7596' // no cors
|
|
69
|
-
];
|
|
70
64
|
export function MediaFromURL({
|
|
71
65
|
mediaProvider,
|
|
72
66
|
onInsert,
|
|
73
67
|
onExternalInsert,
|
|
74
68
|
dispatchAnalyticsEvent,
|
|
75
|
-
|
|
69
|
+
closeMediaInsertPicker
|
|
76
70
|
}) {
|
|
77
71
|
const intl = useIntl();
|
|
78
72
|
const strings = {
|
|
@@ -83,7 +77,7 @@ export function MediaFromURL({
|
|
|
83
77
|
errorMessage: intl.formatMessage(mediaInsertMessages.errorMessage),
|
|
84
78
|
warning: intl.formatMessage(mediaInsertMessages.warning)
|
|
85
79
|
};
|
|
86
|
-
const [inputUrl, setUrl] = React.useState(
|
|
80
|
+
const [inputUrl, setUrl] = React.useState('');
|
|
87
81
|
const [previewState, dispatch] = React.useReducer(previewStateReducer, INITIAL_PREVIEW_STATE);
|
|
88
82
|
const pasteFlag = React.useRef(false);
|
|
89
83
|
const {
|
|
@@ -180,9 +174,33 @@ export function MediaFromURL({
|
|
|
180
174
|
}, [onExternalInsert, onInsert, previewState.previewInfo, previewState.warning, inputUrl]);
|
|
181
175
|
const onInputKeyPress = React.useCallback(event => {
|
|
182
176
|
if (event && event.key === 'Esc') {
|
|
183
|
-
|
|
177
|
+
if (dispatchAnalyticsEvent) {
|
|
178
|
+
const payload = {
|
|
179
|
+
action: ACTION.CLOSED,
|
|
180
|
+
actionSubject: ACTION_SUBJECT.PICKER,
|
|
181
|
+
actionSubjectId: ACTION_SUBJECT_ID.PICKER_MEDIA,
|
|
182
|
+
eventType: EVENT_TYPE.UI,
|
|
183
|
+
attributes: {
|
|
184
|
+
exitMethod: INPUT_METHOD.KEYBOARD
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
dispatchAnalyticsEvent(payload);
|
|
188
|
+
}
|
|
189
|
+
closeMediaInsertPicker();
|
|
190
|
+
}
|
|
191
|
+
}, [dispatchAnalyticsEvent, closeMediaInsertPicker]);
|
|
192
|
+
const onCancel = React.useCallback(() => {
|
|
193
|
+
if (dispatchAnalyticsEvent) {
|
|
194
|
+
const payload = {
|
|
195
|
+
action: ACTION.CANCELLED,
|
|
196
|
+
actionSubject: ACTION_SUBJECT.PICKER,
|
|
197
|
+
actionSubjectId: ACTION_SUBJECT_ID.PICKER_MEDIA,
|
|
198
|
+
eventType: EVENT_TYPE.UI
|
|
199
|
+
};
|
|
200
|
+
dispatchAnalyticsEvent(payload);
|
|
184
201
|
}
|
|
185
|
-
|
|
202
|
+
closeMediaInsertPicker();
|
|
203
|
+
}, [closeMediaInsertPicker, dispatchAnalyticsEvent]);
|
|
186
204
|
return /*#__PURE__*/React.createElement(Box, {
|
|
187
205
|
as: "form",
|
|
188
206
|
onSubmit: e => {
|
|
@@ -219,12 +237,13 @@ export function MediaFromURL({
|
|
|
219
237
|
}, /*#__PURE__*/React.createElement(Button, {
|
|
220
238
|
type: "submit",
|
|
221
239
|
isLoading: previewState.isLoading,
|
|
222
|
-
isDisabled:
|
|
240
|
+
isDisabled: inputUrl.length === 0,
|
|
223
241
|
iconBefore: EditorFilePreviewIcon
|
|
224
242
|
}, strings.loadPreview)), /*#__PURE__*/React.createElement(Box, {
|
|
225
243
|
xcss: ButtonGroupStyles
|
|
226
244
|
}, /*#__PURE__*/React.createElement(ButtonGroup, null, /*#__PURE__*/React.createElement(Button, {
|
|
227
|
-
appearance: "subtle"
|
|
245
|
+
appearance: "subtle",
|
|
246
|
+
onClick: onCancel
|
|
228
247
|
}, strings.cancel), /*#__PURE__*/React.createElement(Button, {
|
|
229
248
|
appearance: "primary",
|
|
230
249
|
isDisabled: !previewState.previewInfo && !previewState.warning,
|
|
@@ -1,21 +1,24 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { useIntl } from 'react-intl-next';
|
|
3
|
+
import { mediaInsertMessages } from '@atlaskit/editor-common/messages';
|
|
2
4
|
import { Box } from '@atlaskit/primitives';
|
|
3
5
|
import Tabs, { Tab, TabList, TabPanel } from '@atlaskit/tabs';
|
|
4
6
|
import { MediaFromURL } from './FromURL';
|
|
5
7
|
export const MediaInsertContent = ({
|
|
6
8
|
mediaProvider,
|
|
7
9
|
dispatchAnalyticsEvent,
|
|
8
|
-
|
|
10
|
+
closeMediaInsertPicker
|
|
9
11
|
}) => {
|
|
12
|
+
const intl = useIntl();
|
|
10
13
|
return /*#__PURE__*/React.createElement(Tabs, {
|
|
11
14
|
id: "media-insert-tab-navigation"
|
|
12
15
|
}, /*#__PURE__*/React.createElement(Box, {
|
|
13
16
|
paddingBlockEnd: "space.150"
|
|
14
|
-
}, /*#__PURE__*/React.createElement(TabList, null, /*#__PURE__*/React.createElement(Tab, null,
|
|
17
|
+
}, /*#__PURE__*/React.createElement(TabList, null, /*#__PURE__*/React.createElement(Tab, null, intl.formatMessage(mediaInsertMessages.linkTabTitle)))), /*#__PURE__*/React.createElement(TabPanel, null, /*#__PURE__*/React.createElement(MediaFromURL, {
|
|
15
18
|
mediaProvider: mediaProvider,
|
|
16
19
|
onExternalInsert: () => {},
|
|
17
20
|
onInsert: () => {},
|
|
18
21
|
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
19
|
-
|
|
22
|
+
closeMediaInsertPicker: closeMediaInsertPicker
|
|
20
23
|
})));
|
|
21
24
|
};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { useIntl } from 'react-intl-next';
|
|
2
3
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
3
4
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
5
|
+
import { mediaInsertMessages } from '@atlaskit/editor-common/messages';
|
|
4
6
|
import { Popup, withOuterListeners } from '@atlaskit/editor-common/ui';
|
|
5
7
|
import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
6
8
|
import { akEditorFloatingDialogZIndex } from '@atlaskit/editor-shared-styles';
|
|
@@ -43,6 +45,7 @@ export const MediaInsertPicker = ({
|
|
|
43
45
|
const targetRef = getDomRefFromSelection(editorView, dispatchAnalyticsEvent);
|
|
44
46
|
const isOpen = (_useSharedPluginState = useSharedPluginState(api, ['mediaInsert'])) === null || _useSharedPluginState === void 0 ? void 0 : (_useSharedPluginState2 = _useSharedPluginState.mediaInsertState) === null || _useSharedPluginState2 === void 0 ? void 0 : _useSharedPluginState2.isOpen;
|
|
45
47
|
const mediaProvider = (_useSharedPluginState3 = useSharedPluginState(api, ['media'])) === null || _useSharedPluginState3 === void 0 ? void 0 : (_useSharedPluginState4 = _useSharedPluginState3.mediaState) === null || _useSharedPluginState4 === void 0 ? void 0 : _useSharedPluginState4.mediaProvider;
|
|
48
|
+
const intl = useIntl();
|
|
46
49
|
if (!isOpen || !mediaProvider) {
|
|
47
50
|
return null;
|
|
48
51
|
}
|
|
@@ -62,10 +65,8 @@ export const MediaInsertPicker = ({
|
|
|
62
65
|
}
|
|
63
66
|
closeMediaInsertPicker();
|
|
64
67
|
};
|
|
65
|
-
return /*#__PURE__*/React.createElement(PopupWithListeners
|
|
66
|
-
|
|
67
|
-
, {
|
|
68
|
-
ariaLabel: 'Media Insert',
|
|
68
|
+
return /*#__PURE__*/React.createElement(PopupWithListeners, {
|
|
69
|
+
ariaLabel: intl.formatMessage(mediaInsertMessages.mediaPickerPopupAriaLabel),
|
|
69
70
|
offset: [0, 12],
|
|
70
71
|
target: targetRef,
|
|
71
72
|
zIndex: akEditorFloatingDialogZIndex,
|
|
@@ -81,6 +82,6 @@ export const MediaInsertPicker = ({
|
|
|
81
82
|
}, /*#__PURE__*/React.createElement(MediaInsertWrapper, null, /*#__PURE__*/React.createElement(MediaInsertContent, {
|
|
82
83
|
mediaProvider: mediaProvider,
|
|
83
84
|
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
84
|
-
|
|
85
|
+
closeMediaInsertPicker: closeMediaInsertPicker
|
|
85
86
|
})));
|
|
86
87
|
};
|
|
@@ -4,7 +4,8 @@ const styles = xcss({
|
|
|
4
4
|
boxShadow: 'elevation.shadow.overflow',
|
|
5
5
|
width: '340px',
|
|
6
6
|
padding: 'space.200',
|
|
7
|
-
borderRadius: 'border.radius'
|
|
7
|
+
borderRadius: 'border.radius',
|
|
8
|
+
backgroundColor: 'elevation.surface.overlay'
|
|
8
9
|
});
|
|
9
10
|
export const MediaInsertWrapper = ({
|
|
10
11
|
children
|
package/dist/esm/ui/FromURL.js
CHANGED
|
@@ -8,6 +8,7 @@ import React from 'react';
|
|
|
8
8
|
import { useIntl } from 'react-intl-next';
|
|
9
9
|
import ButtonGroup from '@atlaskit/button/button-group';
|
|
10
10
|
import Button from '@atlaskit/button/new';
|
|
11
|
+
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
11
12
|
import { mediaInsertMessages } from '@atlaskit/editor-common/messages';
|
|
12
13
|
import EditorFilePreviewIcon from '@atlaskit/icon/glyph/editor/file-preview';
|
|
13
14
|
import { getMediaClient } from '@atlaskit/media-client-react';
|
|
@@ -62,19 +63,12 @@ var previewStateReducer = function previewStateReducer(state, action) {
|
|
|
62
63
|
return state;
|
|
63
64
|
}
|
|
64
65
|
};
|
|
65
|
-
// TODO: Delete these before rollout
|
|
66
|
-
var placeholders = ['https://picsum.photos/200/300',
|
|
67
|
-
// has cors
|
|
68
|
-
'https://placedog.net/500/280',
|
|
69
|
-
// has cors
|
|
70
|
-
'https://preview.redd.it/gabriel-medina-at-the-olympics-after-riding-a-nearly-v0-dbyczz2fkifd1.jpeg?auto=webp&s=045550d672718427b67fb929bc6efc57116a7596' // no cors
|
|
71
|
-
];
|
|
72
66
|
export function MediaFromURL(_ref) {
|
|
73
67
|
var mediaProvider = _ref.mediaProvider,
|
|
74
68
|
onInsert = _ref.onInsert,
|
|
75
69
|
onExternalInsert = _ref.onExternalInsert,
|
|
76
70
|
dispatchAnalyticsEvent = _ref.dispatchAnalyticsEvent,
|
|
77
|
-
|
|
71
|
+
closeMediaInsertPicker = _ref.closeMediaInsertPicker;
|
|
78
72
|
var intl = useIntl();
|
|
79
73
|
var strings = {
|
|
80
74
|
loadPreview: intl.formatMessage(mediaInsertMessages.loadPreview),
|
|
@@ -84,7 +78,7 @@ export function MediaFromURL(_ref) {
|
|
|
84
78
|
errorMessage: intl.formatMessage(mediaInsertMessages.errorMessage),
|
|
85
79
|
warning: intl.formatMessage(mediaInsertMessages.warning)
|
|
86
80
|
};
|
|
87
|
-
var _React$useState = React.useState(
|
|
81
|
+
var _React$useState = React.useState(''),
|
|
88
82
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
89
83
|
inputUrl = _React$useState2[0],
|
|
90
84
|
setUrl = _React$useState2[1];
|
|
@@ -205,9 +199,33 @@ export function MediaFromURL(_ref) {
|
|
|
205
199
|
}, [onExternalInsert, onInsert, previewState.previewInfo, previewState.warning, inputUrl]);
|
|
206
200
|
var onInputKeyPress = React.useCallback(function (event) {
|
|
207
201
|
if (event && event.key === 'Esc') {
|
|
208
|
-
|
|
202
|
+
if (dispatchAnalyticsEvent) {
|
|
203
|
+
var payload = {
|
|
204
|
+
action: ACTION.CLOSED,
|
|
205
|
+
actionSubject: ACTION_SUBJECT.PICKER,
|
|
206
|
+
actionSubjectId: ACTION_SUBJECT_ID.PICKER_MEDIA,
|
|
207
|
+
eventType: EVENT_TYPE.UI,
|
|
208
|
+
attributes: {
|
|
209
|
+
exitMethod: INPUT_METHOD.KEYBOARD
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
dispatchAnalyticsEvent(payload);
|
|
213
|
+
}
|
|
214
|
+
closeMediaInsertPicker();
|
|
209
215
|
}
|
|
210
|
-
}, [
|
|
216
|
+
}, [dispatchAnalyticsEvent, closeMediaInsertPicker]);
|
|
217
|
+
var onCancel = React.useCallback(function () {
|
|
218
|
+
if (dispatchAnalyticsEvent) {
|
|
219
|
+
var payload = {
|
|
220
|
+
action: ACTION.CANCELLED,
|
|
221
|
+
actionSubject: ACTION_SUBJECT.PICKER,
|
|
222
|
+
actionSubjectId: ACTION_SUBJECT_ID.PICKER_MEDIA,
|
|
223
|
+
eventType: EVENT_TYPE.UI
|
|
224
|
+
};
|
|
225
|
+
dispatchAnalyticsEvent(payload);
|
|
226
|
+
}
|
|
227
|
+
closeMediaInsertPicker();
|
|
228
|
+
}, [closeMediaInsertPicker, dispatchAnalyticsEvent]);
|
|
211
229
|
return /*#__PURE__*/React.createElement(Box, {
|
|
212
230
|
as: "form",
|
|
213
231
|
onSubmit: function onSubmit(e) {
|
|
@@ -244,12 +262,13 @@ export function MediaFromURL(_ref) {
|
|
|
244
262
|
}, /*#__PURE__*/React.createElement(Button, {
|
|
245
263
|
type: "submit",
|
|
246
264
|
isLoading: previewState.isLoading,
|
|
247
|
-
isDisabled:
|
|
265
|
+
isDisabled: inputUrl.length === 0,
|
|
248
266
|
iconBefore: EditorFilePreviewIcon
|
|
249
267
|
}, strings.loadPreview)), /*#__PURE__*/React.createElement(Box, {
|
|
250
268
|
xcss: ButtonGroupStyles
|
|
251
269
|
}, /*#__PURE__*/React.createElement(ButtonGroup, null, /*#__PURE__*/React.createElement(Button, {
|
|
252
|
-
appearance: "subtle"
|
|
270
|
+
appearance: "subtle",
|
|
271
|
+
onClick: onCancel
|
|
253
272
|
}, strings.cancel), /*#__PURE__*/React.createElement(Button, {
|
|
254
273
|
appearance: "primary",
|
|
255
274
|
isDisabled: !previewState.previewInfo && !previewState.warning,
|
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { useIntl } from 'react-intl-next';
|
|
3
|
+
import { mediaInsertMessages } from '@atlaskit/editor-common/messages';
|
|
2
4
|
import { Box } from '@atlaskit/primitives';
|
|
3
5
|
import Tabs, { Tab, TabList, TabPanel } from '@atlaskit/tabs';
|
|
4
6
|
import { MediaFromURL } from './FromURL';
|
|
5
7
|
export var MediaInsertContent = function MediaInsertContent(_ref) {
|
|
6
8
|
var mediaProvider = _ref.mediaProvider,
|
|
7
9
|
dispatchAnalyticsEvent = _ref.dispatchAnalyticsEvent,
|
|
8
|
-
|
|
10
|
+
closeMediaInsertPicker = _ref.closeMediaInsertPicker;
|
|
11
|
+
var intl = useIntl();
|
|
9
12
|
return /*#__PURE__*/React.createElement(Tabs, {
|
|
10
13
|
id: "media-insert-tab-navigation"
|
|
11
14
|
}, /*#__PURE__*/React.createElement(Box, {
|
|
12
15
|
paddingBlockEnd: "space.150"
|
|
13
|
-
}, /*#__PURE__*/React.createElement(TabList, null, /*#__PURE__*/React.createElement(Tab, null,
|
|
16
|
+
}, /*#__PURE__*/React.createElement(TabList, null, /*#__PURE__*/React.createElement(Tab, null, intl.formatMessage(mediaInsertMessages.linkTabTitle)))), /*#__PURE__*/React.createElement(TabPanel, null, /*#__PURE__*/React.createElement(MediaFromURL, {
|
|
14
17
|
mediaProvider: mediaProvider,
|
|
15
18
|
onExternalInsert: function onExternalInsert() {},
|
|
16
19
|
onInsert: function onInsert() {},
|
|
17
20
|
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
18
|
-
|
|
21
|
+
closeMediaInsertPicker: closeMediaInsertPicker
|
|
19
22
|
})));
|
|
20
23
|
};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { useIntl } from 'react-intl-next';
|
|
2
3
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
3
4
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
5
|
+
import { mediaInsertMessages } from '@atlaskit/editor-common/messages';
|
|
4
6
|
import { Popup, withOuterListeners } from '@atlaskit/editor-common/ui';
|
|
5
7
|
import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
6
8
|
import { akEditorFloatingDialogZIndex } from '@atlaskit/editor-shared-styles';
|
|
@@ -42,6 +44,7 @@ export var MediaInsertPicker = function MediaInsertPicker(_ref) {
|
|
|
42
44
|
var targetRef = getDomRefFromSelection(editorView, dispatchAnalyticsEvent);
|
|
43
45
|
var isOpen = (_useSharedPluginState = useSharedPluginState(api, ['mediaInsert'])) === null || _useSharedPluginState === void 0 || (_useSharedPluginState = _useSharedPluginState.mediaInsertState) === null || _useSharedPluginState === void 0 ? void 0 : _useSharedPluginState.isOpen;
|
|
44
46
|
var mediaProvider = (_useSharedPluginState2 = useSharedPluginState(api, ['media'])) === null || _useSharedPluginState2 === void 0 || (_useSharedPluginState2 = _useSharedPluginState2.mediaState) === null || _useSharedPluginState2 === void 0 ? void 0 : _useSharedPluginState2.mediaProvider;
|
|
47
|
+
var intl = useIntl();
|
|
45
48
|
if (!isOpen || !mediaProvider) {
|
|
46
49
|
return null;
|
|
47
50
|
}
|
|
@@ -63,10 +66,8 @@ export var MediaInsertPicker = function MediaInsertPicker(_ref) {
|
|
|
63
66
|
closeMediaInsertPicker();
|
|
64
67
|
};
|
|
65
68
|
};
|
|
66
|
-
return /*#__PURE__*/React.createElement(PopupWithListeners
|
|
67
|
-
|
|
68
|
-
, {
|
|
69
|
-
ariaLabel: 'Media Insert',
|
|
69
|
+
return /*#__PURE__*/React.createElement(PopupWithListeners, {
|
|
70
|
+
ariaLabel: intl.formatMessage(mediaInsertMessages.mediaPickerPopupAriaLabel),
|
|
70
71
|
offset: [0, 12],
|
|
71
72
|
target: targetRef,
|
|
72
73
|
zIndex: akEditorFloatingDialogZIndex,
|
|
@@ -82,8 +83,6 @@ export var MediaInsertPicker = function MediaInsertPicker(_ref) {
|
|
|
82
83
|
}, /*#__PURE__*/React.createElement(MediaInsertWrapper, null, /*#__PURE__*/React.createElement(MediaInsertContent, {
|
|
83
84
|
mediaProvider: mediaProvider,
|
|
84
85
|
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
85
|
-
|
|
86
|
-
return handleClose(INPUT_METHOD.KEYBOARD);
|
|
87
|
-
}
|
|
86
|
+
closeMediaInsertPicker: closeMediaInsertPicker
|
|
88
87
|
})));
|
|
89
88
|
};
|
|
@@ -4,7 +4,8 @@ var styles = xcss({
|
|
|
4
4
|
boxShadow: 'elevation.shadow.overflow',
|
|
5
5
|
width: '340px',
|
|
6
6
|
padding: 'space.200',
|
|
7
|
-
borderRadius: 'border.radius'
|
|
7
|
+
borderRadius: 'border.radius',
|
|
8
|
+
backgroundColor: 'elevation.surface.overlay'
|
|
8
9
|
});
|
|
9
10
|
export var MediaInsertWrapper = function MediaInsertWrapper(_ref) {
|
|
10
11
|
var children = _ref.children;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type
|
|
2
|
+
import { type DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
|
|
3
3
|
import type { MediaProvider } from '@atlaskit/editor-common/provider-factory';
|
|
4
4
|
import { type OnInsertAttrs } from './types';
|
|
5
5
|
type Props = {
|
|
@@ -7,7 +7,7 @@ type Props = {
|
|
|
7
7
|
onInsert: (attrs: OnInsertAttrs) => void;
|
|
8
8
|
onExternalInsert: (url: string) => void;
|
|
9
9
|
dispatchAnalyticsEvent?: DispatchAnalyticsEvent;
|
|
10
|
-
|
|
10
|
+
closeMediaInsertPicker: () => void;
|
|
11
11
|
};
|
|
12
|
-
export declare function MediaFromURL({ mediaProvider, onInsert, onExternalInsert, dispatchAnalyticsEvent,
|
|
12
|
+
export declare function MediaFromURL({ mediaProvider, onInsert, onExternalInsert, dispatchAnalyticsEvent, closeMediaInsertPicker, }: Props): JSX.Element;
|
|
13
13
|
export {};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
|
|
3
3
|
import type { MediaProvider } from '@atlaskit/editor-common/provider-factory';
|
|
4
|
-
export declare const MediaInsertContent: ({ mediaProvider, dispatchAnalyticsEvent,
|
|
4
|
+
export declare const MediaInsertContent: ({ mediaProvider, dispatchAnalyticsEvent, closeMediaInsertPicker, }: {
|
|
5
5
|
mediaProvider: MediaProvider;
|
|
6
6
|
dispatchAnalyticsEvent?: DispatchAnalyticsEvent | undefined;
|
|
7
|
-
|
|
7
|
+
closeMediaInsertPicker: () => void;
|
|
8
8
|
}) => JSX.Element;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type
|
|
2
|
+
import { type DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
|
|
3
3
|
import type { MediaProvider } from '@atlaskit/editor-common/provider-factory';
|
|
4
4
|
import { type OnInsertAttrs } from './types';
|
|
5
5
|
type Props = {
|
|
@@ -7,7 +7,7 @@ type Props = {
|
|
|
7
7
|
onInsert: (attrs: OnInsertAttrs) => void;
|
|
8
8
|
onExternalInsert: (url: string) => void;
|
|
9
9
|
dispatchAnalyticsEvent?: DispatchAnalyticsEvent;
|
|
10
|
-
|
|
10
|
+
closeMediaInsertPicker: () => void;
|
|
11
11
|
};
|
|
12
|
-
export declare function MediaFromURL({ mediaProvider, onInsert, onExternalInsert, dispatchAnalyticsEvent,
|
|
12
|
+
export declare function MediaFromURL({ mediaProvider, onInsert, onExternalInsert, dispatchAnalyticsEvent, closeMediaInsertPicker, }: Props): JSX.Element;
|
|
13
13
|
export {};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
|
|
3
3
|
import type { MediaProvider } from '@atlaskit/editor-common/provider-factory';
|
|
4
|
-
export declare const MediaInsertContent: ({ mediaProvider, dispatchAnalyticsEvent,
|
|
4
|
+
export declare const MediaInsertContent: ({ mediaProvider, dispatchAnalyticsEvent, closeMediaInsertPicker, }: {
|
|
5
5
|
mediaProvider: MediaProvider;
|
|
6
6
|
dispatchAnalyticsEvent?: DispatchAnalyticsEvent | undefined;
|
|
7
|
-
|
|
7
|
+
closeMediaInsertPicker: () => void;
|
|
8
8
|
}) => JSX.Element;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-media-insert",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Media Insert plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -25,15 +25,15 @@
|
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@atlaskit/button": "^20.0.0",
|
|
28
|
-
"@atlaskit/editor-common": "^87.
|
|
28
|
+
"@atlaskit/editor-common": "^87.12.0",
|
|
29
29
|
"@atlaskit/editor-plugin-analytics": "^1.7.0",
|
|
30
|
-
"@atlaskit/editor-plugin-media": "^1.
|
|
30
|
+
"@atlaskit/editor-plugin-media": "^1.29.0",
|
|
31
31
|
"@atlaskit/editor-prosemirror": "5.0.1",
|
|
32
32
|
"@atlaskit/editor-shared-styles": "^2.13.0",
|
|
33
33
|
"@atlaskit/icon": "^22.13.0",
|
|
34
34
|
"@atlaskit/media-card": "^78.0.0",
|
|
35
35
|
"@atlaskit/media-client": "^27.3.0",
|
|
36
|
-
"@atlaskit/media-client-react": "^2.
|
|
36
|
+
"@atlaskit/media-client-react": "^2.1.0",
|
|
37
37
|
"@atlaskit/primitives": "^12.0.0",
|
|
38
38
|
"@atlaskit/section-message": "^6.6.0",
|
|
39
39
|
"@atlaskit/tabs": "^16.4.0",
|