@atlaskit/editor-plugin-media-insert 1.2.1 → 1.3.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 +21 -0
- package/dist/cjs/actions.js +28 -0
- package/dist/cjs/plugin.js +57 -10
- package/dist/cjs/pm-plugins/main.js +40 -0
- package/dist/cjs/pm-plugins/plugin-key.js +8 -0
- package/dist/cjs/types.js +5 -0
- package/dist/cjs/ui/FromURL.js +108 -85
- package/dist/cjs/ui/MediaInsertContent.js +24 -0
- package/dist/cjs/ui/MediaInsertPicker.js +86 -0
- package/dist/cjs/ui/MediaInsertWrapper.js +21 -0
- package/dist/es2019/actions.js +21 -0
- package/dist/es2019/plugin.js +62 -12
- package/dist/es2019/pm-plugins/main.js +34 -0
- package/dist/es2019/pm-plugins/plugin-key.js +2 -0
- package/dist/es2019/types.js +1 -0
- package/dist/es2019/ui/FromURL.js +34 -16
- package/dist/es2019/ui/MediaInsertContent.js +14 -0
- package/dist/es2019/ui/MediaInsertPicker.js +79 -0
- package/dist/es2019/ui/MediaInsertWrapper.js +15 -0
- package/dist/esm/actions.js +22 -0
- package/dist/esm/plugin.js +57 -10
- package/dist/esm/pm-plugins/main.js +34 -0
- package/dist/esm/pm-plugins/plugin-key.js +2 -0
- package/dist/esm/types.js +1 -0
- package/dist/esm/ui/FromURL.js +108 -85
- package/dist/esm/ui/MediaInsertContent.js +14 -0
- package/dist/esm/ui/MediaInsertPicker.js +79 -0
- package/dist/esm/ui/MediaInsertWrapper.js +14 -0
- package/dist/types/actions.d.ts +6 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/plugin.d.ts +1 -2
- package/dist/types/pm-plugins/main.d.ts +3 -0
- package/dist/types/pm-plugins/plugin-key.d.ts +3 -0
- package/dist/types/types.d.ts +14 -0
- package/dist/types/ui/MediaInsertContent.d.ts +2 -0
- package/dist/types/ui/MediaInsertPicker.d.ts +3 -0
- package/dist/types/ui/MediaInsertWrapper.d.ts +4 -0
- package/dist/types-ts4.5/actions.d.ts +6 -0
- package/dist/types-ts4.5/index.d.ts +1 -1
- package/dist/types-ts4.5/plugin.d.ts +1 -2
- package/dist/types-ts4.5/pm-plugins/main.d.ts +3 -0
- package/dist/types-ts4.5/pm-plugins/plugin-key.d.ts +3 -0
- package/dist/types-ts4.5/types.d.ts +16 -0
- package/dist/types-ts4.5/ui/MediaInsertContent.d.ts +2 -0
- package/dist/types-ts4.5/ui/MediaInsertPicker.d.ts +3 -0
- package/dist/types-ts4.5/ui/MediaInsertWrapper.d.ts +4 -0
- package/package.json +11 -7
package/dist/esm/ui/FromURL.js
CHANGED
|
@@ -82,118 +82,141 @@ export function MediaFromURL(_ref) {
|
|
|
82
82
|
};
|
|
83
83
|
var _React$useState = React.useState(placeholders[1]),
|
|
84
84
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
85
|
-
|
|
85
|
+
inputUrl = _React$useState2[0],
|
|
86
86
|
setUrl = _React$useState2[1];
|
|
87
87
|
var _React$useReducer = React.useReducer(previewStateReducer, INITIAL_PREVIEW_STATE),
|
|
88
88
|
_React$useReducer2 = _slicedToArray(_React$useReducer, 2),
|
|
89
89
|
previewState = _React$useReducer2[0],
|
|
90
90
|
dispatch = _React$useReducer2[1];
|
|
91
|
+
var pasteFlag = React.useRef(false);
|
|
91
92
|
var _useAnalyticsEvents = useAnalyticsEvents(dispatchAnalyticsEvent),
|
|
92
93
|
onUploadAnalytics = _useAnalyticsEvents.onUploadAnalytics,
|
|
93
94
|
onUploadSuccessAnalytics = _useAnalyticsEvents.onUploadSuccessAnalytics,
|
|
94
95
|
onUploadFailureAnalytics = _useAnalyticsEvents.onUploadFailureAnalytics;
|
|
95
|
-
var
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
var uploadExternalMedia = React.useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
102
|
-
var _yield$mediaProvider, uploadMediaClientConfig, uploadParams, mediaClient, collection, _yield$mediaClient$fi, uploadableFileUpfrontIds, dimensions, message;
|
|
103
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
104
|
-
while (1) switch (_context.prev = _context.next) {
|
|
105
|
-
case 0:
|
|
106
|
-
dispatch({
|
|
107
|
-
type: 'loading'
|
|
108
|
-
});
|
|
109
|
-
_context.next = 3;
|
|
110
|
-
return mediaProvider;
|
|
111
|
-
case 3:
|
|
112
|
-
_yield$mediaProvider = _context.sent;
|
|
113
|
-
uploadMediaClientConfig = _yield$mediaProvider.uploadMediaClientConfig;
|
|
114
|
-
uploadParams = _yield$mediaProvider.uploadParams;
|
|
115
|
-
if (uploadMediaClientConfig) {
|
|
116
|
-
_context.next = 8;
|
|
117
|
-
break;
|
|
118
|
-
}
|
|
119
|
-
return _context.abrupt("return");
|
|
120
|
-
case 8:
|
|
121
|
-
mediaClient = getMediaClient(uploadMediaClientConfig);
|
|
122
|
-
collection = uploadParams === null || uploadParams === void 0 ? void 0 : uploadParams.collection;
|
|
123
|
-
onUploadAnalytics();
|
|
124
|
-
_context.prev = 11;
|
|
125
|
-
_context.next = 14;
|
|
126
|
-
return mediaClient.file.uploadExternal(url, collection);
|
|
127
|
-
case 14:
|
|
128
|
-
_yield$mediaClient$fi = _context.sent;
|
|
129
|
-
uploadableFileUpfrontIds = _yield$mediaClient$fi.uploadableFileUpfrontIds;
|
|
130
|
-
dimensions = _yield$mediaClient$fi.dimensions;
|
|
131
|
-
onUploadSuccessAnalytics();
|
|
132
|
-
dispatch({
|
|
133
|
-
type: 'success',
|
|
134
|
-
payload: {
|
|
135
|
-
id: uploadableFileUpfrontIds.id,
|
|
136
|
-
collection: collection,
|
|
137
|
-
height: dimensions.height,
|
|
138
|
-
width: dimensions.width,
|
|
139
|
-
occurrenceKey: uploadableFileUpfrontIds.occurrenceKey
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
_context.next = 24;
|
|
143
|
-
break;
|
|
144
|
-
case 21:
|
|
145
|
-
_context.prev = 21;
|
|
146
|
-
_context.t0 = _context["catch"](11);
|
|
147
|
-
if (typeof _context.t0 === 'string' && _context.t0 === 'Could not download remote file') {
|
|
148
|
-
// TODO: Make sure this gets good unit test coverage with the actual
|
|
149
|
-
// media plugin. This hard coded error message could be changed at any
|
|
150
|
-
// point and we need a unit test to break to stop people changing it.
|
|
151
|
-
onUploadFailureAnalytics(_context.t0);
|
|
152
|
-
dispatch({
|
|
153
|
-
type: 'warning',
|
|
154
|
-
warning: _context.t0,
|
|
155
|
-
url: url
|
|
156
|
-
});
|
|
157
|
-
} else if (_context.t0 instanceof Error) {
|
|
158
|
-
message = 'Image preview fetch failed';
|
|
159
|
-
onUploadFailureAnalytics(message);
|
|
96
|
+
var uploadExternalMedia = React.useCallback( /*#__PURE__*/function () {
|
|
97
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(url) {
|
|
98
|
+
var _yield$mediaProvider, uploadMediaClientConfig, uploadParams, mediaClient, collection, _yield$mediaClient$fi, uploadableFileUpfrontIds, dimensions, message;
|
|
99
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
100
|
+
while (1) switch (_context.prev = _context.next) {
|
|
101
|
+
case 0:
|
|
160
102
|
dispatch({
|
|
161
|
-
type: '
|
|
162
|
-
error: message
|
|
103
|
+
type: 'loading'
|
|
163
104
|
});
|
|
164
|
-
|
|
165
|
-
|
|
105
|
+
_context.next = 3;
|
|
106
|
+
return mediaProvider;
|
|
107
|
+
case 3:
|
|
108
|
+
_yield$mediaProvider = _context.sent;
|
|
109
|
+
uploadMediaClientConfig = _yield$mediaProvider.uploadMediaClientConfig;
|
|
110
|
+
uploadParams = _yield$mediaProvider.uploadParams;
|
|
111
|
+
if (uploadMediaClientConfig) {
|
|
112
|
+
_context.next = 8;
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
return _context.abrupt("return");
|
|
116
|
+
case 8:
|
|
117
|
+
mediaClient = getMediaClient(uploadMediaClientConfig);
|
|
118
|
+
collection = uploadParams === null || uploadParams === void 0 ? void 0 : uploadParams.collection;
|
|
119
|
+
onUploadAnalytics();
|
|
120
|
+
_context.prev = 11;
|
|
121
|
+
_context.next = 14;
|
|
122
|
+
return mediaClient.file.uploadExternal(url, collection);
|
|
123
|
+
case 14:
|
|
124
|
+
_yield$mediaClient$fi = _context.sent;
|
|
125
|
+
uploadableFileUpfrontIds = _yield$mediaClient$fi.uploadableFileUpfrontIds;
|
|
126
|
+
dimensions = _yield$mediaClient$fi.dimensions;
|
|
127
|
+
onUploadSuccessAnalytics();
|
|
166
128
|
dispatch({
|
|
167
|
-
type: '
|
|
168
|
-
|
|
129
|
+
type: 'success',
|
|
130
|
+
payload: {
|
|
131
|
+
id: uploadableFileUpfrontIds.id,
|
|
132
|
+
collection: collection,
|
|
133
|
+
height: dimensions.height,
|
|
134
|
+
width: dimensions.width,
|
|
135
|
+
occurrenceKey: uploadableFileUpfrontIds.occurrenceKey
|
|
136
|
+
}
|
|
169
137
|
});
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
138
|
+
_context.next = 24;
|
|
139
|
+
break;
|
|
140
|
+
case 21:
|
|
141
|
+
_context.prev = 21;
|
|
142
|
+
_context.t0 = _context["catch"](11);
|
|
143
|
+
if (typeof _context.t0 === 'string' && _context.t0 === 'Could not download remote file') {
|
|
144
|
+
// TODO: Make sure this gets good unit test coverage with the actual
|
|
145
|
+
// media plugin. This hard coded error message could be changed at any
|
|
146
|
+
// point and we need a unit test to break to stop people changing it.
|
|
147
|
+
onUploadFailureAnalytics(_context.t0);
|
|
148
|
+
dispatch({
|
|
149
|
+
type: 'warning',
|
|
150
|
+
warning: _context.t0,
|
|
151
|
+
url: inputUrl
|
|
152
|
+
});
|
|
153
|
+
} else if (_context.t0 instanceof Error) {
|
|
154
|
+
message = 'Image preview fetch failed';
|
|
155
|
+
onUploadFailureAnalytics(message);
|
|
156
|
+
dispatch({
|
|
157
|
+
type: 'error',
|
|
158
|
+
error: message
|
|
159
|
+
});
|
|
160
|
+
} else {
|
|
161
|
+
onUploadFailureAnalytics('Unknown error');
|
|
162
|
+
dispatch({
|
|
163
|
+
type: 'error',
|
|
164
|
+
error: 'Unknown error'
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
case 24:
|
|
168
|
+
case "end":
|
|
169
|
+
return _context.stop();
|
|
170
|
+
}
|
|
171
|
+
}, _callee, null, [[11, 21]]);
|
|
172
|
+
}));
|
|
173
|
+
return function (_x) {
|
|
174
|
+
return _ref2.apply(this, arguments);
|
|
175
|
+
};
|
|
176
|
+
}(), [mediaProvider, onUploadAnalytics, onUploadFailureAnalytics, onUploadSuccessAnalytics, inputUrl]);
|
|
177
|
+
var onURLChange = React.useCallback(function (e) {
|
|
178
|
+
var url = e.target.value;
|
|
179
|
+
setUrl(url);
|
|
180
|
+
dispatch({
|
|
181
|
+
type: 'reset'
|
|
182
|
+
});
|
|
183
|
+
if (pasteFlag.current === true) {
|
|
184
|
+
pasteFlag.current = false;
|
|
185
|
+
uploadExternalMedia(url);
|
|
186
|
+
}
|
|
187
|
+
}, [uploadExternalMedia]);
|
|
188
|
+
var onPaste = React.useCallback(function (e) {
|
|
189
|
+
// Note: this is a little weird, but the paste event will always be
|
|
190
|
+
// fired before the change event when pasting. We don't really want to
|
|
191
|
+
// duplicate logic by handling pastes separately to changes, so we're
|
|
192
|
+
// just noting paste occured to then be handled in the onURLChange fn
|
|
193
|
+
// above. The one exception to this is where paste inputs exactly what was
|
|
194
|
+
// already in the input, in which case we want to ignore it.
|
|
195
|
+
if (e.clipboardData.getData('text') !== inputUrl) {
|
|
196
|
+
pasteFlag.current = true;
|
|
197
|
+
}
|
|
198
|
+
}, [inputUrl]);
|
|
177
199
|
var onInsertClick = React.useCallback(function () {
|
|
178
200
|
if (previewState.previewInfo) {
|
|
179
201
|
return onInsert(previewState.previewInfo);
|
|
180
202
|
}
|
|
181
203
|
if (previewState.warning) {
|
|
182
|
-
return onExternalInsert(
|
|
204
|
+
return onExternalInsert(inputUrl);
|
|
183
205
|
}
|
|
184
|
-
}, [onExternalInsert, onInsert, previewState.previewInfo, previewState.warning,
|
|
206
|
+
}, [onExternalInsert, onInsert, previewState.previewInfo, previewState.warning, inputUrl]);
|
|
185
207
|
return /*#__PURE__*/React.createElement("form", {
|
|
186
208
|
onSubmit: function onSubmit(e) {
|
|
187
209
|
e.preventDefault();
|
|
188
|
-
uploadExternalMedia();
|
|
210
|
+
uploadExternalMedia(inputUrl);
|
|
189
211
|
}
|
|
190
212
|
}, /*#__PURE__*/React.createElement(Stack, {
|
|
191
213
|
space: "space.150"
|
|
192
214
|
}, /*#__PURE__*/React.createElement(TextField, {
|
|
193
215
|
autoFocus: true,
|
|
194
|
-
value:
|
|
216
|
+
value: inputUrl,
|
|
195
217
|
placeholder: strings.pasteLinkToUpload,
|
|
196
|
-
onChange: onURLChange
|
|
218
|
+
onChange: onURLChange,
|
|
219
|
+
onPaste: onPaste
|
|
197
220
|
}), previewState.previewInfo && /*#__PURE__*/React.createElement(Inline, {
|
|
198
221
|
alignInline: "center",
|
|
199
222
|
alignBlock: "center",
|
|
@@ -213,7 +236,7 @@ export function MediaFromURL(_ref) {
|
|
|
213
236
|
}, /*#__PURE__*/React.createElement(Button, {
|
|
214
237
|
type: "submit",
|
|
215
238
|
isLoading: previewState.isLoading,
|
|
216
|
-
isDisabled: !
|
|
239
|
+
isDisabled: !inputUrl,
|
|
217
240
|
iconBefore: EditorFilePreviewIcon
|
|
218
241
|
}, strings.loadPreview)), /*#__PURE__*/React.createElement(Box, {
|
|
219
242
|
xcss: ButtonGroupStyles
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Button from '@atlaskit/button/new';
|
|
3
|
+
import { Box } from '@atlaskit/primitives';
|
|
4
|
+
import Tabs, { Tab, TabList, TabPanel } from '@atlaskit/tabs';
|
|
5
|
+
export var MediaInsertContent = function MediaInsertContent() {
|
|
6
|
+
return /*#__PURE__*/React.createElement(Tabs, {
|
|
7
|
+
id: "media-insert-tab-navigation"
|
|
8
|
+
}, /*#__PURE__*/React.createElement(Box, {
|
|
9
|
+
paddingBlockEnd: "space.150"
|
|
10
|
+
}, /*#__PURE__*/React.createElement(TabList, null, /*#__PURE__*/React.createElement(Tab, null, /*#__PURE__*/React.createElement(Button, {
|
|
11
|
+
autoFocus: true,
|
|
12
|
+
appearance: "subtle"
|
|
13
|
+
}, "Link")))), /*#__PURE__*/React.createElement(TabPanel, null, /*#__PURE__*/React.createElement("p", null, "InsertLinkPanel here")));
|
|
14
|
+
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
3
|
+
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
4
|
+
import { Popup, withOuterListeners } from '@atlaskit/editor-common/ui';
|
|
5
|
+
import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
6
|
+
import { akEditorFloatingDialogZIndex } from '@atlaskit/editor-shared-styles';
|
|
7
|
+
import { MediaInsertContent } from './MediaInsertContent';
|
|
8
|
+
import { MediaInsertWrapper } from './MediaInsertWrapper';
|
|
9
|
+
var PopupWithListeners = withOuterListeners(Popup);
|
|
10
|
+
var getDomRefFromSelection = function getDomRefFromSelection(view, dispatchAnalyticsEvent) {
|
|
11
|
+
try {
|
|
12
|
+
var domRef = findDomRefAtPos(view.state.selection.from, view.domAtPos.bind(view));
|
|
13
|
+
if (domRef instanceof HTMLElement) {
|
|
14
|
+
return domRef;
|
|
15
|
+
} else {
|
|
16
|
+
throw new Error('Invalid DOM reference');
|
|
17
|
+
}
|
|
18
|
+
} catch (error) {
|
|
19
|
+
if (dispatchAnalyticsEvent) {
|
|
20
|
+
var payload = {
|
|
21
|
+
action: ACTION.ERRORED,
|
|
22
|
+
actionSubject: ACTION_SUBJECT.PICKER,
|
|
23
|
+
actionSubjectId: ACTION_SUBJECT_ID.PICKER_MEDIA,
|
|
24
|
+
eventType: EVENT_TYPE.OPERATIONAL,
|
|
25
|
+
attributes: {
|
|
26
|
+
error: 'Error getting DOM reference from selection'
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
dispatchAnalyticsEvent(payload);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
export var MediaInsertPicker = function MediaInsertPicker(_ref) {
|
|
34
|
+
var api = _ref.api,
|
|
35
|
+
editorView = _ref.editorView,
|
|
36
|
+
dispatchAnalyticsEvent = _ref.dispatchAnalyticsEvent,
|
|
37
|
+
popupsMountPoint = _ref.popupsMountPoint,
|
|
38
|
+
popupsBoundariesElement = _ref.popupsBoundariesElement,
|
|
39
|
+
popupsScrollableElement = _ref.popupsScrollableElement,
|
|
40
|
+
closeMediaInsertPicker = _ref.closeMediaInsertPicker;
|
|
41
|
+
var targetRef = getDomRefFromSelection(editorView, dispatchAnalyticsEvent);
|
|
42
|
+
var _useSharedPluginState = useSharedPluginState(api, ['mediaInsert']),
|
|
43
|
+
mediaInsertState = _useSharedPluginState.mediaInsertState;
|
|
44
|
+
if (!mediaInsertState || !mediaInsertState.isOpen) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
var handleClose = function handleClose(exitMethod) {
|
|
48
|
+
return function (event) {
|
|
49
|
+
event.preventDefault();
|
|
50
|
+
if (dispatchAnalyticsEvent) {
|
|
51
|
+
var payload = {
|
|
52
|
+
action: ACTION.CLOSED,
|
|
53
|
+
actionSubject: ACTION_SUBJECT.PICKER,
|
|
54
|
+
actionSubjectId: ACTION_SUBJECT_ID.PICKER_MEDIA,
|
|
55
|
+
eventType: EVENT_TYPE.UI,
|
|
56
|
+
attributes: {
|
|
57
|
+
exitMethod: exitMethod
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
dispatchAnalyticsEvent(payload);
|
|
61
|
+
}
|
|
62
|
+
closeMediaInsertPicker();
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
return /*#__PURE__*/React.createElement(PopupWithListeners
|
|
66
|
+
// TODO: i18n
|
|
67
|
+
, {
|
|
68
|
+
ariaLabel: 'Media Insert',
|
|
69
|
+
offset: [0, 12],
|
|
70
|
+
target: targetRef,
|
|
71
|
+
zIndex: akEditorFloatingDialogZIndex,
|
|
72
|
+
mountTo: popupsMountPoint,
|
|
73
|
+
boundariesElement: popupsBoundariesElement,
|
|
74
|
+
handleClickOutside: handleClose(INPUT_METHOD.MOUSE),
|
|
75
|
+
handleEscapeKeydown: handleClose(INPUT_METHOD.KEYBOARD),
|
|
76
|
+
scrollableElement: popupsScrollableElement,
|
|
77
|
+
focusTrap: true
|
|
78
|
+
}, /*#__PURE__*/React.createElement(MediaInsertWrapper, null, /*#__PURE__*/React.createElement(MediaInsertContent, null)));
|
|
79
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Box, xcss } from '@atlaskit/primitives';
|
|
3
|
+
var styles = xcss({
|
|
4
|
+
boxShadow: 'elevation.shadow.overflow',
|
|
5
|
+
width: '340px',
|
|
6
|
+
padding: 'space.200',
|
|
7
|
+
borderRadius: 'border.radius'
|
|
8
|
+
});
|
|
9
|
+
export var MediaInsertWrapper = function MediaInsertWrapper(_ref) {
|
|
10
|
+
var children = _ref.children;
|
|
11
|
+
return /*#__PURE__*/React.createElement(Box, {
|
|
12
|
+
xcss: styles
|
|
13
|
+
}, children);
|
|
14
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
+
export type MediaInsertPluginAction = typeof ACTION_OPEN_POPUP | typeof ACTION_CLOSE_POPUP;
|
|
3
|
+
export declare const ACTION_OPEN_POPUP = "OPEN_POPUP";
|
|
4
|
+
export declare const ACTION_CLOSE_POPUP = "CLOSE_POPUP";
|
|
5
|
+
export declare const showMediaInsertPopup: (tr: Transaction) => Transaction;
|
|
6
|
+
export declare const closeMediaInsertPicker: (tr: Transaction) => Transaction;
|
package/dist/types/index.d.ts
CHANGED
package/dist/types/plugin.d.ts
CHANGED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { NextEditorPlugin, OptionalPlugin, UiComponentFactoryParams } from '@atlaskit/editor-common/types';
|
|
2
|
+
import { type ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
|
+
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
4
|
+
export type MediaInsertPluginState = {
|
|
5
|
+
isOpen?: boolean;
|
|
6
|
+
};
|
|
7
|
+
export type MediaInsertPlugin = NextEditorPlugin<'mediaInsert', {
|
|
8
|
+
dependencies: [OptionalPlugin<AnalyticsPlugin>];
|
|
9
|
+
sharedState: MediaInsertPluginState;
|
|
10
|
+
}>;
|
|
11
|
+
export type MediaInsertPickerProps = Pick<UiComponentFactoryParams, 'editorView' | 'dispatchAnalyticsEvent' | 'popupsMountPoint' | 'popupsBoundariesElement' | 'popupsScrollableElement'> & {
|
|
12
|
+
api?: ExtractInjectionAPI<MediaInsertPlugin>;
|
|
13
|
+
closeMediaInsertPicker: () => void;
|
|
14
|
+
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { type MediaInsertPickerProps } from '../types';
|
|
3
|
+
export declare const MediaInsertPicker: ({ api, editorView, dispatchAnalyticsEvent, popupsMountPoint, popupsBoundariesElement, popupsScrollableElement, closeMediaInsertPicker, }: MediaInsertPickerProps) => JSX.Element | null;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
+
export type MediaInsertPluginAction = typeof ACTION_OPEN_POPUP | typeof ACTION_CLOSE_POPUP;
|
|
3
|
+
export declare const ACTION_OPEN_POPUP = "OPEN_POPUP";
|
|
4
|
+
export declare const ACTION_CLOSE_POPUP = "CLOSE_POPUP";
|
|
5
|
+
export declare const showMediaInsertPopup: (tr: Transaction) => Transaction;
|
|
6
|
+
export declare const closeMediaInsertPicker: (tr: Transaction) => Transaction;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { NextEditorPlugin, OptionalPlugin, UiComponentFactoryParams } from '@atlaskit/editor-common/types';
|
|
2
|
+
import { type ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
|
+
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
4
|
+
export type MediaInsertPluginState = {
|
|
5
|
+
isOpen?: boolean;
|
|
6
|
+
};
|
|
7
|
+
export type MediaInsertPlugin = NextEditorPlugin<'mediaInsert', {
|
|
8
|
+
dependencies: [
|
|
9
|
+
OptionalPlugin<AnalyticsPlugin>
|
|
10
|
+
];
|
|
11
|
+
sharedState: MediaInsertPluginState;
|
|
12
|
+
}>;
|
|
13
|
+
export type MediaInsertPickerProps = Pick<UiComponentFactoryParams, 'editorView' | 'dispatchAnalyticsEvent' | 'popupsMountPoint' | 'popupsBoundariesElement' | 'popupsScrollableElement'> & {
|
|
14
|
+
api?: ExtractInjectionAPI<MediaInsertPlugin>;
|
|
15
|
+
closeMediaInsertPicker: () => void;
|
|
16
|
+
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { type MediaInsertPickerProps } from '../types';
|
|
3
|
+
export declare const MediaInsertPicker: ({ api, editorView, dispatchAnalyticsEvent, popupsMountPoint, popupsBoundariesElement, popupsScrollableElement, closeMediaInsertPicker, }: MediaInsertPickerProps) => JSX.Element | null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-media-insert",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Media Insert plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -24,21 +24,25 @@
|
|
|
24
24
|
".": "./src/index.ts"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@atlaskit/button": "^19.
|
|
28
|
-
"@atlaskit/editor-common": "^87.
|
|
29
|
-
"@atlaskit/
|
|
27
|
+
"@atlaskit/button": "^19.2.0",
|
|
28
|
+
"@atlaskit/editor-common": "^87.9.0",
|
|
29
|
+
"@atlaskit/editor-plugin-analytics": "^1.7.0",
|
|
30
|
+
"@atlaskit/editor-prosemirror": "5.0.1",
|
|
31
|
+
"@atlaskit/editor-shared-styles": "^2.13.0",
|
|
32
|
+
"@atlaskit/icon": "^22.12.0",
|
|
30
33
|
"@atlaskit/media-card": "^78.0.0",
|
|
31
34
|
"@atlaskit/media-client": "^27.3.0",
|
|
32
35
|
"@atlaskit/media-client-react": "^2.0.0",
|
|
33
36
|
"@atlaskit/primitives": "^12.0.0",
|
|
34
|
-
"@atlaskit/section-message": "^6.
|
|
35
|
-
"@atlaskit/
|
|
37
|
+
"@atlaskit/section-message": "^6.6.0",
|
|
38
|
+
"@atlaskit/tabs": "^16.4.0",
|
|
39
|
+
"@atlaskit/textfield": "^6.5.0",
|
|
36
40
|
"@babel/runtime": "^7.0.0",
|
|
37
41
|
"react": "^16.8.0",
|
|
38
42
|
"react-intl-next": "npm:react-intl@^5.18.1"
|
|
39
43
|
},
|
|
40
44
|
"peerDependencies": {
|
|
41
|
-
"@atlaskit/tokens": "^1.
|
|
45
|
+
"@atlaskit/tokens": "^1.58.0"
|
|
42
46
|
},
|
|
43
47
|
"devDependencies": {
|
|
44
48
|
"typescript": "~5.4.2"
|