@atlaskit/editor-plugin-media-insert 9.0.1 → 9.2.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 CHANGED
@@ -1,5 +1,27 @@
1
1
  # @atlaskit/editor-plugin-media-insert
2
2
 
3
+ ## 9.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`12a4ac6a0a8cd`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/12a4ac6a0a8cd) -
8
+ [ux] this change moves smart value logic out of atlaskit
9
+
10
+ ### Patch Changes
11
+
12
+ - Updated dependencies
13
+
14
+ ## 9.1.0
15
+
16
+ ### Minor Changes
17
+
18
+ - [`4903edc4a60f8`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/4903edc4a60f8) -
19
+ [ux] Adds a configuration for media insert to allow for smart value input
20
+
21
+ ### Patch Changes
22
+
23
+ - Updated dependencies
24
+
3
25
  ## 9.0.1
4
26
 
5
27
  ### Patch Changes
@@ -118,7 +118,9 @@ var mediaInsertPlugin = exports.mediaInsertPlugin = function mediaInsertPlugin(_
118
118
  insertMediaSingle: insertMediaSingle,
119
119
  insertExternalMediaSingle: insertExternalMediaSingle,
120
120
  insertFile: insertFile,
121
- isOnlyExternalLinks: config === null || config === void 0 ? void 0 : config.isOnlyExternalLinks
121
+ isOnlyExternalLinks: config === null || config === void 0 ? void 0 : config.isOnlyExternalLinks,
122
+ customizedUrlValidation: config === null || config === void 0 ? void 0 : config.customizedUrlValidation,
123
+ customizedHelperMessage: config === null || config === void 0 ? void 0 : config.customizedHelperMessage
122
124
  });
123
125
  },
