@atlaskit/editor-plugin-media-insert 1.3.0 → 2.0.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 +13 -0
- package/dist/cjs/index.js +1 -8
- package/dist/cjs/ui/FromURL.js +30 -22
- package/dist/cjs/ui/MediaCard.js +1 -9
- package/dist/cjs/ui/MediaInsertContent.js +12 -6
- package/dist/cjs/ui/MediaInsertPicker.js +14 -4
- package/dist/es2019/index.js +1 -2
- package/dist/es2019/ui/FromURL.js +18 -5
- package/dist/es2019/ui/MediaCard.js +1 -5
- package/dist/es2019/ui/MediaInsertContent.js +13 -6
- package/dist/es2019/ui/MediaInsertPicker.js +12 -5
- package/dist/esm/index.js +1 -2
- package/dist/esm/ui/FromURL.js +30 -22
- package/dist/esm/ui/MediaCard.js +1 -9
- package/dist/esm/ui/MediaInsertContent.js +12 -6
- package/dist/esm/ui/MediaInsertPicker.js +14 -4
- package/dist/types/index.d.ts +0 -1
- package/dist/types/types.d.ts +4 -1
- package/dist/types/ui/FromURL.d.ts +3 -2
- package/dist/types/ui/MediaCard.d.ts +2 -2
- package/dist/types/ui/MediaInsertContent.d.ts +7 -1
- package/dist/types-ts4.5/index.d.ts +0 -1
- package/dist/types-ts4.5/types.d.ts +5 -1
- package/dist/types-ts4.5/ui/FromURL.d.ts +3 -2
- package/dist/types-ts4.5/ui/MediaCard.d.ts +2 -2
- package/dist/types-ts4.5/ui/MediaInsertContent.d.ts +7 -1
- package/package.json +5 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-media-insert
|
|
2
2
|
|
|
3
|
+
## 2.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [#129869](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/129869)
|
|
8
|
+
[`48b31a6b8fb5a`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/48b31a6b8fb5a) -
|
|
9
|
+
[ux] [ED-24566] Integrated Media URL UI into the Insert Media Popup [ED-24589] Removed export of
|
|
10
|
+
UI component from `editor-plugin-media-insert`
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies
|
|
15
|
+
|
|
3
16
|
## 1.3.0
|
|
4
17
|
|
|
5
18
|
### Minor Changes
|
package/dist/cjs/index.js
CHANGED
|
@@ -3,17 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
Object.defineProperty(exports, "MediaFromURL", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function get() {
|
|
9
|
-
return _FromURL.MediaFromURL;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
6
|
Object.defineProperty(exports, "mediaInsertPlugin", {
|
|
13
7
|
enumerable: true,
|
|
14
8
|
get: function get() {
|
|
15
9
|
return _plugin.mediaInsertPlugin;
|
|
16
10
|
}
|
|
17
11
|
});
|
|
18
|
-
var _plugin = require("./plugin");
|
|
19
|
-
var _FromURL = require("./ui/FromURL");
|
|
12
|
+
var _plugin = require("./plugin");
|
package/dist/cjs/ui/FromURL.js
CHANGED
|
@@ -36,6 +36,9 @@ var PreviewImageStyles = (0, _primitives.xcss)({
|
|
|
36
36
|
var ButtonGroupStyles = (0, _primitives.xcss)({
|
|
37
37
|
alignSelf: 'end'
|
|
38
38
|
});
|
|
39
|
+
var FormStyles = (0, _primitives.xcss)({
|
|
40
|
+
flexGrow: 1
|
|
41
|
+
});
|
|
39
42
|
var INITIAL_PREVIEW_STATE = Object.freeze({
|
|
40
43
|
isLoading: false,
|
|
41
44
|
error: null,
|
|
@@ -77,7 +80,8 @@ function MediaFromURL(_ref) {
|
|
|
77
80
|
var mediaProvider = _ref.mediaProvider,
|
|
78
81
|
onInsert = _ref.onInsert,
|
|
79
82
|
onExternalInsert = _ref.onExternalInsert,
|
|
80
|
-
dispatchAnalyticsEvent = _ref.dispatchAnalyticsEvent
|
|
83
|
+
dispatchAnalyticsEvent = _ref.dispatchAnalyticsEvent,
|
|
84
|
+
onEscKeyPressed = _ref.onEscKeyPressed;
|
|
81
85
|
var intl = (0, _reactIntlNext.useIntl)();
|
|
82
86
|
var strings = {
|
|
83
87
|
loadPreview: intl.formatMessage(_messages.mediaInsertMessages.loadPreview),
|
|
@@ -102,32 +106,27 @@ function MediaFromURL(_ref) {
|
|
|
102
106
|
onUploadFailureAnalytics = _useAnalyticsEvents.onUploadFailureAnalytics;
|
|
103
107
|
var uploadExternalMedia = _react.default.useCallback( /*#__PURE__*/function () {
|
|
104
108
|
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(url) {
|
|
105
|
-
var
|
|
109
|
+
var uploadMediaClientConfig, uploadParams, mediaClient, collection, _yield$mediaClient$fi, uploadableFileUpfrontIds, dimensions, message;
|
|
106
110
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
107
111
|
while (1) switch (_context.prev = _context.next) {
|
|
108
112
|
case 0:
|
|
109
113
|
dispatch({
|
|
110
114
|
type: 'loading'
|
|
111
115
|
});
|
|
112
|
-
|
|
113
|
-
return mediaProvider;
|
|
114
|
-
case 3:
|
|
115
|
-
_yield$mediaProvider = _context.sent;
|
|
116
|
-
uploadMediaClientConfig = _yield$mediaProvider.uploadMediaClientConfig;
|
|
117
|
-
uploadParams = _yield$mediaProvider.uploadParams;
|
|
116
|
+
uploadMediaClientConfig = mediaProvider.uploadMediaClientConfig, uploadParams = mediaProvider.uploadParams;
|
|
118
117
|
if (uploadMediaClientConfig) {
|
|
119
|
-
_context.next =
|
|
118
|
+
_context.next = 4;
|
|
120
119
|
break;
|
|
121
120
|
}
|
|
122
121
|
return _context.abrupt("return");
|
|
123
|
-
case
|
|
122
|
+
case 4:
|
|
124
123
|
mediaClient = (0, _mediaClientReact.getMediaClient)(uploadMediaClientConfig);
|
|
125
124
|
collection = uploadParams === null || uploadParams === void 0 ? void 0 : uploadParams.collection;
|
|
126
125
|
onUploadAnalytics();
|
|
127
|
-
_context.prev =
|
|
128
|
-
_context.next =
|
|
126
|
+
_context.prev = 7;
|
|
127
|
+
_context.next = 10;
|
|
129
128
|
return mediaClient.file.uploadExternal(url, collection);
|
|
130
|
-
case
|
|
129
|
+
case 10:
|
|
131
130
|
_yield$mediaClient$fi = _context.sent;
|
|
132
131
|
uploadableFileUpfrontIds = _yield$mediaClient$fi.uploadableFileUpfrontIds;
|
|
133
132
|
dimensions = _yield$mediaClient$fi.dimensions;
|
|
@@ -142,11 +141,11 @@ function MediaFromURL(_ref) {
|
|
|
142
141
|
occurrenceKey: uploadableFileUpfrontIds.occurrenceKey
|
|
143
142
|
}
|
|
144
143
|
});
|
|
145
|
-
_context.next =
|
|
144
|
+
_context.next = 20;
|
|
146
145
|
break;
|
|
147
|
-
case
|
|
148
|
-
_context.prev =
|
|
149
|
-
_context.t0 = _context["catch"](
|
|
146
|
+
case 17:
|
|
147
|
+
_context.prev = 17;
|
|
148
|
+
_context.t0 = _context["catch"](7);
|
|
150
149
|
if (typeof _context.t0 === 'string' && _context.t0 === 'Could not download remote file') {
|
|
151
150
|
// TODO: Make sure this gets good unit test coverage with the actual
|
|
152
151
|
// media plugin. This hard coded error message could be changed at any
|
|
@@ -171,11 +170,11 @@ function MediaFromURL(_ref) {
|
|
|
171
170
|
error: 'Unknown error'
|
|
172
171
|
});
|
|
173
172
|
}
|
|
174
|
-
case
|
|
173
|
+
case 20:
|
|
175
174
|
case "end":
|
|
176
175
|
return _context.stop();
|
|
177
176
|
}
|
|
178
|
-
}, _callee, null, [[
|
|
177
|
+
}, _callee, null, [[7, 17]]);
|
|
179
178
|
}));
|
|
180
179
|
return function (_x) {
|
|
181
180
|
return _ref2.apply(this, arguments);
|
|
@@ -211,18 +210,27 @@ function MediaFromURL(_ref) {
|
|
|
211
210
|
return onExternalInsert(inputUrl);
|
|
212
211
|
}
|
|
213
212
|
}, [onExternalInsert, onInsert, previewState.previewInfo, previewState.warning, inputUrl]);
|
|
214
|
-
|
|
213
|
+
var onInputKeyPress = _react.default.useCallback(function (event) {
|
|
214
|
+
if (event && event.key === 'Esc') {
|
|
215
|
+
onEscKeyPressed();
|
|
216
|
+
}
|
|
217
|
+
}, [onEscKeyPressed]);
|
|
218
|
+
return /*#__PURE__*/_react.default.createElement(_primitives.Box, {
|
|
219
|
+
as: "form",
|
|
215
220
|
onSubmit: function onSubmit(e) {
|
|
216
221
|
e.preventDefault();
|
|
217
222
|
uploadExternalMedia(inputUrl);
|
|
218
|
-
}
|
|
223
|
+
},
|
|
224
|
+
xcss: FormStyles
|
|
219
225
|
}, /*#__PURE__*/_react.default.createElement(_primitives.Stack, {
|
|
220
|
-
space: "space.150"
|
|
226
|
+
space: "space.150",
|
|
227
|
+
grow: "fill"
|
|
221
228
|
}, /*#__PURE__*/_react.default.createElement(_textfield.default, {
|
|
222
229
|
autoFocus: true,
|
|
223
230
|
value: inputUrl,
|
|
224
231
|
placeholder: strings.pasteLinkToUpload,
|
|
225
232
|
onChange: onURLChange,
|
|
233
|
+
onKeyPress: onInputKeyPress,
|
|
226
234
|
onPaste: onPaste
|
|
227
235
|
}), previewState.previewInfo && /*#__PURE__*/_react.default.createElement(_primitives.Inline, {
|
|
228
236
|
alignInline: "center",
|
package/dist/cjs/ui/MediaCard.js
CHANGED
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.MediaCard = void 0;
|
|
8
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
8
|
var _react = _interopRequireDefault(require("react"));
|
|
10
9
|
var _reactIntlNext = require("react-intl-next");
|
|
11
10
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
@@ -16,16 +15,9 @@ var maxDimensions = {
|
|
|
16
15
|
};
|
|
17
16
|
var MediaCard = exports.MediaCard = function MediaCard(_ref) {
|
|
18
17
|
var attrs = _ref.attrs,
|
|
19
|
-
|
|
18
|
+
mediaProvider = _ref.mediaProvider;
|
|
20
19
|
var intl = (0, _reactIntlNext.useIntl)();
|
|
21
20
|
var mediaAlt = intl.formatMessage(_messages.mediaInsertMessages.mediaAlt);
|
|
22
|
-
var _React$useState = _react.default.useState(),
|
|
23
|
-
_React$useState2 = (0, _slicedToArray2.default)(_React$useState, 2),
|
|
24
|
-
mediaProvider = _React$useState2[0],
|
|
25
|
-
setMediaProvider = _React$useState2[1];
|
|
26
|
-
_react.default.useEffect(function () {
|
|
27
|
-
mediaProviderPromise.then(setMediaProvider);
|
|
28
|
-
}, [mediaProviderPromise]);
|
|
29
21
|
var dimensions = _react.default.useMemo(function () {
|
|
30
22
|
return {
|
|
31
23
|
width: attrs.width,
|
|
@@ -7,18 +7,24 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports.MediaInsertContent = void 0;
|
|
9
9
|
var _react = _interopRequireDefault(require("react"));
|
|
10
|
-
var _new = _interopRequireDefault(require("@atlaskit/button/new"));
|
|
11
10
|
var _primitives = require("@atlaskit/primitives");
|
|
12
11
|
var _tabs = _interopRequireWildcard(require("@atlaskit/tabs"));
|
|
12
|
+
var _FromURL = require("./FromURL");
|
|
13
13
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
14
14
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
15
|
-
var MediaInsertContent = exports.MediaInsertContent = function MediaInsertContent() {
|
|
15
|
+
var MediaInsertContent = exports.MediaInsertContent = function MediaInsertContent(_ref) {
|
|
16
|
+
var mediaProvider = _ref.mediaProvider,
|
|
17
|
+
dispatchAnalyticsEvent = _ref.dispatchAnalyticsEvent,
|
|
18
|
+
onEscKeyPressed = _ref.onEscKeyPressed;
|
|
16
19
|
return /*#__PURE__*/_react.default.createElement(_tabs.default, {
|
|
17
20
|
id: "media-insert-tab-navigation"
|
|
18
21
|
}, /*#__PURE__*/_react.default.createElement(_primitives.Box, {
|
|
19
22
|
paddingBlockEnd: "space.150"
|
|
20
|
-
}, /*#__PURE__*/_react.default.createElement(_tabs.TabList, null, /*#__PURE__*/_react.default.createElement(_tabs.Tab, null, /*#__PURE__*/_react.default.createElement(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
}, /*#__PURE__*/_react.default.createElement(_tabs.TabList, null, /*#__PURE__*/_react.default.createElement(_tabs.Tab, null, "Link"))), /*#__PURE__*/_react.default.createElement(_tabs.TabPanel, null, /*#__PURE__*/_react.default.createElement(_FromURL.MediaFromURL, {
|
|
24
|
+
mediaProvider: mediaProvider,
|
|
25
|
+
onExternalInsert: function onExternalInsert() {},
|
|
26
|
+
onInsert: function onInsert() {},
|
|
27
|
+
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
28
|
+
onEscKeyPressed: onEscKeyPressed
|
|
29
|
+
})));
|
|
24
30
|
};
|
|
@@ -38,6 +38,7 @@ var getDomRefFromSelection = function getDomRefFromSelection(view, dispatchAnaly
|
|
|
38
38
|
}
|
|
39
39
|
};
|
|
40
40
|
var MediaInsertPicker = exports.MediaInsertPicker = function MediaInsertPicker(_ref) {
|
|
41
|
+
var _useSharedPluginState, _useSharedPluginState2;
|
|
41
42
|
var api = _ref.api,
|
|
42
43
|
editorView = _ref.editorView,
|
|
43
44
|
dispatchAnalyticsEvent = _ref.dispatchAnalyticsEvent,
|
|
@@ -46,9 +47,9 @@ var MediaInsertPicker = exports.MediaInsertPicker = function MediaInsertPicker(_
|
|
|
46
47
|
popupsScrollableElement = _ref.popupsScrollableElement,
|
|
47
48
|
closeMediaInsertPicker = _ref.closeMediaInsertPicker;
|
|
48
49
|
var targetRef = getDomRefFromSelection(editorView, dispatchAnalyticsEvent);
|
|
49
|
-
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['mediaInsert'])
|
|
50
|
-
|
|
51
|
-
if (!
|
|
50
|
+
var isOpen = (_useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['mediaInsert'])) === null || _useSharedPluginState === void 0 || (_useSharedPluginState = _useSharedPluginState.mediaInsertState) === null || _useSharedPluginState === void 0 ? void 0 : _useSharedPluginState.isOpen;
|
|
51
|
+
var mediaProvider = (_useSharedPluginState2 = (0, _hooks.useSharedPluginState)(api, ['media'])) === null || _useSharedPluginState2 === void 0 || (_useSharedPluginState2 = _useSharedPluginState2.mediaState) === null || _useSharedPluginState2 === void 0 ? void 0 : _useSharedPluginState2.mediaProvider;
|
|
52
|
+
if (!isOpen || !mediaProvider) {
|
|
52
53
|
return null;
|
|
53
54
|
}
|
|
54
55
|
var handleClose = function handleClose(exitMethod) {
|
|
@@ -76,11 +77,20 @@ var MediaInsertPicker = exports.MediaInsertPicker = function MediaInsertPicker(_
|
|
|
76
77
|
offset: [0, 12],
|
|
77
78
|
target: targetRef,
|
|
78
79
|
zIndex: _editorSharedStyles.akEditorFloatingDialogZIndex,
|
|
80
|
+
fitHeight: 390,
|
|
81
|
+
fitWidth: 340,
|
|
79
82
|
mountTo: popupsMountPoint,
|
|
80
83
|
boundariesElement: popupsBoundariesElement,
|
|
81
84
|
handleClickOutside: handleClose(_analytics.INPUT_METHOD.MOUSE),
|
|
82
85
|
handleEscapeKeydown: handleClose(_analytics.INPUT_METHOD.KEYBOARD),
|
|
83
86
|
scrollableElement: popupsScrollableElement,
|
|
87
|
+
preventOverflow: true,
|
|
84
88
|
focusTrap: true
|
|
85
|
-
}, /*#__PURE__*/_react.default.createElement(_MediaInsertWrapper.MediaInsertWrapper, null, /*#__PURE__*/_react.default.createElement(_MediaInsertContent.MediaInsertContent,
|
|
89
|
+
}, /*#__PURE__*/_react.default.createElement(_MediaInsertWrapper.MediaInsertWrapper, null, /*#__PURE__*/_react.default.createElement(_MediaInsertContent.MediaInsertContent, {
|
|
90
|
+
mediaProvider: mediaProvider,
|
|
91
|
+
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
92
|
+
onEscKeyPressed: function onEscKeyPressed() {
|
|
93
|
+
return handleClose(_analytics.INPUT_METHOD.KEYBOARD);
|
|
94
|
+
}
|
|
95
|
+
})));
|
|
86
96
|
};
|
package/dist/es2019/index.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export { mediaInsertPlugin } from './plugin';
|
|
2
|
-
export { MediaFromURL } from './ui/FromURL';
|
|
1
|
+
export { mediaInsertPlugin } from './plugin';
|
|
@@ -23,6 +23,9 @@ const PreviewImageStyles = xcss({
|
|
|
23
23
|
const ButtonGroupStyles = xcss({
|
|
24
24
|
alignSelf: 'end'
|
|
25
25
|
});
|
|
26
|
+
const FormStyles = xcss({
|
|
27
|
+
flexGrow: 1
|
|
28
|
+
});
|
|
26
29
|
const INITIAL_PREVIEW_STATE = Object.freeze({
|
|
27
30
|
isLoading: false,
|
|
28
31
|
error: null,
|
|
@@ -68,7 +71,8 @@ export function MediaFromURL({
|
|
|
68
71
|
mediaProvider,
|
|
69
72
|
onInsert,
|
|
70
73
|
onExternalInsert,
|
|
71
|
-
dispatchAnalyticsEvent
|
|
74
|
+
dispatchAnalyticsEvent,
|
|
75
|
+
onEscKeyPressed
|
|
72
76
|
}) {
|
|
73
77
|
const intl = useIntl();
|
|
74
78
|
const strings = {
|
|
@@ -94,7 +98,7 @@ export function MediaFromURL({
|
|
|
94
98
|
const {
|
|
95
99
|
uploadMediaClientConfig,
|
|
96
100
|
uploadParams
|
|
97
|
-
} =
|
|
101
|
+
} = mediaProvider;
|
|
98
102
|
if (!uploadMediaClientConfig) {
|
|
99
103
|
return;
|
|
100
104
|
}
|
|
@@ -174,18 +178,27 @@ export function MediaFromURL({
|
|
|
174
178
|
return onExternalInsert(inputUrl);
|
|
175
179
|
}
|
|
176
180
|
}, [onExternalInsert, onInsert, previewState.previewInfo, previewState.warning, inputUrl]);
|
|
177
|
-
|
|
181
|
+
const onInputKeyPress = React.useCallback(event => {
|
|
182
|
+
if (event && event.key === 'Esc') {
|
|
183
|
+
onEscKeyPressed();
|
|
184
|
+
}
|
|
185
|
+
}, [onEscKeyPressed]);
|
|
186
|
+
return /*#__PURE__*/React.createElement(Box, {
|
|
187
|
+
as: "form",
|
|
178
188
|
onSubmit: e => {
|
|
179
189
|
e.preventDefault();
|
|
180
190
|
uploadExternalMedia(inputUrl);
|
|
181
|
-
}
|
|
191
|
+
},
|
|
192
|
+
xcss: FormStyles
|
|
182
193
|
}, /*#__PURE__*/React.createElement(Stack, {
|
|
183
|
-
space: "space.150"
|
|
194
|
+
space: "space.150",
|
|
195
|
+
grow: "fill"
|
|
184
196
|
}, /*#__PURE__*/React.createElement(TextField, {
|
|
185
197
|
autoFocus: true,
|
|
186
198
|
value: inputUrl,
|
|
187
199
|
placeholder: strings.pasteLinkToUpload,
|
|
188
200
|
onChange: onURLChange,
|
|
201
|
+
onKeyPress: onInputKeyPress,
|
|
189
202
|
onPaste: onPaste
|
|
190
203
|
}), previewState.previewInfo && /*#__PURE__*/React.createElement(Inline, {
|
|
191
204
|
alignInline: "center",
|
|
@@ -8,14 +8,10 @@ const maxDimensions = {
|
|
|
8
8
|
};
|
|
9
9
|
export const MediaCard = ({
|
|
10
10
|
attrs,
|
|
11
|
-
mediaProvider
|
|
11
|
+
mediaProvider
|
|
12
12
|
}) => {
|
|
13
13
|
const intl = useIntl();
|
|
14
14
|
const mediaAlt = intl.formatMessage(mediaInsertMessages.mediaAlt);
|
|
15
|
-
const [mediaProvider, setMediaProvider] = React.useState();
|
|
16
|
-
React.useEffect(() => {
|
|
17
|
-
mediaProviderPromise.then(setMediaProvider);
|
|
18
|
-
}, [mediaProviderPromise]);
|
|
19
15
|
const dimensions = React.useMemo(() => {
|
|
20
16
|
return {
|
|
21
17
|
width: attrs.width,
|
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import Button from '@atlaskit/button/new';
|
|
3
2
|
import { Box } from '@atlaskit/primitives';
|
|
4
3
|
import Tabs, { Tab, TabList, TabPanel } from '@atlaskit/tabs';
|
|
5
|
-
|
|
4
|
+
import { MediaFromURL } from './FromURL';
|
|
5
|
+
export const MediaInsertContent = ({
|
|
6
|
+
mediaProvider,
|
|
7
|
+
dispatchAnalyticsEvent,
|
|
8
|
+
onEscKeyPressed
|
|
9
|
+
}) => {
|
|
6
10
|
return /*#__PURE__*/React.createElement(Tabs, {
|
|
7
11
|
id: "media-insert-tab-navigation"
|
|
8
12
|
}, /*#__PURE__*/React.createElement(Box, {
|
|
9
13
|
paddingBlockEnd: "space.150"
|
|
10
|
-
}, /*#__PURE__*/React.createElement(TabList, null, /*#__PURE__*/React.createElement(Tab, null, /*#__PURE__*/React.createElement(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
}, /*#__PURE__*/React.createElement(TabList, null, /*#__PURE__*/React.createElement(Tab, null, "Link"))), /*#__PURE__*/React.createElement(TabPanel, null, /*#__PURE__*/React.createElement(MediaFromURL, {
|
|
15
|
+
mediaProvider: mediaProvider,
|
|
16
|
+
onExternalInsert: () => {},
|
|
17
|
+
onInsert: () => {},
|
|
18
|
+
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
19
|
+
onEscKeyPressed: onEscKeyPressed
|
|
20
|
+
})));
|
|
14
21
|
};
|
|
@@ -39,11 +39,11 @@ export const MediaInsertPicker = ({
|
|
|
39
39
|
popupsScrollableElement,
|
|
40
40
|
closeMediaInsertPicker
|
|
41
41
|
}) => {
|
|
42
|
+
var _useSharedPluginState, _useSharedPluginState2, _useSharedPluginState3, _useSharedPluginState4;
|
|
42
43
|
const targetRef = getDomRefFromSelection(editorView, dispatchAnalyticsEvent);
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
if (!mediaInsertState || !mediaInsertState.isOpen) {
|
|
44
|
+
const isOpen = (_useSharedPluginState = useSharedPluginState(api, ['mediaInsert'])) === null || _useSharedPluginState === void 0 ? void 0 : (_useSharedPluginState2 = _useSharedPluginState.mediaInsertState) === null || _useSharedPluginState2 === void 0 ? void 0 : _useSharedPluginState2.isOpen;
|
|
45
|
+
const mediaProvider = (_useSharedPluginState3 = useSharedPluginState(api, ['media'])) === null || _useSharedPluginState3 === void 0 ? void 0 : (_useSharedPluginState4 = _useSharedPluginState3.mediaState) === null || _useSharedPluginState4 === void 0 ? void 0 : _useSharedPluginState4.mediaProvider;
|
|
46
|
+
if (!isOpen || !mediaProvider) {
|
|
47
47
|
return null;
|
|
48
48
|
}
|
|
49
49
|
const handleClose = exitMethod => event => {
|
|
@@ -69,11 +69,18 @@ export const MediaInsertPicker = ({
|
|
|
69
69
|
offset: [0, 12],
|
|
70
70
|
target: targetRef,
|
|
71
71
|
zIndex: akEditorFloatingDialogZIndex,
|
|
72
|
+
fitHeight: 390,
|
|
73
|
+
fitWidth: 340,
|
|
72
74
|
mountTo: popupsMountPoint,
|
|
73
75
|
boundariesElement: popupsBoundariesElement,
|
|
74
76
|
handleClickOutside: handleClose(INPUT_METHOD.MOUSE),
|
|
75
77
|
handleEscapeKeydown: handleClose(INPUT_METHOD.KEYBOARD),
|
|
76
78
|
scrollableElement: popupsScrollableElement,
|
|
79
|
+
preventOverflow: true,
|
|
77
80
|
focusTrap: true
|
|
78
|
-
}, /*#__PURE__*/React.createElement(MediaInsertWrapper, null, /*#__PURE__*/React.createElement(MediaInsertContent,
|
|
81
|
+
}, /*#__PURE__*/React.createElement(MediaInsertWrapper, null, /*#__PURE__*/React.createElement(MediaInsertContent, {
|
|
82
|
+
mediaProvider: mediaProvider,
|
|
83
|
+
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
84
|
+
onEscKeyPressed: () => handleClose(INPUT_METHOD.KEYBOARD)
|
|
85
|
+
})));
|
|
79
86
|
};
|
package/dist/esm/index.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export { mediaInsertPlugin } from './plugin';
|
|
2
|
-
export { MediaFromURL } from './ui/FromURL';
|
|
1
|
+
export { mediaInsertPlugin } from './plugin';
|
package/dist/esm/ui/FromURL.js
CHANGED
|
@@ -29,6 +29,9 @@ var PreviewImageStyles = xcss({
|
|
|
29
29
|
var ButtonGroupStyles = xcss({
|
|
30
30
|
alignSelf: 'end'
|
|
31
31
|
});
|
|
32
|
+
var FormStyles = xcss({
|
|
33
|
+
flexGrow: 1
|
|
34
|
+
});
|
|
32
35
|
var INITIAL_PREVIEW_STATE = Object.freeze({
|
|
33
36
|
isLoading: false,
|
|
34
37
|
error: null,
|
|
@@ -70,7 +73,8 @@ export function MediaFromURL(_ref) {
|
|
|
70
73
|
var mediaProvider = _ref.mediaProvider,
|
|
71
74
|
onInsert = _ref.onInsert,
|
|
72
75
|
onExternalInsert = _ref.onExternalInsert,
|
|
73
|
-
dispatchAnalyticsEvent = _ref.dispatchAnalyticsEvent
|
|
76
|
+
dispatchAnalyticsEvent = _ref.dispatchAnalyticsEvent,
|
|
77
|
+
onEscKeyPressed = _ref.onEscKeyPressed;
|
|
74
78
|
var intl = useIntl();
|
|
75
79
|
var strings = {
|
|
76
80
|
loadPreview: intl.formatMessage(mediaInsertMessages.loadPreview),
|
|
@@ -95,32 +99,27 @@ export function MediaFromURL(_ref) {
|
|
|
95
99
|
onUploadFailureAnalytics = _useAnalyticsEvents.onUploadFailureAnalytics;
|
|
96
100
|
var uploadExternalMedia = React.useCallback( /*#__PURE__*/function () {
|
|
97
101
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(url) {
|
|
98
|
-
var
|
|
102
|
+
var uploadMediaClientConfig, uploadParams, mediaClient, collection, _yield$mediaClient$fi, uploadableFileUpfrontIds, dimensions, message;
|
|
99
103
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
100
104
|
while (1) switch (_context.prev = _context.next) {
|
|
101
105
|
case 0:
|
|
102
106
|
dispatch({
|
|
103
107
|
type: 'loading'
|
|
104
108
|
});
|
|
105
|
-
|
|
106
|
-
return mediaProvider;
|
|
107
|
-
case 3:
|
|
108
|
-
_yield$mediaProvider = _context.sent;
|
|
109
|
-
uploadMediaClientConfig = _yield$mediaProvider.uploadMediaClientConfig;
|
|
110
|
-
uploadParams = _yield$mediaProvider.uploadParams;
|
|
109
|
+
uploadMediaClientConfig = mediaProvider.uploadMediaClientConfig, uploadParams = mediaProvider.uploadParams;
|
|
111
110
|
if (uploadMediaClientConfig) {
|
|
112
|
-
_context.next =
|
|
111
|
+
_context.next = 4;
|
|
113
112
|
break;
|
|
114
113
|
}
|
|
115
114
|
return _context.abrupt("return");
|
|
116
|
-
case
|
|
115
|
+
case 4:
|
|
117
116
|
mediaClient = getMediaClient(uploadMediaClientConfig);
|
|
118
117
|
collection = uploadParams === null || uploadParams === void 0 ? void 0 : uploadParams.collection;
|
|
119
118
|
onUploadAnalytics();
|
|
120
|
-
_context.prev =
|
|
121
|
-
_context.next =
|
|
119
|
+
_context.prev = 7;
|
|
120
|
+
_context.next = 10;
|
|
122
121
|
return mediaClient.file.uploadExternal(url, collection);
|
|
123
|
-
case
|
|
122
|
+
case 10:
|
|
124
123
|
_yield$mediaClient$fi = _context.sent;
|
|
125
124
|
uploadableFileUpfrontIds = _yield$mediaClient$fi.uploadableFileUpfrontIds;
|
|
126
125
|
dimensions = _yield$mediaClient$fi.dimensions;
|
|
@@ -135,11 +134,11 @@ export function MediaFromURL(_ref) {
|
|
|
135
134
|
occurrenceKey: uploadableFileUpfrontIds.occurrenceKey
|
|
136
135
|
}
|
|
137
136
|
});
|
|
138
|
-
_context.next =
|
|
137
|
+
_context.next = 20;
|
|
139
138
|
break;
|
|
140
|
-
case
|
|
141
|
-
_context.prev =
|
|
142
|
-
_context.t0 = _context["catch"](
|
|
139
|
+
case 17:
|
|
140
|
+
_context.prev = 17;
|
|
141
|
+
_context.t0 = _context["catch"](7);
|
|
143
142
|
if (typeof _context.t0 === 'string' && _context.t0 === 'Could not download remote file') {
|
|
144
143
|
// TODO: Make sure this gets good unit test coverage with the actual
|
|
145
144
|
// media plugin. This hard coded error message could be changed at any
|
|
@@ -164,11 +163,11 @@ export function MediaFromURL(_ref) {
|
|
|
164
163
|
error: 'Unknown error'
|
|
165
164
|
});
|
|
166
165
|
}
|
|
167
|
-
case
|
|
166
|
+
case 20:
|
|
168
167
|
case "end":
|
|
169
168
|
return _context.stop();
|
|
170
169
|
}
|
|
171
|
-
}, _callee, null, [[
|
|
170
|
+
}, _callee, null, [[7, 17]]);
|
|
172
171
|
}));
|
|
173
172
|
return function (_x) {
|
|
174
173
|
return _ref2.apply(this, arguments);
|
|
@@ -204,18 +203,27 @@ export function MediaFromURL(_ref) {
|
|
|
204
203
|
return onExternalInsert(inputUrl);
|
|
205
204
|
}
|
|
206
205
|
}, [onExternalInsert, onInsert, previewState.previewInfo, previewState.warning, inputUrl]);
|
|
207
|
-
|
|
206
|
+
var onInputKeyPress = React.useCallback(function (event) {
|
|
207
|
+
if (event && event.key === 'Esc') {
|
|
208
|
+
onEscKeyPressed();
|
|
209
|
+
}
|
|
210
|
+
}, [onEscKeyPressed]);
|
|
211
|
+
return /*#__PURE__*/React.createElement(Box, {
|
|
212
|
+
as: "form",
|
|
208
213
|
onSubmit: function onSubmit(e) {
|
|
209
214
|
e.preventDefault();
|
|
210
215
|
uploadExternalMedia(inputUrl);
|
|
211
|
-
}
|
|
216
|
+
},
|
|
217
|
+
xcss: FormStyles
|
|
212
218
|
}, /*#__PURE__*/React.createElement(Stack, {
|
|
213
|
-
space: "space.150"
|
|
219
|
+
space: "space.150",
|
|
220
|
+
grow: "fill"
|
|
214
221
|
}, /*#__PURE__*/React.createElement(TextField, {
|
|
215
222
|
autoFocus: true,
|
|
216
223
|
value: inputUrl,
|
|
217
224
|
placeholder: strings.pasteLinkToUpload,
|
|
218
225
|
onChange: onURLChange,
|
|
226
|
+
onKeyPress: onInputKeyPress,
|
|
219
227
|
onPaste: onPaste
|
|
220
228
|
}), previewState.previewInfo && /*#__PURE__*/React.createElement(Inline, {
|
|
221
229
|
alignInline: "center",
|
package/dist/esm/ui/MediaCard.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
1
|
import React from 'react';
|
|
3
2
|
import { useIntl } from 'react-intl-next';
|
|
4
3
|
import { mediaInsertMessages } from '@atlaskit/editor-common/messages';
|
|
@@ -9,16 +8,9 @@ var maxDimensions = {
|
|
|
9
8
|
};
|
|
10
9
|
export var MediaCard = function MediaCard(_ref) {
|
|
11
10
|
var attrs = _ref.attrs,
|
|
12
|
-
|
|
11
|
+
mediaProvider = _ref.mediaProvider;
|
|
13
12
|
var intl = useIntl();
|
|
14
13
|
var mediaAlt = intl.formatMessage(mediaInsertMessages.mediaAlt);
|
|
15
|
-
var _React$useState = React.useState(),
|
|
16
|
-
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
17
|
-
mediaProvider = _React$useState2[0],
|
|
18
|
-
setMediaProvider = _React$useState2[1];
|
|
19
|
-
React.useEffect(function () {
|
|
20
|
-
mediaProviderPromise.then(setMediaProvider);
|
|
21
|
-
}, [mediaProviderPromise]);
|
|
22
14
|
var dimensions = React.useMemo(function () {
|
|
23
15
|
return {
|
|
24
16
|
width: attrs.width,
|
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import Button from '@atlaskit/button/new';
|
|
3
2
|
import { Box } from '@atlaskit/primitives';
|
|
4
3
|
import Tabs, { Tab, TabList, TabPanel } from '@atlaskit/tabs';
|
|
5
|
-
|
|
4
|
+
import { MediaFromURL } from './FromURL';
|
|
5
|
+
export var MediaInsertContent = function MediaInsertContent(_ref) {
|
|
6
|
+
var mediaProvider = _ref.mediaProvider,
|
|
7
|
+
dispatchAnalyticsEvent = _ref.dispatchAnalyticsEvent,
|
|
8
|
+
onEscKeyPressed = _ref.onEscKeyPressed;
|
|
6
9
|
return /*#__PURE__*/React.createElement(Tabs, {
|
|
7
10
|
id: "media-insert-tab-navigation"
|
|
8
11
|
}, /*#__PURE__*/React.createElement(Box, {
|
|
9
12
|
paddingBlockEnd: "space.150"
|
|
10
|
-
}, /*#__PURE__*/React.createElement(TabList, null, /*#__PURE__*/React.createElement(Tab, null, /*#__PURE__*/React.createElement(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
}, /*#__PURE__*/React.createElement(TabList, null, /*#__PURE__*/React.createElement(Tab, null, "Link"))), /*#__PURE__*/React.createElement(TabPanel, null, /*#__PURE__*/React.createElement(MediaFromURL, {
|
|
14
|
+
mediaProvider: mediaProvider,
|
|
15
|
+
onExternalInsert: function onExternalInsert() {},
|
|
16
|
+
onInsert: function onInsert() {},
|
|
17
|
+
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
18
|
+
onEscKeyPressed: onEscKeyPressed
|
|
19
|
+
})));
|
|
14
20
|
};
|
|
@@ -31,6 +31,7 @@ var getDomRefFromSelection = function getDomRefFromSelection(view, dispatchAnaly
|
|
|
31
31
|
}
|
|
32
32
|
};
|
|
33
33
|
export var MediaInsertPicker = function MediaInsertPicker(_ref) {
|
|
34
|
+
var _useSharedPluginState, _useSharedPluginState2;
|
|
34
35
|
var api = _ref.api,
|
|
35
36
|
editorView = _ref.editorView,
|
|
36
37
|
dispatchAnalyticsEvent = _ref.dispatchAnalyticsEvent,
|
|
@@ -39,9 +40,9 @@ export var MediaInsertPicker = function MediaInsertPicker(_ref) {
|
|
|
39
40
|
popupsScrollableElement = _ref.popupsScrollableElement,
|
|
40
41
|
closeMediaInsertPicker = _ref.closeMediaInsertPicker;
|
|
41
42
|
var targetRef = getDomRefFromSelection(editorView, dispatchAnalyticsEvent);
|
|
42
|
-
var _useSharedPluginState = useSharedPluginState(api, ['mediaInsert'])
|
|
43
|
-
|
|
44
|
-
if (!
|
|
43
|
+
var isOpen = (_useSharedPluginState = useSharedPluginState(api, ['mediaInsert'])) === null || _useSharedPluginState === void 0 || (_useSharedPluginState = _useSharedPluginState.mediaInsertState) === null || _useSharedPluginState === void 0 ? void 0 : _useSharedPluginState.isOpen;
|
|
44
|
+
var mediaProvider = (_useSharedPluginState2 = useSharedPluginState(api, ['media'])) === null || _useSharedPluginState2 === void 0 || (_useSharedPluginState2 = _useSharedPluginState2.mediaState) === null || _useSharedPluginState2 === void 0 ? void 0 : _useSharedPluginState2.mediaProvider;
|
|
45
|
+
if (!isOpen || !mediaProvider) {
|
|
45
46
|
return null;
|
|
46
47
|
}
|
|
47
48
|
var handleClose = function handleClose(exitMethod) {
|
|
@@ -69,11 +70,20 @@ export var MediaInsertPicker = function MediaInsertPicker(_ref) {
|
|
|
69
70
|
offset: [0, 12],
|
|
70
71
|
target: targetRef,
|
|
71
72
|
zIndex: akEditorFloatingDialogZIndex,
|
|
73
|
+
fitHeight: 390,
|
|
74
|
+
fitWidth: 340,
|
|
72
75
|
mountTo: popupsMountPoint,
|
|
73
76
|
boundariesElement: popupsBoundariesElement,
|
|
74
77
|
handleClickOutside: handleClose(INPUT_METHOD.MOUSE),
|
|
75
78
|
handleEscapeKeydown: handleClose(INPUT_METHOD.KEYBOARD),
|
|
76
79
|
scrollableElement: popupsScrollableElement,
|
|
80
|
+
preventOverflow: true,
|
|
77
81
|
focusTrap: true
|
|
78
|
-
}, /*#__PURE__*/React.createElement(MediaInsertWrapper, null, /*#__PURE__*/React.createElement(MediaInsertContent,
|
|
82
|
+
}, /*#__PURE__*/React.createElement(MediaInsertWrapper, null, /*#__PURE__*/React.createElement(MediaInsertContent, {
|
|
83
|
+
mediaProvider: mediaProvider,
|
|
84
|
+
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
85
|
+
onEscKeyPressed: function onEscKeyPressed() {
|
|
86
|
+
return handleClose(INPUT_METHOD.KEYBOARD);
|
|
87
|
+
}
|
|
88
|
+
})));
|
|
79
89
|
};
|
package/dist/types/index.d.ts
CHANGED
package/dist/types/types.d.ts
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
|
+
import type { Providers } from '@atlaskit/editor-common/provider-factory';
|
|
1
2
|
import type { NextEditorPlugin, OptionalPlugin, UiComponentFactoryParams } from '@atlaskit/editor-common/types';
|
|
2
3
|
import { type ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
4
|
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
5
|
+
import type { MediaPlugin } from '@atlaskit/editor-plugin-media';
|
|
4
6
|
export type MediaInsertPluginState = {
|
|
5
7
|
isOpen?: boolean;
|
|
6
8
|
};
|
|
7
9
|
export type MediaInsertPlugin = NextEditorPlugin<'mediaInsert', {
|
|
8
|
-
dependencies: [OptionalPlugin<AnalyticsPlugin
|
|
10
|
+
dependencies: [OptionalPlugin<AnalyticsPlugin>, MediaPlugin];
|
|
9
11
|
sharedState: MediaInsertPluginState;
|
|
10
12
|
}>;
|
|
11
13
|
export type MediaInsertPickerProps = Pick<UiComponentFactoryParams, 'editorView' | 'dispatchAnalyticsEvent' | 'popupsMountPoint' | 'popupsBoundariesElement' | 'popupsScrollableElement'> & {
|
|
12
14
|
api?: ExtractInjectionAPI<MediaInsertPlugin>;
|
|
13
15
|
closeMediaInsertPicker: () => void;
|
|
16
|
+
mediaProvider?: Providers['mediaProvider'];
|
|
14
17
|
};
|
|
@@ -3,10 +3,11 @@ 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 = {
|
|
6
|
-
mediaProvider:
|
|
6
|
+
mediaProvider: MediaProvider;
|
|
7
7
|
onInsert: (attrs: OnInsertAttrs) => void;
|
|
8
8
|
onExternalInsert: (url: string) => void;
|
|
9
9
|
dispatchAnalyticsEvent?: DispatchAnalyticsEvent;
|
|
10
|
+
onEscKeyPressed: () => void;
|
|
10
11
|
};
|
|
11
|
-
export declare function MediaFromURL({ mediaProvider, onInsert, onExternalInsert, dispatchAnalyticsEvent, }: Props): JSX.Element;
|
|
12
|
+
export declare function MediaFromURL({ mediaProvider, onInsert, onExternalInsert, dispatchAnalyticsEvent, onEscKeyPressed, }: Props): JSX.Element;
|
|
12
13
|
export {};
|
|
@@ -3,7 +3,7 @@ import type { MediaProvider } from '@atlaskit/editor-common/provider-factory';
|
|
|
3
3
|
import { type OnInsertAttrs } from './types';
|
|
4
4
|
type Props = {
|
|
5
5
|
attrs: OnInsertAttrs;
|
|
6
|
-
mediaProvider:
|
|
6
|
+
mediaProvider: MediaProvider;
|
|
7
7
|
};
|
|
8
|
-
export declare const MediaCard: ({ attrs, mediaProvider
|
|
8
|
+
export declare const MediaCard: ({ attrs, mediaProvider }: Props) => JSX.Element;
|
|
9
9
|
export {};
|
|
@@ -1,2 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
|
|
2
|
+
import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
|
|
3
|
+
import type { MediaProvider } from '@atlaskit/editor-common/provider-factory';
|
|
4
|
+
export declare const MediaInsertContent: ({ mediaProvider, dispatchAnalyticsEvent, onEscKeyPressed, }: {
|
|
5
|
+
mediaProvider: MediaProvider;
|
|
6
|
+
dispatchAnalyticsEvent?: DispatchAnalyticsEvent | undefined;
|
|
7
|
+
onEscKeyPressed: () => void;
|
|
8
|
+
}) => JSX.Element;
|
|
@@ -1,16 +1,20 @@
|
|
|
1
|
+
import type { Providers } from '@atlaskit/editor-common/provider-factory';
|
|
1
2
|
import type { NextEditorPlugin, OptionalPlugin, UiComponentFactoryParams } from '@atlaskit/editor-common/types';
|
|
2
3
|
import { type ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
4
|
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
5
|
+
import type { MediaPlugin } from '@atlaskit/editor-plugin-media';
|
|
4
6
|
export type MediaInsertPluginState = {
|
|
5
7
|
isOpen?: boolean;
|
|
6
8
|
};
|
|
7
9
|
export type MediaInsertPlugin = NextEditorPlugin<'mediaInsert', {
|
|
8
10
|
dependencies: [
|
|
9
|
-
OptionalPlugin<AnalyticsPlugin
|
|
11
|
+
OptionalPlugin<AnalyticsPlugin>,
|
|
12
|
+
MediaPlugin
|
|
10
13
|
];
|
|
11
14
|
sharedState: MediaInsertPluginState;
|
|
12
15
|
}>;
|
|
13
16
|
export type MediaInsertPickerProps = Pick<UiComponentFactoryParams, 'editorView' | 'dispatchAnalyticsEvent' | 'popupsMountPoint' | 'popupsBoundariesElement' | 'popupsScrollableElement'> & {
|
|
14
17
|
api?: ExtractInjectionAPI<MediaInsertPlugin>;
|
|
15
18
|
closeMediaInsertPicker: () => void;
|
|
19
|
+
mediaProvider?: Providers['mediaProvider'];
|
|
16
20
|
};
|
|
@@ -3,10 +3,11 @@ 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 = {
|
|
6
|
-
mediaProvider:
|
|
6
|
+
mediaProvider: MediaProvider;
|
|
7
7
|
onInsert: (attrs: OnInsertAttrs) => void;
|
|
8
8
|
onExternalInsert: (url: string) => void;
|
|
9
9
|
dispatchAnalyticsEvent?: DispatchAnalyticsEvent;
|
|
10
|
+
onEscKeyPressed: () => void;
|
|
10
11
|
};
|
|
11
|
-
export declare function MediaFromURL({ mediaProvider, onInsert, onExternalInsert, dispatchAnalyticsEvent, }: Props): JSX.Element;
|
|
12
|
+
export declare function MediaFromURL({ mediaProvider, onInsert, onExternalInsert, dispatchAnalyticsEvent, onEscKeyPressed, }: Props): JSX.Element;
|
|
12
13
|
export {};
|
|
@@ -3,7 +3,7 @@ import type { MediaProvider } from '@atlaskit/editor-common/provider-factory';
|
|
|
3
3
|
import { type OnInsertAttrs } from './types';
|
|
4
4
|
type Props = {
|
|
5
5
|
attrs: OnInsertAttrs;
|
|
6
|
-
mediaProvider:
|
|
6
|
+
mediaProvider: MediaProvider;
|
|
7
7
|
};
|
|
8
|
-
export declare const MediaCard: ({ attrs, mediaProvider
|
|
8
|
+
export declare const MediaCard: ({ attrs, mediaProvider }: Props) => JSX.Element;
|
|
9
9
|
export {};
|
|
@@ -1,2 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
|
|
2
|
+
import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
|
|
3
|
+
import type { MediaProvider } from '@atlaskit/editor-common/provider-factory';
|
|
4
|
+
export declare const MediaInsertContent: ({ mediaProvider, dispatchAnalyticsEvent, onEscKeyPressed, }: {
|
|
5
|
+
mediaProvider: MediaProvider;
|
|
6
|
+
dispatchAnalyticsEvent?: DispatchAnalyticsEvent | undefined;
|
|
7
|
+
onEscKeyPressed: () => void;
|
|
8
|
+
}) => JSX.Element;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-media-insert",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Media Insert plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -24,12 +24,13 @@
|
|
|
24
24
|
".": "./src/index.ts"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@atlaskit/button": "^
|
|
28
|
-
"@atlaskit/editor-common": "^87.
|
|
27
|
+
"@atlaskit/button": "^20.0.0",
|
|
28
|
+
"@atlaskit/editor-common": "^87.10.0",
|
|
29
29
|
"@atlaskit/editor-plugin-analytics": "^1.7.0",
|
|
30
|
+
"@atlaskit/editor-plugin-media": "^1.28.0",
|
|
30
31
|
"@atlaskit/editor-prosemirror": "5.0.1",
|
|
31
32
|
"@atlaskit/editor-shared-styles": "^2.13.0",
|
|
32
|
-
"@atlaskit/icon": "^22.
|
|
33
|
+
"@atlaskit/icon": "^22.13.0",
|
|
33
34
|
"@atlaskit/media-card": "^78.0.0",
|
|
34
35
|
"@atlaskit/media-client": "^27.3.0",
|
|
35
36
|
"@atlaskit/media-client-react": "^2.0.0",
|