@atlaskit/editor-plugin-media-insert 1.3.0 → 2.0.1
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 +23 -0
- package/dist/cjs/index.js +1 -8
- package/dist/cjs/ui/FromURL.js +57 -23
- package/dist/cjs/ui/MediaCard.js +1 -9
- package/dist/cjs/ui/MediaInsertContent.js +12 -6
- package/dist/cjs/ui/MediaInsertPicker.js +12 -4
- package/dist/es2019/index.js +1 -2
- package/dist/es2019/ui/FromURL.js +45 -6
- 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 +57 -23
- package/dist/esm/ui/MediaCard.js +1 -9
- package/dist/esm/ui/MediaInsertContent.js +12 -6
- package/dist/esm/ui/MediaInsertPicker.js +12 -4
- package/dist/types/index.d.ts +0 -1
- package/dist/types/types.d.ts +4 -1
- package/dist/types/ui/FromURL.d.ts +4 -3
- 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 +4 -3
- 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,28 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-media-insert
|
|
2
2
|
|
|
3
|
+
## 2.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#130061](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/130061)
|
|
8
|
+
[`bdad694cb2c24`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/bdad694cb2c24) -
|
|
9
|
+
[ux] [ED-24566] **@atlaskit/editor-plugin-media-insert**: When user clicks "Cancel" button on
|
|
10
|
+
insert media popup the focus is returned to the editor **@atlaskit/editor-common**: Added event
|
|
11
|
+
type for media insert cancelled analytics
|
|
12
|
+
|
|
13
|
+
## 2.0.0
|
|
14
|
+
|
|
15
|
+
### Major Changes
|
|
16
|
+
|
|
17
|
+
- [#129869](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/129869)
|
|
18
|
+
[`48b31a6b8fb5a`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/48b31a6b8fb5a) -
|
|
19
|
+
[ux] [ED-24566] Integrated Media URL UI into the Insert Media Popup [ED-24589] Removed export of
|
|
20
|
+
UI component from `editor-plugin-media-insert`
|
|
21
|
+
|
|
22
|
+
### Patch Changes
|
|
23
|
+
|
|
24
|
+
- Updated dependencies
|
|
25
|
+
|
|
3
26
|
## 1.3.0
|
|
4
27
|
|
|
5
28
|
### 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
|
@@ -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");
|
|
@@ -36,6 +37,9 @@ var PreviewImageStyles = (0, _primitives.xcss)({
|
|
|
36
37
|
var ButtonGroupStyles = (0, _primitives.xcss)({
|
|
37
38
|
alignSelf: 'end'
|
|
38
39
|
});
|
|
40
|
+
var FormStyles = (0, _primitives.xcss)({
|
|
41
|
+
flexGrow: 1
|
|
42
|
+
});
|
|
39
43
|
var INITIAL_PREVIEW_STATE = Object.freeze({
|
|
40
44
|
isLoading: false,
|
|
41
45
|
error: null,
|
|
@@ -77,7 +81,8 @@ function MediaFromURL(_ref) {
|
|
|
77
81
|
var mediaProvider = _ref.mediaProvider,
|
|
78
82
|
onInsert = _ref.onInsert,
|
|
79
83
|
onExternalInsert = _ref.onExternalInsert,
|
|
80
|
-
dispatchAnalyticsEvent = _ref.dispatchAnalyticsEvent
|
|
84
|
+
dispatchAnalyticsEvent = _ref.dispatchAnalyticsEvent,
|
|
85
|
+
closeMediaInsertPicker = _ref.closeMediaInsertPicker;
|
|
81
86
|
var intl = (0, _reactIntlNext.useIntl)();
|
|
82
87
|
var strings = {
|
|
83
88
|
loadPreview: intl.formatMessage(_messages.mediaInsertMessages.loadPreview),
|
|
@@ -102,32 +107,27 @@ function MediaFromURL(_ref) {
|
|
|
102
107
|
onUploadFailureAnalytics = _useAnalyticsEvents.onUploadFailureAnalytics;
|
|
103
108
|
var uploadExternalMedia = _react.default.useCallback( /*#__PURE__*/function () {
|
|
104
109
|
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(url) {
|
|
105
|
-
var
|
|
110
|
+
var uploadMediaClientConfig, uploadParams, mediaClient, collection, _yield$mediaClient$fi, uploadableFileUpfrontIds, dimensions, message;
|
|
106
111
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
107
112
|
while (1) switch (_context.prev = _context.next) {
|
|
108
113
|
case 0:
|
|
109
114
|
dispatch({
|
|
110
115
|
type: 'loading'
|
|
111
116
|
});
|
|
112
|
-
|
|
113
|
-
return mediaProvider;
|
|
114
|
-
case 3:
|
|
115
|
-
_yield$mediaProvider = _context.sent;
|
|
116
|
-
uploadMediaClientConfig = _yield$mediaProvider.uploadMediaClientConfig;
|
|
117
|
-
uploadParams = _yield$mediaProvider.uploadParams;
|
|
117
|
+
uploadMediaClientConfig = mediaProvider.uploadMediaClientConfig, uploadParams = mediaProvider.uploadParams;
|
|
118
118
|
if (uploadMediaClientConfig) {
|
|
119
|
-
_context.next =
|
|
119
|
+
_context.next = 4;
|
|
120
120
|
break;
|
|
121
121
|
}
|
|
122
122
|
return _context.abrupt("return");
|
|
123
|
-
case
|
|
123
|
+
case 4:
|
|
124
124
|
mediaClient = (0, _mediaClientReact.getMediaClient)(uploadMediaClientConfig);
|
|
125
125
|
collection = uploadParams === null || uploadParams === void 0 ? void 0 : uploadParams.collection;
|
|
126
126
|
onUploadAnalytics();
|
|
127
|
-
_context.prev =
|
|
128
|
-
_context.next =
|
|
127
|
+
_context.prev = 7;
|
|
128
|
+
_context.next = 10;
|
|
129
129
|
return mediaClient.file.uploadExternal(url, collection);
|
|
130
|
-
case
|
|
130
|
+
case 10:
|
|
131
131
|
_yield$mediaClient$fi = _context.sent;
|
|
132
132
|
uploadableFileUpfrontIds = _yield$mediaClient$fi.uploadableFileUpfrontIds;
|
|
133
133
|
dimensions = _yield$mediaClient$fi.dimensions;
|
|
@@ -142,11 +142,11 @@ function MediaFromURL(_ref) {
|
|
|
142
142
|
occurrenceKey: uploadableFileUpfrontIds.occurrenceKey
|
|
143
143
|
}
|
|
144
144
|
});
|
|
145
|
-
_context.next =
|
|
145
|
+
_context.next = 20;
|
|
146
146
|
break;
|
|
147
|
-
case
|
|
148
|
-
_context.prev =
|
|
149
|
-
_context.t0 = _context["catch"](
|
|
147
|
+
case 17:
|
|
148
|
+
_context.prev = 17;
|
|
149
|
+
_context.t0 = _context["catch"](7);
|
|
150
150
|
if (typeof _context.t0 === 'string' && _context.t0 === 'Could not download remote file') {
|
|
151
151
|
// TODO: Make sure this gets good unit test coverage with the actual
|
|
152
152
|
// media plugin. This hard coded error message could be changed at any
|
|
@@ -171,11 +171,11 @@ function MediaFromURL(_ref) {
|
|
|
171
171
|
error: 'Unknown error'
|
|
172
172
|
});
|
|
173
173
|
}
|
|
174
|
-
case
|
|
174
|
+
case 20:
|
|
175
175
|
case "end":
|
|
176
176
|
return _context.stop();
|
|
177
177
|
}
|
|
178
|
-
}, _callee, null, [[
|
|
178
|
+
}, _callee, null, [[7, 17]]);
|
|
179
179
|
}));
|
|
180
180
|
return function (_x) {
|
|
181
181
|
return _ref2.apply(this, arguments);
|
|
@@ -211,18 +211,51 @@ function MediaFromURL(_ref) {
|
|
|
211
211
|
return onExternalInsert(inputUrl);
|
|
212
212
|
}
|
|
213
213
|
}, [onExternalInsert, onInsert, previewState.previewInfo, previewState.warning, inputUrl]);
|
|
214
|
-
|
|
214
|
+
var onInputKeyPress = _react.default.useCallback(function (event) {
|
|
215
|
+
if (event && event.key === 'Esc') {
|
|
216
|
+
if (dispatchAnalyticsEvent) {
|
|
217
|
+
var payload = {
|
|
218
|
+
action: _analytics.ACTION.CLOSED,
|
|
219
|
+
actionSubject: _analytics.ACTION_SUBJECT.PICKER,
|
|
220
|
+
actionSubjectId: _analytics.ACTION_SUBJECT_ID.PICKER_MEDIA,
|
|
221
|
+
eventType: _analytics.EVENT_TYPE.UI,
|
|
222
|
+
attributes: {
|
|
223
|
+
exitMethod: _analytics.INPUT_METHOD.KEYBOARD
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
dispatchAnalyticsEvent(payload);
|
|
227
|
+
}
|
|
228
|
+
closeMediaInsertPicker();
|
|
229
|
+
}
|
|
230
|
+
}, [dispatchAnalyticsEvent, closeMediaInsertPicker]);
|
|
231
|
+
var onCancel = _react.default.useCallback(function () {
|
|
232
|
+
if (dispatchAnalyticsEvent) {
|
|
233
|
+
var payload = {
|
|
234
|
+
action: _analytics.ACTION.CANCELLED,
|
|
235
|
+
actionSubject: _analytics.ACTION_SUBJECT.PICKER,
|
|
236
|
+
actionSubjectId: _analytics.ACTION_SUBJECT_ID.PICKER_MEDIA,
|
|
237
|
+
eventType: _analytics.EVENT_TYPE.UI
|
|
238
|
+
};
|
|
239
|
+
dispatchAnalyticsEvent(payload);
|
|
240
|
+
}
|
|
241
|
+
closeMediaInsertPicker();
|
|
242
|
+
}, [closeMediaInsertPicker, dispatchAnalyticsEvent]);
|
|
243
|
+
return /*#__PURE__*/_react.default.createElement(_primitives.Box, {
|
|
244
|
+
as: "form",
|
|
215
245
|
onSubmit: function onSubmit(e) {
|
|
216
246
|
e.preventDefault();
|
|
217
247
|
uploadExternalMedia(inputUrl);
|
|
218
|
-
}
|
|
248
|
+
},
|
|
249
|
+
xcss: FormStyles
|
|
219
250
|
}, /*#__PURE__*/_react.default.createElement(_primitives.Stack, {
|
|
220
|
-
space: "space.150"
|
|
251
|
+
space: "space.150",
|
|
252
|
+
grow: "fill"
|
|
221
253
|
}, /*#__PURE__*/_react.default.createElement(_textfield.default, {
|
|
222
254
|
autoFocus: true,
|
|
223
255
|
value: inputUrl,
|
|
224
256
|
placeholder: strings.pasteLinkToUpload,
|
|
225
257
|
onChange: onURLChange,
|
|
258
|
+
onKeyPress: onInputKeyPress,
|
|
226
259
|
onPaste: onPaste
|
|
227
260
|
}), previewState.previewInfo && /*#__PURE__*/_react.default.createElement(_primitives.Inline, {
|
|
228
261
|
alignInline: "center",
|
|
@@ -248,7 +281,8 @@ function MediaFromURL(_ref) {
|
|
|
248
281
|
}, strings.loadPreview)), /*#__PURE__*/_react.default.createElement(_primitives.Box, {
|
|
249
282
|
xcss: ButtonGroupStyles
|
|
250
283
|
}, /*#__PURE__*/_react.default.createElement(_buttonGroup.default, null, /*#__PURE__*/_react.default.createElement(_new.default, {
|
|
251
|
-
appearance: "subtle"
|
|
284
|
+
appearance: "subtle",
|
|
285
|
+
onClick: onCancel
|
|
252
286
|
}, strings.cancel), /*#__PURE__*/_react.default.createElement(_new.default, {
|
|
253
287
|
appearance: "primary",
|
|
254
288
|
isDisabled: !previewState.previewInfo && !previewState.warning,
|
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
|
+
closeMediaInsertPicker = _ref.closeMediaInsertPicker;
|
|
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
|
+
closeMediaInsertPicker: closeMediaInsertPicker
|
|
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,18 @@ 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
|
+
closeMediaInsertPicker: closeMediaInsertPicker
|
|
93
|
+
})));
|
|
86
94
|
};
|
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';
|
|
@@ -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';
|
|
@@ -23,6 +24,9 @@ const PreviewImageStyles = xcss({
|
|
|
23
24
|
const ButtonGroupStyles = xcss({
|
|
24
25
|
alignSelf: 'end'
|
|
25
26
|
});
|
|
27
|
+
const FormStyles = xcss({
|
|
28
|
+
flexGrow: 1
|
|
29
|
+
});
|
|
26
30
|
const INITIAL_PREVIEW_STATE = Object.freeze({
|
|
27
31
|
isLoading: false,
|
|
28
32
|
error: null,
|
|
@@ -68,7 +72,8 @@ export function MediaFromURL({
|
|
|
68
72
|
mediaProvider,
|
|
69
73
|
onInsert,
|
|
70
74
|
onExternalInsert,
|
|
71
|
-
dispatchAnalyticsEvent
|
|
75
|
+
dispatchAnalyticsEvent,
|
|
76
|
+
closeMediaInsertPicker
|
|
72
77
|
}) {
|
|
73
78
|
const intl = useIntl();
|
|
74
79
|
const strings = {
|
|
@@ -94,7 +99,7 @@ export function MediaFromURL({
|
|
|
94
99
|
const {
|
|
95
100
|
uploadMediaClientConfig,
|
|
96
101
|
uploadParams
|
|
97
|
-
} =
|
|
102
|
+
} = mediaProvider;
|
|
98
103
|
if (!uploadMediaClientConfig) {
|
|
99
104
|
return;
|
|
100
105
|
}
|
|
@@ -174,18 +179,51 @@ export function MediaFromURL({
|
|
|
174
179
|
return onExternalInsert(inputUrl);
|
|
175
180
|
}
|
|
176
181
|
}, [onExternalInsert, onInsert, previewState.previewInfo, previewState.warning, inputUrl]);
|
|
177
|
-
|
|
182
|
+
const onInputKeyPress = React.useCallback(event => {
|
|
183
|
+
if (event && event.key === 'Esc') {
|
|
184
|
+
if (dispatchAnalyticsEvent) {
|
|
185
|
+
const payload = {
|
|
186
|
+
action: ACTION.CLOSED,
|
|
187
|
+
actionSubject: ACTION_SUBJECT.PICKER,
|
|
188
|
+
actionSubjectId: ACTION_SUBJECT_ID.PICKER_MEDIA,
|
|
189
|
+
eventType: EVENT_TYPE.UI,
|
|
190
|
+
attributes: {
|
|
191
|
+
exitMethod: INPUT_METHOD.KEYBOARD
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
dispatchAnalyticsEvent(payload);
|
|
195
|
+
}
|
|
196
|
+
closeMediaInsertPicker();
|
|
197
|
+
}
|
|
198
|
+
}, [dispatchAnalyticsEvent, closeMediaInsertPicker]);
|
|
199
|
+
const onCancel = React.useCallback(() => {
|
|
200
|
+
if (dispatchAnalyticsEvent) {
|
|
201
|
+
const payload = {
|
|
202
|
+
action: ACTION.CANCELLED,
|
|
203
|
+
actionSubject: ACTION_SUBJECT.PICKER,
|
|
204
|
+
actionSubjectId: ACTION_SUBJECT_ID.PICKER_MEDIA,
|
|
205
|
+
eventType: EVENT_TYPE.UI
|
|
206
|
+
};
|
|
207
|
+
dispatchAnalyticsEvent(payload);
|
|
208
|
+
}
|
|
209
|
+
closeMediaInsertPicker();
|
|
210
|
+
}, [closeMediaInsertPicker, dispatchAnalyticsEvent]);
|
|
211
|
+
return /*#__PURE__*/React.createElement(Box, {
|
|
212
|
+
as: "form",
|
|
178
213
|
onSubmit: e => {
|
|
179
214
|
e.preventDefault();
|
|
180
215
|
uploadExternalMedia(inputUrl);
|
|
181
|
-
}
|
|
216
|
+
},
|
|
217
|
+
xcss: FormStyles
|
|
182
218
|
}, /*#__PURE__*/React.createElement(Stack, {
|
|
183
|
-
space: "space.150"
|
|
219
|
+
space: "space.150",
|
|
220
|
+
grow: "fill"
|
|
184
221
|
}, /*#__PURE__*/React.createElement(TextField, {
|
|
185
222
|
autoFocus: true,
|
|
186
223
|
value: inputUrl,
|
|
187
224
|
placeholder: strings.pasteLinkToUpload,
|
|
188
225
|
onChange: onURLChange,
|
|
226
|
+
onKeyPress: onInputKeyPress,
|
|
189
227
|
onPaste: onPaste
|
|
190
228
|
}), previewState.previewInfo && /*#__PURE__*/React.createElement(Inline, {
|
|
191
229
|
alignInline: "center",
|
|
@@ -211,7 +249,8 @@ export function MediaFromURL({
|
|
|
211
249
|
}, strings.loadPreview)), /*#__PURE__*/React.createElement(Box, {
|
|
212
250
|
xcss: ButtonGroupStyles
|
|
213
251
|
}, /*#__PURE__*/React.createElement(ButtonGroup, null, /*#__PURE__*/React.createElement(Button, {
|
|
214
|
-
appearance: "subtle"
|
|
252
|
+
appearance: "subtle",
|
|
253
|
+
onClick: onCancel
|
|
215
254
|
}, strings.cancel), /*#__PURE__*/React.createElement(Button, {
|
|
216
255
|
appearance: "primary",
|
|
217
256
|
isDisabled: !previewState.previewInfo && !previewState.warning,
|
|
@@ -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
|
+
closeMediaInsertPicker
|
|
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
|
+
closeMediaInsertPicker: closeMediaInsertPicker
|
|
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
|
+
closeMediaInsertPicker: closeMediaInsertPicker
|
|
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
|
@@ -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';
|
|
@@ -29,6 +30,9 @@ var PreviewImageStyles = xcss({
|
|
|
29
30
|
var ButtonGroupStyles = xcss({
|
|
30
31
|
alignSelf: 'end'
|
|
31
32
|
});
|
|
33
|
+
var FormStyles = xcss({
|
|
34
|
+
flexGrow: 1
|
|
35
|
+
});
|
|
32
36
|
var INITIAL_PREVIEW_STATE = Object.freeze({
|
|
33
37
|
isLoading: false,
|
|
34
38
|
error: null,
|
|
@@ -70,7 +74,8 @@ export function MediaFromURL(_ref) {
|
|
|
70
74
|
var mediaProvider = _ref.mediaProvider,
|
|
71
75
|
onInsert = _ref.onInsert,
|
|
72
76
|
onExternalInsert = _ref.onExternalInsert,
|
|
73
|
-
dispatchAnalyticsEvent = _ref.dispatchAnalyticsEvent
|
|
77
|
+
dispatchAnalyticsEvent = _ref.dispatchAnalyticsEvent,
|
|
78
|
+
closeMediaInsertPicker = _ref.closeMediaInsertPicker;
|
|
74
79
|
var intl = useIntl();
|
|
75
80
|
var strings = {
|
|
76
81
|
loadPreview: intl.formatMessage(mediaInsertMessages.loadPreview),
|
|
@@ -95,32 +100,27 @@ export function MediaFromURL(_ref) {
|
|
|
95
100
|
onUploadFailureAnalytics = _useAnalyticsEvents.onUploadFailureAnalytics;
|
|
96
101
|
var uploadExternalMedia = React.useCallback( /*#__PURE__*/function () {
|
|
97
102
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(url) {
|
|
98
|
-
var
|
|
103
|
+
var uploadMediaClientConfig, uploadParams, mediaClient, collection, _yield$mediaClient$fi, uploadableFileUpfrontIds, dimensions, message;
|
|
99
104
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
100
105
|
while (1) switch (_context.prev = _context.next) {
|
|
101
106
|
case 0:
|
|
102
107
|
dispatch({
|
|
103
108
|
type: 'loading'
|
|
104
109
|
});
|
|
105
|
-
|
|
106
|
-
return mediaProvider;
|
|
107
|
-
case 3:
|
|
108
|
-
_yield$mediaProvider = _context.sent;
|
|
109
|
-
uploadMediaClientConfig = _yield$mediaProvider.uploadMediaClientConfig;
|
|
110
|
-
uploadParams = _yield$mediaProvider.uploadParams;
|
|
110
|
+
uploadMediaClientConfig = mediaProvider.uploadMediaClientConfig, uploadParams = mediaProvider.uploadParams;
|
|
111
111
|
if (uploadMediaClientConfig) {
|
|
112
|
-
_context.next =
|
|
112
|
+
_context.next = 4;
|
|
113
113
|
break;
|
|
114
114
|
}
|
|
115
115
|
return _context.abrupt("return");
|
|
116
|
-
case
|
|
116
|
+
case 4:
|
|
117
117
|
mediaClient = getMediaClient(uploadMediaClientConfig);
|
|
118
118
|
collection = uploadParams === null || uploadParams === void 0 ? void 0 : uploadParams.collection;
|
|
119
119
|
onUploadAnalytics();
|
|
120
|
-
_context.prev =
|
|
121
|
-
_context.next =
|
|
120
|
+
_context.prev = 7;
|
|
121
|
+
_context.next = 10;
|
|
122
122
|
return mediaClient.file.uploadExternal(url, collection);
|
|
123
|
-
case
|
|
123
|
+
case 10:
|
|
124
124
|
_yield$mediaClient$fi = _context.sent;
|
|
125
125
|
uploadableFileUpfrontIds = _yield$mediaClient$fi.uploadableFileUpfrontIds;
|
|
126
126
|
dimensions = _yield$mediaClient$fi.dimensions;
|
|
@@ -135,11 +135,11 @@ export function MediaFromURL(_ref) {
|
|
|
135
135
|
occurrenceKey: uploadableFileUpfrontIds.occurrenceKey
|
|
136
136
|
}
|
|
137
137
|
});
|
|
138
|
-
_context.next =
|
|
138
|
+
_context.next = 20;
|
|
139
139
|
break;
|
|
140
|
-
case
|
|
141
|
-
_context.prev =
|
|
142
|
-
_context.t0 = _context["catch"](
|
|
140
|
+
case 17:
|
|
141
|
+
_context.prev = 17;
|
|
142
|
+
_context.t0 = _context["catch"](7);
|
|
143
143
|
if (typeof _context.t0 === 'string' && _context.t0 === 'Could not download remote file') {
|
|
144
144
|
// TODO: Make sure this gets good unit test coverage with the actual
|
|
145
145
|
// media plugin. This hard coded error message could be changed at any
|
|
@@ -164,11 +164,11 @@ export function MediaFromURL(_ref) {
|
|
|
164
164
|
error: 'Unknown error'
|
|
165
165
|
});
|
|
166
166
|
}
|
|
167
|
-
case
|
|
167
|
+
case 20:
|
|
168
168
|
case "end":
|
|
169
169
|
return _context.stop();
|
|
170
170
|
}
|
|
171
|
-
}, _callee, null, [[
|
|
171
|
+
}, _callee, null, [[7, 17]]);
|
|
172
172
|
}));
|
|
173
173
|
return function (_x) {
|
|
174
174
|
return _ref2.apply(this, arguments);
|
|
@@ -204,18 +204,51 @@ export function MediaFromURL(_ref) {
|
|
|
204
204
|
return onExternalInsert(inputUrl);
|
|
205
205
|
}
|
|
206
206
|
}, [onExternalInsert, onInsert, previewState.previewInfo, previewState.warning, inputUrl]);
|
|
207
|
-
|
|
207
|
+
var onInputKeyPress = React.useCallback(function (event) {
|
|
208
|
+
if (event && event.key === 'Esc') {
|
|
209
|
+
if (dispatchAnalyticsEvent) {
|
|
210
|
+
var payload = {
|
|
211
|
+
action: ACTION.CLOSED,
|
|
212
|
+
actionSubject: ACTION_SUBJECT.PICKER,
|
|
213
|
+
actionSubjectId: ACTION_SUBJECT_ID.PICKER_MEDIA,
|
|
214
|
+
eventType: EVENT_TYPE.UI,
|
|
215
|
+
attributes: {
|
|
216
|
+
exitMethod: INPUT_METHOD.KEYBOARD
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
dispatchAnalyticsEvent(payload);
|
|
220
|
+
}
|
|
221
|
+
closeMediaInsertPicker();
|
|
222
|
+
}
|
|
223
|
+
}, [dispatchAnalyticsEvent, closeMediaInsertPicker]);
|
|
224
|
+
var onCancel = React.useCallback(function () {
|
|
225
|
+
if (dispatchAnalyticsEvent) {
|
|
226
|
+
var payload = {
|
|
227
|
+
action: ACTION.CANCELLED,
|
|
228
|
+
actionSubject: ACTION_SUBJECT.PICKER,
|
|
229
|
+
actionSubjectId: ACTION_SUBJECT_ID.PICKER_MEDIA,
|
|
230
|
+
eventType: EVENT_TYPE.UI
|
|
231
|
+
};
|
|
232
|
+
dispatchAnalyticsEvent(payload);
|
|
233
|
+
}
|
|
234
|
+
closeMediaInsertPicker();
|
|
235
|
+
}, [closeMediaInsertPicker, dispatchAnalyticsEvent]);
|
|
236
|
+
return /*#__PURE__*/React.createElement(Box, {
|
|
237
|
+
as: "form",
|
|
208
238
|
onSubmit: function onSubmit(e) {
|
|
209
239
|
e.preventDefault();
|
|
210
240
|
uploadExternalMedia(inputUrl);
|
|
211
|
-
}
|
|
241
|
+
},
|
|
242
|
+
xcss: FormStyles
|
|
212
243
|
}, /*#__PURE__*/React.createElement(Stack, {
|
|
213
|
-
space: "space.150"
|
|
244
|
+
space: "space.150",
|
|
245
|
+
grow: "fill"
|
|
214
246
|
}, /*#__PURE__*/React.createElement(TextField, {
|
|
215
247
|
autoFocus: true,
|
|
216
248
|
value: inputUrl,
|
|
217
249
|
placeholder: strings.pasteLinkToUpload,
|
|
218
250
|
onChange: onURLChange,
|
|
251
|
+
onKeyPress: onInputKeyPress,
|
|
219
252
|
onPaste: onPaste
|
|
220
253
|
}), previewState.previewInfo && /*#__PURE__*/React.createElement(Inline, {
|
|
221
254
|
alignInline: "center",
|
|
@@ -241,7 +274,8 @@ export function MediaFromURL(_ref) {
|
|
|
241
274
|
}, strings.loadPreview)), /*#__PURE__*/React.createElement(Box, {
|
|
242
275
|
xcss: ButtonGroupStyles
|
|
243
276
|
}, /*#__PURE__*/React.createElement(ButtonGroup, null, /*#__PURE__*/React.createElement(Button, {
|
|
244
|
-
appearance: "subtle"
|
|
277
|
+
appearance: "subtle",
|
|
278
|
+
onClick: onCancel
|
|
245
279
|
}, strings.cancel), /*#__PURE__*/React.createElement(Button, {
|
|
246
280
|
appearance: "primary",
|
|
247
281
|
isDisabled: !previewState.previewInfo && !previewState.warning,
|
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
|
+
closeMediaInsertPicker = _ref.closeMediaInsertPicker;
|
|
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
|
+
closeMediaInsertPicker: closeMediaInsertPicker
|
|
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,18 @@ 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
|
+
closeMediaInsertPicker: closeMediaInsertPicker
|
|
86
|
+
})));
|
|
79
87
|
};
|
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
|
};
|
|
@@ -1,12 +1,13 @@
|
|
|
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 = {
|
|
6
|
-
mediaProvider:
|
|
6
|
+
mediaProvider: MediaProvider;
|
|
7
7
|
onInsert: (attrs: OnInsertAttrs) => void;
|
|
8
8
|
onExternalInsert: (url: string) => void;
|
|
9
9
|
dispatchAnalyticsEvent?: DispatchAnalyticsEvent;
|
|
10
|
+
closeMediaInsertPicker: () => void;
|
|
10
11
|
};
|
|
11
|
-
export declare function MediaFromURL({ mediaProvider, onInsert, onExternalInsert, dispatchAnalyticsEvent, }: Props): JSX.Element;
|
|
12
|
+
export declare function MediaFromURL({ mediaProvider, onInsert, onExternalInsert, dispatchAnalyticsEvent, closeMediaInsertPicker, }: 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, closeMediaInsertPicker, }: {
|
|
5
|
+
mediaProvider: MediaProvider;
|
|
6
|
+
dispatchAnalyticsEvent?: DispatchAnalyticsEvent | undefined;
|
|
7
|
+
closeMediaInsertPicker: () => 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
|
};
|
|
@@ -1,12 +1,13 @@
|
|
|
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 = {
|
|
6
|
-
mediaProvider:
|
|
6
|
+
mediaProvider: MediaProvider;
|
|
7
7
|
onInsert: (attrs: OnInsertAttrs) => void;
|
|
8
8
|
onExternalInsert: (url: string) => void;
|
|
9
9
|
dispatchAnalyticsEvent?: DispatchAnalyticsEvent;
|
|
10
|
+
closeMediaInsertPicker: () => void;
|
|
10
11
|
};
|
|
11
|
-
export declare function MediaFromURL({ mediaProvider, onInsert, onExternalInsert, dispatchAnalyticsEvent, }: Props): JSX.Element;
|
|
12
|
+
export declare function MediaFromURL({ mediaProvider, onInsert, onExternalInsert, dispatchAnalyticsEvent, closeMediaInsertPicker, }: 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, closeMediaInsertPicker, }: {
|
|
5
|
+
mediaProvider: MediaProvider;
|
|
6
|
+
dispatchAnalyticsEvent?: DispatchAnalyticsEvent | undefined;
|
|
7
|
+
closeMediaInsertPicker: () => 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.1",
|
|
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",
|