124
126
  pluginsOptions: {
@@ -13,7 +13,7 @@ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"))
13
13
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
14
14
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
15
15
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
16
- var _react = _interopRequireDefault(require("react"));
16
+ var _react = _interopRequireWildcard(require("react"));
17
17
  var _reactIntlNext = require("react-intl-next");
18
18
  var _adfSchema = require("@atlaskit/adf-schema");
19
19
  var _buttonGroup = _interopRequireDefault(require("@atlaskit/button/button-group"));
@@ -52,6 +52,12 @@ var INITIAL_PREVIEW_STATE = Object.freeze({
52
52
  warning: null,
53
53
  previewInfo: null
54
54
  });
55
+ var isValidInput = function isValidInput(value, customizedUrlValidation) {
56
+ if (customizedUrlValidation) {
57
+ return customizedUrlValidation(value);
58
+ }
59
+ return isValidUrl(value);
60
+ };
55
61
  var MAX_URL_LENGTH = 2048;
56
62
  var isValidUrl = exports.isValidUrl = function isValidUrl(value) {
57
63
  try {
@@ -97,7 +103,9 @@ function MediaFromURL(_ref) {
97
103
  closeMediaInsertPicker = _ref.closeMediaInsertPicker,
98
104
  insertMediaSingle = _ref.insertMediaSingle,
99
105
  insertExternalMediaSingle = _ref.insertExternalMediaSingle,
100
- isOnlyExternalLinks = _ref.isOnlyExternalLinks;
106
+ isOnlyExternalLinks = _ref.isOnlyExternalLinks,
107
+ customizedUrlValidation = _ref.customizedUrlValidation,
108
+ customizedHelperMessage = _ref.customizedHelperMessage;
101
109
  var intl = (0, _reactIntlNext.useIntl)();
102
110
  var strings = {
103
111
  loadPreview: intl.formatMessage(_messages.mediaInsertMessages.loadPreview),
@@ -114,8 +122,8 @@ function MediaFromURL(_ref) {
114
122
  dispatch = _React$useReducer2[1];
115
123
  var _React$useState = _react.default.useState(''),
116
124
  _React$useState2 = (0, _slicedToArray2.default)(_React$useState, 2),
117
- url = _React$useState2[0],
118
- setUrl = _React$useState2[1];
125
+ input = _React$useState2[0],
126
+ setInput = _React$useState2[1];
119
127
  var pasteFlag = _react.default.useRef(false);
120
128
  var _useAnalyticsEvents = (0, _useAnalyticsEvents2.useAnalyticsEvents)(dispatchAnalyticsEvent),
121
129
  onUploadButtonClickedAnalytics = _useAnalyticsEvents.onUploadButtonClickedAnalytics,
@@ -205,8 +213,8 @@ function MediaFromURL(_ref) {
205
213
  dispatch({
206
214
  type: 'reset'
207
215
  });
208
- setUrl(url);
209
- if (!isValidUrl(url)) {
216
+ setInput(url);
217
+ if (!isValidInput(url, customizedUrlValidation)) {
210
218
  return;
211
219
  }
212
220
  if (pasteFlag.current) {
@@ -215,7 +223,7 @@ function MediaFromURL(_ref) {
215
223
  uploadExternalMedia(url);
216
224
  }
217
225
  }
218
- }, [uploadExternalMedia, isOnlyExternalLinks]);
226
+ }, [uploadExternalMedia, isOnlyExternalLinks, customizedUrlValidation]);
219
227
  var _onPaste = _react.default.useCallback(function (e, inputUrl) {
220
228
  // Note: this is a little weird, but the paste event will always be
221
229
  // fired before the change event when pasting. We don't really want to
@@ -308,7 +316,7 @@ function MediaFromURL(_ref) {
308
316
  isRequired: true,
309
317
  name: "inputUrl",
310
318
  validate: function validate(value) {
311
- return value && isValidUrl(value) ? undefined : strings.invalidUrl;
319
+ return value && isValidInput(value, customizedUrlValidation) ? undefined : strings.invalidUrl;
312
320
  }
313
321
  }, function (_ref5) {
314
322
  var _ref5$fieldProps = _ref5.fieldProps,
@@ -341,7 +349,7 @@ function MediaFromURL(_ref) {
341
349
  formProps.onSubmit();
342
350
  }
343
351
  }
344
- })), /*#__PURE__*/_react.default.createElement(_form.MessageWrapper, null, error && /*#__PURE__*/_react.default.createElement(_form.ErrorMessage, null, /*#__PURE__*/_react.default.createElement(_primitives.Box, {
352
+ })), customizedHelperMessage && /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement(_form.HelperMessage, null, customizedHelperMessage)), /*#__PURE__*/_react.default.createElement(_form.MessageWrapper, null, error && /*#__PURE__*/_react.default.createElement(_form.ErrorMessage, null, /*#__PURE__*/_react.default.createElement(_primitives.Box, {
345
353
  as: "span"
346
354
  }, error)))), !previewState.previewInfo && !previewState.error && !previewState.warning && !isOnlyExternalLinks && /*#__PURE__*/_react.default.createElement(_primitives.Flex, {
347
355
  xcss: PreviewBoxStyles,
@@ -377,9 +385,9 @@ function MediaFromURL(_ref) {
377
385
  appearance: "subtle",
378
386
  onClick: onCancel
379
387
  }, strings.cancel), /*#__PURE__*/_react.default.createElement(_new.default, {
380
- type: "button",
388
+ type: "submit",
381
389
  appearance: "primary",
382
- isDisabled: isOnlyExternalLinks ? !url || !isValidUrl(url) : !previewState.previewInfo && !previewState.warning,
390
+ isDisabled: isOnlyExternalLinks ? !input || !isValidInput(input, customizedUrlValidation) : !previewState.previewInfo && !previewState.warning,
383
391
  onClick: function onClick() {
384
392
  return formProps.onSubmit();
385
393
  }
@@ -13,7 +13,7 @@ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"))
13
13
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
14
14
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
15
15
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
16
- var _react = _interopRequireDefault(require("react"));
16
+ var _react = _interopRequireWildcard(require("react"));
17
17
  var _reactIntlNext = require("react-intl-next");
18
18
  var _adfSchema = require("@atlaskit/adf-schema");
19
19
  var _buttonGroup = _interopRequireDefault(require("@atlaskit/button/button-group"));
@@ -53,6 +53,12 @@ var INITIAL_PREVIEW_STATE = Object.freeze({
53
53
  previewInfo: null
54
54
  });
55
55
  var MAX_URL_LENGTH = 2048;
56
+ var isValidInput = function isValidInput(value, customizedUrlValidation) {
57
+ if (customizedUrlValidation) {
58
+ return customizedUrlValidation(value);
59
+ }
60
+ return isValidUrl(value);
61
+ };
56
62
  var isValidUrl = exports.isValidUrl = function isValidUrl(value) {
57
63
  try {
58
64
  // Check for spaces and length first to avoid the expensive URL parsing
@@ -97,7 +103,9 @@ function MediaFromURLWithForm(_ref) {
97
103
  closeMediaInsertPicker = _ref.closeMediaInsertPicker,
98
104
  insertMediaSingle = _ref.insertMediaSingle,
99
105
  insertExternalMediaSingle = _ref.insertExternalMediaSingle,
100
- isOnlyExternalLinks = _ref.isOnlyExternalLinks;
106
+ isOnlyExternalLinks = _ref.isOnlyExternalLinks,
107
+ customizedUrlValidation = _ref.customizedUrlValidation,
108
+ customizedHelperMessage = _ref.customizedHelperMessage;
101
109
  var intl = (0, _reactIntlNext.useIntl)();
102
110
  var strings = {
103
111
  loadPreview: intl.formatMessage(_messages.mediaInsertMessages.loadPreview),
@@ -114,8 +122,8 @@ function MediaFromURLWithForm(_ref) {
114
122
  dispatch = _React$useReducer2[1];
115
123
  var _React$useState = _react.default.useState(''),
116
124
  _React$useState2 = (0, _slicedToArray2.default)(_React$useState, 2),
117
- url = _React$useState2[0],
118
- setUrl = _React$useState2[1];
125
+ input = _React$useState2[0],
126
+ setInput = _React$useState2[1];
119
127
  var pasteFlag = _react.default.useRef(false);
120
128
  var _useAnalyticsEvents = (0, _useAnalyticsEvents2.useAnalyticsEvents)(dispatchAnalyticsEvent),
121
129
  onUploadButtonClickedAnalytics = _useAnalyticsEvents.onUploadButtonClickedAnalytics,
@@ -205,8 +213,8 @@ function MediaFromURLWithForm(_ref) {
205
213
  dispatch({
206
214
  type: 'reset'
207
215
  });
208
- setUrl(url);
209
- if (!isValidUrl(url)) {
216
+ setInput(url);
217
+ if (!isValidInput(url, customizedUrlValidation)) {
210
218
  return;
211
219
  }
212
220
  if (pasteFlag.current) {
@@ -215,7 +223,7 @@ function MediaFromURLWithForm(_ref) {
215
223
  uploadExternalMedia(url);
216
224
  }
217
225
  }
218
- }, [uploadExternalMedia, isOnlyExternalLinks]);
226
+ }, [uploadExternalMedia, isOnlyExternalLinks, customizedUrlValidation]);
219
227
  var _onPaste = _react.default.useCallback(function (e, inputUrl) {
220
228
  // Note: this is a little weird, but the paste event will always be
221
229
  // fired before the change event when pasting. We don't really want to
@@ -310,7 +318,7 @@ function MediaFromURLWithForm(_ref) {
310
318
  isRequired: true,
311
319
  name: "inputUrl",
312
320
  validate: function validate(value) {
313
- return value && isValidUrl(value) ? undefined : strings.invalidUrl;
321
+ return value && isValidInput(value, customizedUrlValidation) ? undefined : strings.invalidUrl;
314
322
  }
315
323
  }, function (_ref5) {
316
324
  var _ref5$fieldProps = _ref5.fieldProps,
@@ -337,7 +345,7 @@ function MediaFromURLWithForm(_ref) {
337
345
  onURLChange(value);
338
346
  _onChange(value);
339
347
  }
340
- })), /*#__PURE__*/_react.default.createElement(_form.MessageWrapper, null, error && /*#__PURE__*/_react.default.createElement(_form.ErrorMessage, null, /*#__PURE__*/_react.default.createElement(_primitives.Box, {
348
+ })), customizedHelperMessage && /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement(_form.HelperMessage, null, customizedHelperMessage)), /*#__PURE__*/_react.default.createElement(_form.MessageWrapper, null, error && /*#__PURE__*/_react.default.createElement(_form.ErrorMessage, null, /*#__PURE__*/_react.default.createElement(_primitives.Box, {
341
349
  as: "span"
342
350
  }, error)))), !previewState.previewInfo && !previewState.error && !previewState.warning && !isOnlyExternalLinks && /*#__PURE__*/_react.default.createElement(_primitives.Flex, {
343
351
  xcss: PreviewBoxStyles,
@@ -372,7 +380,7 @@ function MediaFromURLWithForm(_ref) {
372
380
  }, strings.cancel), /*#__PURE__*/_react.default.createElement(_new.default, {
373
381
  type: "submit",
374
382
  appearance: "primary",
375
- isDisabled: isOnlyExternalLinks ? !url || !isValidUrl(url) : !previewState.previewInfo && !previewState.warning
383
+ isDisabled: isOnlyExternalLinks ? !input || !isValidInput(input, customizedUrlValidation) : !previewState.previewInfo && !previewState.warning
376
384
  }, strings.insert)))))
377
385
  );
378
386
  });
@@ -75,7 +75,9 @@ var MediaInsertPicker = exports.MediaInsertPicker = function MediaInsertPicker(_
75
75
  insertExternalMediaSingle = _ref2.insertExternalMediaSingle,
76
76
  insertFile = _ref2.insertFile,
77
77
  _ref2$isOnlyExternalL = _ref2.isOnlyExternalLinks,
78
- isOnlyExternalLinks = _ref2$isOnlyExternalL === void 0 ? false : _ref2$isOnlyExternalL;
78
+ isOnlyExternalLinks = _ref2$isOnlyExternalL === void 0 ? false : _ref2$isOnlyExternalL,
79
+ customizedUrlValidation = _ref2.customizedUrlValidation,
80
+ customizedHelperMessage = _ref2.customizedHelperMessage;
79
81
  var _useSharedState = useSharedState(api),
80
82
  mediaProvider = _useSharedState.mediaProvider,
81
83
  isOpen = _useSharedState.isOpen,
@@ -160,7 +162,9 @@ var MediaInsertPicker = exports.MediaInsertPicker = function MediaInsertPicker(_
160
162
  },
161
163
  insertMediaSingle: insertMediaSingle,
162
164
  insertExternalMediaSingle: insertExternalMediaSingle,
163
- isOnlyExternalLinks: isOnlyExternalLinks
165
+ isOnlyExternalLinks: isOnlyExternalLinks,
166
+ customizedUrlValidation: customizedUrlValidation,
167
+ customizedHelperMessage: customizedHelperMessage
164
168
  }) : /*#__PURE__*/_react.default.createElement(_MediaFromURLWithForm.MediaFromURLWithForm, {
165
169
  mediaProvider: mediaProvider,
166
170
  dispatchAnalyticsEvent: dispatchAnalyticsEvent,
@@ -170,7 +174,9 @@ var MediaInsertPicker = exports.MediaInsertPicker = function MediaInsertPicker(_
170
174
  },
171
175
  insertMediaSingle: insertMediaSingle,
172
176
  insertExternalMediaSingle: insertExternalMediaSingle,
173
- isOnlyExternalLinks: isOnlyExternalLinks
177
+ isOnlyExternalLinks: isOnlyExternalLinks,
178
+ customizedUrlValidation: customizedUrlValidation,
179
+ customizedHelperMessage: customizedHelperMessage
174
180
  }))));
175
181
  }));
176
182
  };
@@ -112,7 +112,9 @@ export const mediaInsertPlugin = ({
112
112
  insertMediaSingle: insertMediaSingle,
113
113
  insertExternalMediaSingle: insertExternalMediaSingle,
114
114
  insertFile: insertFile,
115
- isOnlyExternalLinks: config === null || config === void 0 ? void 0 : config.isOnlyExternalLinks
115
+ isOnlyExternalLinks: config === null || config === void 0 ? void 0 : config.isOnlyExternalLinks,
116
+ customizedUrlValidation: config === null || config === void 0 ? void 0 : config.customizedUrlValidation,
117
+ customizedHelperMessage: config === null || config === void 0 ? void 0 : config.customizedHelperMessage
116
118
  });
117
119
  },
118
120
  pluginsOptions: {
@@ -1,12 +1,12 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
- import React from 'react';
2
+ import React, { Fragment } from 'react';
3
3
  import { useIntl } from 'react-intl-next';
4
4
  import { isSafeUrl } from '@atlaskit/adf-schema';
5
5
  import ButtonGroup from '@atlaskit/button/button-group';
6
6
  import Button from '@atlaskit/button/new';
7
7
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
8
8
  import { mediaInsertMessages } from '@atlaskit/editor-common/messages';
9
- import Form, { ErrorMessage, Field, FormFooter, MessageWrapper } from '@atlaskit/form';
9
+ import Form, { ErrorMessage, Field, FormFooter, HelperMessage, MessageWrapper } from '@atlaskit/form';
10
10
  import ExpandIcon from '@atlaskit/icon/core/grow-diagonal';
11
11
  import { default as EditorFilePreviewIconLegacy } from '@atlaskit/icon/glyph/editor/file-preview';
12
12
  import { getMediaClient } from '@atlaskit/media-client-react';
@@ -35,6 +35,12 @@ const INITIAL_PREVIEW_STATE = Object.freeze({
35
35
  warning: null,
36
36
  previewInfo: null
37
37
  });
38
+ const isValidInput = (value, customizedUrlValidation) => {
39
+ if (customizedUrlValidation) {
40
+ return customizedUrlValidation(value);
41
+ }
42
+ return isValidUrl(value);
43
+ };
38
44
  const MAX_URL_LENGTH = 2048;
39
45
  export const isValidUrl = value => {
40
46
  try {
@@ -84,7 +90,9 @@ export function MediaFromURL({
84
90
  closeMediaInsertPicker,
85
91
  insertMediaSingle,
86
92
  insertExternalMediaSingle,
87
- isOnlyExternalLinks
93
+ isOnlyExternalLinks,
94
+ customizedUrlValidation,
95
+ customizedHelperMessage
88
96
  }) {
89
97
  const intl = useIntl();
90
98
  const strings = {
@@ -97,7 +105,7 @@ export function MediaFromURL({
97
105
  invalidUrl: intl.formatMessage(mediaInsertMessages.invalidUrlErrorMessage)
98
106
  };
99
107
  const [previewState, dispatch] = React.useReducer(previewStateReducer, INITIAL_PREVIEW_STATE);
100
- const [url, setUrl] = React.useState('');
108
+ const [input, setInput] = React.useState('');
101
109
  const pasteFlag = React.useRef(false);
102
110
  const {
103
111
  onUploadButtonClickedAnalytics,
@@ -169,8 +177,8 @@ export function MediaFromURL({
169
177
  dispatch({
170
178
  type: 'reset'
171
179
  });
172
- setUrl(url);
173
- if (!isValidUrl(url)) {
180
+ setInput(url);
181
+ if (!isValidInput(url, customizedUrlValidation)) {
174
182
  return;
175
183
  }
176
184
  if (pasteFlag.current) {
@@ -179,7 +187,7 @@ export function MediaFromURL({
179
187
  uploadExternalMedia(url);
180
188
  }
181
189
  }
182
- }, [uploadExternalMedia, isOnlyExternalLinks]);
190
+ }, [uploadExternalMedia, isOnlyExternalLinks, customizedUrlValidation]);
183
191
  const onPaste = React.useCallback((e, inputUrl) => {
184
192
  // Note: this is a little weird, but the paste event will always be
185
193
  // fired before the change event when pasting. We don't really want to
@@ -272,7 +280,7 @@ export function MediaFromURL({
272
280
  "aria-required": true,
273
281
  isRequired: true,
274
282
  name: "inputUrl",
275
- validate: value => value && isValidUrl(value) ? undefined : strings.invalidUrl
283
+ validate: value => value && isValidInput(value, customizedUrlValidation) ? undefined : strings.invalidUrl
276
284
  }, ({
277
285
  fieldProps: {
278
286
  value,
@@ -303,7 +311,7 @@ export function MediaFromURL({
303
311
  formProps.onSubmit();
304
312
  }
305
313
  }
306
- })), /*#__PURE__*/React.createElement(MessageWrapper, null, error && /*#__PURE__*/React.createElement(ErrorMessage, null, /*#__PURE__*/React.createElement(Box, {
314
+ })), customizedHelperMessage && /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(HelperMessage, null, customizedHelperMessage)), /*#__PURE__*/React.createElement(MessageWrapper, null, error && /*#__PURE__*/React.createElement(ErrorMessage, null, /*#__PURE__*/React.createElement(Box, {
307
315
  as: "span"
308
316
  }, error)))), !previewState.previewInfo && !previewState.error && !previewState.warning && !isOnlyExternalLinks && /*#__PURE__*/React.createElement(Flex, {
309
317
  xcss: PreviewBoxStyles,
@@ -334,9 +342,9 @@ export function MediaFromURL({
334
342
  appearance: "subtle",
335
343
  onClick: onCancel
336
344
  }, strings.cancel), /*#__PURE__*/React.createElement(Button, {
337
- type: "button",
345
+ type: "submit",
338
346
  appearance: "primary",
339
- isDisabled: isOnlyExternalLinks ? !url || !isValidUrl(url) : !previewState.previewInfo && !previewState.warning,
347
+ isDisabled: isOnlyExternalLinks ? !input || !isValidInput(input, customizedUrlValidation) : !previewState.previewInfo && !previewState.warning,
340
348
  onClick: () => formProps.onSubmit()
341
349
  }, strings.insert))))));
342
350
  }
@@ -1,12 +1,12 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
- import React from 'react';
2
+ import React, { Fragment } from 'react';
3
3
  import { useIntl } from 'react-intl-next';
4
4
  import { isSafeUrl } from '@atlaskit/adf-schema';
5
5
  import ButtonGroup from '@atlaskit/button/button-group';
6
6
  import Button from '@atlaskit/button/new';
7
7
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
8
8
  import { mediaInsertMessages } from '@atlaskit/editor-common/messages';
9
- import Form, { ErrorMessage, Field, FormFooter, MessageWrapper } from '@atlaskit/form';
9
+ import Form, { ErrorMessage, Field, FormFooter, MessageWrapper, HelperMessage } from '@atlaskit/form';
10
10
  import ExpandIcon from '@atlaskit/icon/core/grow-diagonal';
11
11
  import { default as EditorFilePreviewIconLegacy } from '@atlaskit/icon/glyph/editor/file-preview';
12
12
  import { getMediaClient } from '@atlaskit/media-client-react';
@@ -36,6 +36,12 @@ const INITIAL_PREVIEW_STATE = Object.freeze({
36
36
  previewInfo: null
37
37
  });
38
38
  const MAX_URL_LENGTH = 2048;
39
+ const isValidInput = (value, customizedUrlValidation) => {
40
+ if (customizedUrlValidation) {
41
+ return customizedUrlValidation(value);
42
+ }
43
+ return isValidUrl(value);
44
+ };
39
45
  export const isValidUrl = value => {
40
46
  try {
41
47
  // Check for spaces and length first to avoid the expensive URL parsing
@@ -84,7 +90,9 @@ export function MediaFromURLWithForm({
84
90
  closeMediaInsertPicker,
85
91
  insertMediaSingle,
86
92
  insertExternalMediaSingle,
87
- isOnlyExternalLinks
93
+ isOnlyExternalLinks,
94
+ customizedUrlValidation,
95
+ customizedHelperMessage
88
96
  }) {
89
97
  const intl = useIntl();
90
98
  const strings = {
@@ -97,7 +105,7 @@ export function MediaFromURLWithForm({
97
105
  invalidUrl: intl.formatMessage(mediaInsertMessages.invalidUrlErrorMessage)
98
106
  };
99
107
  const [previewState, dispatch] = React.useReducer(previewStateReducer, INITIAL_PREVIEW_STATE);
100
- const [url, setUrl] = React.useState('');
108
+ const [input, setInput] = React.useState('');
101
109
  const pasteFlag = React.useRef(false);
102
110
  const {
103
111
  onUploadButtonClickedAnalytics,
@@ -169,8 +177,8 @@ export function MediaFromURLWithForm({
169
177
  dispatch({
170
178
  type: 'reset'
171
179
  });
172
- setUrl(url);
173
- if (!isValidUrl(url)) {
180
+ setInput(url);
181
+ if (!isValidInput(url, customizedUrlValidation)) {
174
182
  return;
175
183
  }
176
184
  if (pasteFlag.current) {
@@ -179,7 +187,7 @@ export function MediaFromURLWithForm({
179
187
  uploadExternalMedia(url);
180
188
  }
181
189
  }
182
- }, [uploadExternalMedia, isOnlyExternalLinks]);
190
+ }, [uploadExternalMedia, isOnlyExternalLinks, customizedUrlValidation]);
183
191
  const onPaste = React.useCallback((e, inputUrl) => {
184
192
  // Note: this is a little weird, but the paste event will always be
185
193
  // fired before the change event when pasting. We don't really want to
@@ -274,7 +282,7 @@ export function MediaFromURLWithForm({
274
282
  "aria-required": true,
275
283
  isRequired: true,
276
284
  name: "inputUrl",
277
- validate: value => value && isValidUrl(value) ? undefined : strings.invalidUrl
285
+ validate: value => value && isValidInput(value, customizedUrlValidation) ? undefined : strings.invalidUrl
278
286
  }, ({
279
287
  fieldProps: {
280
288
  value,
@@ -299,7 +307,7 @@ export function MediaFromURLWithForm({
299
307
  onURLChange(value);
300
308
  onChange(value);
301
309
  }
302
- })), /*#__PURE__*/React.createElement(MessageWrapper, null, error && /*#__PURE__*/React.createElement(ErrorMessage, null, /*#__PURE__*/React.createElement(Box, {
310
+ })), customizedHelperMessage && /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(HelperMessage, null, customizedHelperMessage)), /*#__PURE__*/React.createElement(MessageWrapper, null, error && /*#__PURE__*/React.createElement(ErrorMessage, null, /*#__PURE__*/React.createElement(Box, {
303
311
  as: "span"
304
312
  }, error)))), !previewState.previewInfo && !previewState.error && !previewState.warning && !isOnlyExternalLinks && /*#__PURE__*/React.createElement(Flex, {
305
313
  xcss: PreviewBoxStyles,
@@ -331,6 +339,6 @@ export function MediaFromURLWithForm({
331
339
  }, strings.cancel), /*#__PURE__*/React.createElement(Button, {
332
340
  type: "submit",
333
341
  appearance: "primary",
334
- isDisabled: isOnlyExternalLinks ? !url || !isValidUrl(url) : !previewState.previewInfo && !previewState.warning
342
+ isDisabled: isOnlyExternalLinks ? !input || !isValidInput(input, customizedUrlValidation) : !previewState.previewInfo && !previewState.warning
335
343
  }, strings.insert))))));
336
344
  }
@@ -67,7 +67,9 @@ export const MediaInsertPicker = ({
67
67
  insertMediaSingle,
68
68
  insertExternalMediaSingle,
69
69
  insertFile,
70
- isOnlyExternalLinks = false
70
+ isOnlyExternalLinks = false,
71
+ customizedUrlValidation,
72
+ customizedHelperMessage
71
73
  }) => {
72
74
  const {
73
75
  mediaProvider,
@@ -152,7 +154,9 @@ export const MediaInsertPicker = ({
152
154
  },
153
155
  insertMediaSingle: insertMediaSingle,
154
156
  insertExternalMediaSingle: insertExternalMediaSingle,
155
- isOnlyExternalLinks: isOnlyExternalLinks
157
+ isOnlyExternalLinks: isOnlyExternalLinks,
158
+ customizedUrlValidation: customizedUrlValidation,
159
+ customizedHelperMessage: customizedHelperMessage
156
160
  }) : /*#__PURE__*/React.createElement(MediaFromURLWithForm, {
157
161
  mediaProvider: mediaProvider,
158
162
  dispatchAnalyticsEvent: dispatchAnalyticsEvent,
@@ -162,6 +166,8 @@ export const MediaInsertPicker = ({
162
166
  },
163
167
  insertMediaSingle: insertMediaSingle,
164
168
  insertExternalMediaSingle: insertExternalMediaSingle,
165
- isOnlyExternalLinks: isOnlyExternalLinks
169
+ isOnlyExternalLinks: isOnlyExternalLinks,
170
+ customizedUrlValidation: customizedUrlValidation,
171
+ customizedHelperMessage: customizedHelperMessage
166
172
  }))))));
167
173
  };
@@ -111,7 +111,9 @@ export var mediaInsertPlugin = function mediaInsertPlugin(_ref) {
111
111
  insertMediaSingle: insertMediaSingle,
112
112
  insertExternalMediaSingle: insertExternalMediaSingle,
113
113
  insertFile: insertFile,
114
- isOnlyExternalLinks: config === null || config === void 0 ? void 0 : config.isOnlyExternalLinks
114
+ isOnlyExternalLinks: config === null || config === void 0 ? void 0 : config.isOnlyExternalLinks,
115
+ customizedUrlValidation: config === null || config === void 0 ? void 0 : config.customizedUrlValidation,
116
+ customizedHelperMessage: config === null || config === void 0 ? void 0 : config.customizedHelperMessage
115
117
  });
116
118
  },
117
119
  pluginsOptions: {
@@ -7,14 +7,14 @@ var _excluded = ["value", "onChange"];
7
7
  import _regeneratorRuntime from "@babel/runtime/regenerator";
8
8
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
9
9
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
10
- import React from 'react';
10
+ import React, { Fragment } from 'react';
11
11
  import { useIntl } from 'react-intl-next';
12
12
  import { isSafeUrl } from '@atlaskit/adf-schema';
13
13
  import ButtonGroup from '@atlaskit/button/button-group';
14
14
  import Button from '@atlaskit/button/new';
15
15
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
16
16
  import { mediaInsertMessages } from '@atlaskit/editor-common/messages';
17
- import Form, { ErrorMessage, Field, FormFooter, MessageWrapper } from '@atlaskit/form';
17
+ import Form, { ErrorMessage, Field, FormFooter, HelperMessage, MessageWrapper } from '@atlaskit/form';
18
18
  import ExpandIcon from '@atlaskit/icon/core/grow-diagonal';
19
19
  import { default as EditorFilePreviewIconLegacy } from '@atlaskit/icon/glyph/editor/file-preview';
20
20
  import { getMediaClient } from '@atlaskit/media-client-react';
@@ -43,6 +43,12 @@ var INITIAL_PREVIEW_STATE = Object.freeze({
43
43
  warning: null,
44
44
  previewInfo: null
45
45
  });
46
+ var isValidInput = function isValidInput(value, customizedUrlValidation) {
47
+ if (customizedUrlValidation) {
48
+ return customizedUrlValidation(value);
49
+ }
50
+ return isValidUrl(value);
51
+ };
46
52
  var MAX_URL_LENGTH = 2048;
47
53
  export var isValidUrl = function isValidUrl(value) {
48
54
  try {
@@ -88,7 +94,9 @@ export function MediaFromURL(_ref) {
88
94
  closeMediaInsertPicker = _ref.closeMediaInsertPicker,
89
95
  insertMediaSingle = _ref.insertMediaSingle,
90
96
  insertExternalMediaSingle = _ref.insertExternalMediaSingle,
91
- isOnlyExternalLinks = _ref.isOnlyExternalLinks;
97
+ isOnlyExternalLinks = _ref.isOnlyExternalLinks,
98
+ customizedUrlValidation = _ref.customizedUrlValidation,
99
+ customizedHelperMessage = _ref.customizedHelperMessage;
92
100
  var intl = useIntl();
93
101
  var strings = {
94
102
  loadPreview: intl.formatMessage(mediaInsertMessages.loadPreview),
@@ -105,8 +113,8 @@ export function MediaFromURL(_ref) {
105
113
  dispatch = _React$useReducer2[1];
106
114
  var _React$useState = React.useState(''),
107
115
  _React$useState2 = _slicedToArray(_React$useState, 2),
108
- url = _React$useState2[0],
109
- setUrl = _React$useState2[1];
116
+ input = _React$useState2[0],
117
+ setInput = _React$useState2[1];
110
118
  var pasteFlag = React.useRef(false);
111
119
  var _useAnalyticsEvents = useAnalyticsEvents(dispatchAnalyticsEvent),
112
120
  onUploadButtonClickedAnalytics = _useAnalyticsEvents.onUploadButtonClickedAnalytics,
@@ -196,8 +204,8 @@ export function MediaFromURL(_ref) {
196
204
  dispatch({
197
205
  type: 'reset'
198
206
  });
199
- setUrl(url);
200
- if (!isValidUrl(url)) {
207
+ setInput(url);
208
+ if (!isValidInput(url, customizedUrlValidation)) {
201
209
  return;
202
210
  }
203
211
  if (pasteFlag.current) {
@@ -206,7 +214,7 @@ export function MediaFromURL(_ref) {
206
214
  uploadExternalMedia(url);
207
215
  }
208
216
  }
209
- }, [uploadExternalMedia, isOnlyExternalLinks]);
217
+ }, [uploadExternalMedia, isOnlyExternalLinks, customizedUrlValidation]);
210
218
  var _onPaste = React.useCallback(function (e, inputUrl) {
211
219
  // Note: this is a little weird, but the paste event will always be
212
220
  // fired before the change event when pasting. We don't really want to
@@ -299,7 +307,7 @@ export function MediaFromURL(_ref) {
299
307
  isRequired: true,
300
308
  name: "inputUrl",
301
309
  validate: function validate(value) {
302
- return value && isValidUrl(value) ? undefined : strings.invalidUrl;
310
+ return value && isValidInput(value, customizedUrlValidation) ? undefined : strings.invalidUrl;
303
311
  }
304
312
  }, function (_ref5) {
305
313
  var _ref5$fieldProps = _ref5.fieldProps,
@@ -332,7 +340,7 @@ export function MediaFromURL(_ref) {
332
340
  formProps.onSubmit();
333
341
  }
334
342
  }
335
- })), /*#__PURE__*/React.createElement(MessageWrapper, null, error && /*#__PURE__*/React.createElement(ErrorMessage, null, /*#__PURE__*/React.createElement(Box, {
343
+ })), customizedHelperMessage && /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(HelperMessage, null, customizedHelperMessage)), /*#__PURE__*/React.createElement(MessageWrapper, null, error && /*#__PURE__*/React.createElement(ErrorMessage, null, /*#__PURE__*/React.createElement(Box, {
336
344
  as: "span"
337
345
  }, error)))), !previewState.previewInfo && !previewState.error && !previewState.warning && !isOnlyExternalLinks && /*#__PURE__*/React.createElement(Flex, {
338
346
  xcss: PreviewBoxStyles,
@@ -368,9 +376,9 @@ export function MediaFromURL(_ref) {
368
376
  appearance: "subtle",
369
377
  onClick: onCancel
370
378
  }, strings.cancel), /*#__PURE__*/React.createElement(Button, {
371
- type: "button",
379
+ type: "submit",
372
380
  appearance: "primary",
373
- isDisabled: isOnlyExternalLinks ? !url || !isValidUrl(url) : !previewState.previewInfo && !previewState.warning,
381
+ isDisabled: isOnlyExternalLinks ? !input || !isValidInput(input, customizedUrlValidation) : !previewState.previewInfo && !previewState.warning,
374
382
  onClick: function onClick() {
375
383
  return formProps.onSubmit();
376
384
  }
@@ -7,14 +7,14 @@ var _excluded = ["value", "onChange"];
7
7
  import _regeneratorRuntime from "@babel/runtime/regenerator";
8
8
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
9
9
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
10
- import React from 'react';
10
+ import React, { Fragment } from 'react';
11
11
  import { useIntl } from 'react-intl-next';
12
12
  import { isSafeUrl } from '@atlaskit/adf-schema';
13
13
  import ButtonGroup from '@atlaskit/button/button-group';
14
14
  import Button from '@atlaskit/button/new';
15
15
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
16
16
  import { mediaInsertMessages } from '@atlaskit/editor-common/messages';
17
- import Form, { ErrorMessage, Field, FormFooter, MessageWrapper } from '@atlaskit/form';
17
+ import Form, { ErrorMessage, Field, FormFooter, MessageWrapper, HelperMessage } from '@atlaskit/form';
18
18
  import ExpandIcon from '@atlaskit/icon/core/grow-diagonal';
19
19
  import { default as EditorFilePreviewIconLegacy } from '@atlaskit/icon/glyph/editor/file-preview';
20
20
  import { getMediaClient } from '@atlaskit/media-client-react';
@@ -44,6 +44,12 @@ var INITIAL_PREVIEW_STATE = Object.freeze({
44
44
  previewInfo: null
45
45
  });
46
46
  var MAX_URL_LENGTH = 2048;
47
+ var isValidInput = function isValidInput(value, customizedUrlValidation) {
48
+ if (customizedUrlValidation) {
49
+ return customizedUrlValidation(value);
50
+ }
51
+ return isValidUrl(value);
52
+ };
47
53
  export var isValidUrl = function isValidUrl(value) {
48
54
  try {
49
55
  // Check for spaces and length first to avoid the expensive URL parsing
@@ -88,7 +94,9 @@ export function MediaFromURLWithForm(_ref) {
88
94
  closeMediaInsertPicker = _ref.closeMediaInsertPicker,
89
95
  insertMediaSingle = _ref.insertMediaSingle,
90
96
  insertExternalMediaSingle = _ref.insertExternalMediaSingle,
91
- isOnlyExternalLinks = _ref.isOnlyExternalLinks;
97
+ isOnlyExternalLinks = _ref.isOnlyExternalLinks,
98
+ customizedUrlValidation = _ref.customizedUrlValidation,
99
+ customizedHelperMessage = _ref.customizedHelperMessage;
92
100
  var intl = useIntl();
93
101
  var strings = {
94
102
  loadPreview: intl.formatMessage(mediaInsertMessages.loadPreview),
@@ -105,8 +113,8 @@ export function MediaFromURLWithForm(_ref) {
105
113
  dispatch = _React$useReducer2[1];
106
114
  var _React$useState = React.useState(''),
107
115
  _React$useState2 = _slicedToArray(_React$useState, 2),
108
- url = _React$useState2[0],
109
- setUrl = _React$useState2[1];
116
+ input = _React$useState2[0],
117
+ setInput = _React$useState2[1];
110
118
  var pasteFlag = React.useRef(false);
111
119
  var _useAnalyticsEvents = useAnalyticsEvents(dispatchAnalyticsEvent),
112
120
  onUploadButtonClickedAnalytics = _useAnalyticsEvents.onUploadButtonClickedAnalytics,
@@ -196,8 +204,8 @@ export function MediaFromURLWithForm(_ref) {
196
204
  dispatch({
197
205
  type: 'reset'
198
206
  });
199
- setUrl(url);
200
- if (!isValidUrl(url)) {
207
+ setInput(url);
208
+ if (!isValidInput(url, customizedUrlValidation)) {
201
209
  return;
202
210
  }
203
211
  if (pasteFlag.current) {
@@ -206,7 +214,7 @@ export function MediaFromURLWithForm(_ref) {
206
214
  uploadExternalMedia(url);
207
215
  }
208
216
  }
209
- }, [uploadExternalMedia, isOnlyExternalLinks]);
217
+ }, [uploadExternalMedia, isOnlyExternalLinks, customizedUrlValidation]);
210
218
  var _onPaste = React.useCallback(function (e, inputUrl) {
211
219
  // Note: this is a little weird, but the paste event will always be
212
220
  // fired before the change event when pasting. We don't really want to
@@ -301,7 +309,7 @@ export function MediaFromURLWithForm(_ref) {
301
309
  isRequired: true,
302
310
  name: "inputUrl",
303
311
  validate: function validate(value) {
304
- return value && isValidUrl(value) ? undefined : strings.invalidUrl;
312
+ return value && isValidInput(value, customizedUrlValidation) ? undefined : strings.invalidUrl;
305
313
  }
306
314
  }, function (_ref5) {
307
315
  var _ref5$fieldProps = _ref5.fieldProps,
@@ -328,7 +336,7 @@ export function MediaFromURLWithForm(_ref) {
328
336
  onURLChange(value);
329
337
  _onChange(value);
330
338
  }
331
- })), /*#__PURE__*/React.createElement(MessageWrapper, null, error && /*#__PURE__*/React.createElement(ErrorMessage, null, /*#__PURE__*/React.createElement(Box, {
339
+ })), customizedHelperMessage && /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(HelperMessage, null, customizedHelperMessage)), /*#__PURE__*/React.createElement(MessageWrapper, null, error && /*#__PURE__*/React.createElement(ErrorMessage, null, /*#__PURE__*/React.createElement(Box, {
332
340
  as: "span"
333
341
  }, error)))), !previewState.previewInfo && !previewState.error && !previewState.warning && !isOnlyExternalLinks && /*#__PURE__*/React.createElement(Flex, {
334
342
  xcss: PreviewBoxStyles,
@@ -363,7 +371,7 @@ export function MediaFromURLWithForm(_ref) {
363
371
  }, strings.cancel), /*#__PURE__*/React.createElement(Button, {
364
372
  type: "submit",
365
373
  appearance: "primary",
366
- isDisabled: isOnlyExternalLinks ? !url || !isValidUrl(url) : !previewState.previewInfo && !previewState.warning
374
+ isDisabled: isOnlyExternalLinks ? !input || !isValidInput(input, customizedUrlValidation) : !previewState.previewInfo && !previewState.warning
367
375
  }, strings.insert)))))
368
376
  );
369
377
  });
@@ -66,7 +66,9 @@ export var MediaInsertPicker = function MediaInsertPicker(_ref2) {
66
66
  insertExternalMediaSingle = _ref2.insertExternalMediaSingle,
67
67
  insertFile = _ref2.insertFile,
68
68
  _ref2$isOnlyExternalL = _ref2.isOnlyExternalLinks,
69
- isOnlyExternalLinks = _ref2$isOnlyExternalL === void 0 ? false : _ref2$isOnlyExternalL;
69
+ isOnlyExternalLinks = _ref2$isOnlyExternalL === void 0 ? false : _ref2$isOnlyExternalL,
70
+ customizedUrlValidation = _ref2.customizedUrlValidation,
71
+ customizedHelperMessage = _ref2.customizedHelperMessage;
70
72
  var _useSharedState = useSharedState(api),
71
73
  mediaProvider = _useSharedState.mediaProvider,
72
74
  isOpen = _useSharedState.isOpen,
@@ -151,7 +153,9 @@ export var MediaInsertPicker = function MediaInsertPicker(_ref2) {
151
153
  },
152
154
  insertMediaSingle: insertMediaSingle,
153
155
  insertExternalMediaSingle: insertExternalMediaSingle,
154
- isOnlyExternalLinks: isOnlyExternalLinks
156
+ isOnlyExternalLinks: isOnlyExternalLinks,
157
+ customizedUrlValidation: customizedUrlValidation,
158
+ customizedHelperMessage: customizedHelperMessage
155
159
  }) : /*#__PURE__*/React.createElement(MediaFromURLWithForm, {
156
160
  mediaProvider: mediaProvider,
157
161
  dispatchAnalyticsEvent: dispatchAnalyticsEvent,
@@ -161,7 +165,9 @@ export var MediaInsertPicker = function MediaInsertPicker(_ref2) {
161
165
  },
162
166
  insertMediaSingle: insertMediaSingle,
163
167
  insertExternalMediaSingle: insertExternalMediaSingle,
164
- isOnlyExternalLinks: isOnlyExternalLinks
168
+ isOnlyExternalLinks: isOnlyExternalLinks,
169
+ customizedUrlValidation: customizedUrlValidation,
170
+ customizedHelperMessage: customizedHelperMessage
165
171
  }))));
166
172
  }));
167
173
  };
@@ -2,6 +2,7 @@ import type { EditorCommand, NextEditorPlugin, OptionalPlugin } from '@atlaskit/
2
2
  import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
3
3
  import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
4
4
  import type { MediaPlugin } from '@atlaskit/editor-plugin-media';
5
+ import type { CustomizedHelperMessage } from './types';
5
6
  export type MediaInsertPluginState = {
6
7
  isOpen?: boolean;
7
8
  mountInfo?: {
@@ -50,6 +51,8 @@ export type MediaInsertPluginConfig = {
50
51
  * ```
51
52
  */
52
53
  isOnlyExternalLinks?: boolean;
54
+ customizedUrlValidation?: (input: string) => boolean;
55
+ customizedHelperMessage?: CustomizedHelperMessage;
53
56
  };
54
57
  export type MediaInsertPlugin = NextEditorPlugin<'mediaInsert', {
55
58
  dependencies: MediaInsertPluginDependencies;
@@ -7,6 +7,7 @@ export type InsertMediaSingle = (props: {
7
7
  mediaState: MediaState;
8
8
  inputMethod: InputMethodInsertMedia;
9
9
  }) => boolean;
10
+ export type CustomizedHelperMessage = string;
10
11
  export type InsertExternalMediaSingle = (props: {
11
12
  url: string;
12
13
  alt: string;
@@ -25,4 +26,6 @@ export type MediaInsertPickerProps = Pick<UiComponentFactoryParams, 'editorView'
25
26
  insertExternalMediaSingle: InsertExternalMediaSingle;
26
27
  insertFile: InsertFile;
27
28
  isOnlyExternalLinks: MediaInsertPluginConfig['isOnlyExternalLinks'];
29
+ customizedUrlValidation?: MediaInsertPluginConfig['customizedUrlValidation'];
30
+ customizedHelperMessage?: MediaInsertPluginConfig['customizedHelperMessage'];
28
31
  };
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { type DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
3
3
  import type { MediaProvider } from '@atlaskit/editor-common/provider-factory';
4
- import { type InsertExternalMediaSingle, type InsertMediaSingle } from '../types';
4
+ import { type CustomizedHelperMessage, type InsertExternalMediaSingle, type InsertMediaSingle } from '../types';
5
5
  export declare const isValidUrl: (value: string) => boolean;
6
6
  type Props = {
7
7
  mediaProvider: MediaProvider;
@@ -10,6 +10,8 @@ type Props = {
10
10
  insertMediaSingle: InsertMediaSingle;
11
11
  insertExternalMediaSingle: InsertExternalMediaSingle;
12
12
  isOnlyExternalLinks: boolean;
13
+ customizedUrlValidation?: (input: string) => boolean;
14
+ customizedHelperMessage?: CustomizedHelperMessage;
13
15
  };
14
- export declare function MediaFromURL({ mediaProvider, dispatchAnalyticsEvent, closeMediaInsertPicker, insertMediaSingle, insertExternalMediaSingle, isOnlyExternalLinks, }: Props): React.JSX.Element;
16
+ export declare function MediaFromURL({ mediaProvider, dispatchAnalyticsEvent, closeMediaInsertPicker, insertMediaSingle, insertExternalMediaSingle, isOnlyExternalLinks, customizedUrlValidation, customizedHelperMessage, }: Props): React.JSX.Element;
15
17
  export {};
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { type DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
3
3
  import type { MediaProvider } from '@atlaskit/editor-common/provider-factory';
4
- import { type InsertExternalMediaSingle, type InsertMediaSingle } from '../types';
4
+ import { type CustomizedHelperMessage, type InsertExternalMediaSingle, type InsertMediaSingle } from '../types';
5
5
  export declare const isValidUrl: (value: string) => boolean;
6
6
  type Props = {
7
7
  mediaProvider: MediaProvider;
@@ -10,6 +10,8 @@ type Props = {
10
10
  insertMediaSingle: InsertMediaSingle;
11
11
  insertExternalMediaSingle: InsertExternalMediaSingle;
12
12
  isOnlyExternalLinks: boolean;
13
+ customizedUrlValidation?: (input: string) => boolean;
14
+ customizedHelperMessage?: CustomizedHelperMessage;
13
15
  };
14
- export declare function MediaFromURLWithForm({ mediaProvider, dispatchAnalyticsEvent, closeMediaInsertPicker, insertMediaSingle, insertExternalMediaSingle, isOnlyExternalLinks, }: Props): React.JSX.Element;
16
+ export declare function MediaFromURLWithForm({ mediaProvider, dispatchAnalyticsEvent, closeMediaInsertPicker, insertMediaSingle, insertExternalMediaSingle, isOnlyExternalLinks, customizedUrlValidation, customizedHelperMessage, }: Props): React.JSX.Element;
15
17
  export {};
@@ -1,3 +1,3 @@
1
1
  import React from 'react';
2
2
  import { type MediaInsertPickerProps } from '../types';
3
- export declare const MediaInsertPicker: ({ api, editorView, dispatchAnalyticsEvent, popupsMountPoint, popupsBoundariesElement, popupsScrollableElement, closeMediaInsertPicker, insertMediaSingle, insertExternalMediaSingle, insertFile, isOnlyExternalLinks, }: MediaInsertPickerProps) => React.JSX.Element | null;
3
+ export declare const MediaInsertPicker: ({ api, editorView, dispatchAnalyticsEvent, popupsMountPoint, popupsBoundariesElement, popupsScrollableElement, closeMediaInsertPicker, insertMediaSingle, insertExternalMediaSingle, insertFile, isOnlyExternalLinks, customizedUrlValidation, customizedHelperMessage, }: MediaInsertPickerProps) => React.JSX.Element | null;
@@ -2,6 +2,7 @@ import type { EditorCommand, NextEditorPlugin, OptionalPlugin } from '@atlaskit/
2
2
  import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
3
3
  import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
4
4
  import type { MediaPlugin } from '@atlaskit/editor-plugin-media';
5
+ import type { CustomizedHelperMessage } from './types';
5
6
  export type MediaInsertPluginState = {
6
7
  isOpen?: boolean;
7
8
  mountInfo?: {
@@ -50,6 +51,8 @@ export type MediaInsertPluginConfig = {
50
51
  * ```
51
52
  */
52
53
  isOnlyExternalLinks?: boolean;
54
+ customizedUrlValidation?: (input: string) => boolean;
55
+ customizedHelperMessage?: CustomizedHelperMessage;
53
56
  };
54
57
  export type MediaInsertPlugin = NextEditorPlugin<'mediaInsert', {
55
58
  dependencies: MediaInsertPluginDependencies;
@@ -7,6 +7,7 @@ export type InsertMediaSingle = (props: {
7
7
  mediaState: MediaState;
8
8
  inputMethod: InputMethodInsertMedia;
9
9
  }) => boolean;
10
+ export type CustomizedHelperMessage = string;
10
11
  export type InsertExternalMediaSingle = (props: {
11
12
  url: string;
12
13
  alt: string;
@@ -25,4 +26,6 @@ export type MediaInsertPickerProps = Pick<UiComponentFactoryParams, 'editorView'
25
26
  insertExternalMediaSingle: InsertExternalMediaSingle;
26
27
  insertFile: InsertFile;
27
28
  isOnlyExternalLinks: MediaInsertPluginConfig['isOnlyExternalLinks'];
29
+ customizedUrlValidation?: MediaInsertPluginConfig['customizedUrlValidation'];
30
+ customizedHelperMessage?: MediaInsertPluginConfig['customizedHelperMessage'];
28
31
  };
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { type DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
3
3
  import type { MediaProvider } from '@atlaskit/editor-common/provider-factory';
4
- import { type InsertExternalMediaSingle, type InsertMediaSingle } from '../types';
4
+ import { type CustomizedHelperMessage, type InsertExternalMediaSingle, type InsertMediaSingle } from '../types';
5
5
  export declare const isValidUrl: (value: string) => boolean;
6
6
  type Props = {
7
7
  mediaProvider: MediaProvider;
@@ -10,6 +10,8 @@ type Props = {
10
10
  insertMediaSingle: InsertMediaSingle;
11
11
  insertExternalMediaSingle: InsertExternalMediaSingle;
12
12
  isOnlyExternalLinks: boolean;
13
+ customizedUrlValidation?: (input: string) => boolean;
14
+ customizedHelperMessage?: CustomizedHelperMessage;
13
15
  };
14
- export declare function MediaFromURL({ mediaProvider, dispatchAnalyticsEvent, closeMediaInsertPicker, insertMediaSingle, insertExternalMediaSingle, isOnlyExternalLinks, }: Props): React.JSX.Element;
16
+ export declare function MediaFromURL({ mediaProvider, dispatchAnalyticsEvent, closeMediaInsertPicker, insertMediaSingle, insertExternalMediaSingle, isOnlyExternalLinks, customizedUrlValidation, customizedHelperMessage, }: Props): React.JSX.Element;
15
17
  export {};
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { type DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
3
3
  import type { MediaProvider } from '@atlaskit/editor-common/provider-factory';
4
- import { type InsertExternalMediaSingle, type InsertMediaSingle } from '../types';
4
+ import { type CustomizedHelperMessage, type InsertExternalMediaSingle, type InsertMediaSingle } from '../types';
5
5
  export declare const isValidUrl: (value: string) => boolean;
6
6
  type Props = {
7
7
  mediaProvider: MediaProvider;
@@ -10,6 +10,8 @@ type Props = {
10
10
  insertMediaSingle: InsertMediaSingle;
11
11
  insertExternalMediaSingle: InsertExternalMediaSingle;
12
12
  isOnlyExternalLinks: boolean;
13
+ customizedUrlValidation?: (input: string) => boolean;
14
+ customizedHelperMessage?: CustomizedHelperMessage;
13
15
  };
14
- export declare function MediaFromURLWithForm({ mediaProvider, dispatchAnalyticsEvent, closeMediaInsertPicker, insertMediaSingle, insertExternalMediaSingle, isOnlyExternalLinks, }: Props): React.JSX.Element;
16
+ export declare function MediaFromURLWithForm({ mediaProvider, dispatchAnalyticsEvent, closeMediaInsertPicker, insertMediaSingle, insertExternalMediaSingle, isOnlyExternalLinks, customizedUrlValidation, customizedHelperMessage, }: Props): React.JSX.Element;
15
17
  export {};
@@ -1,3 +1,3 @@
1
1
  import React from 'react';
2
2
  import { type MediaInsertPickerProps } from '../types';
3
- export declare const MediaInsertPicker: ({ api, editorView, dispatchAnalyticsEvent, popupsMountPoint, popupsBoundariesElement, popupsScrollableElement, closeMediaInsertPicker, insertMediaSingle, insertExternalMediaSingle, insertFile, isOnlyExternalLinks, }: MediaInsertPickerProps) => React.JSX.Element | null;
3
+ export declare const MediaInsertPicker: ({ api, editorView, dispatchAnalyticsEvent, popupsMountPoint, popupsBoundariesElement, popupsScrollableElement, closeMediaInsertPicker, insertMediaSingle, insertExternalMediaSingle, insertFile, isOnlyExternalLinks, customizedUrlValidation, customizedHelperMessage, }: MediaInsertPickerProps) => React.JSX.Element | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-media-insert",
3
- "version": "9.0.1",
3
+ "version": "9.2.0",
4
4
  "description": "Media Insert plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -29,11 +29,11 @@
29
29
  "@atlaskit/editor-plugin-analytics": "^3.0.0",
30
30
  "@atlaskit/editor-plugin-media": "^5.2.0",
31
31
  "@atlaskit/editor-prosemirror": "7.0.0",
32
- "@atlaskit/editor-shared-styles": "^3.5.0",
32
+ "@atlaskit/editor-shared-styles": "^3.6.0",
33
33
  "@atlaskit/form": "^12.0.0",
34
- "@atlaskit/icon": "^27.9.0",
35
- "@atlaskit/media-card": "^79.4.0",
36
- "@atlaskit/media-client": "^35.2.0",
34
+ "@atlaskit/icon": "^27.12.0",
35
+ "@atlaskit/media-card": "^79.5.0",
36
+ "@atlaskit/media-client": "^35.3.0",
37
37
  "@atlaskit/media-client-react": "^4.1.0",
38
38
  "@atlaskit/media-picker": "^70.0.0",
39
39
  "@atlaskit/platform-feature-flags": "^1.1.0",
@@ -41,19 +41,16 @@
41
41
  "@atlaskit/section-message": "^8.5.0",
42
42
  "@atlaskit/tabs": "^18.1.0",
43
43
  "@atlaskit/textfield": "^8.0.0",
44
- "@atlaskit/tmp-editor-statsig": "^9.22.0",
44
+ "@atlaskit/tmp-editor-statsig": "^9.28.0",
45
45
  "@babel/runtime": "^7.0.0",
46
46
  "react-intl-next": "npm:react-intl@^5.18.1"
47
47
  },
48
48
  "peerDependencies": {
49
- "@atlaskit/editor-common": "^107.16.0",
49
+ "@atlaskit/editor-common": "^107.23.0",
50
50
  "@atlaskit/tokens": "^6.0.0",
51
51
  "react": "^18.2.0",
52
52
  "react-dom": "^18.2.0"
53
53
  },
54
- "devDependencies": {
55
- "typescript": "~5.4.2"
56
- },
57
54
  "techstack": {
58
55
  "@atlassian/frontend": {
59
56
  "code-structure": [